Segment an image by ``pouring water'' over it.
pouring regards the input image as a ``mountain range.'' Larger gray values correspond to mountain peaks, while smaller gray values correspond to valley bottoms. pouring segments the input image in several steps. First the local maxima are extracted, i.e., pixels which either alone or in the form of an extended plateau have larger gray values than their immediate neighbors (in 4-connectivity). In the next step, the maxima thus found are the starting points for an expansion until ``valley bottoms'' are reached. The expansion is done as long as there are chains of pixels in which the gray value gets smaller (like water running downhill from the maxima in all directions). Again, 4-connectivity is used, but with a weaker condition (smaller or equal). This means that points at valley bottoms may belong to more than one maximum. These areas are at first not assigned to a region, but rather are split among all competing segments in the last step. The split is done by a uniform expansion of all involved segments, until all ambiguous pixels were assigned. The parameter Mode determines which steps are executed. The following values are possible:
'all' This is the normal mode of operation. All steps of the segmentation are performed. The regions are assigned to maxima, and overlapping regions are split. 'maxima' The segmentation only extracts the local maxima of the input image. No corresponding regions are extracted. 'regions' The segmentation extracts the local maxima of the input image and the corresponding regions, which are uniquely determined. Areas which could be assigned to more than one maximum are not split.
In order to prevent the algorithm from splitting a uniform background, which is different from the rest of the image, the parameters MinGrey and MaxGrey determine gray value threshold for regions in the image which should be regarded as background. All parts of the image haveing a gray value smaller than MinGrey or larger than MaxGrey are disregarded for the extraction of the maxima as well as for the assignment of regions. For a complete segmentation of the image, MinGrey = 0 und MaxGrey = 255 should be selected. In any case, MinGrey < MaxGrey must be observed.
Image (input_object) |
image -> object : byte |
Image to be segmented. |
Regions (output_object) |
region-array -> object |
Segmentation result. |
Mode (input_control) |
string -> string |
Mode of operation. | |
Default value: 'all' | |
List of values: 'all', 'maxima', 'regions' |
MinGrey (input_control) |
integer -> integer |
All gray values smaller than this threshold are disregarded. | |
Default value: 0 | |
Suggested values: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110 | |
Range of values: 0 <= MinGrey <= 256 (lin) | |
Minimum increment: 1 | |
Recommended increment: 10 | |
Restriction: MinGrey >= 0 |
MaxGrey (input_control) |
integer -> integer |
All gray values larger than this threshold are disregarded. | |
Default value: 255 | |
Suggested values: 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 255 | |
Range of values: 0 <= MaxGrey <= 256 (lin) | |
Minimum increment: 1 | |
Recommended increment: 10 | |
Restriction: (MaxGrey <= 255) && (MaxGrey > MinGrey) |
/* Segmentation of a filtering Image */ read_image(:Image:'br2':) > mean__(Image:Mean:11,11) > pouring(Mean:Seg:'all',0,255:) > disp_image(Mean:::) > set_colored(::12:) > disp_region(Seg:::). /* Segmentation of a Image with masking of a dark backround */ read_image(:Image:'hand':) > mean__(Image:Mean:15,15) > pouring(Mean:Seg:'all',40,255:) > disp_image(Mean:::) > set_colored(::12:) > disp_region(Seg:::). /* Segmentation of a histogram */ read_image(:Image:'affe':) > laws_byte(Image:Texture:'el',2,5:) > draw_region(:Region::) > reduce_domain(Texture,Region:Testreg::) > histo_2dim__(Testreg,Texture,Region:Histo::) > pouring(Histo:Seg:'all',0,255:).
Let N be the number of pixels in the input image and M be the number of found segments, where the enclosing rectangle of the segment i contains m_{i} pixels. Furthermore, let K_{i} be the number of chords in segment i. Then the runtime complexity is
O(3*N + sum_M (3*m_i) + sum_M (K_i)) .
pouring usually returns the value TRUE. If necessary, an exception is raised.
histo_2dim__, expand, expand_grey1, expand_grey2