Skip to content

mean_spMeanSpMeanSpmean_spmean_sp🔗

Short description🔗

mean_spMeanSpMeanSpmean_spmean_sp — Suppress salt and pepper noise.

Signature🔗

mean_sp( image Image, out image ImageSPMean, extent.x MaskWidth, extent.y MaskHeight, integer MinThresh, integer MaxThresh )void MeanSp( const HObject& Image, HObject* ImageSPMean, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& MinThresh, const HTuple& MaxThresh )static void HOperatorSet.MeanSp( HObject image, out HObject imageSPMean, HTuple maskWidth, HTuple maskHeight, HTuple minThresh, HTuple maxThresh )def mean_sp( image: HObject, mask_width: int, mask_height: int, min_thresh: int, max_thresh: int ) -> HObject

Herror mean_sp( const Hobject Image, Hobject* ImageSPMean, const Hlong MaskWidth, const Hlong MaskHeight, const Hlong MinThresh, const Hlong MaxThresh )

Herror T_mean_sp( const Hobject Image, Hobject* ImageSPMean, const Htuple MaskWidth, const Htuple MaskHeight, const Htuple MinThresh, const Htuple MaxThresh )

HImage HImage::MeanSp( Hlong MaskWidth, Hlong MaskHeight, Hlong MinThresh, Hlong MaxThresh ) const

HImage HImage.MeanSp( int maskWidth, int maskHeight, int minThresh, int maxThresh )

Description🔗

The operator mean_spMeanSp carries out a smoothing by averaging the values. Only the gray values within the interval from MinThreshminThreshmin_thresh to MaxThreshmaxThreshmax_thresh are averaged. Gray values which are too light or too dark are ignored during summation. If no gray value lies within the default interval during summation the original gray value is adopted. If the thresholds are set at 00 or 255255, respectively, the operator mean_spMeanSp behaves like mean_imageMeanImage except for the running time.

The operator mean_spMeanSp is used to suppress extreme gray values (salt and pepper noise = white and black dots).

For an explanation of the concept of smoothing filters see the introduction of chapter Filters / Smoothing.

Attention🔗

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

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on domain level.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image(-array) → object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image.

ImageSPMeanimageSPMeanimage_spmean (output_object) (multichannel-)image(-array) → object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject * (byte / uint2)

Smoothed image.

MaskWidthmaskWidthmask_width (input_control) extent.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of filter mask.

Default: 33
Suggested values: 3, 5, 7, 9, 113, 5, 7, 9, 11
Value range: MaskWidth (lin)
Minimum increment: 2
Recommended increment: 2
Restriction: odd(MaskWidth) && MaskWidth < width(Image) * 2

MaskHeightmaskHeightmask_height (input_control) extent.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of filter mask.

Default: 33
Suggested values: 3, 5, 7, 9, 113, 5, 7, 9, 11
Value range: MaskHeight (lin)
Minimum increment: 2
Recommended increment: 2
Restriction: odd(MaskHeight) && MaskHeight < height(Image) * 2

MinThreshminThreshmin_thresh (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum gray value.

Default: 11
Suggested values: 1, 5, 7, 9, 11, 15, 23, 31, 43, 61, 1011, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101
Value range: 0 ≤ MinThresh

MaxThreshmaxThreshmax_thresh (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Maximum gray value.

Default: 254254
Suggested values: 5, 7, 9, 11, 15, 23, 31, 43, 61, 101, 200, 230, 250, 2545, 7, 9, 11, 15, 23, 31, 43, 61, 101, 200, 230, 250, 254
Restriction: MinThresh <= MaxThresh

Example🔗

(HDevelop)

read_image(Image,'mreut')
dev_display(Image)
mean_sp(Image,ImageMeansp,3,3,101,201)
dev_display(ImageMeansp)
(C)
read_image(&Image,"mreut")\;
disp_image(Image,WindowHandle)\;
mean_sp(Image,&ImageMeansp,3,3,101,201)\;
disp_image(ImageMeansp,WindowHandle)\;

Combinations with other operators🔗

Combinations

Possible successors

disp_imageDispImage

Alternatives

mean_imageMeanImage, median_imageMedianImage, median_separateMedianSeparate, eliminate_min_maxEliminateMinMax

See also

anisotropic_diffusionAnisotropicDiffusion, sigma_imageSigmaImage, binomial_filterBinomialFilter, gauss_filterGaussFilter, smooth_imageSmoothImage, eliminate_min_maxEliminateMinMax

Module🔗

Foundation