Herror ::opening (
    Hobject Region,
    Hobject StructElement,
    Hobject *RegionOpening
)
HRegion HRegion::Opening (
    const HRegion &StructElement
) const
HRegionArray HRegionArray::Opening (
    const HRegion &StructElement
) const

Open a region.

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

::opening serves to eliminate small regions (smaller than StructElement) and to smooth the boundaries of a region. The position of StructElement is meaningless, since an opening operation is invariant with respect to the choice of the reference point.

Structuring elements (StructElement) can be generated with operators such as ::gen_circle, ::gen_rectangle1, ::gen_rectangle2, ::gen_ellipse, ::draw_region, ::gen_region_polygon, ::gen_region_points, etc.


Parameters

Region (input_object)
region(-array) -> Hobject: HRegion(Array)
Regions to be opened.

StructElement (input_object)
region -> Hobject: HRegion
Structuring element (position-invariant).

RegionOpening (output_object)
region(-array) -> Hobject * : HRegion(Array)
Opened regions.


Example
#include  <iostream.h>
#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);
}

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

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

  a) no region:    set_system('no_object_result',<RegionResult>)
  b) empty region: set_system('empty_region_result',<RegionResult>)
Otherwise, an exception is raised.


Possible Predecessors

::threshold, ::regiongrowing, ::connection, ::union1, ::watersheds, ::class_ndim_norm, ::gen_circle, ::gen_ellipse, ::gen_rectangle1, ::gen_rectangle2, ::draw_region, ::gen_region_points, ::gen_struct_elements, ::gen_region_polygon_filled


Possible Successors

::reduce_domain, ::select_shape, ::area_center, ::connection


Alternatives

::minkowski_add1, ::erosion1, ::opening_circle


See also

::gen_circle, ::gen_rectangle2, ::gen_region_polygon


Module

Morphology



Copyright © 1996-2002 MVTec Software GmbH