HALCON Reference Manual 10.0.2
Table of Contents / Filters / Smoothing ClassesClassesClasses | | | Operators

mean_imagemean_imagemean_imageMeanImageMeanImage (Operator)

Name

mean_imagemean_imagemean_imageMeanImageMeanImage — Smooth by averaging.

Signature

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)

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

HImage HImage::MeanImage(const HTuple& MaskWidth, const HTuple& MaskHeight) const

HImageArray HImageArray::MeanImage(const HTuple& MaskWidth, const HTuple& MaskHeight) const

void HOperatorSetX.MeanImage(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*ImageMean, [in] VARIANT MaskWidth, [in] VARIANT MaskHeight)

IHImageX* HImageX.MeanImage(
[in] Hlong MaskWidth, [in] Hlong MaskHeight)

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

HImage HImage.MeanImage(int maskWidth, int maskHeight)

Description

The operator mean_imagemean_imagemean_imageMeanImageMeanImage carries out a linear smoothing with the gray values of all input images (ImageImageImageImageimage). 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_imagemean_imageMeanImageMeanImage 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" (see set_systemset_systemset_systemSetSystemSetSystem). If 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to '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_imagemean_imageMeanImageMeanImage might even take significantly more time with SIMD technology than without.

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

Attention

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

mean_imagemean_imagemean_imageMeanImageMeanImage can be executed on OpenCL devices for byte, int2, uint2, int4 and real images if MaskHeightMaskHeightMaskHeightMaskHeightmaskHeight is less than twice the height of ImageImageImageImageimage. 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 ImageImageImageImageimage 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 ImageImageImageImageimage is calculated (again using either 32 bit integer or single precision floating point arithmetic) if MaskWidthMaskWidthMaskWidthMaskWidthmaskWidth 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_imagemean_imageMeanImageMeanImage should be used.

Parallelization

Parameters

ImageImageImageImageimage (input_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject (byte* / int2* / uint2* / int4* / int8 / real* / vector_field) *allowed for compute devices

Image to be smoothed.

ImageMeanImageMeanImageMeanImageMeanimageMean (output_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject * (byte / int2 / uint2 / int4 / int8 / real / vector_field)

Smoothed image.

MaskWidthMaskWidthMaskWidthMaskWidthmaskWidth (input_control)  extent.x HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Width of filter mask.

Default value: 9

Suggested values: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101

Typical range of values: 1 ≤ MaskWidth MaskWidth MaskWidth MaskWidth maskWidth ≤ 501

Minimum increment: 2

Recommended increment: 2

Restriction: odd(MaskWidth)

MaskHeightMaskHeightMaskHeightMaskHeightmaskHeight (input_control)  extent.y HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Height of filter mask.

Default value: 9

Suggested values: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101

Typical range of values: 1 ≤ MaskHeight MaskHeight MaskHeight MaskHeight maskHeight ≤ 501

Minimum increment: 2

Recommended increment: 2

Restriction: odd(MaskHeight)

Example (HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
disp_image(Mean,WindowHandle)

Example (C)

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

Example (HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
disp_image(Mean,WindowHandle)

Example (HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
disp_image(Mean,WindowHandle)

Example (HDevelop)

read_image(Image,'fabrik')
mean_image(Image,Mean,3,3)
disp_image(Mean,WindowHandle)

Complexity

For each pixel: O(15).

Result

If the parameter values are correct the operator mean_imagemean_imagemean_imageMeanImageMeanImage returns the value 2 (H_MSG_TRUE). The behavior in case of empty input (no input images available) is set via the operator set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). If necessary an exception is raised.

Possible Predecessors

reduce_domainreduce_domainreduce_domainReduceDomainReduceDomain, rectangle1_domainrectangle1_domainrectangle1_domainRectangle1DomainRectangle1Domain

Possible Successors

dyn_thresholddyn_thresholddyn_thresholdDynThresholdDynThreshold, regiongrowingregiongrowingregiongrowingRegiongrowingRegiongrowing

Alternatives

binomial_filterbinomial_filterbinomial_filterBinomialFilterBinomialFilter, gauss_imagegauss_imagegauss_imageGaussImageGaussImage, smooth_imagesmooth_imagesmooth_imageSmoothImageSmoothImage

See also

anisotropic_diffusionanisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion, sigma_imagesigma_imagesigma_imageSigmaImageSigmaImage, convol_imageconvol_imageconvol_imageConvolImageConvolImage, gen_lowpassgen_lowpassgen_lowpassGenLowpassGenLowpass

Module

Foundation


Table of Contents / Filters / Smoothing ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH