CompareImage
Performs a comparison test between two images and outputs the number of pixels that successfully passed the test.
Access to parameter description
For an introduction:
The proposed comparison criteria are less-than, less-or-equal, equal-to, greater-or-equal, greater-than, and not-equal-to.
Note : CompareImage can be useful to check whether two images are exactly identical. Both images must have same size and type.
See also
Access to parameter description
For an introduction:
- section Image Analysis
- section Image Statistics
The proposed comparison criteria are less-than, less-or-equal, equal-to, greater-or-equal, greater-than, and not-equal-to.
Note : CompareImage can be useful to check whether two images are exactly identical. Both images must have same size and type.
See also
Function Syntax
This function returns outputMeasurement.
// Function prototype
CompareMsr::Ptr compareImage( std::shared_ptr< iolink::ImageView > inputImage1, std::shared_ptr< iolink::ImageView > inputImage2, CompareImage::ComparisonCriterion comparisonCriterion, CompareMsr::Ptr outputMeasurement = NULL );
This function returns outputMeasurement.
// Function prototype. compare_image( input_image1, input_image2, comparison_criterion = CompareImage.ComparisonCriterion.NOT_EQUAL_TO, output_measurement = None )
This function returns outputMeasurement.
// Function prototype. public static CompareMsr CompareImage( IOLink.ImageView inputImage1, IOLink.ImageView inputImage2, CompareImage.ComparisonCriterion comparisonCriterion = ImageDev.CompareImage.ComparisonCriterion.NOT_EQUAL_TO, CompareMsr outputMeasurement = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputImage1 |
The first input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||||||||||
inputImage2 |
The second input image. Its dimensions and type must be the same as the first input. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||||||||||
comparisonCriterion |
The comparison test to perform between images.
|
Enumeration | NOT_EQUAL_TO | ||||||||||||||
outputMeasurement |
The output measurement result. | CompareMsr | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input_image1 |
The first input image. | image | Binary, Label, Grayscale or Multispectral | None | |||||||||||||
input_image2 |
The second input image. Its dimensions and type must be the same as the first input. | image | Binary, Label, Grayscale or Multispectral | None | |||||||||||||
comparison_criterion |
The comparison test to perform between images.
|
enumeration | NOT_EQUAL_TO | ||||||||||||||
output_measurement |
The output measurement result. | CompareMsr | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputImage1 |
The first input image. | Image | Binary, Label, Grayscale or Multispectral | null | |||||||||||||
inputImage2 |
The second input image. Its dimensions and type must be the same as the first input. | Image | Binary, Label, Grayscale or Multispectral | null | |||||||||||||
comparisonCriterion |
The comparison test to perform between images.
|
Enumeration | NOT_EQUAL_TO | ||||||||||||||
outputMeasurement |
The output measurement result. | CompareMsr | null |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); CompareImage compareImageAlgo; compareImageAlgo.setInputImage1( polystyrene ); compareImageAlgo.setInputImage2( polystyrene ); compareImageAlgo.setComparisonCriterion( CompareImage::ComparisonCriterion::NOT_EQUAL_TO ); compareImageAlgo.execute(); std::cout << "pixelCount: " << compareImageAlgo.outputMeasurement()->pixelCount( 0 , 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) compare_image_algo = imagedev.CompareImage() compare_image_algo.input_image1 = polystyrene compare_image_algo.input_image2 = polystyrene compare_image_algo.comparison_criterion = imagedev.CompareImage.NOT_EQUAL_TO compare_image_algo.execute() print( "pixelCount: ", str( compare_image_algo.output_measurement.pixel_count( 0 , 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); CompareImage compareImageAlgo = new CompareImage { inputImage1 = polystyrene, inputImage2 = polystyrene, comparisonCriterion = CompareImage.ComparisonCriterion.NOT_EQUAL_TO }; compareImageAlgo.Execute(); Console.WriteLine( "pixelCount: " + compareImageAlgo.outputMeasurement.pixelCount( 0 , 0 ) );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = compareImage( polystyrene, polystyrene, CompareImage::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_image( polystyrene, polystyrene, imagedev.CompareImage.NOT_EQUAL_TO ) print( "pixelCount: ", str( result.pixel_count( 0 , 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); CompareMsr result = Processing.CompareImage( polystyrene, polystyrene, CompareImage.ComparisonCriterion.NOT_EQUAL_TO ); Console.WriteLine( "pixelCount: " + result.pixelCount( 0 , 0 ) );