pouringpouringPouringPouringpouring (算子)

名称

pouringpouringPouringPouringpouring — 通过在图像上“浇水”来分割图像。

签名

pouring(Image : Regions : Mode, MinGray, MaxGray : )

Herror pouring(const Hobject Image, Hobject* Regions, const char* Mode, const Hlong MinGray, const Hlong MaxGray)

Herror T_pouring(const Hobject Image, Hobject* Regions, const Htuple Mode, const Htuple MinGray, const Htuple MaxGray)

void Pouring(const HObject& Image, HObject* Regions, const HTuple& Mode, const HTuple& MinGray, const HTuple& MaxGray)

HRegion HImage::Pouring(const HString& Mode, Hlong MinGray, Hlong MaxGray) const

HRegion HImage::Pouring(const char* Mode, Hlong MinGray, Hlong MaxGray) const

HRegion HImage::Pouring(const wchar_t* Mode, Hlong MinGray, Hlong MaxGray) const   ( Windows only)

static void HOperatorSet.Pouring(HObject image, out HObject regions, HTuple mode, HTuple minGray, HTuple maxGray)

HRegion HImage.Pouring(string mode, int minGray, int maxGray)

def pouring(image: HObject, mode: str, min_gray: int, max_gray: int) -> HObject

描述

pouringpouringPouringPouringPouringpouring regards the input image as a “mountain range.” Larger gray values correspond to mountain peaks, while smaller gray values correspond to valley bottoms. pouringpouringPouringPouringPouringpouring segments the input image in several steps. First, the local maxima are extracted, i.e., pixels which either alone or in the form of an extended plateau have larger gray values than their immediate neighbors (in 4-neighborhood). In the next step, the maxima thus found are the starting points for an expansion until “valley bottoms” are reached. The expansion is done as long as there are chains of pixels in which the gray value becomes smaller (like water running downhill from the maxima in all directions). Again, the 4-neighborhood is used, but with a weaker condition (smaller or equal). This means that points at valley bottoms may belong to more than one maximum. These areas are at first not assigned to a region, but rather are split among all competing segments in the last step. The split is done by a uniform expansion of all involved segments, until all ambiguous pixels were assigned. The parameter ModeModeModeModemodemode determines which steps are executed. The following values are possible:

'all'

This is the normal mode of operation. All steps of the segmentation are performed. The regions are assigned to maxima, and overlapping regions are split.

'maxima'

The segmentation only extracts the local maxima of the input image. No corresponding regions are extracted.

'regions'

The segmentation extracts the local maxima of the input image and the corresponding regions, which are uniquely determined. Areas that were assigned to more than one maximum are not split.

In order to prevent the algorithm from splitting a uniform background that is different from the rest of the image, the parameters MinGrayMinGrayMinGrayMinGrayminGraymin_gray and MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray determine gray value thresholds for regions in the image that should be regarded as background. All parts of the image having a gray value smaller than MinGrayMinGrayMinGrayMinGrayminGraymin_gray or larger than MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray are disregarded for the extraction of the maxima as well as for the assignment of regions. For a complete segmentation of the image, MinGrayMinGrayMinGrayMinGrayminGraymin_gray = 0 and MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray = 255 should be selected. MinGrayMinGrayMinGrayMinGrayminGraymin_gray < MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray must be observed.

执行信息

参数

ImageImageImageImageimageimage (输入对象)  singlechannelimage objectHImageHObjectHImageHobject (byte)

输入图像。

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

Segmented regions.

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

Mode of operation.

默认值: 'all' "all" "all" "all" "all" "all"

值列表: 'all'"all""all""all""all""all", 'maxima'"maxima""maxima""maxima""maxima""maxima", 'regions'"regions""regions""regions""regions""regions"

MinGrayMinGrayMinGrayMinGrayminGraymin_gray (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

All gray values smaller than this threshold are disregarded.

默认值: 0

建议值: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110

值范围: 0 ≤ MinGray MinGray MinGray MinGray minGray min_gray ≤ 254 (lin)

最小增量: 1

建议增量: 10

MaxGrayMaxGrayMaxGrayMaxGraymaxGraymax_gray (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

All gray values larger than this threshold are disregarded.

默认值: 255

建议值: 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 255

值范围: 1 ≤ MaxGray MaxGray MaxGray MaxGray maxGray max_gray ≤ 255 (lin)

最小增量: 1

建议增量: 10

限制: MaxGray > MinGray

示例(HDevelop)

* Segment a filtered image
read_image(Image,'particle')
mean_image(Image,Mean,11,11)
pouring(Mean,Seg,'all',0,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

* Segment an image while masking the dark background
read_image(Image,'particle')
mean_image(Image,ImageMean,15,15)
pouring(Mean,Seg,'all',90,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

示例(C)

/* Segmentation of a filtered image */
read_image(&Image,"br2");
mean_image(Image,&Mean,11,11);
pouring(Mean,&Seg,"all",0,255);
disp_image(Mean,WindowHandle);
set_colored(WindowHandle,12);
disp_region(Seg,WindowHandle);

/* Segmentation of an image with masking of a dark backround */
read_image(&Image,"hand");
mean_image(Image,&Mean,15,15);
pouring(Mean,&Seg,"all",40,255);
disp_image(Mean,WindowHandle);
set_colored(WindowHandle,12);
disp_region(Seg,WindowHandle);

示例(HDevelop)

* Segment a filtered image
read_image(Image,'particle')
mean_image(Image,Mean,11,11)
pouring(Mean,Seg,'all',0,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

* Segment an image while masking the dark background
read_image(Image,'particle')
mean_image(Image,ImageMean,15,15)
pouring(Mean,Seg,'all',90,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

示例(HDevelop)

* Segment a filtered image
read_image(Image,'particle')
mean_image(Image,Mean,11,11)
pouring(Mean,Seg,'all',0,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

* Segment an image while masking the dark background
read_image(Image,'particle')
mean_image(Image,ImageMean,15,15)
pouring(Mean,Seg,'all',90,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

示例(HDevelop)

* Segment a filtered image
read_image(Image,'particle')
mean_image(Image,Mean,11,11)
pouring(Mean,Seg,'all',0,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

* Segment an image while masking the dark background
read_image(Image,'particle')
mean_image(Image,ImageMean,15,15)
pouring(Mean,Seg,'all',90,255)
dev_display(Mean)
dev_set_colored(12)
dev_display(Seg)

复杂度

Let be the number of pixels in the input image and be the number of found segments, where the enclosing rectangle of the segment contains pixels. Furthermore, let be the number of chords in segment . Then the runtime complexity is

结果

pouringpouringPouringPouringPouringpouring usually returns the value 2 ( H_MSG_TRUE) 。如有必要,则抛出异常。

可能的前趋

binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, smooth_imagesmooth_imageSmoothImageSmoothImageSmoothImagesmooth_image, mean_imagemean_imageMeanImageMeanImageMeanImagemean_image

替代

watershedswatershedsWatershedsWatershedsWatershedswatersheds, local_maxlocal_maxLocalMaxLocalMaxLocalMaxlocal_max, watersheds_thresholdwatersheds_thresholdWatershedsThresholdWatershedsThresholdWatershedsThresholdwatersheds_threshold, watersheds_markerwatersheds_markerWatershedsMarkerWatershedsMarkerWatershedsMarkerwatersheds_marker

另见

histo_2dimhisto_2dimHisto2dimHisto2dimHisto2dimhisto_2dim, expand_regionexpand_regionExpandRegionExpandRegionExpandRegionexpand_region, expand_grayexpand_grayExpandGrayExpandGrayExpandGrayexpand_gray, expand_gray_refexpand_gray_refExpandGrayRefExpandGrayRefExpandGrayRefexpand_gray_ref

模块

基础