Smooth an image with an arbitrary rank mask.
The operator rank_image carries out a non-linear smoothing of the gray values of all input images (Image). The filter mask (Mask) is transmitted as a region. In contrast to many other filters you can choose an arbitrary shape, e.g., by using operators like gen_circle or draw_region. The position of the mask region has no influence on the result; the center of gravity of the region is used as the reference point of the filter mask.
The specified mask is moved over the image to be filtered in such a way that the reference point of the mask touches all pixels once. At each position a histogram is calculated from the gray values of all pixels covered by the mask. By specifying Rank = 1 the lowest (= darkest) gray value appearing in the histogram is selected and entered as resulting gray value in the output image ImageRank; if Rank corresponds to the number of pixels of the filter mask, i.e., its area, the brightest gray value is selected. This behavior is idential to the erosion/dilation operators in gray morphology (gray_erosion, gray_dilation). If you use a rank that is equal to half of the pixels of the filter mask you get the same behavior as for the the median filter (median_image).
You can use rank_image to eliminate noise, to eliminate structures with a given orientation (use gen_rectangle2 to create the mask region), or as an advanced gray morphologic operator that is more robust against noise. In this case you will not use 1 or the mask area as rank values, but a slightly higher or lower value, respectively.
Several border treatments can be chosen for filtering (Margin):
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.
|
Image (input_object) |
multichannel-image(-array) -> object : byte / int2 / uint2 / int4 / real |
| Image to be filtered. | |
|
Mask (input_object) |
region -> object : byte |
| Region serving as filter mask. | |
|
ImageRank (output_object) |
multichannel-image(-array) -> object : byte / int2 / uint2 / int4 / real |
| Filtered image. | |
|
Rank (input_control) |
integer -> integer |
| Rank of the output gray value in the sorted sequence of input gray values inside the filter mask. Typical value (median): area(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 <= Rank <= 512 | |
| Minimum increment: 1 | |
|
Recommended increment: 2 | |
|
Margin (input_control) |
string -> string / integer / real |
| Border treatment. | |
| Default value: 'mirrored' | |
| Suggested values: 'mirrored', 'cyclic', 'continued', 0, 30, 60, 90, 120, 150, 180, 210, 240, 255 | |
read_image(Image,'fabrik') draw_region(Region,WindowHandle) rank_image(Image,Region,ImageRank,5,'mirrored') disp_image(ImageRank,WindowHandle).
For each pixel: O(sqrt(F) * 5) with F = area of Mask.
If the parameter values are correct the operator rank_image 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>). If necessary an exception handling is raised.
rank_image is reentrant and automatically parallelized (on tuple level, channel level, domain level).
read_image, draw_region, gen_circle, gen_rectangle1
threshold, dyn_threshold, regiongrowing
gen_circle, gen_rectangle1, gray_erosion_rect, gray_dilation_rect
R. Haralick, L. Shapiro; ``Computer and Robot Vision''; Addison-Wesley, 1992, Seite 318-320
Foundation