ClassesClasses | | Operators

trimmed_meantrimmed_meanTrimmedMeanTrimmedMean (Operator)

Name

trimmed_meantrimmed_meanTrimmedMeanTrimmedMean — Smooth an image with an arbitrary rank mask.

Signature

trimmed_mean(Image, Mask : ImageTMean : Number, Margin : )

Herror trimmed_mean(const Hobject Image, const Hobject Mask, Hobject* ImageTMean, const Hlong Number, const char* Margin)

Herror T_trimmed_mean(const Hobject Image, const Hobject Mask, Hobject* ImageTMean, const Htuple Number, const Htuple Margin)

void TrimmedMean(const HObject& Image, const HObject& Mask, HObject* ImageTMean, const HTuple& Number, const HTuple& Margin)

HImage HImage::TrimmedMean(const HRegion& Mask, Hlong Number, const HTuple& Margin) const

HImage HImage::TrimmedMean(const HRegion& Mask, Hlong Number, const HString& Margin) const

HImage HImage::TrimmedMean(const HRegion& Mask, Hlong Number, const char* Margin) const

static void HOperatorSet.TrimmedMean(HObject image, HObject mask, out HObject imageTMean, HTuple number, HTuple margin)

HImage HImage.TrimmedMean(HRegion mask, int number, HTuple margin)

HImage HImage.TrimmedMean(HRegion mask, int number, string margin)

Description

The operator trimmed_meantrimmed_meanTrimmedMeanTrimmedMeanTrimmedMean carries out a non-linear smoothing of the gray values of all input images (ImageImageImageImageimage). The filter mask (MaskMaskMaskMaskmask) is passed in the form of a region. The average of NumberNumberNumberNumbernumber gray values located near the median is calculated. Several border treatments can be chosen for filtering (MarginMarginMarginMarginmargin):

    gray value   Pixels outside of the image edges
                 are assumed to be constant (with the
                 indicated gray value).
    'continued'  Continuation of edge pixels.
    'cyclic'     Cyclic continuation of image edges.
    'mirrored'   Reflection of pixels at the image edges.
The indicated mask (= region of the mask image) is put over the image to be filtered in such a way that the center of the mask touches all pixels once. For each of these pixels all neighboring pixels covered by the mask are sorted in an ascending sequence according to their gray values. Thus, each of these sorted gray value sequences contains exactly as many gray values as the mask has pixels. If F is the area of the mask the average of these sequences is calculated as follows: The first (F - Number)/2 gray values are ignored. Then the following NumberNumberNumberNumbernumber gray values are summed up and divided by NumberNumberNumberNumbernumber. Again the remaining (F - NumberNumberNumberNumbernumber)/2 gray values are ignored.

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

Attention

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

Parameters

ImageImageImageImageimage (input_object)  (multichannel-)image(-array) objectHImageHImageHobject (byte / int2 / uint2 / int4 / real)

Image to be filtered.

MaskMaskMaskMaskmask (input_object)  region objectHRegionHRegionHobject

Image whose region serves as filter mask.

ImageTMeanImageTMeanImageTMeanImageTMeanimageTMean (output_object)  (multichannel-)image(-array) objectHImageHImageHobject * (byte / int2 / uint2 / int4 / real)

Filtered output image.

NumberNumberNumberNumbernumber (input_control)  integer HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of averaged pixels. Typical value: Surface(Mask) / 2.

Default value: 5

Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31

Typical range of values: 1 ≤ Number Number Number Number number ≤ 401

Minimum increment: 1

Recommended increment: 2

MarginMarginMarginMarginmargin (input_control)  string HTupleHTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Border treatment.

Default value: 'mirrored' "mirrored" "mirrored" "mirrored" "mirrored"

Suggested values: 'mirrored'"mirrored""mirrored""mirrored""mirrored", 'cyclic'"cyclic""cyclic""cyclic""cyclic", 'continued'"continued""continued""continued""continued", 0, 30, 60, 90, 120, 150, 180, 210, 240, 255

Example (HDevelop)

read_image(Image,'fabrik')
draw_region(Region,WindowHandle)
trimmed_mean(Image,Region,TrimmedMean,5,'mirrored')
dev_display(TrimmedMean)

Example (C)

read_image(&Image,"fabrik");
draw_region(&Region,WindowHandle);
trimmed_mean(Image,Region,&TrimmedMean,5,"mirrored");
disp_image(TrimmedMean,WindowHandle);

Example (HDevelop)

read_image(Image,'fabrik')
draw_region(Region,WindowHandle)
trimmed_mean(Image,Region,TrimmedMean,5,'mirrored')
dev_display(TrimmedMean)

Example (HDevelop)

read_image(Image,'fabrik')
draw_region(Region,WindowHandle)
trimmed_mean(Image,Region,TrimmedMean,5,'mirrored')
dev_display(TrimmedMean)

Example (HDevelop)

read_image(Image,'fabrik')
draw_region(Region,WindowHandle)
trimmed_mean(Image,Region,TrimmedMean,5,'mirrored')
dev_display(TrimmedMean)

Result

If the parameter values are correct the operator trimmed_meantrimmed_meanTrimmedMeanTrimmedMeanTrimmedMean 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>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). If necessary an exception is raised.

Possible Predecessors

read_imageread_imageReadImageReadImageReadImage, draw_regiondraw_regionDrawRegionDrawRegionDrawRegion, gen_circlegen_circleGenCircleGenCircleGenCircle, gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1

Possible Successors

thresholdthresholdThresholdThresholdThreshold, dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThreshold, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowing

Alternatives

sigma_imagesigma_imageSigmaImageSigmaImageSigmaImage, median_weightedmedian_weightedMedianWeightedMedianWeightedMedianWeighted, median_imagemedian_imageMedianImageMedianImageMedianImage

See also

gen_circlegen_circleGenCircleGenCircleGenCircle, gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1, gray_erosion_rectgray_erosion_rectGrayErosionRectGrayErosionRectGrayErosionRect, gray_dilation_rectgray_dilation_rectGrayDilationRectGrayDilationRectGrayDilationRect

References

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 320

Module

Foundation


ClassesClasses | | Operators