HALCON Reference Manual 10.0.2
Table of Contents / Morphology / Region ClassesClassesClasses | | | Operators

morph_hatmorph_hatmorph_hatMorphHatMorphHat (Operator)

Name

morph_hatmorph_hatmorph_hatMorphHatMorphHat — Compute the union of bottom_hatbottom_hatbottom_hatBottomHatBottomHat and top_hattop_hattop_hatTopHatTopHat.

Signature

morph_hat(Region, StructElement : RegionMorphHat : : )

Herror morph_hat(const Hobject Region, const Hobject StructElement, Hobject* RegionMorphHat)

Herror T_morph_hat(const Hobject Region, const Hobject StructElement, Hobject* RegionMorphHat)

Herror morph_hat(Hobject Region, Hobject StructElement, Hobject* RegionMorphHat)

HRegion HRegion::MorphHat(const HRegion& StructElement) const

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

void HOperatorSetX.MorphHat(
[in] IHUntypedObjectX* Region, [in] IHUntypedObjectX* StructElement, [out] IHUntypedObjectX*RegionMorphHat)

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

static void HOperatorSet.MorphHat(HObject region, HObject structElement, out HObject regionMorphHat)

HRegion HRegion.MorphHat(HRegion structElement)

Description

morph_hatmorph_hatmorph_hatMorphHatMorphHat computes the union of the regions that are removed by an openingopeningopeningOpeningOpening operation with the regions that are added by a closingclosingclosingClosingClosing operation. Hence this is the union of the results of top_hattop_hattop_hatTopHatTopHat and bottom_hatbottom_hatbottom_hatBottomHatBottomHat. The position of StructElementStructElementStructElementStructElementstructElement does not influence the result.

Structuring elements (StructElementStructElementStructElementStructElementstructElement) can be generated with operators such as gen_circlegen_circlegen_circleGenCircleGenCircle, gen_rectangle1gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1, gen_rectangle2gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2, gen_ellipsegen_ellipsegen_ellipseGenEllipseGenEllipse, draw_regiondraw_regiondraw_regionDrawRegionDrawRegion, gen_region_polygongen_region_polygongen_region_polygonGenRegionPolygonGenRegionPolygon, gen_region_pointsgen_region_pointsgen_region_pointsGenRegionPointsGenRegionPoints, etc.

Attention

The individual regions are processed separately.

Parallelization

Parameters

RegionRegionRegionRegionregion (input_object)  region(-array) objectHRegionHRegionHRegionXHobject

Regions to be processed.

StructElementStructElementStructElementStructElementstructElement (input_object)  region objectHRegionHRegionHRegionXHobject

Structuring element (position-invariant).

RegionMorphHatRegionMorphHatRegionMorphHatRegionMorphHatregionMorphHat (output_object)  region(-array) objectHRegionHRegionHRegionXHobject *

Union of top hat and bottom hat.

Example (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.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("monkey");
  HWindow    w;

  HRegion      circ   = HRegion::GenCircle (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);
}

Example (C)

my_morph_hat(Hobject *In, Hobject StructElement, Hobject *Out)
{
  Hobject top, bottom;
  top_hat(In,StructElement,&top);
  bottom_hat(In,StructElement,&bottom);
  union2(top,bottom,Out);
  clear_obj(top); clear_obj(bottom);
}

Example (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.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("monkey");
  HWindow    w;

  HRegion      circ   = HRegion::GenCircle (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);
}

Example (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.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("monkey");
  HWindow    w;

  HRegion      circ   = HRegion::GenCircle (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);
}

Example (C++)

#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.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("monkey");
  HWindow    w;

  HRegion      circ   = HRegion::GenCircle (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_hatmorph_hatmorph_hatMorphHatMorphHat 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

thresholdthresholdthresholdThresholdThreshold, regiongrowingregiongrowingregiongrowingRegiongrowingRegiongrowing, connectionconnectionconnectionConnectionConnection, union1union1union1Union1Union1, watershedswatershedswatershedsWatershedsWatersheds, class_ndim_normclass_ndim_normclass_ndim_normClassNdimNormClassNdimNorm, gen_circlegen_circlegen_circleGenCircleGenCircle, gen_ellipsegen_ellipsegen_ellipseGenEllipseGenEllipse, gen_rectangle1gen_rectangle1gen_rectangle1GenRectangle1GenRectangle1, gen_rectangle2gen_rectangle2gen_rectangle2GenRectangle2GenRectangle2, draw_regiondraw_regiondraw_regionDrawRegionDrawRegion, gen_region_pointsgen_region_pointsgen_region_pointsGenRegionPointsGenRegionPoints, gen_struct_elementsgen_struct_elementsgen_struct_elementsGenStructElementsGenStructElements, gen_region_polygon_filledgen_region_polygon_filledgen_region_polygon_filledGenRegionPolygonFilledGenRegionPolygonFilled

Possible Successors

reduce_domainreduce_domainreduce_domainReduceDomainReduceDomain, select_shapeselect_shapeselect_shapeSelectShapeSelectShape, area_centerarea_centerarea_centerAreaCenterAreaCenter, connectionconnectionconnectionConnectionConnection

Alternatives

top_hattop_hattop_hatTopHatTopHat, bottom_hatbottom_hatbottom_hatBottomHatBottomHat, union2union2union2Union2Union2

See also

openingopeningopeningOpeningOpening, closingclosingclosingClosingClosing

Module

Foundation


Table of Contents / Morphology / Region ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH