Skip to content

closingClosingClosingclosingclosingπŸ”—

Short descriptionπŸ”—

closingClosingClosingclosingclosing β€” Close a region.

SignatureπŸ”—

closing( region Region, region StructElement, out region RegionClosing )void Closing( const HObject& Region, const HObject& StructElement, HObject* RegionClosing )static void HOperatorSet.Closing( HObject region, HObject structElement, out HObject regionClosing )def closing( region: HObject, struct_element: HObject ) -> HObject

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

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

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

HRegion HRegion.Closing( HRegion structElement )

DescriptionπŸ”—

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

Structuring elements (StructElementstructElementstruct_element) can be generated with operators such as gen_circleGenCircle, gen_rectangle1GenRectangle1, gen_rectangle2GenRectangle2, gen_ellipseGenEllipse, draw_regionDrawRegion, gen_region_polygonGenRegionPolygon, gen_region_pointsGenRegionPoints, etc.

AttentionπŸ”—

closingClosing is applied to each input region separately. If gaps between different regions are to be closed, union1Union1 or union2Union2 has to be called first.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

ParametersπŸ”—

Regionregionregion (input_object) region(-array) β†’ objectHObjectHRegionHObjectHobject

Regions to be closed.

StructElementstructElementstruct_element (input_object) region β†’ objectHObjectHRegionHObjectHobject

Structuring element (position-invariant).

RegionClosingregionClosingregion_closing (output_object) region(-array) β†’ objectHObjectHRegionHObjectHobject *

Closed regions.

ExampleπŸ”—

(C)

my_closing(Hobject In, Hobject StructElement, Hobject *Out)
{
  Hobject  tmp\;
  dilation1(In,StructElement,&tmp,1)\;
  minkowski_sub1(tmp,StructElement,Out,1)\;
}
(C++)
#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:

\[\begin{eqnarray*} O(2 \cdot \sqrt{F1} \cdot \sqrt{F2}) \enspace . \end{eqnarray*}\]

ResultπŸ”—

closingClosing 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.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection, union1Union1, watershedsWatersheds, class_ndim_normClassNdimNorm, gen_circleGenCircle, gen_ellipseGenEllipse, gen_rectangle1GenRectangle1, gen_rectangle2GenRectangle2, draw_regionDrawRegion, gen_region_pointsGenRegionPoints, gen_region_polygon_filledGenRegionPolygonFilled

Possible successors

reduce_domainReduceDomain, select_shapeSelectShape, area_centerAreaCenter, connectionConnection

Alternatives

closing_circleClosingCircle

See also

dilation1Dilation1, erosion1Erosion1, openingOpening, minkowski_sub1MinkowskiSub1

ModuleπŸ”—

Foundation