ImageDev

CompareValue

Performs a comparison test between an image and value and outputs the number of pixels that successfully passed the test.

Access to parameter description

For an introduction: This algorithm computes the number of pixels which fulfill a point-wise comparison criterion between an image $I$ and and a constant value $C$.

The proposed comparison criteria are less-than, less-or-equal, equal-to, greater-or-equal, greater-than and not-equal-to.

See also

Function Syntax

This function returns outputMeasurement.
// Function prototype
CompareMsr::Ptr compareValue( std::shared_ptr< iolink::ImageView > inputImage, double value, CompareValue::ComparisonCriterion comparisonCriterion, CompareMsr::Ptr outputMeasurement = NULL );
This function returns outputMeasurement.
// Function prototype.
compare_value( input_image,
               value = 0,
               comparison_criterion = CompareValue.ComparisonCriterion.NOT_EQUAL_TO,
               output_measurement = None )
This function returns outputMeasurement.
// Function prototype.
public static CompareMsr
CompareValue( IOLink.ImageView inputImage,
              double value = 0,
              CompareValue.ComparisonCriterion comparisonCriterion = ImageDev.CompareValue.ComparisonCriterion.NOT_EQUAL_TO,
              CompareMsr outputMeasurement = null );

Class Syntax

Parameters

Class Name CompareValue

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
value
The floating value to compare. Float64 Any value 0
input
comparisonCriterion
The comparison test to perform between images.
LESS_THAN The number of pixels of the image having an intensity strictly less than the constant value.
LESS_OR_EQUAL The number of pixels of the image having an intensity less than or equal to the constant value.
EQUAL_TO The number of pixels of the image having an intensity equal to the constant value.
GREATER_OR_EQUAL The number of pixels of the image having an intensity greater than or equal to the constant value.
GREATER_THAN The number of pixels of the image having an intensity strictly greater than the constant value.
NOT_EQUAL_TO The number of pixels of the image having an intensity different than the constant value.
Enumeration NOT_EQUAL_TO
output
outputMeasurement
The output measurement result. CompareMsr nullptr

Object Examples

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

CompareValue compareValueAlgo;
compareValueAlgo.setInputImage( polystyrene );
compareValueAlgo.setValue( 0 );
compareValueAlgo.setComparisonCriterion( CompareValue::ComparisonCriterion::NOT_EQUAL_TO );
compareValueAlgo.execute();

std::cout << "pixelCount: " << compareValueAlgo.outputMeasurement()->pixelCount( 0 , 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

compare_value_algo = imagedev.CompareValue()
compare_value_algo.input_image = polystyrene
compare_value_algo.value = 0
compare_value_algo.comparison_criterion = imagedev.CompareValue.NOT_EQUAL_TO
compare_value_algo.execute()

print( "pixelCount: ", str( compare_value_algo.output_measurement.pixel_count( 0 , 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

CompareValue compareValueAlgo = new CompareValue
{
    inputImage = polystyrene,
    value = 0,
    comparisonCriterion = CompareValue.ComparisonCriterion.NOT_EQUAL_TO
};
compareValueAlgo.Execute();

Console.WriteLine( "pixelCount: " + compareValueAlgo.outputMeasurement.pixelCount( 0 , 0 ) );

Function Examples

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

auto result = compareValue( polystyrene, 0, CompareValue::ComparisonCriterion::NOT_EQUAL_TO );

std::cout << "pixelCount: " << result->pixelCount( 0 , 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.compare_value( polystyrene, 0, imagedev.CompareValue.NOT_EQUAL_TO )

print( "pixelCount: ", str( result.pixel_count( 0 , 0 ) )  )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

CompareMsr result = Processing.CompareValue( polystyrene, 0, CompareValue.ComparisonCriterion.NOT_EQUAL_TO );

Console.WriteLine(  "pixelCount: " + result.pixelCount( 0 , 0 )  );