Skip to content

opening_segOpeningSegOpeningSegopening_segopening_seg🔗

Short description🔗

opening_segOpeningSegOpeningSegopening_segopening_seg — Separate overlapping regions.

Warning🔗

opening_segOpeningSeg is obsolete and is only provided for reasons of backward compatibility.

Signature🔗

opening_seg( region Region, region StructElement, out region RegionOpening )void OpeningSeg( const HObject& Region, const HObject& StructElement, HObject* RegionOpening )static void HOperatorSet.OpeningSeg( HObject region, HObject structElement, out HObject regionOpening )def opening_seg( region: HObject, struct_element: HObject ) -> HObject

Herror opening_seg( const Hobject Region, const Hobject StructElement, Hobject* RegionOpening )

Herror T_opening_seg( const Hobject Region, const Hobject StructElement, Hobject* RegionOpening )

HRegion HRegion::OpeningSeg( const HRegion& StructElement ) const

HRegion HRegion.OpeningSeg( HRegion structElement )

Description🔗

The opening_segOpeningSeg operation is defined as a sequence of the following operators: erosion1Erosion1, connectionConnection and dilation1Dilation1 (see example). Only one iteration is done in erosion1Erosion1 and dilation1Dilation1.

opening_segOpeningSeg serves to separate overlapping regions whose area of overlap is smaller than StructElementstructElementstruct_element. It should be noted that the resulting regions can overlap without actually merging (see expand_regionExpandRegion). opening_segOpeningSeg uses the center of gravity as the reference point of the structuring element.

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.

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

StructElementstructElementstruct_element (input_object) region → objectHObjectHRegionHObjectHobject

Structuring element (position-invariant).

RegionOpeningregionOpeningregion_opening (output_object) region-array → objectHObjectHRegionHObjectHobject *

Opened regions.

Example🔗

(HDevelop)

* Simulation of opening_seg
* opening_seg(Region,StructElement,RegionOpening):
    erosion1(Region,StructElement,H1,1)
    connection(H1,H2)
    dilation1(H2,StructElement,RegionOpening,1)
(C)
/* Simulation of opening_seg */
my_opening_seg(Hobject Region, Hobject StructElement, Hobject *Opening)
{
  Hobject  H1,H2\;
  erosion1(Region,StructElement,&H1,1)\;
  connection(H1,&H2)\;
  dilation1(H2,StructElement,Opening,1)\;
}

/* separation of circular objects */
gen_random_regions(&Regions,"circle",8.5,10.5,0.0,0.0,0.0,0.0,400,512,512)\;
union1(Regions,&UnionReg)\;
gen_circle(&Mask,100,100,8.5)\;
opening_seg(UnionReg,Mask,&RegionsNew)\;
(C++)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#include "HalconCpp.h"

main()
{
  HWindow  w\;
  HRegionArray regs = HRegionArray::GenRandomRegions("circle",8.5,10.5,
                                                  0,0,0,0,400,512,512)\;
 HRegionArray ureg = regs.Union1()\;
  HRegion      crc  = HRegion::GenCircle(100,100,8.5)\;
  HRegionArray ops  = ureg.OpeningSeg(crc)\;
 w.SetColor("red")\;   regs.Display(w)\;  w.Click()\;
  w.SetColored(12)\;    ops.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(\sqrt{F1} \cdot \sqrt{F2} \cdot \sqrt{\sqrt{F1}}) \enspace . \end{eqnarray*}\]

Result🔗

opening_segOpeningSeg 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

expand_regionExpandRegion, reduce_domainReduceDomain, select_shapeSelectShape, area_centerAreaCenter, connectionConnection

Alternatives

erosion1Erosion1, connectionConnection, dilation1Dilation1

Module🔗

Foundation