expand_grey1 ( Regions, Image, ForbiddenArea : RegionExpand : Iterations, Mode, Threshold : )
Fill gaps between regions (depending on gray value or color) or split
overlapping regions.
expand_grey1 closes gaps between the input regions,
which resulted from the suppression of small regions in a
segmentation operator, for example, (mode 'image'), or to
separate overlapping regions 'region'). Both uses result
from the expansion of regions. The operator works by adding a one
pixel wide ``strip'' to a region, in which the gray values or color
are different from the gray values or color of neighboring pixles on
the region's border by at most Threshold (in each
channel). For images of type 'cyclic' (e.g., direction
images), also points with a gray value difference of at least 255 -
Threshold are added to the output region.
The expansion takes place only in regions, which are designated as
not ``forbidden'' (parameter ForbiddenArea). The number
of iterations is determined by the parameter Iterations.
By passing 'maximal', expand_grey1 iterates
until convergence, i.e., until no more changes occur. By passing 0
for this parameter, all non-overlapping regions are returned. The
two modes of operation ('image' and 'region')
are different in the following ways:
'image'
The input regions are expanded iteratively until they
touch another region or the image border, or the expansion
stops because of too high gray value differences. Because
expand_grey1 processes all regions simultaneously, gaps
between regions are distributed evenly to all regions with
a similar gray value. Overlapping regions are split by
distributing the area of overlap evenly to both regions.
'region'
No expansion of the input regions is performed. Instead,
only overlapping regions are split by distributing the
area of overlap evenly to regions having a matching gray
value or color.
Attention
Because regions are only expanded into areas having a matching gray
value or color, usually gaps will remain between the output regions,
i.e., the segmentation is not complete.
Parameters
Regions (input_object)
|
region(-array) -> object
|
Regions for which the gaps are to be closed, or which
are to be separated. |
Image (input_object)
|
image -> object
|
Image (possibly multi-channel) for gray value or color
comparison. |
ForbiddenArea (input_object)
|
region -> object
|
Regions in which no expasion takes place. |
RegionExpand (output_object)
|
region(-array) -> object
|
Expanded or separated regions. |
Iterations (input_control)
|
string -> string / integer
|
Number of iterations. |
Default value: 'maximal' |
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'maximal' |
Range of values: 1 <= Iterations <= 500 (lin) |
Minimum increment: 1
|
Recommended increment: 1
|
Mode (input_control)
|
string -> string
|
Expansion mode. |
Default value: 'image' |
List of values: 'image', 'region' |
Threshold (input_control)
|
integer(-array) -> integer
|
Maximum difference between the gray value or color at
the region's border and a candidate for expansion. |
Default value: 32 |
Suggested values: 5, 10, 15, 20, 25, 30, 40, 50 |
Range of values: 1 <= Threshold <= 255 (lin) |
Minimum increment: 1
|
Recommended increment: 5
|
Example
#include
#include "HCPP.H"
int main (int argc, char *argv[])
{
HImage image (argv[1]);
HRegion empty_region;
HWindow win;
image.Display (win);
HRegionArray seg = (image >= 100).Connection ();
seg.Display (win);
HRegionArray exp = seg.ExpandGrey1 (image, empty_region,
"maximal", "image", 32);
win.SetDraw ("margin");
win.SetColored (12);
exp.Display (win);
win.Click ();
return (0);
}
Result
expand_grey1 always returns the value TRUE. The
behavior in case of empty input (no regions given) can be set via
set_system(::'no_object_result',<Result>:),
the behavior in case of an empty input region via
set_system(::'empty_region_result',<Result>:),
and the behavior in case of an empty result region via
set_system(::'store_empty_region',<true/false>:).
If necessary, an exception is raised.
Possible Predecessors
connection,
regiongrowing__,
pouring,
class_ndim1__
Possible Successors
select_shape
See also
expand_grey2,
expand
Copyright © 1996-1997 MVTec Software GmbH