opening_seg🔗
Short description🔗
opening_seg — Separate overlapping regions.
Warning🔗
opening_seg is obsolete and is only provided for
reasons of backward compatibility.
Signature🔗
opening_seg( region Region, region StructElement, out region RegionOpening )
Description🔗
The opening_seg operation is defined as a sequence of
the following operators: erosion1,
connection and dilation1 (see example).
Only one iteration is done in erosion1 and
dilation1.
opening_seg serves to separate overlapping regions whose
area of overlap is smaller than StructElement. It should
be noted that the resulting regions can overlap without actually
merging (see expand_region). opening_seg uses the
center of gravity as the reference point of the structuring element.
Structuring elements (StructElement) can be generated
with operators such as gen_circle, gen_rectangle1,
gen_rectangle2, gen_ellipse,
draw_region, gen_region_polygon,
gen_region_points, etc.
Execution information🔗
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
Parameters🔗
Region (input_object) region(-array) → object
Regions to be opened.
StructElement (input_object) region → object
Structuring element (position-invariant).
RegionOpening (output_object) region-array → object
Opened regions.
Example🔗
(HDevelop)
* Simulation of opening_seg
* opening_seg(Region,StructElement,RegionOpening):
erosion1(Region,StructElement,H1,1)
connection(H1,H2)
dilation1(H2,StructElement,RegionOpening,1)
/* Simulation of opening_seg */
my_opening_seg(Hobject Region, Hobject StructElement, Hobject *Opening)
{
Hobject H1,H2\;
erosion1(Region,StructElement,&H1,1)\;
connection(H1,&H2)\;
dilation1(H2,StructElement,Opening,1)\;
}
/* separation of circular objects */
gen_random_regions(&Regions,"circle",8.5,10.5,0.0,0.0,0.0,0.0,400,512,512)\;
union1(Regions,&UnionReg)\;
gen_circle(&Mask,100,100,8.5)\;
opening_seg(UnionReg,Mask,&RegionsNew)\;
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"
main()
{
HWindow w\;
HRegionArray regs = HRegionArray::GenRandomRegions("circle",8.5,10.5,
0,0,0,0,400,512,512)\;
HRegionArray ureg = regs.Union1()\;
HRegion crc = HRegion::GenCircle(100,100,8.5)\;
HRegionArray ops = ureg.OpeningSeg(crc)\;
w.SetColor("red")\; regs.Display(w)\; w.Click()\;
w.SetColored(12)\; ops.Display(w)\; w.Click()\;
return(0)\;
}
Complexity🔗
Let \(F1\) be the area of the input region, and \(F2\) be the area of the structuring element. Then the runtime complexity for one region is:
Result🔗
opening_seg returns 2 (H_MSG_TRUE) if all parameters are correct.
The behavior in case of empty or no input region can be set via:
-
no region:
set_system('no_object_result',<RegionResult>) -
empty region:
set_system('empty_region_result',<RegionResult>)
Otherwise, an exception is raised.
Combinations with other operators🔗
Combinations
Possible predecessors
threshold, regiongrowing, connection, union1, watersheds, class_ndim_norm, gen_circle, gen_ellipse, gen_rectangle1, gen_rectangle2, draw_region, gen_region_points, gen_region_polygon_filled
Possible successors
expand_region, reduce_domain, select_shape, area_center, connection
Alternatives
Module🔗
Foundation