morph_hat ( Region, StructElement : RegionTopHat : : )

Compute the union of bottom_hat and top_hat.

morph_hat computes the union of the regions that are removed by a opening operation with the regions that are added by a closing operation. Hence this is the union of the results of top_hat and bottom_hat. The position of StructElement does not influence the result.

Structuring elements (StructElement) can be generated with operators such as circle, rectangle1, rectangle2, ellipse, draw_region, store_polygon, store_coord, etc.


Attention

The individual regions are processed separately.


Parameters

Region (input_object)
region(-array) -> object
Regions to be processed.

StructElement (input_object)
region -> object
Structuring element (position-invariant).

RegionTopHat (output_object)
region(-array) -> object
Union of top hat and bottom hat.


Example
#include  
#include  "HCPP.H"

main()
{
  cout << "Reproduction of 'dilation_circle ()" << endl;
  cout << "First = original image " << endl;
  cout << "Red   = after segmentation " << endl;
  cout << "Blue  = after erosion " << endl;

  HByteImage img("affe");
  HWindow    w;

  HRegion      circ   = HRegion::Circle (10, 10, 1.5);
  HRegionArray regs   = (img >= 128).Connection();
  HRegionArray tophat = regs.TopHat (circ);
  HRegionArray bothat = regs.BottomHat (circ);
  HRegionArray unionX = tophat.Union2 (bothat);

                        img.Display (w);      w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();
  w.SetColor ("blue");  tophat.Display (w);   w.Click ();
  w.SetColor ("green"); bothat.Display (w);   w.Click ();
  w.SetColor ("white"); unionX.Display (w);   w.Click ();

  return(0);
}

Result

morph_hat returns 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_ndim1__, circle, ellipse, rectangle1, rectangle2, draw_region, store_coord, struct_elements, store_filled_polygon


Possible Successors

reduce_domain, select_shape, area_center, connection


Alternatives

top_hat, bottom_hat, union2


See also

opening, closing



Copyright © 1996-1997 MVTec Software GmbH