Skip to content

fast_thresholdFastThresholdFastThresholdfast_thresholdfast_threshold🔗

Short description🔗

fast_thresholdFastThresholdFastThresholdfast_thresholdfast_threshold — Fast thresholding of images using global thresholds.

Signature🔗

fast_threshold( image Image, out region Region, number MinGray, number MaxGray, number MinSize )void FastThreshold( const HObject& Image, HObject* Region, const HTuple& MinGray, const HTuple& MaxGray, const HTuple& MinSize )static void HOperatorSet.FastThreshold( HObject image, out HObject region, HTuple minGray, HTuple maxGray, HTuple minSize )def fast_threshold( image: HObject, min_gray: Union[int, float], max_gray: Union[int, float], min_size: int ) -> HObject

Herror fast_threshold( const Hobject Image, Hobject* Region, double MinGray, double MaxGray, const Hlong MinSize )

Herror T_fast_threshold( const Hobject Image, Hobject* Region, const Htuple MinGray, const Htuple MaxGray, const Htuple MinSize )

HRegion HImage::FastThreshold( const HTuple& MinGray, const HTuple& MaxGray, Hlong MinSize ) const

HRegion HImage::FastThreshold( double MinGray, double MaxGray, Hlong MinSize ) const

HRegion HImage.FastThreshold( HTuple minGray, HTuple maxGray, int minSize )

HRegion HImage.FastThreshold( double minGray, double maxGray, int minSize )

Description🔗

fast_thresholdFastThreshold selects the pixels from the input image whose gray values \(g\) fulfill the following condition:

\[\begin{eqnarray*} \textrm{MinGray} \le g \le \textrm{MaxGray} \enspace . \end{eqnarray*}\]

To reduce the processing time, the selection is done in two steps: At first, all points lying on selected horizontal lines that are specified by their distance MinSizeminSizemin_size are processed. In the next step the neighborhood (size (2MinSize+1) x (2MinSize+1)) of all previously selected points are processed.

Attention🔗

On multi-core computers supporting the SSE2 instruction set, thresholdThreshold is most likely faster than fast_thresholdFastThreshold. fast_thresholdFastThreshold may only be preferred to thresholdThreshold if those features are not available, e.g., on embedded platforms.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on internal data level.

Parameters🔗

Imageimageimage (input_object) singlechannelimage(-array) → object (byte / uint2 / direction / cyclic / real)HObject (byte / uint2 / direction / cyclic / real)HImage (byte / uint2 / direction / cyclic / real)HObject (byte / uint2 / direction / cyclic / real)Hobject (byte / uint2 / direction / cyclic / real)

Input image.

Regionregionregion (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Segmented regions.

MinGrayminGraymin_gray (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Lower threshold for the gray values.

Default: 128128
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.00.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0
Value range: 0.0 ≤ MinGray ≤ 255.0 (lin)
Minimum increment: 1
Recommended increment: 5.0

MaxGraymaxGraymax_gray (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Upper threshold for the gray values.

Default: 255.0255.0
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.00.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0
Value range: 0.0 ≤ MaxGray ≤ 255.0 (lin)
Minimum increment: 1
Recommended increment: 5.0

MinSizeminSizemin_size (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Minimum size of objects to be extracted.

Default: 2020
Suggested values: 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 1005, 10, 15, 20, 25, 30, 40, 50, 60, 70, 100
Value range: 2 ≤ MinSize ≤ 200 (lin)
Minimum increment: 1
Recommended increment: 2

Complexity🔗

Let \(A\) be the area of the output region and \(height\) the height of Imageimageimage. Then the runtime complexity is \(O(A + height / \textrm{MinSize})\).

Result🔗

fast_thresholdFastThreshold 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", 'empty_region_result'"empty_region_result", and 'store_empty_region'"store_empty_region" with set_systemSetSystem. If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

histo_to_threshHistoToThresh, min_max_grayMinMaxGray, sobel_ampSobelAmp, binomial_filterBinomialFilter, gauss_filterGaussFilter, reduce_domainReduceDomain, fill_interlaceFillInterlace

Possible successors

connectionConnection, dilation1Dilation1, erosion1Erosion1, openingOpening, closingClosing, rank_regionRankRegion, shape_transShapeTrans, skeletonSkeleton

Alternatives

thresholdThreshold, gen_grid_regionGenGridRegion, dilation_rectangle1DilationRectangle1, dyn_thresholdDynThreshold

See also

class_2dim_supClass2dimSup, hysteresis_thresholdHysteresisThreshold

Module🔗

Foundation