segment_image_mserT_segment_image_mserSegmentImageMserSegmentImageMsersegment_image_mser (算子)

名称

segment_image_mserT_segment_image_mserSegmentImageMserSegmentImageMsersegment_image_mser — 使用最大稳定极值区域(Maximally Stable Extremal Regions,MSER)分割图像。

签名

segment_image_mser(Image : MSERDark, MSERLight : Polarity, MinArea, MaxArea, Delta, GenParamName, GenParamValue : )

Herror T_segment_image_mser(const Hobject Image, Hobject* MSERDark, Hobject* MSERLight, const Htuple Polarity, const Htuple MinArea, const Htuple MaxArea, const Htuple Delta, const Htuple GenParamName, const Htuple GenParamValue)

void SegmentImageMser(const HObject& Image, HObject* MSERDark, HObject* MSERLight, const HTuple& Polarity, const HTuple& MinArea, const HTuple& MaxArea, const HTuple& Delta, const HTuple& GenParamName, const HTuple& GenParamValue)

HRegion HImage::SegmentImageMser(HRegion* MSERLight, const HString& Polarity, const HTuple& MinArea, const HTuple& MaxArea, const HTuple& Delta, const HTuple& GenParamName, const HTuple& GenParamValue) const

HRegion HImage::SegmentImageMser(HRegion* MSERLight, const HString& Polarity, Hlong MinArea, Hlong MaxArea, Hlong Delta, const HTuple& GenParamName, const HTuple& GenParamValue) const

HRegion HImage::SegmentImageMser(HRegion* MSERLight, const char* Polarity, Hlong MinArea, Hlong MaxArea, Hlong Delta, const HTuple& GenParamName, const HTuple& GenParamValue) const

HRegion HImage::SegmentImageMser(HRegion* MSERLight, const wchar_t* Polarity, Hlong MinArea, Hlong MaxArea, Hlong Delta, const HTuple& GenParamName, const HTuple& GenParamValue) const   ( Windows only)

static void HOperatorSet.SegmentImageMser(HObject image, out HObject MSERDark, out HObject MSERLight, HTuple polarity, HTuple minArea, HTuple maxArea, HTuple delta, HTuple genParamName, HTuple genParamValue)

HRegion HImage.SegmentImageMser(out HRegion MSERLight, string polarity, HTuple minArea, HTuple maxArea, HTuple delta, HTuple genParamName, HTuple genParamValue)

HRegion HImage.SegmentImageMser(out HRegion MSERLight, string polarity, int minArea, int maxArea, int delta, HTuple genParamName, HTuple genParamValue)

def segment_image_mser(image: HObject, polarity: str, min_area: MaybeSequence[Union[int, float]], max_area: MaybeSequence[Union[int, float]], delta: Union[int, float], gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, float, int]]) -> Tuple[HObject, HObject]

描述

segment_image_msersegment_image_mserSegmentImageMserSegmentImageMserSegmentImageMsersegment_image_mser segments an image into regions of homogenous gray values using the approach of Maximally Stable Extremal Regions (MSER). The segmentation process determines if a region is homogenous by observing the local region surrounding. Therefore, the operator is particularly suited to robustly segment objects in front of inhomogeneous background or in applications with changing illumination.

Parameters

PolarityPolarityPolarityPolaritypolaritypolarity

The PolarityPolarityPolarityPolaritypolaritypolarity determines the type of the regions that are extracted.

Value Meaning
'dark'"dark""dark""dark""dark""dark" Only MSERs that are darker than their surroundings are extracted
'light'"light""light""light""light""light" Only MSERs that are lighter than their surroundings are extracted
'both'"both""both""both""both""both" (default) Both types of MSERs are extracted
MinAreaMinAreaMinAreaMinAreaminAreamin_area, MaxAreaMaxAreaMaxAreaMaxAreamaxAreamax_area

The values MinAreaMinAreaMinAreaMinAreaminAreamin_area and MaxAreaMaxAreaMaxAreaMaxAreamaxAreamax_area restrict the size of the returned MSERs.

Note that very small values of MinAreaMinAreaMinAreaMinAreaminAreamin_area, e.g., values smaller than 5, can increase the runtime significantly, especially for noisy images.

If MaxAreaMaxAreaMaxAreaMaxAreamaxAreamax_area is set to an empty tuple (default), the MSERs are restricted to be true subsets of the connected components of the input domain.

DeltaDeltaDeltaDeltadeltadelta

The value of DeltaDeltaDeltaDeltadeltadelta influences the selectivity of the algorithm. Larger values lead to fewer MSERs. Smaller values lead to more MSERs.

Please read the description of the segmentation process below to help understand the effect of this parameter.

The following generic parameters can be used to fine-tune the segmentation of MSERs. The generic parameters can be set with GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value

'max_variation'"max_variation""max_variation""max_variation""max_variation""max_variation"

The maximum variation of a component's area within the range of DeltaDeltaDeltaDeltadeltadelta thresholds. Larger values lead to more MSERs. Smaller values lead to fewer MSERs.

Please read the description of the segmentation process below for a definition of 'variation' and to help understand the effect of this generic parameter.

Values: real values larger than or equal to 0.0

建议值: 0.1, 0.2, 0.5, 1.0, 2.0, 5.0

Default: 0.2

'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity"

The minimum relative difference of the sizes of two overlapping MSERs. Smaller values lead to more overlapping MSERs. Larger values lead to fewer overlapping MSERs.

Please read the description of the segmentation process below for a definition of 'diversity' and to help understand the effect of this generic parameter.

Setting 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity" very close to 0.0 may increase the runtime.

Values: real values larger than or equal to 0.0

建议值: 0.1, 0.5, 0.8, 1.0, 2.0, 5.0

Default: 0.8

'may_touch_border'"may_touch_border""may_touch_border""may_touch_border""may_touch_border""may_touch_border"

Controls if regions that touch the border of the input domain are returned ('true'"true""true""true""true""true") or rejected ('false'"false""false""false""false""false").

Values: 'false'"false""false""false""false""false", 'true'"true""true""true""true""true"

Default: 'false'"false""false""false""false""false" if a full domain is used, 'true'"true""true""true""true""true" if the input domain is reduced.

'min_gray'"min_gray""min_gray""min_gray""min_gray""min_gray", 'max_gray'"max_gray""max_gray""max_gray""max_gray""max_gray"

The values 'min_gray'"min_gray""min_gray""min_gray""min_gray""min_gray" and 'max_gray'"max_gray""max_gray""max_gray""max_gray""max_gray" reduce the input domain dynamically by applying a thresholdthresholdThresholdThresholdThresholdthreshold to the input image. All pixels outside the specified gray value range are ignored in the segmentation process. This may reduce the runtime considerably.

Please note, that if ImageImageImageImageimageimage has a full domain and the domain is reduced by the settings of 'min_gray'"min_gray""min_gray""min_gray""min_gray""min_gray" or 'max_gray'"max_gray""max_gray""max_gray""max_gray""max_gray", the default behavior of 'may_touch_border'"may_touch_border""may_touch_border""may_touch_border""may_touch_border""may_touch_border" may lead to more result regions than without restricted gray value range.

Values: integer values larger than or equal to 0

Default: 'min_gray'"min_gray""min_gray""min_gray""min_gray""min_gray":0, 'max_gray'"max_gray""max_gray""max_gray""max_gray""max_gray":255 for byte images, 65535 for uint2 images

Segmentation Process

In a first step, the image is segmented with all threshold values t, from 0 to the maximal present gray value.

To illustrate this, the following example input image with twelve gray values (0...11) is used. On the right, the boundaries of the resulting threshold regions are shown.

Example input image with twelve gray values reaching from 0 (= black) to 11 (= white)
Boundaries of the threshold regions for all thresholds (t = 0...11)

The resulting threshold regions are split into their connected components (4-connected neighborhood) and the area increase of the individual components is monitored over the increasing thresholds. The area of each individual component increases monotonically with each (increasing) threshold. An MSER is a component whose area does not vary significantly within the range of DeltaDeltaDeltaDeltadeltadelta thresholds. To be accepted as an MSER, the variation of the component's area within the range of DeltaDeltaDeltaDeltadeltadelta thresholds must be a local minimum and it must be lower than 'max_variation'"max_variation""max_variation""max_variation""max_variation""max_variation". Furthermore, the diversity of overlapping MSERs must be greater than 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity" (see below).

The variation of a component's area is defined by

where

Decreasing the value of 'max_variation'"max_variation""max_variation""max_variation""max_variation""max_variation" will reduce the number of accepted regions.

In our example, each threshold region consists of only one component. Therefore, the terms 'threshold region' and 'component' are used synonymously hereinafter. The following table shows the area of the threshold regions and their variations for DeltaDeltaDeltaDeltadeltadelta set to 1 and for DeltaDeltaDeltaDeltadeltadelta set to 2.

Threshold value t Threshold region Area of the threshold region Variation of the area (for DeltaDeltaDeltaDeltadeltadelta = 1) Variation of the area (for DeltaDeltaDeltaDeltadeltadelta = 2)

0
320 0.28 0.53
1
410 0.41 0.54
2
490 0.27 0.49
3
540 0.13 0.31
4
560 0.07 0.25
5
580 0.12 0.29
6
630 0.21 0.38
7
710 0.24 0.44
8
800 0.23 0.41
9
890 0.18 1.67
10
960 1.36 1.46
11
2200 0.56 0.60

The area of the threshold regions increases with the threshold value t. If DeltaDeltaDeltaDeltadeltadelta is set to 1, the local minima of the variation are obtained for the threshold values t = 0, t = 4, t = 9, and t = 11. Therefore, the threshold regions for t = 0, t = 4, t = 9, and t = 11 are MSER candidates. If DeltaDeltaDeltaDeltadeltadelta is set to 2, the MSER candidates correspond to the threshold regions for t = 0, t = 4, t = 8, t = 11.

Per default, the connected components of the image domain will not be returned as MSER. This behavior can be altered by explicitly setting MaxAreaMaxAreaMaxAreaMaxAreamaxAreamax_area to a value larger than the area of the input domain and 'may_touch_border'"may_touch_border""may_touch_border""may_touch_border""may_touch_border""may_touch_border" to 'true'"true""true""true""true""true". In our example, the default behavior eliminates the MSER candidates that correspond to the threshold regions for t = 11.

The following figure shows the resulting MSER candidates for DeltaDeltaDeltaDeltadeltadelta = 1 and for DeltaDeltaDeltaDeltadeltadelta = 2 (with 'max_variation'"max_variation""max_variation""max_variation""max_variation""max_variation" set to 1.0), overlaid over the input image.

MSER candidates for Delta = 1 MSER candidates for Delta = 2
corresponds to t = 0
corresponds to t = 0
corresponds to t = 4
corresponds to t = 4
corresponds to t = 9
corresponds to t = 8

The MSER segmentation does not divide the image into disjunct regions, but rather determines all MSERs within the input image. Hence for one image, multiple mutual overlapping regions may be returned as MSER candidates. Since the MSERs are calculated by continuously increasing the threshold t, two regions that overlap each other always consist of a larger region that completely contains the smaller one. The 'diversity' measures, how much the areas of two overlapping MSERs differ. It is calculated as the relative difference of the areas of the two MSER candidates: where : is the area of the currently examined MSER candidate and : is the area of the MSER candidate that contains the currently examined MSER candidate.

If the diversity of an MSER candidate is smaller than 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity", it is discarded. Hence the parameter 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity" is used to control the amount of overlapping regions. Higher values of 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity" reduce the number of overlapping regions and lower values increase it. Note that the largest MSER candidates, i.e., those candidates that are not contained in another MSER candidate are always kept.

MSER candidate index i Threshold value t Area of the threshold region Diversity of the MSER candidate
0 0 320 0.75
Delta=1 1 4 560 0.59
2 9 890 N/A
0 0 320 0.75
Delta=2 1 4 560 0.43
2 8 800 N/A

First, the MSER candidate with the smallest diversity is eliminated if its diversity is less than 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity". In our example, the value for 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity" is set to 0.5. For delta = 2, the MSER candidate with the diversity of 0.43 is eliminated. Then, the diversity is recalculated for the remaining MSER candidates. In our example, this yields a diversity of 1.5 for the MSER candidate 0. Now, all remaining MSER candidates have a diversity greater than 0.5 and are therefore accepted as MSERs.

The segmentation process calculates MSERs for each connected component of the input domain independently.

执行信息

此算子支持取消超时和中断。

参数

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

输入图像。

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

Segmented dark MSERs.

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

Segmented light MSERs.

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

The polarity of the returned MSERs.

默认值: 'both' "both" "both" "both" "both" "both"

值列表: 'both'"both""both""both""both""both", 'dark'"dark""dark""dark""dark""dark", 'light'"light""light""light""light""light"

MinAreaMinAreaMinAreaMinAreaminAreamin_area (输入控制)  number(-array) HTupleMaybeSequence[Union[int, float]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Minimal size of an MSER.

默认值: 10

建议值: 1, 10, 100, 10000

值范围: 1 ≤ MinArea MinArea MinArea MinArea minArea min_area

MaxAreaMaxAreaMaxAreaMaxAreamaxAreamax_area (输入控制)  number(-array) HTupleMaybeSequence[Union[int, float]]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Maximal size of an MSER.

默认值: []

建议值: 1, 10, 100, 10000

值范围: 1 ≤ MaxArea MaxArea MaxArea MaxArea maxArea max_area

DeltaDeltaDeltaDeltadeltadelta (输入控制)  number HTupleUnion[int, float]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Amount of thresholds for which a region needs to be stable.

默认值: 15

建议值: 5, 10, 20, 50

值范围: 1 ≤ Delta Delta Delta Delta delta delta ≤ 65535

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制)  attribute.name-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

List of generic parameter names.

默认值: []

值列表: 'max_gray'"max_gray""max_gray""max_gray""max_gray""max_gray", 'max_variation'"max_variation""max_variation""max_variation""max_variation""max_variation", 'may_touch_border'"may_touch_border""may_touch_border""may_touch_border""may_touch_border""may_touch_border", 'min_diversity'"min_diversity""min_diversity""min_diversity""min_diversity""min_diversity", 'min_gray'"min_gray""min_gray""min_gray""min_gray""min_gray"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制)  attribute.value-array HTupleSequence[Union[str, float, int]]HTupleHtuple (string / real / integer) (string / double / int / long) (HString / double / Hlong) (char* / double / Hlong)

List of generic parameter values.

默认值: []

建议值: 0.5, 0.8, 'true'"true""true""true""true""true", 'false'"false""false""false""false""false", 30, 50, 200, 230

示例(HDevelop)

read_image (Image,'pellets')
segment_image_mser (Image, MSERDark, MSERLight, 'light',\
                    1000, 10000, 3, [],[])

结果

segment_image_msersegment_image_mserSegmentImageMserSegmentImageMserSegmentImageMsersegment_image_mser returns 2 ( H_MSG_TRUE) if all parameter values are correct。如有必要,则抛出异常。

可能的后继

select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray

替代

auto_thresholdauto_thresholdAutoThresholdAutoThresholdAutoThresholdauto_threshold, binary_thresholdbinary_thresholdBinaryThresholdBinaryThresholdBinaryThresholdbinary_threshold, char_thresholdchar_thresholdCharThresholdCharThresholdCharThresholdchar_threshold, local_thresholdlocal_thresholdLocalThresholdLocalThresholdLocalThresholdlocal_threshold, watershedswatershedsWatershedsWatershedsWatershedswatersheds, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing

参考文献

J. Matas, O. Chum, M. Urban, and T. Pajdla: “Robust wide baseline stereo from maximally stable extremal regions.”; Proc. of British Machine Vision Conference, pages 384-396; 2002.

模块

基础