Smooth an image with an arbitrary rank mask.
The operator rank__ carries out a non-linear smoothing of the gray values of all input images (Image). The shift mask (Mask) is transmitted in the form of a region. The rank gray value (Rank) within the shift mask is calculated for all pixels. 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 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. From these sequences the n-largest element (= Rank) is selected and entered as resulting gray value at the corresponding output image.
If Rank is applied to the median the known median filter is returned. For Mask images can be created e.g., via the operators circle or rectangle1. If Rank is applied to 1 or the area of Mask, respectively, the effect is the same as in case of min1__ or max1__.
Image (input_object) |
image(-array) -> object : byte |
Image to be filtered. |
Mask (input_object) |
region -> object : byte |
Region serving as filter mask. |
ImageRank (output_object) |
image(-array) -> object |
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 | |
Range of values: 1 <= Rank <= 512 | |
Minimum increment: 1 | |
Recommended increment: 2 |
Margin (input_control) |
integer -> integer |
Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection). | |
Default value: -3 | |
Range of values: -3 <= Margin <= 255 |
read_image(:Image:'fabrik':) > draw_region(:Region::) > rank__(Image,Region:ImageRank:5,-3:) > disp_image(ImageRank:::).
For each pixel: O(sqrt(F) * 5) with F = area of Mask.
If the parameter values are correct the operator rank__ returns the value TRUE. The behavior in case of empty input (no input images available) is set via the operator set_system(::'no_object_result',<Resultat>:). If necessary an exception is raised.
read_image, draw_region, circle, rectangle1
threshold__, dyn_threshold__, regiongrowing__
circle, rectangle1, min1__, max1__
R. Haralick, L. Shapiro; "Computer and Robot Vision"; Addison-Wesley, 1992, Seite 318-320