ImageDev

FeatureAdaptiveThresholding

Thresholds an image depending on two grayscale measurements.

Access to parameter description

This algorithm computes the thresholds of a grayscale image, given a label image corresponding to the pre-segmentation of the original image. Instead of giving two fixed values for the thresholding, two representative measurements are provided to the algorithm (for example, the 10th and the 90th percentile of the histogram, native measurements HistogramQuantile10 and HistogramQuantile90).
The minimum and maximum thresholding values are dynamically computed for each label and applied to give an adaptive thresholding on each of them.
For instance, the label image can be a grid of contiguous squares of different intensity to ensure a thresholding locally adapted to each square.

See also

Function Syntax

This function returns the outputBinaryImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
featureAdaptiveThresholding( std::shared_ptr< iolink::ImageView > inputLabelImage,
                             std::shared_ptr< iolink::ImageView > inputGrayImage,
                             std::string measurementLow,
                             std::string measurementHigh,
                             std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
This function returns the outputBinaryImage output parameter.
// Function prototype.
feature_adaptive_thresholding( input_label_image,
                               input_gray_image,
                               measurement_low = "",
                               measurement_high = "",
                               output_binary_image = None )
This function returns the outputBinaryImage output parameter.
// Function prototype.
public static IOLink.ImageView
FeatureAdaptiveThresholding( IOLink.ImageView inputLabelImage,
                             IOLink.ImageView inputGrayImage,
                             string measurementLow = "",
                             string measurementHigh = "",
                             IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Class Name FeatureAdaptiveThresholding

Parameter Name Description Type Supported Values Default Value
input
inputLabelImage
The input label image. Image Binary or Label nullptr
input
inputGrayImage
The input grayscale image. This image must have same dimensions as the input label image. Image Grayscale nullptr
input
measurementLow
The measurement defining the lower threshold. Measurement ""
input
measurementHigh
The measurement defining the higher threshold. Measurement ""
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image nullptr

Object Examples

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

FeatureAdaptiveThresholding featureAdaptiveThresholdingAlgo;
featureAdaptiveThresholdingAlgo.setInputLabelImage( polystyrene_sep_label );
featureAdaptiveThresholdingAlgo.setInputGrayImage( polystyrene );
featureAdaptiveThresholdingAlgo.setMeasurementLow( "HistogramQuantile10" );
featureAdaptiveThresholdingAlgo.setMeasurementHigh( "HistogramQuantile90" );
featureAdaptiveThresholdingAlgo.execute();

std::cout << "outputBinaryImage:" << featureAdaptiveThresholdingAlgo.outputBinaryImage()->toString();
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

feature_adaptive_thresholding_algo = imagedev.FeatureAdaptiveThresholding()
feature_adaptive_thresholding_algo.input_label_image = polystyrene_sep_label
feature_adaptive_thresholding_algo.input_gray_image = polystyrene
feature_adaptive_thresholding_algo.measurement_low = "HistogramQuantile10"
feature_adaptive_thresholding_algo.measurement_high = "HistogramQuantile90"
feature_adaptive_thresholding_algo.execute()

print( "output_binary_image:", str( feature_adaptive_thresholding_algo.output_binary_image ) );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

FeatureAdaptiveThresholding featureAdaptiveThresholdingAlgo = new FeatureAdaptiveThresholding
{
    inputLabelImage = polystyrene_sep_label,
    inputGrayImage = polystyrene,
    measurementLow = "HistogramQuantile10",
    measurementHigh = "HistogramQuantile90"
};
featureAdaptiveThresholdingAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + featureAdaptiveThresholdingAlgo.outputBinaryImage.ToString() );

Function Examples

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

auto result = featureAdaptiveThresholding( polystyrene_sep_label, polystyrene, "HistogramQuantile10", "HistogramQuantile90" );

std::cout << "outputBinaryImage:" << result->toString();
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.feature_adaptive_thresholding( polystyrene_sep_label, polystyrene, "HistogramQuantile10", "HistogramQuantile90" )

print( "output_binary_image:", str( result ) );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.FeatureAdaptiveThresholding( polystyrene_sep_label, polystyrene, "HistogramQuantile10", "HistogramQuantile90" );

Console.WriteLine( "outputBinaryImage:" + result.ToString() );