expand_grayπ
Short descriptionπ
expand_gray β Fill gaps between regions (depending on gray value or color) or split
overlapping regions.
Signatureπ
expand_gray( region Regions, image Image, region ForbiddenArea, out region RegionExpand, string Iterations, string Mode, integer Threshold )
Descriptionπ
expand_gray closes gaps between the input regions,
which resulted from the suppression of small regions in a
segmentation operator, (mode 'image'), for example, or
separates 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 pixels 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 -
\textrm{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_gray 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_grayprocesses 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.
Execution informationπ
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
-
Processed without parallelization.
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) (multichannel-)image β object (byte / cyclic)
Image (possibly multi-channel) for gray value or color comparison.
ForbiddenArea (input_object) region β object
Regions in which no expansion takes place.
RegionExpand (output_object) region(-array) β object
Expanded or separated regions.
Iterations (input_control) string β (string / integer)
Number of iterations.
Default: 'maximal'
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'maximal'
Value range: 1 β€ Iterations β€ 500 (lin)
Minimum increment: 1
Recommended increment: 1
Mode (input_control) string β (string)
Expansion mode.
Default: '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: 32
Suggested values: 5, 10, 15, 20, 25, 30, 40, 50
Value range: 1 β€ Threshold β€ 255 (lin)
Minimum increment: 1
Recommended increment: 5
Exampleπ
(C)
read_image(&Image,"fabrik")\;
disp_image(Image,WindowHandle)\;
regiongrowing(Image,&RawSegments,3,3,6.0,100)\;
set_colored(WindowHandle,12)\;
disp_region(RawSegments,WindowHandle)\;
expand_gray(RawSegments,Image,EMPTY_REGION,&Segments,"maximal","image",24)\;
disp_region(Segments,WindowHandle)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"
using namespace Halcon\;
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.ExpandGray1 (image, empty_region,
"maximal", "image", 32)\;
win.SetDraw ("margin")\;
win.SetColored (12)\;
exp.Display (win)\;
win.Click ()\;
return (0)\;
}
Resultπ
expand_gray always returns the value 2 (H_MSG_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.
Combinations with other operatorsπ
Combinations
Possible predecessors
connection, regiongrowing, pouring, class_ndim_norm
Possible successors
See also
Moduleπ
Foundation