scale_imagescale_imageScaleImageScaleImagescale_image (算子)

名称

scale_imagescale_imageScaleImageScaleImagescale_image — 缩放图像的灰度值。

签名

scale_image(Image : ImageScaled : Mult, Add : )

Herror scale_image(const Hobject Image, Hobject* ImageScaled, double Mult, double Add)

Herror T_scale_image(const Hobject Image, Hobject* ImageScaled, const Htuple Mult, const Htuple Add)

void ScaleImage(const HObject& Image, HObject* ImageScaled, const HTuple& Mult, const HTuple& Add)

HImage HImage::ScaleImage(const HTuple& Mult, const HTuple& Add) const

HImage HImage::ScaleImage(double Mult, double Add) const

static void HOperatorSet.ScaleImage(HObject image, out HObject imageScaled, HTuple mult, HTuple add)

HImage HImage.ScaleImage(HTuple mult, HTuple add)

HImage HImage.ScaleImage(double mult, double add)

def scale_image(image: HObject, mult: Union[int, float], add: Union[int, float]) -> HObject

描述

The operator scale_imagescale_imageScaleImageScaleImageScaleImagescale_image scales the input images (ImageImageImageImageimageimage) by the following transformation: g' := g * Mult + Add 若发生溢出或下溢,数值将被截断。 请注意,循环和方向图像不存在此情况。

This operator can be applied, e.g., to map the gray values of an image, i.e., the interval [GMin,GMax], to the maximum range [0:255]. For this, the parameters are chosen as follows: The values for GMin and GMax can be determined, e.g., with the operator min_max_graymin_max_grayMinMaxGrayMinMaxGrayMinMaxGraymin_max_gray.

请注意,算子的运行时间会因不同的控制参数而变化。对于常用组合,会采用特殊的优化方案。此外,还实现了使用定点运算(针对 int2 和 uint2 图像)的特殊优化,以及利用 SIMD 技术(针对 byte、int2 和 uint2 图像)的进一步优化。 The actual application of these special optimizations is controlled by the system parameters 'int_zooming'"int_zooming""int_zooming""int_zooming""int_zooming""int_zooming" and 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable""mmx_enable" (see set_systemset_systemSetSystemSetSystemSetSystemset_system). If 'int_zooming'"int_zooming""int_zooming""int_zooming""int_zooming""int_zooming" is set to 'true'"true""true""true""true""true", the internal calculation is performed using fixed point arithmetic, leading to much shorter execution times. However, the accuracy of the transformed gray values is slightly lower in this mode. The difference to the more accurate calculation (using 'int_zooming'"int_zooming""int_zooming""int_zooming""int_zooming""int_zooming" = 'false'"false""false""false""false""false") is typically less than two gray levels. If 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to 'true'"true""true""true""true""true"(and the SIMD instruction set is available), the internal calculations are performed using fixed point arithmetic and SIMD technology. In this case the setting of 'int_zooming'"int_zooming""int_zooming""int_zooming""int_zooming""int_zooming" is ignored.

scale_imagescale_imageScaleImageScaleImageScaleImagescale_image 可在 OpenCL 设备上执行,适用于 byteint1int2 uint2int4realdirectioncycliccomplex 图像。然而,由于 OpenCL 1.0 仅支持所有设备使用单精度浮点运算,且并非所有舍入模式均被支持,因此 OpenCL 实现可能会产生与标量或 SIMD 实现略有差异的结果。

注意

请注意,SIMD 技术获得的加速效果在大型、紧凑输入区域上最为显著。然而,在极少数情况下,根据输入区域和硬件性能的不同,使用 SIMD 技术执行 scale_imagescale_imageScaleImageScaleImageScaleImagescale_image 可能比不使用时耗时显著增加。在这些情况下,可通过 set_system(::'mmx_enable','false':)set_system("mmx_enable","false")SetSystem("mmx_enable","false")SetSystem("mmx_enable","false")SetSystem("mmx_enable","false")set_system("mmx_enable","false") 来避免使用 SIMD 技术。

执行信息

参数

ImageImageImageImageimageimage (输入对象)  (multichannel-)image(-array) objectHImageHObjectHImageHobject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *允许用于计算设备

需要缩放灰度值的图像。

ImageScaledImageScaledImageScaledImageScaledimageScaledimage_scaled (输出对象)  (multichannel-)image(-array) objectHImageHObjectHImageHobject * (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *允许用于计算设备

按比例缩放后的图像。

MultMultMultMultmultmult (输入控制)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

比例系数。

默认值: 0.01

建议值: 0.001, 0.003, 0.005, 0.008, 0.01, 0.02, 0.03, 0.05, 0.08, 0.1, 0.5, 1.0

最小增量: 0.001

建议增量: 0.1

AddAddAddAddaddadd (输入控制)  number HTupleUnion[int, float]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

偏移量。

默认值: 0

建议值: 0, 10, 50, 100, 200, 500

最小增量: 0.01

建议增量: 1.0

示例(HDevelop)

* Complement of the gray values:
scale_image(Image,Invert,-1.0,255.0)

示例(C)

/* simulation of invert for type 'byte' */
byte_invert(Hobject In, Hobject *out)
{
  scale_image(In,Out,-1.0,255.0);
}

示例(HDevelop)

* Complement of the gray values:
scale_image(Image,Invert,-1.0,255.0)

示例(HDevelop)

* Complement of the gray values:
scale_image(Image,Invert,-1.0,255.0)

示例(HDevelop)

* Complement of the gray values:
scale_image(Image,Invert,-1.0,255.0)

结果

如果参数正确,算子 scale_imagescale_imageScaleImageScaleImageScaleImagescale_image 返回值 2 ( H_MSG_TRUE)。当输入为空(无可用输入图像)时,其行为通过算子 set_system(::'no_object_result',<Result>:)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>) 进行设置。否则将执行异常处理。

可能的前趋

min_max_graymin_max_grayMinMaxGrayMinMaxGrayMinMaxGraymin_max_gray

替代

mult_imagemult_imageMultImageMultImageMultImagemult_image, add_imageadd_imageAddImageAddImageAddImageadd_image, sub_imagesub_imageSubImageSubImageSubImagesub_image

另见

min_max_graymin_max_grayMinMaxGrayMinMaxGrayMinMaxGraymin_max_gray

模块

基础