Name
closingclosingClosingClosing — Close a region.
A closingclosingClosingClosingClosing operation is defined as a dilation followed
by a Minkowsi subtraction. By applying closingclosingClosingClosingClosing to a
region, larger structures remain mostly intact, while small gaps
between adjacent regions and holes smaller than
StructElementStructElementStructElementStructElementstructElement are closed, and the regions' boundaries are
smoothed. All closingclosingClosingClosingClosing variants share the property that
separate regions are not merged, but remain separate objects. The
position of StructElementStructElementStructElementStructElementstructElement is meaningless, since a closing
operation is invariant with respect to the choice of the reference
point.
Structuring elements (StructElementStructElementStructElementStructElementstructElement) can be generated
with operators such as gen_circlegen_circleGenCircleGenCircleGenCircle, gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1,
gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2GenRectangle2, gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipse,
draw_regiondraw_regionDrawRegionDrawRegionDrawRegion, gen_region_polygongen_region_polygonGenRegionPolygonGenRegionPolygonGenRegionPolygon,
gen_region_pointsgen_region_pointsGenRegionPointsGenRegionPointsGenRegionPoints, etc.
closingclosingClosingClosingClosing is applied to each input region separately. If
gaps between different regions are to be closed, union1union1Union1Union1Union1
or union2union2Union2Union2Union2 has to be called first.
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Automatically parallelized on tuple level.
Structuring element (position-invariant).
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#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);
}
my_closing(Hobject In, Hobject StructElement, Hobject *Out)
{
Hobject tmp;
dilation1(In,StructElement,&tmp,1);
minkowski_sub1(tmp,StructElement,Out,1);
clear_obj(tmp);
}
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#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);
}
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#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);
}
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#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:
closingclosingClosingClosingClosing 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.
thresholdthresholdThresholdThresholdThreshold,
regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowing,
connectionconnectionConnectionConnectionConnection,
union1union1Union1Union1Union1,
watershedswatershedsWatershedsWatershedsWatersheds,
class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNorm,
gen_circlegen_circleGenCircleGenCircleGenCircle,
gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipse,
gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1,
gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2GenRectangle2,
draw_regiondraw_regionDrawRegionDrawRegionDrawRegion,
gen_region_pointsgen_region_pointsGenRegionPointsGenRegionPointsGenRegionPoints,
gen_region_polygon_filledgen_region_polygon_filledGenRegionPolygonFilledGenRegionPolygonFilledGenRegionPolygonFilled
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomain,
select_shapeselect_shapeSelectShapeSelectShapeSelectShape,
area_centerarea_centerAreaCenterAreaCenterAreaCenter,
connectionconnectionConnectionConnectionConnection
closing_circleclosing_circleClosingCircleClosingCircleClosingCircle
dilation1dilation1Dilation1Dilation1Dilation1,
erosion1erosion1Erosion1Erosion1Erosion1,
openingopeningOpeningOpeningOpening,
minkowski_sub1minkowski_sub1MinkowskiSub1MinkowskiSub1MinkowskiSub1
Foundation