ClassesClassesClassesClasses | | | | Operators

closingclosingClosingclosingClosingClosing (Operator)

Name

closingclosingClosingclosingClosingClosing — Close a region.

Signature

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)

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

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

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

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

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

void HOperatorSetX.Closing(
[in] IHUntypedObjectX* Region, [in] IHUntypedObjectX* StructElement, [out] IHUntypedObjectX*RegionClosing)

IHRegionX* HRegionX.Closing([in] IHRegionX* StructElement)

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

HRegion HRegion.Closing(HRegion structElement)

Description

A closingclosingClosingclosingClosingClosing operation is defined as a dilation followed by a Minkowsi subtraction. By applying closingclosingClosingclosingClosingClosing to a region, larger structures remain mostly intact, while small gaps between adjacent regions and holes smaller than StructElementStructElementStructElementStructElementStructElementstructElement are closed, and the regions' boundaries are smoothed. All closingclosingClosingclosingClosingClosing variants share the property that separate regions are not merged, but remain separate objects. The position of StructElementStructElementStructElementStructElementStructElementstructElement is meaningless, since a closing operation is invariant with respect to the choice of the reference point.

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.

Attention

closingclosingClosingclosingClosingClosing is applied to each input region separately. If gaps between different regions are to be closed, union1union1Union1union1Union1Union1 or union2union2Union2union2Union2Union2 has to be called first.

Parallelization

Parameters

RegionRegionRegionRegionRegionregion (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Regions to be closed.

StructElementStructElementStructElementStructElementStructElementstructElement (input_object)  region objectHRegionHRegionHRegionHRegionXHobject

Structuring element (position-invariant).

RegionClosingRegionClosingRegionClosingRegionClosingRegionClosingregionClosing (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Closed regions.

Example (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);
}

Example (C)

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

Example (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);
}

Example (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);
}

Example (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);
}

Example (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);
}

Complexity

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:

Result

closingclosingClosingclosingClosingClosing returns 2 (H_MSG_TRUE) if all parameters are correct. The behavior in case of empty or no input region can be set via:

Otherwise, an exception is raised.

Possible Predecessors

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

Possible Successors

reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain, select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter, connectionconnectionConnectionconnectionConnectionConnection

Alternatives

closing_circleclosing_circleClosingCircleclosing_circleClosingCircleClosingCircle, closing_golayclosing_golayClosingGolayclosing_golayClosingGolayClosingGolay

See also

dilation1dilation1Dilation1dilation1Dilation1Dilation1, erosion1erosion1Erosion1erosion1Erosion1Erosion1, openingopeningOpeningopeningOpeningOpening, minkowski_sub1minkowski_sub1MinkowskiSub1minkowski_sub1MinkowskiSub1MinkowskiSub1

Module

Foundation


ClassesClassesClassesClasses | | | | Operators