ClassesClassesClassesClasses | | | | Operators

regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing (Operator)


regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing — Segment an image using regiongrowing.


regiongrowing(Image : Regions : Row, Column, Tolerance, MinSize : )

Herror regiongrowing(const Hobject Image, Hobject* Regions, const Hlong Row, const Hlong Column, double Tolerance, const Hlong MinSize)

Herror T_regiongrowing(const Hobject Image, Hobject* Regions, const Htuple Row, const Htuple Column, const Htuple Tolerance, const Htuple MinSize)

Herror regiongrowing(Hobject Image, Hobject* Regions, const HTuple& Row, const HTuple& Column, const HTuple& Tolerance, const HTuple& MinSize)

HRegionArray HImage::Regiongrowing(const HTuple& Row, const HTuple& Column, const HTuple& Tolerance, const HTuple& MinSize) const

HRegionArray HImageArray::Regiongrowing(const HTuple& Row, const HTuple& Column, const HTuple& Tolerance, const HTuple& MinSize) const

void Regiongrowing(const HObject& Image, HObject* Regions, const HTuple& Row, const HTuple& Column, const HTuple& Tolerance, const HTuple& MinSize)

HRegion HImage::Regiongrowing(Hlong Row, Hlong Column, const HTuple& Tolerance, Hlong MinSize) const

HRegion HImage::Regiongrowing(Hlong Row, Hlong Column, double Tolerance, Hlong MinSize) const

void HOperatorSetX.Regiongrowing(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*Regions, [in] VARIANT Row, [in] VARIANT Column, [in] VARIANT Tolerance, [in] VARIANT MinSize)

IHRegionX* HImageX.Regiongrowing(
[in] Hlong Row, [in] Hlong Column, [in] VARIANT Tolerance, [in] Hlong MinSize)

static void HOperatorSet.Regiongrowing(HObject image, out HObject regions, HTuple row, HTuple column, HTuple tolerance, HTuple minSize)

HRegion HImage.Regiongrowing(int row, int column, HTuple tolerance, int minSize)

HRegion HImage.Regiongrowing(int row, int column, double tolerance, int minSize)


regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing segments images into regions of the same intensity --- rastered into rectangles of size Row * Column. In order to decide whether two adjacent rectangles belong to the same region only the gray value of their center points is used. If the gray value difference is less then or equal to ToleranceToleranceToleranceToleranceTolerancetolerance the rectangles are merged into one region.

If g_{1} and g_{2} are two gray values to be examined, they are merged into the same region if:

    |g_1 - g_2| < Tolerance

For images of type 'cyclic', the following formulas are used:

          |g1 - g2| < Tolerance and |g1 - g2| <= 127
    256 - |g1 - g2| < Tolerance and |g1 - g2| >  127

For rectangles larger than one pixel, ususally the images should be smoothed with a lowpass filter with a size of at least Row * Column before calling regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing (so that the gray values at the centers of the regtangles are “representative” for the whole rectangle). If the image contains little noise and the rectangles are small, the smoothing can be omitted in many cases.

The resulting regions are collections of rectangles of the chosen size Row * Column. Only regions containing at least MinSizeMinSizeMinSizeMinSizeMinSizeminSize points are returned.

Regiongrowing is a very fast operation, and thus suited for time-critical applications.


ColumnColumnColumnColumnColumncolumn and RowRowRowRowRowrow are automatically converted to odd values if necessary.



ImageImageImageImageImageimage (input_object)  singlechannelimage(-array) objectHImageHImageHImageHImageXHobject (byte / direction / cyclic / int1 / int2 / int4 / real)

Input image.

RegionsRegionsRegionsRegionsRegionsregions (output_object)  region-array objectHRegionHRegionHRegionArrayHRegionXHobject *

Segmented regions.

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

Vertical distance between tested pixels (height of the raster).

Default value: 3

Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21

Typical range of values: 1 ≤ Row Row Row Row Row row ≤ 99 (lin)

Minimum increment: 2

Recommended increment: 2

Restriction: Row >= 1 && odd(Row)

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

Horizontal distance between tested pixels (height of the raster).

Default value: 3

Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21

Typical range of values: 1 ≤ Column Column Column Column Column column ≤ 99 (lin)

Minimum increment: 2

Recommended increment: 2

Restriction: Column >= 1 && odd(Column)

ToleranceToleranceToleranceToleranceTolerancetolerance (input_control)  number HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Points with a gray value difference less then or equal to tolerance are accumulated into the same object.

Default value: 6.0

Suggested values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 18.0, 25.0

Typical range of values: 1.0 ≤ Tolerance Tolerance Tolerance Tolerance Tolerance tolerance ≤ 127.0 (lin)

Minimum increment: 0.01

Recommended increment: 1.0

Restriction: 0 <= Tolerance && Tolerance < 127

MinSizeMinSizeMinSizeMinSizeMinSizeminSize (input_control)  integer HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Minimum size of the output regions.

Default value: 100

Suggested values: 1, 5, 10, 20, 50, 100, 200, 500, 1000

Typical range of values: 1 ≤ MinSize MinSize MinSize MinSize MinSize minSize

Minimum increment: 1

Recommended increment: 5

Restriction: MinSize >= 1

Example (HDevelop)


Example (C)


Example (HDevelop)


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

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

int main (int argc, char *argv[])
  if (argc != 2)
    cout << "Usage : " << argv[0] << " <name of the image>" << endl;
    return (-1);

  HImage   image (argv[1]),
  HWindow  win;

  mean = image.MeanImage (5, 5);

  HRegionArray reg = mean.Regiongrowing (5, 5, 6, 100);

  reg.Display (win);
  win.Click ();

  return (0);

Example (HDevelop)


Example (HDevelop)



Let N be the number of found regions and M the number of points in one of these regions. Then the runtime complexity is O(N * log(M) * M).


regiongrowingregiongrowingRegiongrowingregiongrowingRegiongrowingRegiongrowing returns 2 (H_MSG_TRUE) if all parameters are correct. The behavior with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result'"no_object_result""no_object_result""no_object_result""no_object_result""no_object_result", 'empty_region_result'"empty_region_result""empty_region_result""empty_region_result""empty_region_result""empty_region_result", and 'store_empty_region'"store_empty_region""store_empty_region""store_empty_region""store_empty_region""store_empty_region" with set_systemset_systemSetSystemset_systemSetSystemSetSystem. If necessary, an exception is raised.

Possible Predecessors

binomial_filterbinomial_filterBinomialFilterbinomial_filterBinomialFilterBinomialFilter, mean_imagemean_imageMeanImagemean_imageMeanImageMeanImage, gauss_imagegauss_imageGaussImagegauss_imageGaussImageGaussImage, smooth_imagesmooth_imageSmoothImagesmooth_imageSmoothImageSmoothImage, median_imagemedian_imageMedianImagemedian_imageMedianImageMedianImage, anisotropic_diffusionanisotropic_diffusionAnisotropicDiffusionanisotropic_diffusionAnisotropicDiffusionAnisotropicDiffusion

Possible Successors

select_shapeselect_shapeSelectShapeselect_shapeSelectShapeSelectShape, reduce_domainreduce_domainReduceDomainreduce_domainReduceDomainReduceDomain, select_grayselect_graySelectGrayselect_graySelectGraySelectGray


regiongrowing_nregiongrowing_nRegiongrowingNregiongrowing_nRegiongrowingNRegiongrowingN, regiongrowing_meanregiongrowing_meanRegiongrowingMeanregiongrowing_meanRegiongrowingMeanRegiongrowingMean, label_to_regionlabel_to_regionLabelToRegionlabel_to_regionLabelToRegionLabelToRegion



ClassesClassesClassesClasses | | | | Operators