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:
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
Access to parameter description
This algorithm computes a similarity between two images $I_1$ and $I_2$.
The proposed comparison metrics are:
- The Mean Square Error:
$$ MSE = \frac{1}{N}\sum_{i=1}^{N}(I_1(i)-I_2(i))^2 $$ - The normalized crossed correlation:
$$ NCC=\frac{\sum_{i=1}^{N}(I_1(i)-\overline{I_1})\ast (I_2(i)-\overline{I_2})}{ \sqrt{\sum_{i=1}^{N}(I_1(i)-\overline{I_1})^2}\ast\sqrt{\sum_{i=1}^{N}(I_2(i)-\overline{I_2})^2}} $$
(a) |
(b) |
(c) |
(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 | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage1 |
The first input image to compare. | Image | Binary, Label or Grayscale | nullptr | |||||
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 | |||||
metricType |
The metric used to compare both input images
|
Enumeration | MEAN_SQUARE_ERROR | ||||||
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_image1 |
The first input image to compare. | image | Binary, Label or Grayscale | None | |||||
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 | |||||
metric_type |
The metric used to compare both input images
|
enumeration | MEAN_SQUARE_ERROR | ||||||
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 | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage1 |
The first input image to compare. | Image | Binary, Label or Grayscale | null | |||||
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 | |||||
metricType |
The metric used to compare both input images
|
Enumeration | MEAN_SQUARE_ERROR | ||||||
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 ) );