dyn_thresholddyn_thresholdDynThresholdDynThresholddyn_threshold (算子)

名称

dyn_thresholddyn_thresholdDynThresholdDynThresholddyn_threshold — 使用局部阈值分割图像。

签名

dyn_threshold(OrigImage, ThresholdImage : RegionDynThresh : Offset, LightDark : )

Herror dyn_threshold(const Hobject OrigImage, const Hobject ThresholdImage, Hobject* RegionDynThresh, double Offset, const char* LightDark)

Herror T_dyn_threshold(const Hobject OrigImage, const Hobject ThresholdImage, Hobject* RegionDynThresh, const Htuple Offset, const Htuple LightDark)

void DynThreshold(const HObject& OrigImage, const HObject& ThresholdImage, HObject* RegionDynThresh, const HTuple& Offset, const HTuple& LightDark)

HRegion HImage::DynThreshold(const HImage& ThresholdImage, const HTuple& Offset, const HString& LightDark) const

HRegion HImage::DynThreshold(const HImage& ThresholdImage, double Offset, const HString& LightDark) const

HRegion HImage::DynThreshold(const HImage& ThresholdImage, double Offset, const char* LightDark) const

HRegion HImage::DynThreshold(const HImage& ThresholdImage, double Offset, const wchar_t* LightDark) const   ( Windows only)

static void HOperatorSet.DynThreshold(HObject origImage, HObject thresholdImage, out HObject regionDynThresh, HTuple offset, HTuple lightDark)

HRegion HImage.DynThreshold(HImage thresholdImage, HTuple offset, string lightDark)

HRegion HImage.DynThreshold(HImage thresholdImage, double offset, string lightDark)

def dyn_threshold(orig_image: HObject, threshold_image: HObject, offset: Union[int, float], light_dark: str) -> HObject

描述

dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold selects from the input image those regions in which the pixels fulfill a threshold condition. Let g_{o} = g_{OrigImageOrigImageOrigImageOrigImageorigImageorig_image}, and g_{t} = g_{ThresholdImageThresholdImageThresholdImageThresholdImagethresholdImagethreshold_image}. Then the condition for LightDarkLightDarkLightDarkLightDarklightDarklight_dark = 'light'"light""light""light""light""light" is: For LightDarkLightDarkLightDarkLightDarklightDarklight_dark = 'dark'"dark""dark""dark""dark""dark" the condition is: For LightDarkLightDarkLightDarkLightDarklightDarklight_dark = 'equal'"equal""equal""equal""equal""equal" it is: Finally, for LightDarkLightDarkLightDarkLightDarklightDarklight_dark = 'not_equal'"not_equal""not_equal""not_equal""not_equal""not_equal" it is:

Typically, the threshold images are smoothed versions of the original image (e.g., by applying mean_imagemean_imageMeanImageMeanImageMeanImagemean_image, binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, etc.). Then the effect of dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold is similar to applying thresholdthresholdThresholdThresholdThresholdthreshold to a highpass-filtered version of the original image (see highpass_imagehighpass_imageHighpassImageHighpassImageHighpassImagehighpass_image).

With dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold, contours of an object can be extracted, where the objects' size (diameter) is determined by the mask size of the lowpass filter and the amplitude of the objects' edges:

The larger the mask size is chosen, the larger the found regions become. As a rule of thumb, the mask size should be about twice the diameter of the objects to be extracted. It is important not to set the parameter OffsetOffsetOffsetOffsetoffsetoffset to zero because in this case too many small regions will be found (noise). Values between 5 and 40 are a useful choice. The larger OffsetOffsetOffsetOffsetoffsetoffset is chosen, the smaller the extracted regions become.

All points of the input image fulfilling the above condition are stored jointly in one region. If necessary, the connected components can be obtained by calling connectionconnectionConnectionConnectionConnectionconnection

注意

If OffsetOffsetOffsetOffsetoffsetoffset is chosen from -1 to 1 usually a very noisy region is generated, requiring large storage. If OffsetOffsetOffsetOffsetoffsetoffset is chosen too large (> 60, say) it may happen that no points fulfill the threshold condition (i.e., an empty region is returned). If OffsetOffsetOffsetOffsetoffsetoffset is chosen too small (< -60, say) it may happen that all points fulfill the threshold condition (i.e., a full region is returned).

执行信息

参数

OrigImageOrigImageOrigImageOrigImageorigImageorig_image (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / int2 / uint2 / int4 / real)

输入图像。

ThresholdImageThresholdImageThresholdImageThresholdImagethresholdImagethreshold_image (输入对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / int2 / uint2 / int4 / real)

Image containing the local thresholds.

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

Segmented regions.

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

Offset applied to ThresholdImage.

默认值: 5.0

建议值: 1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0

值范围: -255.0 ≤ Offset Offset Offset Offset offset offset ≤ 255.0 (lin)

最小增量: 0.01

建议增量: 5

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

Extract light, dark or similar areas?

默认值: 'light' "light" "light" "light" "light" "light"

值列表: 'dark'"dark""dark""dark""dark""dark", 'equal'"equal""equal""equal""equal""equal", 'light'"light""light""light""light""light", 'not_equal'"not_equal""not_equal""not_equal""not_equal""not_equal"

示例(HDevelop)

* Looking for regions with the diameter D
mean_image(Image,Mean,D*2+1,D*2+1)
dyn_threshold(Image,Mean,Seg,5,'light')
connection(Seg,Regions)

示例(C)

/* Looking for regions with the diameter D */
mean_image(Image,&Mean,D*2+1,D*2+1);
dyn_threshold(Image,Mean,&Seg,5.0,"light");
connection(Seg,&Region);

示例(HDevelop)

* Looking for regions with the diameter D
mean_image(Image,Mean,D*2+1,D*2+1)
dyn_threshold(Image,Mean,Seg,5,'light')
connection(Seg,Regions)

示例(HDevelop)

* Looking for regions with the diameter D
mean_image(Image,Mean,D*2+1,D*2+1)
dyn_threshold(Image,Mean,Seg,5,'light')
connection(Seg,Regions)

示例(HDevelop)

* Looking for regions with the diameter D
mean_image(Image,Mean,D*2+1,D*2+1)
dyn_threshold(Image,Mean,Seg,5,'light')
connection(Seg,Regions)

复杂度

Let A be the area of the input region. Then the runtime complexity is O(A).

结果

dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold 在所有参数正确时返回 2 ( H_MSG_TRUE )。 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""no_object_result""no_object_result""no_object_result""no_object_result", 'empty_region_result'"empty_region_result""empty_region_result""empty_region_result""empty_region_result""empty_region_result", and 'store_empty_region'"store_empty_region""store_empty_region""store_empty_region""store_empty_region""store_empty_region" with set_systemset_systemSetSystemSetSystemSetSystemset_system。如有必要,则抛出异常。

可能的前趋

mean_imagemean_imageMeanImageMeanImageMeanImagemean_image, smooth_imagesmooth_imageSmoothImageSmoothImageSmoothImagesmooth_image, binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter

可能的后继

connectionconnectionConnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray, rank_regionrank_regionRankRegionRankRegionRankRegionrank_region, dilation1dilation1Dilation1Dilation1Dilation1dilation1, openingopeningOpeningOpeningOpeningopening, erosion1erosion1Erosion1Erosion1Erosion1erosion1

替代

check_differencecheck_differenceCheckDifferenceCheckDifferenceCheckDifferencecheck_difference, thresholdthresholdThresholdThresholdThresholdthreshold

另见

highpass_imagehighpass_imageHighpassImageHighpassImageHighpassImagehighpass_image, sub_imagesub_imageSubImageSubImageSubImagesub_image

模块

基础