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 $I_1$ and $I_2$.
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 $\sigma$ on an original image:
(a) the reference image to compare, (b) $\sigma$=25, MSE = 513, NCC = 0.95 , (c) $\sigma$=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 );
This function returns outputMeasurement.
// Function prototype.
similarity_metric_value(input_image1: idt.ImageType,
                        input_image2: idt.ImageType,
                        metric_type: SimilarityMetricValue.MetricType = SimilarityMetricValue.MetricType.MEAN_SQUARE_ERROR,
                        output_measurement: Union[Any, None] = None) -> SimilarityMetricValueMsr
This function returns outputMeasurement.
// Function prototype.
public static SimilarityMetricValueMsr
SimilarityMetricValue( IOLink.ImageView inputImage1,
                       IOLink.ImageView inputImage2,
                       SimilarityMetricValue.MetricType metricType = ImageDev.SimilarityMetricValue.MetricType.MEAN_SQUARE_ERROR,
                       SimilarityMetricValueMsr outputMeasurement = null );

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
Parameter Name Description Type Supported Values Default Value
input
input_image1
The first input image to compare. image Binary, Label or Grayscale None
input
input_image2
The second input image to compare. Its dimensions and type must be the same as the first input. image Binary, Label, Grayscale or Multispectral None
input
metric_type
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
output_measurement
The output measurement result containing the similarity value in accordance with the selected metric. SimilarityMetricValueMsr None
Parameter Name Description Type Supported Values Default Value
input
inputImage1
The first input image to compare. Image Binary, Label or Grayscale null
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 null
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 null

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 ) ;
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))
foam_gaussian_noise = imagedev.read_vip_image(imagedev_data.get_image_path("foam_gaussian_noise.vip"))

similarity_metric_value_algo = imagedev.SimilarityMetricValue()
similarity_metric_value_algo.input_image1 = foam
similarity_metric_value_algo.input_image2 = foam_gaussian_noise
similarity_metric_value_algo.metric_type = imagedev.SimilarityMetricValue.MEAN_SQUARE_ERROR
similarity_metric_value_algo.execute()

print("metric: ", str(similarity_metric_value_algo.output_measurement.metric(0)))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );
ImageView foam_gaussian_noise = Data.ReadVipImage( @"Data/images/foam_gaussian_noise.vip" );

SimilarityMetricValue similarityMetricValueAlgo = new SimilarityMetricValue
{
    inputImage1 = foam,
    inputImage2 = foam_gaussian_noise,
    metricType = SimilarityMetricValue.MetricType.MEAN_SQUARE_ERROR
};
similarityMetricValueAlgo.Execute();

Console.WriteLine( "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 ) ;
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))
foam_gaussian_noise = imagedev.read_vip_image(imagedev_data.get_image_path("foam_gaussian_noise.vip"))

result = imagedev.similarity_metric_value(foam, foam_gaussian_noise, imagedev.SimilarityMetricValue.MEAN_SQUARE_ERROR)

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

SimilarityMetricValueMsr result = Processing.SimilarityMetricValue( foam, foam_gaussian_noise, SimilarityMetricValue.MetricType.MEAN_SQUARE_ERROR );

Console.WriteLine(  "metric: " + result.metric( 0 )  );