mean_imagemean_imageMeanImageMeanImagemean_image (算子)

名称

mean_imagemean_imageMeanImageMeanImagemean_image — 通过平均平滑。

签名

mean_image(Image : ImageMean : MaskWidth, MaskHeight : )

Herror mean_image(const Hobject Image, Hobject* ImageMean, const Hlong MaskWidth, const Hlong MaskHeight)

Herror T_mean_image(const Hobject Image, Hobject* ImageMean, const Htuple MaskWidth, const Htuple MaskHeight)

void MeanImage(const HObject& Image, HObject* ImageMean, const HTuple& MaskWidth, const HTuple& MaskHeight)

HImage HImage::MeanImage(Hlong MaskWidth, Hlong MaskHeight) const

static void HOperatorSet.MeanImage(HObject image, out HObject imageMean, HTuple maskWidth, HTuple maskHeight)

HImage HImage.MeanImage(int maskWidth, int maskHeight)

def mean_image(image: HObject, mask_width: int, mask_height: int) -> HObject

描述

算子 mean_imagemean_imageMeanImageMeanImageMeanImagemean_image carries out a linear smoothing with the gray values of all input images (ImageImageImageImageimageimage). The filter matrix consists of ones (evaluated equally) and has the size MaskHeight x MaskWidth. The result of the convolution is divided by MaskHeight x MaskWidth. For border treatment the gray values are reflected at the image edges.

For mean_imagemean_imageMeanImageMeanImageMeanImagemean_image special optimizations are implemented that use SIMD technology. The actual application of these special optimizations is controlled by the system parameter 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable""mmx_enable" (see set_systemset_systemSetSystemSetSystemSetSystemset_system). 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 SIMD technology. Note that SIMD technology performs best on large, compact input regions. Depending on the input region and the capabilities of the hardware the execution of mean_imagemean_imageMeanImageMeanImageMeanImagemean_image might even take significantly more time with SIMD technology than without.

At any rate, it is advantageous for the performance of mean_imagemean_imageMeanImageMeanImageMeanImagemean_image to choose the input region of ImageImageImageImageimageimage such that any border treatment is avoided.

有关平滑滤波器概念的说明,请参阅 滤波器 / 平滑 一章的引言。

注意

If even values instead of odd values are given for MaskHeightMaskHeightMaskHeightMaskHeightmaskHeightmask_height or MaskWidthMaskWidthMaskWidthMaskWidthmaskWidthmask_width, the routine uses the next larger odd values instead (this way the center of the filter mask is always explicitly determined).

The mean filter value on real images is calculated internally using single precision floating point. This can lead to overflows (and thus incorrect results) if the full dynamic range is used.

mean_imagemean_imageMeanImageMeanImageMeanImagemean_image can be executed on OpenCL devices for byte, int2, uint2, int4 and real images if MaskHeightMaskHeightMaskHeightMaskHeightmaskHeightmask_height is less than twice the height of ImageImageImageImageimageimage. For OpenCL, the mean filter value is calculated internally using either 32 bit signed integers (for all integer image types) or single precision floating point (for real images). This can lead to overflows (and thus incorrect results) if ImageImageImageImageimageimage is either an int4 or real image and the full dynamic range is used. Additionally, to improve performance a full scan of each row of ImageImageImageImageimageimage is calculated (again using either 32 bit integer or single precision floating point arithmetic) if MaskWidthMaskWidthMaskWidthMaskWidthmaskWidthmask_width is bigger than 9. This can also lead to overflows with very wide images even for byte, int2, or uint2 images. In these cases, the CPU version of mean_imagemean_imageMeanImageMeanImageMeanImagemean_image should be used.

请注意,若使用域缩减后的图像作为输入,滤波器算子可能会返回意外结果。请参阅 滤波器 一章

执行信息

参数

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

待平滑的图像。

ImageMeanImageMeanImageMeanImageMeanimageMeanimage_mean (输出对象)  (multichannel-)image(-array) objectHImageHObjectHImageHobject * (byte / int2 / uint2 / int4 / int8 / real / vector_field)

平滑后的图像。

MaskWidthMaskWidthMaskWidthMaskWidthmaskWidthmask_width (输入控制)  extent.x HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of filter mask.

默认值: 9

建议值: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101

值范围: 1 ≤ MaskWidth MaskWidth MaskWidth MaskWidth maskWidth mask_width

最小增量: 2

建议增量: 2

限制: odd(MaskWidth) && MaskWidth < width(Image) * 2

MaskHeightMaskHeightMaskHeightMaskHeightmaskHeightmask_height (输入控制)  extent.y HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of filter mask.

默认值: 9

建议值: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101

值范围: 1 ≤ MaskHeight MaskHeight MaskHeight MaskHeight maskHeight mask_height

最小增量: 2

建议增量: 2

限制: odd(MaskHeight) && MaskHeight < height(Image) * 2

示例(HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
dev_display(Mean)

示例(C)

read_image(&Image,"fabrik");
mean_image(Image,&Mean,3,3);
disp_image(Mean,WindowHandle);

示例(HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
dev_display(Mean)

示例(HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
dev_display(Mean)

示例(HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
dev_display(Mean)

复杂度

For each pixel: O(15).

结果

如果参数值正确,算子 mean_imagemean_imageMeanImageMeanImageMeanImagemean_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>)。如有必要,则抛出异常。

可能的前趋

reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, rectangle1_domainrectangle1_domainRectangle1DomainRectangle1DomainRectangle1Domainrectangle1_domain

可能的后继

dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing

替代

binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, smooth_imagesmooth_imageSmoothImageSmoothImageSmoothImagesmooth_image, mean_image_shapemean_image_shapeMeanImageShapeMeanImageShapeMeanImageShapemean_image_shape

另见

anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusionAnisotropicDiffusionanisotropic_diffusion, sigma_imagesigma_imageSigmaImageSigmaImageSigmaImagesigma_image, convol_imageconvol_imageConvolImageConvolImageConvolImageconvol_image, gen_lowpassgen_lowpassGenLowpassGenLowpassGenLowpassgen_lowpass

模块

基础