AutoThresholdingValue
Computes a threshold value partitioning automatically a gray level image into two classes.
Access to parameter description
For an introduction:
Four methods of classification are available to determine $C_0$ and $C_1$: Entropy, Factorisation, Moments, and Isodata. These methods are detailed in the AutoThresholdingBright documentation.
The computed threshold is returned in the AutoThresholdingMsr object. See also
Access to parameter description
For an introduction:
- section Image Segmentation
- section Binarization
- section AutoThresholdingBright
- $C_0=[I_1,T]$ represents the first class pixels.
- $C_1=[T+1,I_2]$ represents the second class pixels.
Four methods of classification are available to determine $C_0$ and $C_1$: 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 );
This function returns outputMeasurement.
// Function prototype. auto_thresholding_value( input_gray_image, range_mode = AutoThresholdingValue.RangeMode.MIN_MAX, intensity_input_range = [0, 255], threshold_criterion = AutoThresholdingValue.ThresholdCriterion.ENTROPY, output_measurement = None )
This function returns outputMeasurement.
// Function prototype. public static AutoThresholdingMsr AutoThresholdingValue( IOLink.ImageView inputGrayImage, AutoThresholdingValue.RangeMode rangeMode = ImageDev.AutoThresholdingValue.RangeMode.MIN_MAX, double[] intensityInputRange = null, AutoThresholdingValue.ThresholdCriterion thresholdCriterion = ImageDev.AutoThresholdingValue.ThresholdCriterion.ENTROPY, AutoThresholdingMsr outputMeasurement = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputGrayImage |
The input grayscale image | Image | Grayscale | nullptr | |||||||||
rangeMode |
The way to determine the input intensity range.
|
Enumeration | MIN_MAX | ||||||||||
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} | |||||||||
thresholdCriterion |
The criterion to compute the threshold from the histogram.
|
Enumeration | ENTROPY | ||||||||||
outputMeasurement |
The output measurement containing the computed threshold. | AutoThresholdingMsr | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input_gray_image |
The input grayscale image | image | Grayscale | None | |||||||||
range_mode |
The way to determine the input intensity range.
|
enumeration | MIN_MAX | ||||||||||
intensity_input_range |
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, 255] | |||||||||
threshold_criterion |
The criterion to compute the threshold from the histogram.
|
enumeration | ENTROPY | ||||||||||
output_measurement |
The output measurement containing the computed threshold. | AutoThresholdingMsr | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputGrayImage |
The input grayscale image | Image | Grayscale | null | |||||||||
rangeMode |
The way to determine the input intensity range.
|
Enumeration | MIN_MAX | ||||||||||
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 | {0f, 255f} | |||||||||
thresholdCriterion |
The criterion to compute the threshold from the histogram.
|
Enumeration | ENTROPY | ||||||||||
outputMeasurement |
The output measurement containing the computed threshold. | AutoThresholdingMsr | null |
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 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) auto_thresholding_value_algo = imagedev.AutoThresholdingValue() auto_thresholding_value_algo.input_gray_image = polystyrene auto_thresholding_value_algo.range_mode = imagedev.AutoThresholdingValue.MIN_MAX auto_thresholding_value_algo.intensity_input_range = [0, 255] auto_thresholding_value_algo.threshold_criterion = imagedev.AutoThresholdingValue.ENTROPY auto_thresholding_value_algo.execute() print( "threshold: ", str( auto_thresholding_value_algo.output_measurement.threshold( 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); AutoThresholdingValue autoThresholdingValueAlgo = new AutoThresholdingValue { inputGrayImage = polystyrene, rangeMode = AutoThresholdingValue.RangeMode.MIN_MAX, intensityInputRange = new double[]{0, 255}, thresholdCriterion = AutoThresholdingValue.ThresholdCriterion.ENTROPY }; autoThresholdingValueAlgo.Execute(); Console.WriteLine( "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 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.auto_thresholding_value( polystyrene, imagedev.AutoThresholdingValue.MIN_MAX, [0, 255], imagedev.AutoThresholdingValue.ENTROPY ) print( "threshold: ", str( result.threshold( 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); AutoThresholdingMsr result = Processing.AutoThresholdingValue( polystyrene, AutoThresholdingValue.RangeMode.MIN_MAX, new double[]{0, 255}, AutoThresholdingValue.ThresholdCriterion.ENTROPY ); Console.WriteLine( "threshold: " + result.threshold( 0 ) );