Skip to content

morph_hatMorphHatMorphHatmorph_hatmorph_hat🔗

Short description🔗

morph_hatMorphHatMorphHatmorph_hatmorph_hat — Compute the union of bottom_hatBottomHat and top_hatTopHat.

Warning🔗

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

Signature🔗

morph_hat( region Region, region StructElement, out region RegionMorphHat )void MorphHat( const HObject& Region, const HObject& StructElement, HObject* RegionMorphHat )static void HOperatorSet.MorphHat( HObject region, HObject structElement, out HObject regionMorphHat )def morph_hat( region: HObject, struct_element: HObject ) -> HObject

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

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

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

HRegion HRegion.MorphHat( HRegion structElement )

Description🔗

morph_hatMorphHat computes the union of the regions that are removed by an openingOpening operation with the regions that are added by a closingClosing operation. Hence this is the union of the results of top_hatTopHat and bottom_hatBottomHat. The position of StructElementstructElementstruct_element does not influence the result.

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.

Attention🔗

The individual regions are processed separately.

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

StructElementstructElementstruct_element (input_object) region → objectHObjectHRegionHObjectHobject

Structuring element (position-invariant).

RegionMorphHatregionMorphHatregion_morph_hat (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Union of top hat and bottom hat.

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)\;
}
(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_hatMorphHat 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

reduce_domainReduceDomain, select_shapeSelectShape, area_centerAreaCenter, connectionConnection

Alternatives

top_hatTopHat, bottom_hatBottomHat, union2Union2

See also

openingOpening, closingClosing

Module🔗

Foundation