Loading [MathJax]/jax/output/CommonHTML/jax.js
ImageDev

AutoThresholdingValue

Computes a threshold value partitioning automatically a gray level image into two classes.

Access to parameter description

For an introduction: This algorithm computes an automatic threshold on a grayscale image; that is, separates the input image histogram in two classes of pixels from an input range [I1,I2]. Each class can be either considered as background or foreground depending on the acquisition device and the nature of the scene.

Four methods of classification are available to determine C0 and C1: Entropy, Factorisation, Moments, and Isodata. These methods are detailed in the AutoThresholdingBright documentation.
The computed threshold is returned in the AutoThresholdingMsr object. See also

Function Syntax

This function returns outputMeasurement.
// Function prototype
AutoThresholdingMsr::Ptr autoThresholdingValue( std::shared_ptr< iolink::ImageView > inputGrayImage, AutoThresholdingValue::RangeMode rangeMode, iolink::Vector2d intensityInputRange, AutoThresholdingValue::ThresholdCriterion thresholdCriterion, AutoThresholdingMsr::Ptr outputMeasurement = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
The input grayscale image Image Grayscale nullptr
input
rangeMode
The way to determine the input intensity range.
MIN_MAX The histogram is computed between the minimum and the maximum of the image.
OTHER The histogram is computed between user-defined bounds [a,b].
Enumeration MIN_MAX
input
intensityInputRange
The input intensity range [a,b] inside which the threshold is searched. This parameter is ignored if the range mode is set to MIN_MAX. Vector2d Any value {0.f, 255.f}
input
thresholdCriterion
The criterion to compute the threshold from the histogram.
ENTROPY The measurement of dispersion used in the algorithm is the entropy of the intensity distribution.
FACTORISATION The measurement of dispersion used in the algorithm is the variance of the intensity distribution (also known as the Otsu method).
MOMENTS The measurement of dispersion used in the algorithm is the moments of the intensity distribution.
ISODATA The measurement of dispersion used in the algorithm is the isodata of the intensity distribution.
Enumeration ENTROPY
output
outputMeasurement
The output measurement containing the computed threshold. AutoThresholdingMsr nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

AutoThresholdingValue autoThresholdingValueAlgo;
autoThresholdingValueAlgo.setInputGrayImage( polystyrene );
autoThresholdingValueAlgo.setRangeMode( AutoThresholdingValue::RangeMode::MIN_MAX );
autoThresholdingValueAlgo.setIntensityInputRange( {0, 255} );
autoThresholdingValueAlgo.setThresholdCriterion( AutoThresholdingValue::ThresholdCriterion::ENTROPY );
autoThresholdingValueAlgo.execute();

std::cout << "threshold: " << autoThresholdingValueAlgo.outputMeasurement()->threshold( 0 ) ;

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = autoThresholdingValue( polystyrene, AutoThresholdingValue::RangeMode::MIN_MAX, {0, 255}, AutoThresholdingValue::ThresholdCriterion::ENTROPY );

std::cout << "threshold: " << result->threshold( 0 ) ;