ImageDev

ThresholdingByCriterion

Performs a criterion based thresholding on a grayscale image.

Access to parameter description

For an introduction: For each input pixel, if its intensity meets the user-defined criterion, the output is set to 1 (foreground pixel); otherwise it is set to 0 (background pixel).

See also
See related examples

Function Syntax

This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > thresholdingByCriterion( std::shared_ptr< iolink::ImageView > inputGrayImage, ThresholdingByCriterion::ComparisonCriterion comparisonCriterion, double comparisonValue, std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
This function returns outputBinaryImage.
// Function prototype.
thresholding_by_criterion( input_gray_image,
                           comparison_criterion = ThresholdingByCriterion.ComparisonCriterion.GREATER_THAN_OR_EQUAL_TO,
                           comparison_value = 128,
                           output_binary_image = None )
This function returns outputBinaryImage.
// Function prototype.
public static IOLink.ImageView
ThresholdingByCriterion( IOLink.ImageView inputGrayImage,
                         ThresholdingByCriterion.ComparisonCriterion comparisonCriterion = ImageDev.ThresholdingByCriterion.ComparisonCriterion.GREATER_THAN_OR_EQUAL_TO,
                         double comparisonValue = 128,
                         IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
Input gray level image. Image Binary, Label, Grayscale or Multispectral nullptr
input
comparisonCriterion
The criterion of comparison.
LESS_THAN Pixels having a value less than the comparison value are set to 1, others are set to 0.
LESS_THAN_OR_EQUAL_TO Pixels having a value less than or equal to the comparison value are set to 1, others are set to 0.
EQUAL_TO Pixels having a value equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN_OR_EQUAL_TO Pixels having a value greater than or equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN Pixels having a value greater than the comparison value are set to 1, others are set to 0.
NOT_EQUAL_TO Pixels having a value different from the comparison value are set to 1, others are set to 0.
Enumeration GREATER_THAN_OR_EQUAL_TO
input
comparisonValue
The threshold level. Float64 Any value 128
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_gray_image
Input gray level image. image Binary, Label, Grayscale or Multispectral None
input
comparison_criterion
The criterion of comparison.
LESS_THAN Pixels having a value less than the comparison value are set to 1, others are set to 0.
LESS_THAN_OR_EQUAL_TO Pixels having a value less than or equal to the comparison value are set to 1, others are set to 0.
EQUAL_TO Pixels having a value equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN_OR_EQUAL_TO Pixels having a value greater than or equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN Pixels having a value greater than the comparison value are set to 1, others are set to 0.
NOT_EQUAL_TO Pixels having a value different from the comparison value are set to 1, others are set to 0.
enumeration GREATER_THAN_OR_EQUAL_TO
input
comparison_value
The threshold level. float64 Any value 128
output
output_binary_image
The output binary image. Its dimensions are forced to the same values as the input. image None
Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
Input gray level image. Image Binary, Label, Grayscale or Multispectral null
input
comparisonCriterion
The criterion of comparison.
LESS_THAN Pixels having a value less than the comparison value are set to 1, others are set to 0.
LESS_THAN_OR_EQUAL_TO Pixels having a value less than or equal to the comparison value are set to 1, others are set to 0.
EQUAL_TO Pixels having a value equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN_OR_EQUAL_TO Pixels having a value greater than or equal to the comparison value are set to 1, others are set to 0.
GREATER_THAN Pixels having a value greater than the comparison value are set to 1, others are set to 0.
NOT_EQUAL_TO Pixels having a value different from the comparison value are set to 1, others are set to 0.
Enumeration GREATER_THAN_OR_EQUAL_TO
input
comparisonValue
The threshold level. Float64 Any value 128
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image null

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

ThresholdingByCriterion thresholdingByCriterionAlgo;
thresholdingByCriterionAlgo.setInputGrayImage( foam );
thresholdingByCriterionAlgo.setComparisonCriterion( ThresholdingByCriterion::ComparisonCriterion::NOT_EQUAL_TO );
thresholdingByCriterionAlgo.setComparisonValue( 0.0 );
thresholdingByCriterionAlgo.execute();

std::cout << "outputBinaryImage:" << thresholdingByCriterionAlgo.outputBinaryImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

thresholding_by_criterion_algo = imagedev.ThresholdingByCriterion()
thresholding_by_criterion_algo.input_gray_image = foam
thresholding_by_criterion_algo.comparison_criterion = imagedev.ThresholdingByCriterion.NOT_EQUAL_TO
thresholding_by_criterion_algo.comparison_value = 0.0
thresholding_by_criterion_algo.execute()

print( "output_binary_image:", str( thresholding_by_criterion_algo.output_binary_image ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

ThresholdingByCriterion thresholdingByCriterionAlgo = new ThresholdingByCriterion
{
    inputGrayImage = foam,
    comparisonCriterion = ThresholdingByCriterion.ComparisonCriterion.NOT_EQUAL_TO,
    comparisonValue = 0.0
};
thresholdingByCriterionAlgo.Execute();

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

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = thresholdingByCriterion( foam, ThresholdingByCriterion::ComparisonCriterion::NOT_EQUAL_TO, 0.0 );

std::cout << "outputBinaryImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.thresholding_by_criterion( foam, imagedev.ThresholdingByCriterion.NOT_EQUAL_TO, 0.0 )

print( "output_binary_image:", str( result ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.ThresholdingByCriterion( foam, ThresholdingByCriterion.ComparisonCriterion.NOT_EQUAL_TO, 0.0 );

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