ClassesClassesClassesClasses | | | | Operators

binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter (Operator)

Name

binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter — Smooth an image using the binomial filter.

Signature

binomial_filter(Image : ImageBinomial : MaskWidth, MaskHeight : )

Herror binomial_filter(const Hobject Image, Hobject* ImageBinomial, const Hlong MaskWidth, const Hlong MaskHeight)

Herror T_binomial_filter(const Hobject Image, Hobject* ImageBinomial, const Htuple MaskWidth, const Htuple MaskHeight)

Herror binomial_filter(Hobject Image, Hobject* ImageBinomial, const HTuple& MaskWidth, const HTuple& MaskHeight)

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

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

void BinomialFilter(const HObject& Image, HObject* ImageBinomial, const HTuple& MaskWidth, const HTuple& MaskHeight)

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

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

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

static void HOperatorSet.BinomialFilter(HObject image, out HObject imageBinomial, HTuple maskWidth, HTuple maskHeight)

HImage HImage.BinomialFilter(int maskWidth, int maskHeight)

Description

binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter smooths the image ImageImageImageImageImageimage using a binomial filter with a mask size of MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth * MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight pixels and returns the smoothed image in ImageBinomialImageBinomialImageBinomialImageBinomialImageBinomialimageBinomial. The binomial filter is a very good approximation of a Gaussian filter that can be implemented extremely efficiently using only integer operations. Hence, binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter is very fast. Let m = MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight and n = MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth. Then, the filter coefficients b_ij are given by binomial coefficients

/ l \      l!
|   | = ---------
\ k /   k! (l-k)!

as follows:

       1     / m-1 \ / n-1 \
b   = ------ |     | |     |
 ij    n+m-2 \  i  / \  j  /
      2

Here, i = 0, ..., m-1 and j = 0, ..., n-1. The binomial filter performs approximately the same smoothing as a Gaussian filter with sigma = sqrt(n-1)/2, where for simplicity it is assumed that m = n. In detail, the relationship between n and sigma is:

 n  |  sigma
-------------
 3  |  0.7523
 5  |  1.0317
 7  |  1.2505
 9  |  1.4365
11  |  1.6010
13  |  1.7502
15  |  1.8876
17  |  2.0157
19  |  2.1361
21  |  2.2501
23  |  2.3586
25  |  2.4623
27  |  2.5618
29  |  2.6576
31  |  2.7500
33  |  2.8395
35  |  2.9262
37  |  3.0104

If different values are chosen for MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight and MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth, the above relation between n and sigma still holds and refers to the amount of smoothing in the row and column directions.

binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter can be executed on OpenCL devices for all supported image types.

Parallelization

Parameters

ImageImageImageImageImageimage (input_object)  (multichannel-)image(-array) objectHImageHImageHImageHImageXHobject (byte* / uint2* / real*) *allowed for compute devices

Input image.

ImageBinomialImageBinomialImageBinomialImageBinomialImageBinomialimageBinomial (output_object)  (multichannel-)image(-array) objectHImageHImageHImageHImageXHobject * (byte / uint2 / real)

Smoothed image.

MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Filter width.

Default value: 5

List of values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37

MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Filter height.

Default value: 5

List of values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37

Result

If the parameter values are correct the operator binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter 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>)SetSystem("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

read_imageread_imageReadImageread_imageReadImageReadImage, grab_imagegrab_imageGrabImagegrab_imageGrabImageGrabImage

Possible Successors

regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing, thresholdthresholdThresholdthresholdThresholdThreshold, sub_imagesub_imageSubImagesub_imageSubImageSubImage, dyn_thresholddyn_thresholdDynThresholddyn_thresholdDynThresholdDynThreshold, auto_thresholdauto_thresholdAutoThresholdauto_thresholdAutoThresholdAutoThreshold

Alternatives

gauss_imagegauss_imageGaussImagegauss_imageGaussImageGaussImage, smooth_imagesmooth_imageSmoothImagesmooth_imageSmoothImageSmoothImage, derivate_gaussderivate_gaussDerivateGaussderivate_gaussDerivateGaussDerivateGauss, isotropic_diffusionisotropic_diffusionIsotropicDiffusionisotropic_diffusionIsotropicDiffusionIsotropicDiffusion

See also

mean_imagemean_imageMeanImagemean_imageMeanImageMeanImage, anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion, sigma_imagesigma_imageSigmaImagesigma_imageSigmaImageSigmaImage, gen_lowpassgen_lowpassGenLowpassgen_lowpassGenLowpassGenLowpass

Module

Foundation


ClassesClassesClassesClasses | | | | Operators