morph_hatmorph_hatMorphHatMorphHatmorph_hat (算子)
名称
morph_hatmorph_hatMorphHatMorphHatmorph_hat — Compute the union of bottom_hatbottom_hatBottomHatBottomHatBottomHatbottom_hat and top_hattop_hatTopHatTopHatTopHattop_hat.
警告
morph_hatmorph_hatMorphHatMorphHatMorphHatmorph_hat 已过时,仅出于向后兼容性考虑而保留。
签名
描述
morph_hatmorph_hatMorphHatMorphHatMorphHatmorph_hat 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_hatTopHatTopHatTopHattop_hat and bottom_hatbottom_hatBottomHatBottomHatBottomHatbottom_hat.
The position of StructElementStructElementStructElementStructElementstructElementstruct_element does not influence the
result.
Structuring elements (StructElementStructElementStructElementStructElementstructElementstruct_element) can be generated
with operators such as gen_circlegen_circleGenCircleGenCircleGenCirclegen_circle, gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1gen_rectangle1,
gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2GenRectangle2gen_rectangle2, gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipsegen_ellipse,
draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region, gen_region_polygongen_region_polygonGenRegionPolygonGenRegionPolygonGenRegionPolygongen_region_polygon,
gen_region_pointsgen_region_pointsGenRegionPointsGenRegionPointsGenRegionPointsgen_region_points, etc.
注意
各个区域将分别进行处理。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 在元组级别上自动并行化。
参数
RegionRegionRegionRegionregionregion (input_object) region(-array) → objectHRegionHObjectHRegionHobject
Regions to be processed.
StructElementStructElementStructElementStructElementstructElementstruct_element (input_object) region → objectHRegionHObjectHRegionHobject
Structuring element (position-invariant).
RegionMorphHatRegionMorphHatRegionMorphHatRegionMorphHatregionMorphHatregion_morph_hat (output_object) region(-array) → objectHRegionHObjectHRegionHobject *
Union of top hat and bottom hat.
示例 (C++ (HALCON 5.0-10.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);
}
示例(C)
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);
}
示例 (C++ (HALCON 5.0-10.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);
}
示例 (C++ (HALCON 5.0-10.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);
}
示例 (C++ (HALCON 5.0-10.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_hatMorphHatMorphHatMorphHatmorph_hat 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>)set_system("no_object_result",<RegionResult>)SetSystem("no_object_result",<RegionResult>)SetSystem("no_object_result",<RegionResult>)SetSystem("no_object_result",<RegionResult>)set_system("no_object_result",<RegionResult>)
-
empty region:
set_system('empty_region_result',<RegionResult>)set_system("empty_region_result",<RegionResult>)SetSystem("empty_region_result",<RegionResult>)SetSystem("empty_region_result",<RegionResult>)SetSystem("empty_region_result",<RegionResult>)set_system("empty_region_result",<RegionResult>)
否则,将抛出异常。
可能的前趋
thresholdthresholdThresholdThresholdThresholdthreshold,
regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing,
connectionconnectionConnectionConnectionConnectionconnection,
union1union1Union1Union1Union1union1,
watershedswatershedsWatershedsWatershedsWatershedswatersheds,
class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNormclass_ndim_norm,
gen_circlegen_circleGenCircleGenCircleGenCirclegen_circle,
gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipsegen_ellipse,
gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1gen_rectangle1,
gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2GenRectangle2gen_rectangle2,
draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region,
gen_region_pointsgen_region_pointsGenRegionPointsGenRegionPointsGenRegionPointsgen_region_points,
gen_region_polygon_filledgen_region_polygon_filledGenRegionPolygonFilledGenRegionPolygonFilledGenRegionPolygonFilledgen_region_polygon_filled
可能的后继
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain,
select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape,
area_centerarea_centerAreaCenterAreaCenterAreaCenterarea_center,
connectionconnectionConnectionConnectionConnectionconnection
替代
top_hattop_hatTopHatTopHatTopHattop_hat,
bottom_hatbottom_hatBottomHatBottomHatBottomHatbottom_hat,
union2union2Union2Union2Union2union2
另见
openingopeningOpeningOpeningOpeningopening,
closingclosingClosingClosingClosingclosing
模块
Foundation