AutoThresholdingDark
Computes and applies an automatic threshold on a gray level image to detect dark particles on a bright background.
Access to parameter description
For an introduction:
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 object or foreground pixels for which the output intensity is set to 1. Intensities lower than $I_1$ are also set to 1.
- $C_1=[T+1,I_2]$ represents the background pixels for which the output intensity is set to 0. Intensities greater than $I_2$ are also set to 0.
The computed threshold is returned in the AutoThresholdingMsr object.
See also
Function Syntax
This function returns a AutoThresholdingDarkOutput structure containing the outputBinaryImage and outputMeasurement output parameters.
// Output structure.
struct AutoThresholdingDarkOutput
{
std::shared_ptr< iolink::ImageView > outputBinaryImage;
AutoThresholdingMsr::Ptr outputMeasurement;
};
// Function prototype.
AutoThresholdingDarkOutput
autoThresholdingDark( std::shared_ptr< iolink::ImageView > inputGrayImage,
AutoThresholdingDark::RangeMode rangeMode,
iolink::Vector2d intensityInputRange,
AutoThresholdingDark::ThresholdCriterion thresholdCriterion,
std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL,
AutoThresholdingMsr::Ptr outputMeasurement = NULL );
This function returns a tuple containing the output_binary_image and output_measurement output parameters.
// Function prototype.
auto_thresholding_dark( input_gray_image,
range_mode = AutoThresholdingDark.RangeMode.MIN_MAX,
intensity_input_range = [0, 255],
threshold_criterion = AutoThresholdingDark.ThresholdCriterion.ENTROPY,
output_binary_image = None,
output_measurement = None )
This function returns a AutoThresholdingDarkOutput structure containing the outputBinaryImage and outputMeasurement output parameters.
/// Output structure of the AutoThresholdingDark function.
public struct AutoThresholdingDarkOutput
{
public IOLink.ImageView outputBinaryImage;
public AutoThresholdingMsr outputMeasurement;
};
// Function prototype.
public static AutoThresholdingDarkOutput
AutoThresholdingDark( IOLink.ImageView inputGrayImage,
AutoThresholdingDark.RangeMode rangeMode = ImageDev.AutoThresholdingDark.RangeMode.MIN_MAX,
double[] intensityInputRange = null,
AutoThresholdingDark.ThresholdCriterion thresholdCriterion = ImageDev.AutoThresholdingDark.ThresholdCriterion.ENTROPY,
IOLink.ImageView outputBinaryImage = null,
AutoThresholdingMsr outputMeasurement = null );
Class Syntax
Parameters
| Class Name | AutoThresholdingDark |
|---|
| 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 | |||||||||
![]() |
outputBinaryImage |
The output binary image. Its dimensions are forced to the same values as the input. | Image | nullptr | |||||||||
![]() |
outputMeasurement |
The computed threshold value. | AutoThresholdingMsr | nullptr | |||||||||
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
AutoThresholdingDark autoThresholdingDarkAlgo;
autoThresholdingDarkAlgo.setInputGrayImage( polystyrene );
autoThresholdingDarkAlgo.setRangeMode( AutoThresholdingDark::RangeMode::MIN_MAX );
autoThresholdingDarkAlgo.setIntensityInputRange( {0, 255} );
autoThresholdingDarkAlgo.setThresholdCriterion( AutoThresholdingDark::ThresholdCriterion::ENTROPY );
autoThresholdingDarkAlgo.execute();
std::cout << "outputBinaryImage:" << autoThresholdingDarkAlgo.outputBinaryImage()->toString();
std::cout << "threshold: " << autoThresholdingDarkAlgo.outputMeasurement()->threshold( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
auto_thresholding_dark_algo = imagedev.AutoThresholdingDark()
auto_thresholding_dark_algo.input_gray_image = polystyrene
auto_thresholding_dark_algo.range_mode = imagedev.AutoThresholdingDark.MIN_MAX
auto_thresholding_dark_algo.intensity_input_range = [0, 255]
auto_thresholding_dark_algo.threshold_criterion = imagedev.AutoThresholdingDark.ENTROPY
auto_thresholding_dark_algo.execute()
print( "output_binary_image:", str( auto_thresholding_dark_algo.output_binary_image ) );
print(
print("threshold: ", auto_thresholding_dark_algo.output_measurement.threshold( 0 ) ) );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
AutoThresholdingDark autoThresholdingDarkAlgo = new AutoThresholdingDark
{
inputGrayImage = polystyrene,
rangeMode = AutoThresholdingDark.RangeMode.MIN_MAX,
intensityInputRange = new double[]{0, 255},
thresholdCriterion = AutoThresholdingDark.ThresholdCriterion.ENTROPY
};
autoThresholdingDarkAlgo.Execute();
Console.WriteLine( "outputBinaryImage:" + autoThresholdingDarkAlgo.outputBinaryImage.ToString() );
Console.WriteLine( "threshold: " + autoThresholdingDarkAlgo.outputMeasurement.threshold( 0 ) );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto result = autoThresholdingDark( polystyrene, AutoThresholdingDark::RangeMode::MIN_MAX, {0, 255}, AutoThresholdingDark::ThresholdCriterion::ENTROPY );
std::cout << "outputBinaryImage:" << result.outputBinaryImage->toString();
std::cout << "threshold: " << result.outputMeasurement->threshold( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
result_output_binary_image, result_output_measurement = imagedev.auto_thresholding_dark( polystyrene, imagedev.AutoThresholdingDark.MIN_MAX, [0, 255], imagedev.AutoThresholdingDark.ENTROPY )
print( "output_binary_image:", str( result_output_binary_image ) );
print( "threshold: ", result_output_measurement.threshold( 0 ) );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
Processing.AutoThresholdingDarkOutput result = Processing.AutoThresholdingDark( polystyrene, AutoThresholdingDark.RangeMode.MIN_MAX, new double[]{0, 255}, AutoThresholdingDark.ThresholdCriterion.ENTROPY );
Console.WriteLine( "outputBinaryImage:" + result.outputBinaryImage.ToString() );
Console.WriteLine( "threshold: " + result.outputMeasurement.threshold( 0 ) );

