Close a region.
A ::closing operation is defined as a dilation followed by a Minkowsi subtraction. By applying ::closing to a region, larger structures remain mostly intact, while small gaps between adjacent regions and holes smaller than StructElement are closed, and the regions' boundaries are smoothed. All ::closing variants share the property that separate regions are not merged, but remain separate objects. The position of StructElement is meaningless, since a closing operation is invariant with respect to the choice of the reference point.
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.
::closing is applied to each input region separately. If gaps between different regions are to be closed, ::union1 or ::union2 has to be called first.
|
Region (input_object) |
region(-array) -> Hobject: HRegion(Array) |
| Regions to be closed. | |
|
StructElement (input_object) |
region -> Hobject: HRegion |
| Structuring element (position-invariant). | |
|
RegionClosing (output_object) |
region(-array) -> Hobject * : HRegion(Array) |
| Closed regions. | |
#include <iostream.h>
#include "HalconCpp.h"
main()
{
cout << "Reproduction of 'closing ()' using " << endl;
cout << "'dilation()' and 'minkowski_sub1()'" << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray dilreg = regs.Dilation1 (circ, 1);
HRegionArray minsub = dilreg.MinkowskiSub1 (circ, 1);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("green"); dilreg.Display (w); w.Click ();
w.SetColor ("blue"); minsub.Display (w); w.Click ();
return(0);
}
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:
O(2 * sqrt(F1) * sqrt(F2)) .
::closing returns H_MSG_TRUE if all parameters are correct. The behavior in case of empty or no input region can be set via:
a) no region: set_system('no_object_result',<RegionResult>)
b) empty region: set_system('empty_region_result',<RegionResult>)
Otherwise, an exception is raised.
::threshold, ::regiongrowing, ::connection, ::union1, ::watersheds, ::class_ndim_norm, ::gen_circle, ::gen_ellipse, ::gen_rectangle1, ::gen_rectangle2, ::draw_region, ::gen_region_points, ::gen_struct_elements, ::gen_region_polygon_filled
::reduce_domain, ::select_shape, ::area_center, ::connection
::closing_circle, ::closing_golay
::dilation1, ::erosion1, ::opening, ::minkowski_sub1
Morphology