Skip to content

regiongrowingRegiongrowingRegiongrowingregiongrowingregiongrowingπŸ”—

Short descriptionπŸ”—

regiongrowingRegiongrowingRegiongrowingregiongrowingregiongrowing β€” Segment an image using region growing.

SignatureπŸ”—

regiongrowing( image Image, out region Regions, extent.y RasterHeight, extent.x RasterWidth, number Tolerance, integer MinSize )void Regiongrowing( const HObject& Image, HObject* Regions, const HTuple& RasterHeight, const HTuple& RasterWidth, const HTuple& Tolerance, const HTuple& MinSize )static void HOperatorSet.Regiongrowing( HObject image, out HObject regions, HTuple rasterHeight, HTuple rasterWidth, HTuple tolerance, HTuple minSize )def regiongrowing( image: HObject, raster_height: int, raster_width: int, tolerance: Union[int, float], min_size: int ) -> HObject

Herror regiongrowing( const Hobject Image, Hobject* Regions, const Hlong RasterHeight, const Hlong RasterWidth, double Tolerance, const Hlong MinSize )

Herror T_regiongrowing( const Hobject Image, Hobject* Regions, const Htuple RasterHeight, const Htuple RasterWidth, const Htuple Tolerance, const Htuple MinSize )

HRegion HImage::Regiongrowing( Hlong RasterHeight, Hlong RasterWidth, const HTuple& Tolerance, Hlong MinSize ) const

HRegion HImage::Regiongrowing( Hlong RasterHeight, Hlong RasterWidth, double Tolerance, Hlong MinSize ) const

HRegion HImage.Regiongrowing( int rasterHeight, int rasterWidth, HTuple tolerance, int minSize )

HRegion HImage.Regiongrowing( int rasterHeight, int rasterWidth, double tolerance, int minSize )

DescriptionπŸ”—

regiongrowingRegiongrowing segments images into regions of the same intensity - rastered into rectangles of size RasterHeightrasterHeightraster_height \(\times\) RasterWidthrasterWidthraster_width. 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 Tolerancetolerancetolerance 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:

\[\begin{eqnarray*} |g_{1} - g_{2}| < \textrm{Tolerance} \end{eqnarray*}\]

For images of type β€˜cyclic’, the following formulas are used:

\[\begin{eqnarray*} (|g_{1} - g_{2}| < \textrm{Tolerance}) \hspace{2mm} &\wedge& \hspace{2mm} (|g_{1} - g_{2}| \le 127)\\ (256 - |g_{1} - g_{2}| < \textrm{Tolerance}) \hspace{2mm} &\wedge& \hspace{2mm} (|g_{1} - g_{2}| > 127) \end{eqnarray*}\]

For rectangles larger than one pixel, usually the images should be smoothed with a lowpass filter with a size of at least RasterHeightrasterHeightraster_height \(\times\) RasterWidthrasterWidthraster_width before calling regiongrowingRegiongrowing (so that the gray values at the centers of the rectangles 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 RasterHeightrasterHeightraster_height \(\times\) RasterWidthrasterWidthraster_width. Only regions containing at least MinSizeminSizemin_size points are returned.

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

AttentionπŸ”—

RasterWidthrasterWidthraster_width and RasterHeightrasterHeightraster_height are automatically converted to odd values if necessary.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

ParametersπŸ”—

Imageimageimage (input_object) singlechannelimage(-array) β†’ object (byte / direction / cyclic / int1 / int2 / int4 / real)HObject (byte / direction / cyclic / int1 / int2 / int4 / real)HImage (byte / direction / cyclic / int1 / int2 / int4 / real)HObject (byte / direction / cyclic / int1 / int2 / int4 / real)Hobject (byte / direction / cyclic / int1 / int2 / int4 / real)

Input image.

Regionsregionsregions (output_object) region-array β†’ objectHObjectHRegionHObjectHobject *

Segmented regions.

RasterHeightrasterHeightraster_height (input_control) extent.y β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

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

Default: 33
Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 211, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21
Value range: 1 ≀ RasterHeight ≀ 99 (lin)
Minimum increment: 2
Recommended increment: 2
Restriction: RasterHeight >= 1 && odd(RasterHeight)

RasterWidthrasterWidthraster_width (input_control) extent.x β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

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

Default: 33
Suggested values: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 211, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21
Value range: 1 ≀ RasterWidth ≀ 99 (lin)
Minimum increment: 2
Recommended increment: 2
Restriction: RasterWidth >= 1 && odd(RasterWidth)

Tolerancetolerancetolerance (input_control) number β†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

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

Default: 6.06.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.01.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
Value range: 0 ≀ Tolerance (lin)
Minimum increment: 0.01
Recommended increment: 1.0

MinSizeminSizemin_size (input_control) integer β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum size of the output regions.

Default: 100100
Suggested values: 1, 5, 10, 20, 50, 100, 200, 500, 10001, 5, 10, 20, 50, 100, 200, 500, 1000
Value range: 1 ≀ MinSize
Minimum increment: 1
Recommended increment: 5

ExampleπŸ”—

(C)

read_image(&Image,"fabrik")\;
mean_image(Image,&Mean,RasterHeight,RasterWidth)\;
regiongrowing(Mean,&Result,RasterHeight,RasterWidth,6,100)\;
(HDevelop)
read_image(Image,'fabrik')
mean_image(Image,Mean,RasterHeight,RasterWidth)
regiongrowing(Mean,Result,RasterHeight,RasterWidth,6.0,100)
(C++)
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif
#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]),
           mean\;
  HWindow  win\;
 mean = image.MeanImage (5, 5)\;
 HRegionArray reg = mean.Regiongrowing (5, 5, 6, 100)\;
 reg.Display (win)\;
  win.Click ()\;
 return (0)\;
}

ComplexityπŸ”—

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)\).

ResultπŸ”—

regiongrowingRegiongrowing 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", 'empty_region_result'"empty_region_result", and 'store_empty_region'"store_empty_region" with set_systemSetSystem. If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

binomial_filterBinomialFilter, mean_imageMeanImage, gauss_filterGaussFilter, smooth_imageSmoothImage, median_imageMedianImage, anisotropic_diffusionAnisotropicDiffusion

Possible successors

select_shapeSelectShape, reduce_domainReduceDomain, select_graySelectGray

Alternatives

regiongrowing_nRegiongrowingN, regiongrowing_meanRegiongrowingMean, label_to_regionLabelToRegion

ModuleπŸ”—

Foundation