Processing math: 100%
ImageDev

SimilarityMetricValue

Computes a similarity criterion between two images and outputs the corresponding metric value.

Access to parameter description

This algorithm computes a similarity between two images I1 and I2.
The proposed comparison metrics are:
Where N is the total pixel number of each image.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 1. Comparison of similarity metrics after adding an artificial gaussian noise of standard deviation σ on an original image:
(a) the reference image to compare, (b) σ=25, MSE = 513, NCC = 0.95 , (c) σ=80, MSE = 3235, NCC = 0.74

Note : Both input images must have same size and type.

See also

Function Syntax

This function returns outputMeasurement.
// Function prototype
SimilarityMetricValueMsr::Ptr similarityMetricValue( std::shared_ptr< iolink::ImageView > inputImage1, std::shared_ptr< iolink::ImageView > inputImage2, SimilarityMetricValue::MetricType metricType, SimilarityMetricValueMsr::Ptr outputMeasurement = nullptr );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage1
The first input image to compare. Image Binary, Label or Grayscale nullptr
input
inputImage2
The second input image to compare. Its dimensions and type must be the same as the first input. Image Binary, Label, Grayscale or Multispectral nullptr
input
metricType
The metric used to compare both input images
MEAN_SQUARE_ERROR The computed metric is the mean-squared error.This metric is greater than or equal to 0. A value close to 0 means that both input images are similar. A high value that the image are significantly different.
CORRELATION The computed metric is the correlation between both images, normalized in mean and variance.This metric is between 0 and 1. A high value means that both input images are similar. A value close to 0 means that the images are significantly different.
Enumeration MEAN_SQUARE_ERROR
output
outputMeasurement
The output measurement result containing the similarity value in accordance with the selected metric. SimilarityMetricValueMsr nullptr

Object Examples

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

SimilarityMetricValue similarityMetricValueAlgo;
similarityMetricValueAlgo.setInputImage1( foam );
similarityMetricValueAlgo.setInputImage2( foam_gaussian_noise );
similarityMetricValueAlgo.setMetricType( SimilarityMetricValue::MetricType::MEAN_SQUARE_ERROR );
similarityMetricValueAlgo.execute();

std::cout << "metric: " << similarityMetricValueAlgo.outputMeasurement()->metric( 0 ) ;

Function Examples

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

auto result = similarityMetricValue( foam, foam_gaussian_noise, SimilarityMetricValue::MetricType::MEAN_SQUARE_ERROR );

std::cout << "metric: " << result->metric( 0 ) ;