Name
morph_hatmorph_hatMorphHatmorph_hatMorphHatMorphHat — Compute the union of bottom_hatbottom_hatBottomHatbottom_hatBottomHatBottomHat and top_hattop_hatTopHattop_hatTopHatTopHat.
morph_hatmorph_hatMorphHatmorph_hatMorphHatMorphHat computes the union of the regions that are
removed by an openingopeningOpeningopeningOpeningOpening operation with the regions that are
added by a closingclosingClosingclosingClosingClosing operation. Hence this is the union
of the results of top_hattop_hatTopHattop_hatTopHatTopHat and bottom_hatbottom_hatBottomHatbottom_hatBottomHatBottomHat.
The position of StructElementStructElementStructElementStructElementStructElementstructElement does not influence the
result.
Structuring elements (StructElementStructElementStructElementStructElementStructElementstructElement) can be generated
with operators such as gen_circlegen_circleGenCirclegen_circleGenCircleGenCircle, gen_rectangle1gen_rectangle1GenRectangle1gen_rectangle1GenRectangle1GenRectangle1,
gen_rectangle2gen_rectangle2GenRectangle2gen_rectangle2GenRectangle2GenRectangle2, gen_ellipsegen_ellipseGenEllipsegen_ellipseGenEllipseGenEllipse,
draw_regiondraw_regionDrawRegiondraw_regionDrawRegionDrawRegion, gen_region_polygongen_region_polygonGenRegionPolygongen_region_polygonGenRegionPolygonGenRegionPolygon,
gen_region_pointsgen_region_pointsGenRegionPointsgen_region_pointsGenRegionPointsGenRegionPoints, etc.
The individual regions are processed separately.
- 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).
Union of top hat and bottom hat.
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
main()
{
cout << "Reproduction of 'dilation_circle ()'" << endl;
cout << "First = original image " << endl;
cout << "Red = after segmentation " << endl;
cout << "Blue = after erosion " << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray tophat = regs.TopHat (circ);
HRegionArray bothat = regs.BottomHat (circ);
HRegionArray unionX = tophat.Union2 (bothat);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("blue"); tophat.Display (w); w.Click ();
w.SetColor ("green"); bothat.Display (w); w.Click ();
w.SetColor ("white"); unionX.Display (w); w.Click ();
return(0);
}
my_morph_hat(Hobject *In, Hobject StructElement, Hobject *Out)
{
Hobject top, bottom;
top_hat(In,StructElement,&top);
bottom_hat(In,StructElement,&bottom);
union2(top,bottom,Out);
clear_obj(top); clear_obj(bottom);
}
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
main()
{
cout << "Reproduction of 'dilation_circle ()'" << endl;
cout << "First = original image " << endl;
cout << "Red = after segmentation " << endl;
cout << "Blue = after erosion " << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray tophat = regs.TopHat (circ);
HRegionArray bothat = regs.BottomHat (circ);
HRegionArray unionX = tophat.Union2 (bothat);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("blue"); tophat.Display (w); w.Click ();
w.SetColor ("green"); bothat.Display (w); w.Click ();
w.SetColor ("white"); unionX.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 'dilation_circle ()'" << endl;
cout << "First = original image " << endl;
cout << "Red = after segmentation " << endl;
cout << "Blue = after erosion " << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray tophat = regs.TopHat (circ);
HRegionArray bothat = regs.BottomHat (circ);
HRegionArray unionX = tophat.Union2 (bothat);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("blue"); tophat.Display (w); w.Click ();
w.SetColor ("green"); bothat.Display (w); w.Click ();
w.SetColor ("white"); unionX.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 'dilation_circle ()'" << endl;
cout << "First = original image " << endl;
cout << "Red = after segmentation " << endl;
cout << "Blue = after erosion " << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray tophat = regs.TopHat (circ);
HRegionArray bothat = regs.BottomHat (circ);
HRegionArray unionX = tophat.Union2 (bothat);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("blue"); tophat.Display (w); w.Click ();
w.SetColor ("green"); bothat.Display (w); w.Click ();
w.SetColor ("white"); unionX.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 'dilation_circle ()'" << endl;
cout << "First = original image " << endl;
cout << "Red = after segmentation " << endl;
cout << "Blue = after erosion " << endl;
HByteImage img("monkey");
HWindow w;
HRegion circ = HRegion::GenCircle (10, 10, 1.5);
HRegionArray regs = (img >= 128).Connection();
HRegionArray tophat = regs.TopHat (circ);
HRegionArray bothat = regs.BottomHat (circ);
HRegionArray unionX = tophat.Union2 (bothat);
img.Display (w); w.Click ();
w.SetColor ("red"); regs.Display (w); w.Click ();
w.SetColor ("blue"); tophat.Display (w); w.Click ();
w.SetColor ("green"); bothat.Display (w); w.Click ();
w.SetColor ("white"); unionX.Display (w); w.Click ();
return(0);
}
morph_hatmorph_hatMorphHatmorph_hatMorphHatMorphHat 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.
thresholdthresholdThresholdthresholdThresholdThreshold,
regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing,
connectionconnectionConnectionconnectionConnectionConnection,
union1union1Union1union1Union1Union1,
watershedswatershedsWatershedswatershedsWatershedsWatersheds,
class_ndim_normclass_ndim_normClassNdimNormclass_ndim_normClassNdimNormClassNdimNorm,
gen_circlegen_circleGenCirclegen_circleGenCircleGenCircle,
gen_ellipsegen_ellipseGenEllipsegen_ellipseGenEllipseGenEllipse,
gen_rectangle1gen_rectangle1GenRectangle1gen_rectangle1GenRectangle1GenRectangle1,
gen_rectangle2gen_rectangle2GenRectangle2gen_rectangle2GenRectangle2GenRectangle2,
draw_regiondraw_regionDrawRegiondraw_regionDrawRegionDrawRegion,
gen_region_pointsgen_region_pointsGenRegionPointsgen_region_pointsGenRegionPointsGenRegionPoints,
gen_struct_elementsgen_struct_elementsGenStructElementsgen_struct_elementsGenStructElementsGenStructElements,
gen_region_polygon_filledgen_region_polygon_filledGenRegionPolygonFilledgen_region_polygon_filledGenRegionPolygonFilledGenRegionPolygonFilled
reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain,
select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape,
area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter,
connectionconnectionConnectionconnectionConnectionConnection
top_hattop_hatTopHattop_hatTopHatTopHat,
bottom_hatbottom_hatBottomHatbottom_hatBottomHatBottomHat,
union2union2Union2union2Union2Union2
openingopeningOpeningopeningOpeningOpening,
closingclosingClosingclosingClosingClosing
Foundation