dual_thresholddual_thresholdDualThresholdDualThresholddual_threshold (Operator)

Name

dual_thresholddual_thresholdDualThresholdDualThresholddual_threshold — Threshold operator for signed images.

Signature

dual_threshold(Image : RegionCrossings : MinSize, MinGray, Threshold : )

Herror dual_threshold(const Hobject Image, Hobject* RegionCrossings, const Hlong MinSize, double MinGray, double Threshold)

Herror T_dual_threshold(const Hobject Image, Hobject* RegionCrossings, const Htuple MinSize, const Htuple MinGray, const Htuple Threshold)

void DualThreshold(const HObject& Image, HObject* RegionCrossings, const HTuple& MinSize, const HTuple& MinGray, const HTuple& Threshold)

HRegion HImage::DualThreshold(Hlong MinSize, double MinGray, double Threshold) const

static void HOperatorSet.DualThreshold(HObject image, out HObject regionCrossings, HTuple minSize, HTuple minGray, HTuple threshold)

HRegion HImage.DualThreshold(int minSize, double minGray, double threshold)

def dual_threshold(image: HObject, min_size: int, min_gray: float, threshold: float) -> HObject

Description

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold segments the input image into a region with gray values ThresholdThresholdThresholdThresholdthresholdthreshold (“positive” regions) and a region with gray values ThresholdThresholdThresholdThresholdthresholdthreshold (“negative” regions). Only “positive” or “negative” regions having a size larger than MinSizeMinSizeMinSizeMinSizeminSizemin_size are taken into account. And regions whose maximum gray value is less than MinGrayMinGrayMinGrayMinGrayminGraymin_gray in absolute value are suppressed.

The segmentation performed is not complete, i.e., the “positive” and “negative” regions together do not necessarily cover the entire image: Areas with a gray value between ThresholdThresholdThresholdThresholdthresholdthreshold and ThresholdThresholdThresholdThresholdthresholdthreshold, MinGrayMinGrayMinGrayMinGrayminGraymin_gray and MinGrayMinGrayMinGrayMinGrayminGraymin_gray, respectively, are not taken into account.

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold is usually called after applying a Laplace operator (laplacelaplaceLaplaceLaplaceLaplacelaplace, laplace_of_gausslaplace_of_gaussLaplaceOfGaussLaplaceOfGaussLaplaceOfGausslaplace_of_gauss, derivate_gaussderivate_gaussDerivateGaussDerivateGaussDerivateGaussderivate_gauss or diff_of_gaussdiff_of_gaussDiffOfGaussDiffOfGaussDiffOfGaussdiff_of_gauss) to an image or with the difference of two images (sub_imagesub_imageSubImageSubImageSubImagesub_image).

The zero crossings of a Laplace image correspond to edges in an image, and are the separating regions of the “positive” and “negative” regions in the Laplace image. They can be determined by calling dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold with ThresholdThresholdThresholdThresholdthresholdthreshold = 1 and then creating the complement regions with complementcomplementComplementComplementComplementcomplement. The parameter MinGrayMinGrayMinGrayMinGrayminGraymin_gray determines the noise invariance, while MinSizeMinSizeMinSizeMinSizeminSizemin_size determines the resolution of the edge detection.

Using byte images, only the positive part of the operator is applied. Therefore dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold behaves like a standard threshold operator (thresholdthresholdThresholdThresholdThresholdthreshold) with successive connectionconnectionConnectionConnectionConnectionconnection and select_grayselect_graySelectGraySelectGraySelectGrayselect_gray.

Execution Information

Parameters

ImageImageImageImageimageimage (input_object)  singlechannelimage(-array) objectHImageHObjectHImageHobject (byte / int1 / int2 / int4 / real)

Input image.

RegionCrossingsRegionCrossingsRegionCrossingsRegionCrossingsregionCrossingsregion_crossings (output_object)  region-array objectHRegionHObjectHRegionHobject *

Positive and negative regions.

MinSizeMinSizeMinSizeMinSizeminSizemin_size (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Regions smaller than MinSize are suppressed.

Default value: 20

Suggested values: 0, 10, 20, 50, 100, 200, 500, 1000

Typical range of values: 0 ≤ MinSize MinSize MinSize MinSize minSize min_size ≤ 10000 (lin)

Minimum increment: 1

Recommended increment: 10

MinGrayMinGrayMinGrayMinGrayminGraymin_gray (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Regions whose maximum absolute gray value is smaller than MinGray are suppressed.

Default value: 5.0

Suggested values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0

Typical range of values: 0.001 ≤ MinGray MinGray MinGray MinGray minGray min_gray ≤ 10000.0 (lin)

Minimum increment: 1.0

Recommended increment: 10.0

Restriction: MinGray > 0

ThresholdThresholdThresholdThresholdthresholdthreshold (input_control)  real HTuplefloatHTupleHtuple (real) (double) (double) (double)

Regions that have a gray value smaller than Threshold (or larger than -Threshold) are suppressed.

Default value: 2.0

Suggested values: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0

Typical range of values: 0.001 ≤ Threshold Threshold Threshold Threshold threshold threshold ≤ 10000.0 (lin)

Minimum increment: 1.0

Recommended increment: 10.0

Restriction: Threshold >= 1 && Threshold <= MinGray

Example (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Example (C)

/* Edge detection with the Laplace operator (and edge thinning) */
diff_of_gauss(Image,&Laplace,2.0,1.6);
/* find "`positive"' and "`negative"' regions: */
dual_threshold(Laplace,&Region,20,2,1);
/*The zero runnings are the complement to these image section: */
complement(Region,ZeroCrossings);

Example (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Example (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Example (HDevelop)

* Edge detection with the Laplace operator (and edge thinning)
diff_of_gauss(Image,Laplace,2.0,1.6)
* find "`positive"' and "`negative"' regions:
dual_threshold(Laplace,Region,20,2,1)
* The zero runnings are the complement to these image section:
complement(Region,ZeroCrossings)

* Simulation of dual_threshold
dual_threshold(Laplace,Result,MinS,MinG,Threshold)
threshold(Laplace,Tmp1,Threshold,999999)
connection(Tmp1,Tmp2)
select_shape(Tmp2,Tmp3,'area','and',MinS,999999)
select_gray(Laplace,Tmp3,Tmp4,'max','and',MinG,999999)
threshold(Laplace,Tmp5,-999999,-Threshold)
connection(Tmp5,Tmp6)
select_shape(Tmp6,Tmp7,'area','and',MinS,999999)
select_gray(Laplace,Tmp7,Tmp8,'min','and',-999999,-MinG)
concat_obj(Tmp4,Tmp8,Result)

Result

dual_thresholddual_thresholdDualThresholdDualThresholdDualThresholddual_threshold returns 2 (H_MSG_TRUE) if all parameters are correct. 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. If necessary, an exception is raised.

Possible Predecessors

min_max_graymin_max_grayMinMaxGrayMinMaxGrayMinMaxGraymin_max_gray, sobel_ampsobel_ampSobelAmpSobelAmpSobelAmpsobel_amp, binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain, diff_of_gaussdiff_of_gaussDiffOfGaussDiffOfGaussDiffOfGaussdiff_of_gauss, sub_imagesub_imageSubImageSubImageSubImagesub_image, derivate_gaussderivate_gaussDerivateGaussDerivateGaussDerivateGaussderivate_gauss, laplace_of_gausslaplace_of_gaussLaplaceOfGaussLaplaceOfGaussLaplaceOfGausslaplace_of_gauss, laplacelaplaceLaplaceLaplaceLaplacelaplace, expand_regionexpand_regionExpandRegionExpandRegionExpandRegionexpand_region

Possible Successors

connectionconnectionConnectionConnectionConnectionconnection, dilation1dilation1Dilation1Dilation1Dilation1dilation1, erosion1erosion1Erosion1Erosion1Erosion1erosion1, openingopeningOpeningOpeningOpeningopening, closingclosingClosingClosingClosingclosing, rank_regionrank_regionRankRegionRankRegionRankRegionrank_region, shape_transshape_transShapeTransShapeTransShapeTransshape_trans, skeletonskeletonSkeletonSkeletonSkeletonskeleton

Alternatives

thresholdthresholdThresholdThresholdThresholdthreshold, dyn_thresholddyn_thresholdDynThresholdDynThresholdDynThresholddyn_threshold, check_differencecheck_differenceCheckDifferenceCheckDifferenceCheckDifferencecheck_difference

See also

connectionconnectionConnectionConnectionConnectionconnection, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, select_grayselect_graySelectGraySelectGraySelectGrayselect_gray

Module

Foundation