closingclosingClosingClosingclosing闭(算子)

名称

closingclosingClosingClosingclosing — 关闭一个区域。

签名

closing(Region, StructElement : RegionClosing : : )

Herror closing(const Hobject Region, const Hobject StructElement, Hobject* RegionClosing)

Herror T_closing(const Hobject Region, const Hobject StructElement, Hobject* RegionClosing)

void Closing(const HObject& Region, const HObject& StructElement, HObject* RegionClosing)

HRegion HRegion::Closing(const HRegion& StructElement) const

static void HOperatorSet.Closing(HObject region, HObject structElement, out HObject regionClosing)

HRegion HRegion.Closing(HRegion structElement)

def closing(region: HObject, struct_element: HObject) -> HObject

描述

closingclosingClosingClosingClosingclosing 操作定义为先进行膨胀处理,再执行明可夫斯基减法。对区域应用 closingclosingClosingClosingClosingclosing 操作时,较大结构基本保持完整,而相邻区域间的小间隙及小于 StructElementStructElementStructElementStructElementstructElementstruct_element 孔洞会被填补,区域边界亦得到平滑处理。所有 closingclosingClosingClosingClosingclosing 变体均具有以下特性:独立区域不会被合并,而是保持为独立对象。StructElementStructElementStructElementStructElementstructElementstruct_element 的位置无关紧要,因为闭操作对参考点的选择具有不变性。

结构元素(StructElementStructElementStructElementStructElementstructElementstruct_element)可通过以下算子生成:gen_circlegen_circleGenCircleGenCircleGenCirclegen_circlegen_rectangle1gen_rectangle1GenRectangle1GenRectangle1GenRectangle1gen_rectangle1gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2GenRectangle2gen_rectangle2gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipsegen_ellipsedraw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_regiongen_region_polygongen_region_polygonGenRegionPolygonGenRegionPolygonGenRegionPolygongen_region_polygongen_region_pointsgen_region_pointsGenRegionPointsGenRegionPointsGenRegionPointsgen_region_points 等。

注意

closingclosingClosingClosingClosingclosing 对每个输入区域分别应用。若要消除不同区域之间的间隙,必须先调用 union1union1Union1Union1Union1union1union2union2Union2Union2Union2union2

执行信息

参数

RegionRegionRegionRegionregionregion (输入对象)  region(-array) objectHRegionHObjectHRegionHobject

待关闭的区域。

StructElementStructElementStructElementStructElementstructElementstruct_element (输入对象)  region objectHRegionHObjectHRegionHobject

结构元素(位置不变)。

RegionClosingRegionClosingRegionClosingRegionClosingregionClosingregion_closing (输出对象)  region(-array) objectHRegionHObjectHRegionHobject *

关闭区域。

示例 (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 '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);
}

示例(C)

my_closing(Hobject In, Hobject StructElement, Hobject *Out)
{
  Hobject  tmp;
  dilation1(In,StructElement,&tmp,1);
  minkowski_sub1(tmp,StructElement,Out,1);
}

示例 (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 '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);
}

示例 (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 '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);
}

示例 (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 '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);
}

复杂度

设 F1 为输入区域的面积,F2 为结构元素的面积。则单个区域的运行时间复杂度为:

结果

closingclosingClosingClosingClosingclosing 在所有参数正确时返回 2 (H_MSG_TRUE)。当输入区域为空或不存在时,其行为可通过以下方式设置:

否则,将抛出异常。

可能的前趋

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

替代

closing_circleclosing_circleClosingCircleClosingCircleClosingCircleclosing_circle

另见

dilation1dilation1Dilation1Dilation1Dilation1dilation1, erosion1erosion1Erosion1Erosion1Erosion1erosion1, openingopeningOpeningOpeningOpeningopening, minkowski_sub1minkowski_sub1MinkowskiSub1MinkowskiSub1MinkowskiSub1minkowski_sub1

模块

基础