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

expand_grayexpand_grayexpand_grayExpandGrayExpandGray (Operator)

Name

expand_grayexpand_grayexpand_grayExpandGrayExpandGray — Fill gaps between regions (depending on gray value or color) or split overlapping regions.

Signature

expand_gray(Regions, Image, ForbiddenArea : RegionExpand : Iterations, Mode, Threshold : )

Herror expand_gray(const Hobject Regions, const Hobject Image, const Hobject ForbiddenArea, Hobject* RegionExpand, const char* Iterations, const char* Mode, const Hlong Threshold)

Herror T_expand_gray(const Hobject Regions, const Hobject Image, const Hobject ForbiddenArea, Hobject* RegionExpand, const Htuple Iterations, const Htuple Mode, const Htuple Threshold)

Herror expand_gray(Hobject Regions, Hobject Image, Hobject ForbiddenArea, Hobject* RegionExpand, const HTuple& Iterations, const HTuple& Mode, const HTuple& Threshold)

HRegion HRegion::ExpandGray(const HImage& Image, const HRegion& ForbiddenArea, const HTuple& Iterations, const HTuple& Mode, const HTuple& Threshold) const

HRegionArray HRegionArray::ExpandGray(const HImage& Image, const HRegion& ForbiddenArea, const HTuple& Iterations, const HTuple& Mode, const HTuple& Threshold) const

void HOperatorSetX.ExpandGray(
[in] IHUntypedObjectX* Regions, [in] IHUntypedObjectX* Image, [in] IHUntypedObjectX* ForbiddenArea, [out] IHUntypedObjectX*RegionExpand, [in] VARIANT Iterations, [in] VARIANT Mode, [in] VARIANT Threshold)

IHRegionX* HImageX.ExpandGray(
[in] IHRegionX* Regions, [in] IHRegionX* ForbiddenArea, [in] VARIANT Iterations, [in] BSTR Mode, [in] VARIANT Threshold)

IHRegionX* HRegionX.ExpandGray(
[in] IHImageX* Image, [in] IHRegionX* ForbiddenArea, [in] VARIANT Iterations, [in] BSTR Mode, [in] VARIANT Threshold)

static void HOperatorSet.ExpandGray(HObject regions, HObject image, HObject forbiddenArea, out HObject regionExpand, HTuple iterations, HTuple mode, HTuple threshold)

HRegion HImage.ExpandGray(HRegion regions, HRegion forbiddenArea, HTuple iterations, string mode, HTuple threshold)

HRegion HImage.ExpandGray(HRegion regions, HRegion forbiddenArea, string iterations, string mode, int threshold)

HRegion HRegion.ExpandGray(HImage image, HRegion forbiddenArea, HTuple iterations, string mode, HTuple threshold)

HRegion HRegion.ExpandGray(HImage image, HRegion forbiddenArea, string iterations, string mode, int threshold)

Description

expand_grayexpand_grayexpand_grayExpandGrayExpandGray closes gaps between the input regions, which resulted from the suppression of small regions in a segmentation operator, (mode 'image'"image""image""image""image"), for example, or separates overlapping regions 'region'"region""region""region""region"). Both uses result from the expansion of regions. The operator works by adding a one pixel wide “strip” to a region, in which the gray values or color are different from the gray values or color of neighboring pixles on the region's border by at most ThresholdThresholdThresholdThresholdthreshold (in each channel). For images of type 'cyclic'"cyclic""cyclic""cyclic""cyclic" (e.g., direction images), also points with a gray value difference of at least 255 - ThresholdThresholdThresholdThresholdthreshold are added to the output region.

The expansion takes place only in regions, which are designated as not “forbidden” (parameter ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenArea). The number of iterations is determined by the parameter IterationsIterationsIterationsIterationsiterations. By passing 'maximal'"maximal""maximal""maximal""maximal", expand_grayexpand_grayexpand_grayExpandGrayExpandGray iterates until convergence, i.e., until no more changes occur. By passing 0 for this parameter, all non-overlapping regions are returned. The two modes of operation ('image'"image""image""image""image" and 'region'"region""region""region""region") are different in the following ways:

'image'

The input regions are expanded iteratively until they touch another region or the image border, or the expansion stops because of too high gray value differences. Because expand_grayexpand_grayexpand_grayExpandGrayExpandGray processes all regions simultaneously, gaps between regions are distributed evenly to all regions with a similar gray value. Overlapping regions are split by distributing the area of overlap evenly to both regions.

'region'

No expansion of the input regions is performed. Instead, only overlapping regions are split by distributing the area of overlap evenly to regions having a matching gray value or color.

Attention

Because regions are only expanded into areas having a matching gray value or color, usually gaps will remain between the output regions, i.e., the segmentation is not complete.

Parallelization

Parameters

RegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHRegionXHobject

Regions for which the gaps are to be closed, or which are to be separated.

ImageImageImageImageimage (input_object)  image objectHImageHImageHImageXHobject (byte / cyclic)

Image (possibly multi-channel) for gray value or color comparison.

ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenArea (input_object)  region objectHRegionHRegionHRegionXHobject

Regions in which no expansion takes place.

RegionExpandRegionExpandRegionExpandRegionExpandregionExpand (output_object)  region(-array) objectHRegionHRegionHRegionXHobject *

Expanded or separated regions.

IterationsIterationsIterationsIterationsiterations (input_control)  string HTupleHTupleVARIANTHtuple (string / integer) (string / int / long) (char* / Hlong) (BSTR / Hlong) (char* / Hlong)

Number of iterations.

Default value: 'maximal' "maximal" "maximal" "maximal" "maximal"

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'maximal'"maximal""maximal""maximal""maximal"

Typical range of values: 1 ≤ Iterations Iterations Iterations Iterations iterations ≤ 500 (lin)

Minimum increment: 1

Recommended increment: 1

ModeModeModeModemode (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Expansion mode.

Default value: 'image' "image" "image" "image" "image"

List of values: 'image'"image""image""image""image", 'region'"region""region""region""region"

ThresholdThresholdThresholdThresholdthreshold (input_control)  integer(-array) HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Maximum difference between the gray value or color at the region's border and a candidate for expansion.

Default value: 32

Suggested values: 5, 10, 15, 20, 25, 30, 40, 50

Typical range of values: 1 ≤ Threshold Threshold Threshold Threshold threshold ≤ 255 (lin)

Minimum increment: 1

Recommended increment: 5

Example (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[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();

  seg.Display (win);
  HRegionArray exp = seg.ExpandGray1 (image, empty_region,
                                      "maximal", "image", 32);
  win.SetDraw ("margin");
  win.SetColored (12);
  exp.Display (win);
  win.Click ();

  return (0);
}

Example (C)

read_image(&Image,"fabrik");
disp_image(Image,WindowHandle);
regiongrowing(Image,&RawSegments,3,3,6.0,100);
set_colored(WindowHandle,12);
disp_region(RawSegments,WindowHandle);
expand_gray(RawSegments,Image,EMPTY_REGION,&Segments,"maximal","image",24);
clear_window(WindowHandle);
disp_region(Segments,WindowHandle)

Example (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[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();

  seg.Display (win);
  HRegionArray exp = seg.ExpandGray1 (image, empty_region,
                                      "maximal", "image", 32);
  win.SetDraw ("margin");
  win.SetColored (12);
  exp.Display (win);
  win.Click ();

  return (0);
}

Example (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[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();

  seg.Display (win);
  HRegionArray exp = seg.ExpandGray1 (image, empty_region,
                                      "maximal", "image", 32);
  win.SetDraw ("margin");
  win.SetColored (12);
  exp.Display (win);
  win.Click ();

  return (0);
}

Example (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[])
{
  HImage   image (argv[1]);
  HRegion  empty_region;
  HWindow  win;

  image.Display (win);

  HRegionArray seg = (image >= 100).Connection ();

  seg.Display (win);
  HRegionArray exp = seg.ExpandGray1 (image, empty_region,
                                      "maximal", "image", 32);
  win.SetDraw ("margin");
  win.SetColored (12);
  exp.Display (win);
  win.Click ();

  return (0);
}

Result

expand_grayexpand_grayexpand_grayExpandGrayExpandGray always returns the value 2 (H_MSG_TRUE). The behavior in case of empty input (no regions given) can be set via set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>), the behavior in case of an empty input region via set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>), and the behavior in case of an empty result region via set_system('store_empty_region',<true/false>)set_system("store_empty_region",<true/false>)set_system("store_empty_region",<true/false>)SetSystem("store_empty_region",<true/false>)SetSystem("store_empty_region",<true/false>). If necessary, an exception is raised.

Possible Predecessors

connectionconnectionconnectionConnectionConnection, regiongrowingregiongrowingregiongrowingRegiongrowingRegiongrowing, pouringpouringpouringPouringPouring, class_ndim_normclass_ndim_normclass_ndim_normClassNdimNormClassNdimNorm

Possible Successors

select_shapeselect_shapeselect_shapeSelectShapeSelectShape

See also

expand_gray_refexpand_gray_refexpand_gray_refExpandGrayRefExpandGrayRef, expand_regionexpand_regionexpand_regionExpandRegionExpandRegion

Module

Foundation


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