ClassesClassesClassesClasses | | | | Operators

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 (Operator)

Name

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 — Dilate a region with a rectangular structuring element.

Signature

dilation_rectangle1(Region : RegionDilation : Width, Height : )

Herror dilation_rectangle1(const Hobject Region, Hobject* RegionDilation, const Hlong Width, const Hlong Height)

Herror T_dilation_rectangle1(const Hobject Region, Hobject* RegionDilation, const Htuple Width, const Htuple Height)

Herror dilation_rectangle1(Hobject Region, Hobject* RegionDilation, const HTuple& Width, const HTuple& Height)

HRegion HRegion::DilationRectangle1(const HTuple& Width, const HTuple& Height) const

HRegionArray HRegionArray::DilationRectangle1(const HTuple& Width, const HTuple& Height) const

void DilationRectangle1(const HObject& Region, HObject* RegionDilation, const HTuple& Width, const HTuple& Height)

HRegion HRegion::DilationRectangle1(Hlong Width, Hlong Height) const

void HOperatorSetX.DilationRectangle1(
[in] IHUntypedObjectX* Region, [out] IHUntypedObjectX*RegionDilation, [in] VARIANT Width, [in] VARIANT Height)

IHRegionX* HRegionX.DilationRectangle1(
[in] Hlong Width, [in] Hlong Height)

static void HOperatorSet.DilationRectangle1(HObject region, out HObject regionDilation, HTuple width, HTuple height)

HRegion HRegion.DilationRectangle1(int width, int height)

Description

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 applies a dilation with a rectangular structuring element to the input regions RegionRegionRegionRegionRegionregion. The size of the structuring rectangle is WidthWidthWidthWidthWidthwidth x HeightHeightHeightHeightHeightheight. The operator results in enlarged regions, and the holes smaller than the rectangular mask in the interior of the regions are closed.

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 is a very fast operation because the height of the rectangle enters only logarithmically into the runtime complexity, while the width does not enter at all. This leads to excellent runtime efficiency, even in the case of very large rectangles (edge length > 100).

Attention

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 is applied to each input region separately. If gaps between different regions are to be closed, union1union1Union1union1Union1Union1 or union2union2Union2union2Union2Union2 has to be called first.

To enlarge a region by the same amount in all directions, WidthWidthWidthWidthWidthwidth and HeightHeightHeightHeightHeightheight must be odd. If this is not the case, the region is dilated by a larger amount at the right or at the bottom, respectively, than at the left or at the top.

Parallelization

Parameters

RegionRegionRegionRegionRegionregion (input_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject

Regions to be dilated.

RegionDilationRegionDilationRegionDilationRegionDilationRegionDilationregionDilation (output_object)  region(-array) objectHRegionHRegionHRegionHRegionXHobject *

Dilated regions.

WidthWidthWidthWidthWidthwidth (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the structuring rectangle.

Default value: 11

Suggested values: 1, 2, 3, 4, 5, 11, 15, 21, 31, 51, 71, 101, 151, 201

Typical range of values: 1 ≤ Width Width Width Width Width width ≤ 511 (lin)

Minimum increment: 1

Recommended increment: 10

HeightHeightHeightHeightHeightheight (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the structuring rectangle.

Default value: 11

Suggested values: 1, 2, 3, 4, 5, 11, 15, 21, 31, 51, 71, 101, 151, 201

Typical range of values: 1 ≤ Height Height Height Height Height height ≤ 511 (lin)

Minimum increment: 1

Recommended increment: 10

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

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

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

  HByteImage img("monkey");
  HWindow    w;

  HRegionArray regs   = (img >= 220).Connection();
  HRegionArray dilreg = regs.DilationRectangle1 (2, 4);

                        img.Display (w);      w.Click ();
  w.SetColor ("blue");  dilreg.Display (w);   w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();

  return(0);
}

Example (C)

threshold(Image,&Light,220.0,255.0);
dilation_rectangle1(Light,&Wide,50,50);
set_color(WindowHandle,"red");
disp_region(Wide,WindowHandle);
set_color(WindowHandle,"white");
disp_region(Light,WindowHandle);

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

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

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

  HByteImage img("monkey");
  HWindow    w;

  HRegionArray regs   = (img >= 220).Connection();
  HRegionArray dilreg = regs.DilationRectangle1 (2, 4);

                        img.Display (w);      w.Click ();
  w.SetColor ("blue");  dilreg.Display (w);   w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();

  return(0);
}

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

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

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

  HByteImage img("monkey");
  HWindow    w;

  HRegionArray regs   = (img >= 220).Connection();
  HRegionArray dilreg = regs.DilationRectangle1 (2, 4);

                        img.Display (w);      w.Click ();
  w.SetColor ("blue");  dilreg.Display (w);   w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();

  return(0);
}

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

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

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

  HByteImage img("monkey");
  HWindow    w;

  HRegionArray regs   = (img >= 220).Connection();
  HRegionArray dilreg = regs.DilationRectangle1 (2, 4);

                        img.Display (w);      w.Click ();
  w.SetColor ("blue");  dilreg.Display (w);   w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();

  return(0);
}

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

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

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

  HByteImage img("monkey");
  HWindow    w;

  HRegionArray regs   = (img >= 220).Connection();
  HRegionArray dilreg = regs.DilationRectangle1 (2, 4);

                        img.Display (w);      w.Click ();
  w.SetColor ("blue");  dilreg.Display (w);   w.Click ();
  w.SetColor ("red");   regs.Display (w);     w.Click ();

  return(0);
}

Complexity

Let F1 be the area of an input region and H be the height of the rectangle. Then the runtime complexity for one region is:

Result

dilation_rectangle1dilation_rectangle1DilationRectangle1dilation_rectangle1DilationRectangle1DilationRectangle1 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

Possible Successors

reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain, select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, area_centerarea_centerAreaCenterarea_centerAreaCenterAreaCenter, connectionconnectionConnectionconnectionConnectionConnection

Alternatives

minkowski_add1minkowski_add1MinkowskiAdd1minkowski_add1MinkowskiAdd1MinkowskiAdd1, minkowski_add2minkowski_add2MinkowskiAdd2minkowski_add2MinkowskiAdd2MinkowskiAdd2, expand_regionexpand_regionExpandRegionexpand_regionExpandRegionExpandRegion, dilation1dilation1Dilation1dilation1Dilation1Dilation1, dilation2dilation2Dilation2dilation2Dilation2Dilation2, dilation_circledilation_circleDilationCircledilation_circleDilationCircleDilationCircle

See also

gen_rectangle1gen_rectangle1GenRectangle1gen_rectangle1GenRectangle1GenRectangle1, gen_region_polygon_filledgen_region_polygon_filledGenRegionPolygonFilledgen_region_polygon_filledGenRegionPolygonFilledGenRegionPolygonFilled

Module

Foundation


ClassesClassesClassesClasses | | | | Operators