Herror ::median_image (
    Hobject Image,
    Hobject *ImageMedian,
    const HTuple &MaskType,
    const HTuple &Radius,
    const HTuple &Margin
)
HImage HImage::MedianImage (
    const HTuple &MaskType,
    const HTuple &Radius,
    const HTuple &Margin
) const
HImageArray HImageArray::MedianImage (
    const HTuple &MaskType,
    const HTuple &Radius,
    const HTuple &Margin
) const

Median filtering with different rank masks.

The operator ::median_image carries out a non-linear smoothing of the gray values of all input images (Image). The shift mask (MaskType) is transmitted in the form of an object (more precisely: its region). Several margin controls can be chosen for filtering (Margin):

    0...255   pixels outside of the image edges
              are assumed constant (with the indicated
              gray value).
    -1        Continuation of edge pixels.
    -2        Cyclic continuation of image edges.
    -3        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 of the objects 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. From these sequences the median is selected and entered as resulting gray value at the corresponding output image.


Parameters

Image (input_object)
(multichannel-)image(-array) -> Hobject: HImage(Array) ( byte )
Image to be filtered.

ImageMedian (output_object)
(multichannel-)image(-array) -> Hobject * : HImage(Array) ( byte )
Median filtered image.

MaskType (input_control)
string -> HTuple.char *
Type of median mask.
Default value: 'circle'
List of values: 'circle', 'rectangle'

Radius (input_control)
integer -> HTuple.long
Radius of median mask.
Default value: 1
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 19, 25, 31, 39, 47, 59
Typical range of values: 1 <= Radius <= 101
Minimum increment: 1
Recommended increment: 2

Margin (input_control)
integer -> HTuple.long
Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).
Default value: -3
Typical range of values: -3 <= Margin <= 255


Example
read_image(&Image,"fabrik");
median_image(Image,&Median,"circle",3,-1);
disp_image(MedianWeighted,WindowHandle);

Complexity

For each pixel: O(sqrt(F) * 5) with F = area of MaskType.


Result

If the parameter values are correct the operator ::median_image returns the value 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>). If necessary an exception handling is raised.


Possible Predecessors

::read_image


Possible Successors

::threshold, ::dyn_threshold, ::regiongrowing


Alternatives

::rank_image


See also

::gen_circle, ::gen_rectangle1, ::gray_erosion_rect, ::gray_dilation_rect


References

R. Haralick, L. Shapiro; ``Computer and Robot Vision''; Addison-Wesley, 1992, Seite 318-319


Module

Image filters



Copyright © 1996-2002 MVTec Software GmbH