expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefexpand_gray_ref (算子)

名称

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefexpand_gray_ref — 填充区域之间的间隙(取决于灰度值或颜色)或分割重叠区域。

签名

expand_gray_ref(Regions, Image, ForbiddenArea : RegionExpand : Iterations, Mode, RefGray, Threshold : )

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

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

void ExpandGrayRef(const HObject& Regions, const HObject& Image, const HObject& ForbiddenArea, HObject* RegionExpand, const HTuple& Iterations, const HTuple& Mode, const HTuple& RefGray, const HTuple& Threshold)

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const HTuple& Iterations, const HString& Mode, const HTuple& RefGray, const HTuple& Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const HString& Iterations, const HString& Mode, Hlong RefGray, Hlong Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const char* Iterations, const char* Mode, Hlong RefGray, Hlong Threshold) const

HRegion HImage::ExpandGrayRef(const HRegion& Regions, const HRegion& ForbiddenArea, const wchar_t* Iterations, const wchar_t* Mode, Hlong RefGray, Hlong Threshold) const   ( Windows only)

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const HTuple& Iterations, const HString& Mode, const HTuple& RefGray, const HTuple& Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const HString& Iterations, const HString& Mode, Hlong RefGray, Hlong Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const char* Iterations, const char* Mode, Hlong RefGray, Hlong Threshold) const

HRegion HRegion::ExpandGrayRef(const HImage& Image, const HRegion& ForbiddenArea, const wchar_t* Iterations, const wchar_t* Mode, Hlong RefGray, Hlong Threshold) const   ( Windows only)

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

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

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

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

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

def expand_gray_ref(regions: HObject, image: HObject, forbidden_area: HObject, iterations: Union[int, str], mode: str, ref_gray: MaybeSequence[int], threshold: MaybeSequence[int]) -> HObject

描述

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref closes gaps between the input regions, which resulted from the suppression of small regions in a segmentation operator, (mode 'image'"image""image""image""image""image"), for example, or separates overlapping regions 'region'"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 a reference gray value or color by at most ThresholdThresholdThresholdThresholdthresholdthreshold (in each channel). For images of type 'cyclic'"cyclic""cyclic""cyclic""cyclic""cyclic" (e.g., direction images), also points with a gray value difference of at least 255 - ThresholdThresholdThresholdThresholdthresholdthreshold are added to the output region.

The expansion takes place only in regions, which are designated as not “forbidden” (parameter ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenAreaforbidden_area). The number of iterations is determined by the parameter IterationsIterationsIterationsIterationsiterationsiterations. By passing 'maximal'"maximal""maximal""maximal""maximal""maximal", expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref 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""image" and 'region'"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_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref 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.

注意

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.

执行信息

参数

RegionsRegionsRegionsRegionsregionsregions (输入对象)  region(-array) objectHRegionHObjectHRegionHobject

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

ImageImageImageImageimageimage (输入对象)  (multichannel-)image objectHImageHObjectHImageHobject (byte / cyclic)

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

ForbiddenAreaForbiddenAreaForbiddenAreaForbiddenAreaforbiddenAreaforbidden_area (输入对象)  region objectHRegionHObjectHRegionHobject

Regions in which no expansion takes place.

RegionExpandRegionExpandRegionExpandRegionExpandregionExpandregion_expand (输出对象)  region(-array) objectHRegionHObjectHRegionHobject *

Expanded or separated regions.

IterationsIterationsIterationsIterationsiterationsiterations (输入控制)  string HTupleUnion[int, str]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Number of iterations.

默认值: 'maximal' "maximal" "maximal" "maximal" "maximal" "maximal"

建议值: 'maximal'"maximal""maximal""maximal""maximal""maximal", 1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 50, 70, 100, 150, 200, 300, 500

值范围: 1 ≤ Iterations Iterations Iterations Iterations iterations iterations ≤ 500 (lin)

最小增量: 1

建议增量: 1

ModeModeModeModemodemode (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Expansion mode.

默认值: 'image' "image" "image" "image" "image" "image"

值列表: 'image'"image""image""image""image""image", 'region'"region""region""region""region""region"

RefGrayRefGrayRefGrayRefGrayrefGrayref_gray (输入控制)  integer(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Reference gray value or color for comparison.

默认值: 128

建议值: 1, 10, 20, 50, 100, 128, 200, 255

值范围: 1 ≤ RefGray RefGray RefGray RefGray refGray ref_gray ≤ 255 (lin)

最小增量: 1

建议增量: 10

ThresholdThresholdThresholdThresholdthresholdthreshold (输入控制)  integer(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Maximum difference between the reference gray value or color and a candidate for expansion.

默认值: 32

建议值: 4, 10, 15, 20, 25, 30, 40

值范围: 1 ≤ Threshold Threshold Threshold Threshold threshold threshold ≤ 255 (lin)

最小增量: 1

建议增量: 5

示例 (C++ (HALCON 5.0-10.0))

#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;

  win.SetDraw ("margin");
  win.SetColored (12);

  image.Display (win);

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

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

示例(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);
T_intensity(RawSegments,Image,&Mean,NULL);
set_i(Thresh,24,0);
set_s(Iter,"maximal",0);
set_s(Mode,"image",0);
T_expand_gray_ref(RawSegments,Image,EMPTY_REGION,&Segments,Iter,Mode,
               Mean,Thresh);
disp_region(Segments,WindowHandle);

示例 (C++ (HALCON 5.0-10.0))

#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;

  win.SetDraw ("margin");
  win.SetColored (12);

  image.Display (win);

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

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

示例 (C++ (HALCON 5.0-10.0))

#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;

  win.SetDraw ("margin");
  win.SetColored (12);

  image.Display (win);

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

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

示例 (C++ (HALCON 5.0-10.0))

#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;

  win.SetDraw ("margin");
  win.SetColored (12);

  image.Display (win);

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

  Tuple iter = "maximal";
  Tuple mode = "image";
  Tuple refg = 128;
  Tuple thrs = 32;

  HRegionArray exp = seg.ExpandGrayRef (image, empty_region,
                                        iter, mode, refg, thrs);
  exp.Display (win);
  win.Click ();

  return (0);
}

结果

expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref 始终返回值 2 ( H_MSG_TRUE )。当输入为空(未指定区域)时则可设置行为通过 set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>),当输入区域为空时则设置行为通过 set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>),以及当结果区域为空时则设置行为通过 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">)SetSystem("store_empty_region",<"true"/"false">)set_system("store_empty_region",<"true"/"false">)。如有必要,则抛出异常。

可能的前趋

connectionconnectionConnectionConnectionConnectionconnection, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing, pouringpouringPouringPouringPouringpouring, class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNormclass_ndim_norm

可能的后继

select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape

另见

expand_grayexpand_grayExpandGrayExpandGrayExpandGrayexpand_gray, expand_regionexpand_regionExpandRegionExpandRegionExpandRegionexpand_region

模块

基础