ClassesClassesClassesClasses | | | | Operators

openingopeningOpeningopeningOpeningOpening (Operator)

Name

openingopeningOpeningopeningOpeningOpening — Open a region.

Signature

opening(Region, StructElement : RegionOpening : : )

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

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

Herror opening(Hobject Region, Hobject StructElement, Hobject* RegionOpening)

HRegion HRegion::Opening(const HRegion& StructElement) const

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

void Opening(const HObject& Region, const HObject& StructElement, HObject* RegionOpening)

HRegion HRegion::Opening(const HRegion& StructElement) const

void HOperatorSetX.Opening(
[in] IHUntypedObjectX* Region, [in] IHUntypedObjectX* StructElement, [out] IHUntypedObjectX*RegionOpening)

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

static void HOperatorSet.Opening(HObject region, HObject structElement, out HObject regionOpening)

HRegion HRegion.Opening(HRegion structElement)

Description

An openingopeningOpeningopeningOpeningOpening operation is defined as an erosion followed by a Minkowsi addition. By applying openingopeningOpeningopeningOpeningOpening to a region, larger structures remain mostly intact, while small structures like lines or points are eliminated. In contrast, a closingclosingClosingclosingClosingClosing operation results in small gaps being retained or filled up (see closingclosingClosingclosingClosingClosing).

openingopeningOpeningopeningOpeningOpening serves to eliminate small regions (smaller than StructElementStructElementStructElementStructElementStructElementstructElement) and to smooth the boundaries of a region. The position of StructElementStructElementStructElementStructElementStructElementstructElement is meaningless, since an opening 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.

Parallelization

Parameters

RegionRegionRegionRegionRegionregion (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Regions to be opened.

StructElementStructElementStructElementStructElementStructElementstructElement (input_object)  region objectHRegionHRegionHRegionHRegionXHobject

Structuring element (position-invariant).

RegionOpeningRegionOpeningRegionOpeningRegionOpeningRegionOpeningregionOpening (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Opened regions.

Example (HDevelop)

* Large regions in an aerial picture (beech trees or meadows):
read_image(Image,'forest')
threshold(Image,Light,80,255)
gen_circle(StructElement1,100,100,2)
gen_circle(StructElement2,100,100,20)
* close the small gap
closing(Light,StructElement1,H)
* selecting the large regions
opening(H,StructElement2,Large)

* Selecting of edges with certain orientation:
read_image(Image,'fabrik')
sobel_amp(Image,Sobel,'sum_abs',3)
threshold(Sobel,Edges,10,255)
gen_rectangle2(StructElement,100,100,3.07819,20,1)
opening(Edges,StructElement,Direction)

Example (C)

/* simulation of opening */
my_opening(Hobject In, Hobject StructElement, Hobject *Out)
{
  Hobject  H;
  erosion1(In,StructElement,&H,1);
  minkowski_add1(H,StructElement,Out,1);
  clear_obj(H);
}

/* Large regions in an aerial picture (beech trees or meadows): */
read_image(&Image,"wald1");
threshold(Image,&Light,80.0,255.0);
gen_circle(&StructElement1,100.0,100.0,2.0);
gen_circle(&StructElement2,100.0,100.0,20.0);
/* close the small gap */
closing(Light,StructElement1,&H);
/* selecting the large regions */
opening(H,StructElement2,&Large);

/* Selecting of edges with certain orientation: */
read_image(&Image,"fabrik");
sobel_amp(Image,&Sobel,"sum_abs",3);
threshold(Sobel,Edges,30.0,255.0);
gen_rectangle2(&StructElement,100.0,100.0,3.07819,20.0,1.0);
opening(Edges,StructElement,&Direction);

Example (HDevelop)

* Large regions in an aerial picture (beech trees or meadows):
read_image(Image,'forest')
threshold(Image,Light,80,255)
gen_circle(StructElement1,100,100,2)
gen_circle(StructElement2,100,100,20)
* close the small gap
closing(Light,StructElement1,H)
* selecting the large regions
opening(H,StructElement2,Large)

* Selecting of edges with certain orientation:
read_image(Image,'fabrik')
sobel_amp(Image,Sobel,'sum_abs',3)
threshold(Sobel,Edges,10,255)
gen_rectangle2(StructElement,100,100,3.07819,20,1)
opening(Edges,StructElement,Direction)

Example (C++ (HALCON 5.0-10.0))

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"

main()
{
  HImage     img("wald1");
  HWindow    w;

  cout << "Example: Large regions in an aerial picture: " << endl;
  cout << "Beech Trees or Meadows" << endl;

  /* Struct elements */
  HRegion      circ1  = HRegion::GenCircle (10, 10, 2);
  HRegion      circ2  = HRegion::GenCircle (10, 10, 20);
  HRegion      rect1  = HRegion::GenRectangle2 (100, 100, 3.07819, 20, 1);

  /* Segmentation, closing () -> close the small gap
                   opening () -> select large regions */
  HRegionArray regs   = (img >= 80).Connection();
  HRegionArray clos   = regs.Closing (circ1);
  HRegionArray open   = clos.Opening (circ2);

                        img.Display (w);    w.Click ();
  w.SetColor ("red");   regs.Display (w);   w.Click ();
  w.SetColor ("blue");  clos.Display (w);   w.Click ();
  w.SetColor ("green"); open.Display (w);   w.Click ();

  cout << "Example: Selecting of edges with certain orientation" << endl;

  HByteImage hbi ("fabrik");

  HImage  sobel = hbi.SobelAmp ("sum_abs", 3);
  regs = (sobel >= 30).Connection ();

  HRegionArray direc = regs.Opening (rect1);

                        hbi.Display (w);    w.Click ();
  w.SetColor ("red");   regs.Display (w);   w.Click ();
  w.SetColor ("blue");  sobel.Display (w);  w.Click ();
  w.SetColor ("green"); direc.Display (w);  w.Click ();

  return(0);
}

Example (HDevelop)

* Large regions in an aerial picture (beech trees or meadows):
read_image(Image,'forest')
threshold(Image,Light,80,255)
gen_circle(StructElement1,100,100,2)
gen_circle(StructElement2,100,100,20)
* close the small gap
closing(Light,StructElement1,H)
* selecting the large regions
opening(H,StructElement2,Large)

* Selecting of edges with certain orientation:
read_image(Image,'fabrik')
sobel_amp(Image,Sobel,'sum_abs',3)
threshold(Sobel,Edges,10,255)
gen_rectangle2(StructElement,100,100,3.07819,20,1)
opening(Edges,StructElement,Direction)

Example (HDevelop)

* Large regions in an aerial picture (beech trees or meadows):
read_image(Image,'forest')
threshold(Image,Light,80,255)
gen_circle(StructElement1,100,100,2)
gen_circle(StructElement2,100,100,20)
* close the small gap
closing(Light,StructElement1,H)
* selecting the large regions
opening(H,StructElement2,Large)

* Selecting of edges with certain orientation:
read_image(Image,'fabrik')
sobel_amp(Image,Sobel,'sum_abs',3)
threshold(Sobel,Edges,10,255)
gen_rectangle2(StructElement,100,100,3.07819,20,1)
opening(Edges,StructElement,Direction)

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:

    O(2 * sqrt(F1) * sqrt(F2)) .

Result

openingopeningOpeningopeningOpeningOpening 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

minkowski_add1minkowski_add1MinkowskiAdd1minkowski_add1MinkowskiAdd1MinkowskiAdd1, erosion1erosion1Erosion1erosion1Erosion1Erosion1, opening_circleopening_circleOpeningCircleopening_circleOpeningCircleOpeningCircle

See also

gen_circlegen_circleGenCirclegen_circleGenCircleGenCircle, gen_rectangle2gen_rectangle2GenRectangle2gen_rectangle2GenRectangle2GenRectangle2, gen_region_polygongen_region_polygonGenRegionPolygongen_region_polygonGenRegionPolygonGenRegionPolygon

Module

Foundation


ClassesClassesClassesClasses | | | | Operators