SsimValue2d
Computes the mean structural similarity (SSIM) index between two two-dimensional images.
Access to parameter description
This algorithm provides a measure of similarity by computing the SSIM value for each pixel of the couple of image and by returning the mean of all these values.
For each pixel, we compute the SSIM value by using the following formula :
SSIM(I1,I2)=(2μ1μ2+C1)(2σ12+C2)(μ21+μ22+C1)(σ21+σ22+C2)
Where:
Figure 1. Comparison of the SSIM values after adding an artificial gaussian noise of standard
deviation σ on an original image:
(a) the reference image to compare, (b) σ=25, SSIM = 0.05 , (c) σ=80, SSIM = 0.01
Reference:
Z. Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli. "Image quality assessment: From error visibility to structural similarity". IEEE Transactions on Image Processing , vol. 13, pp. 600-612, Apr. 2004.
See also
Access to parameter description
This algorithm provides a measure of similarity by computing the SSIM value for each pixel of the couple of image and by returning the mean of all these values.
For each pixel, we compute the SSIM value by using the following formula :
SSIM(I1,I2)=(2μ1μ2+C1)(2σ12+C2)(μ21+μ22+C1)(σ21+σ22+C2)
Where:
- μ1 is the mean in the tile arround the current pixel in the image I1,
- μ2 is the mean in the tile arround the current pixel in the image I2,
- σ1 is the standard deviation in the tile arround the current pixel in the image I1,
- σ2 is the standard deviation in the tile arround the current pixel in the image I2,
- σ12 is the covariance in the tile arround the current pixel in each image I1 and I2
- C1 is a constant computed with the choosen range R and the parameter k1 as follow : C1=(k1R)2
- C2 is a constant computed with the choosen range R and the parameter k2 as follow : C2=(k2R)2
![]() (a) |
![]() (b) |
![]() (c) |
(a) the reference image to compare, (b) σ=25, SSIM = 0.05 , (c) σ=80, SSIM = 0.01
Reference:
Z. Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli. "Image quality assessment: From error visibility to structural similarity". IEEE Transactions on Image Processing , vol. 13, pp. 600-612, Apr. 2004.
See also
Function Syntax
This function returns outputMeasurement.
// Function prototype
SsimValueMsr::Ptr ssimValue2d( std::shared_ptr< iolink::ImageView > inputImage1, std::shared_ptr< iolink::ImageView > inputImage2, iolink::Vector2u32 tileSize, SsimValue2d::RangeMode rangeMode, double range, double k1, double k2, SsimValueMsr::Ptr outputMeasurement = nullptr );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage1 |
The first input image to compare. | Image | Grayscale | nullptr | ||||
![]() |
inputImage2 |
The second input image to compare. | Image | Binary, Label, Grayscale or Multispectral | nullptr | ||||
![]() |
tileSize |
The X and Y sizes, in pixels, of the tile used to compute the SSIM for each pixel | Vector2u32 | >=1 | {8, 8} | ||||
![]() |
rangeMode |
The way to consider the dynamic range used to compute the regularization constants C1 and C2 of the similarity formula.
|
Enumeration | DATA_TYPE_RANGE | |||||
![]() |
range |
The data range used to compute the constants C1 and C2 of the similarity formula. It corresponds to the distance between the maximum and minimum of the representative image intensities. It is used only if rangeMode parameter is set to OTHER value. | Float64 | >0 | 255 | ||||
![]() |
k1 |
The small weight used to compute the regularization constant C1 of the similarity formula. | Float64 | >0 | 0.01 | ||||
![]() |
k2 |
The small weight used to compute the regularization constant C2 of the similarity formula. | Float64 | >0 | 0.03 | ||||
![]() |
outputMeasurement |
The output measurement results containing the SSIM value. | SsimValueMsr | nullptr |
Object Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto polystyrene_gaussian_noise = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_gaussian_noise.vip" ); SsimValue2d ssimValue2dAlgo; ssimValue2dAlgo.setInputImage1( polystyrene ); ssimValue2dAlgo.setInputImage2( polystyrene_gaussian_noise ); ssimValue2dAlgo.setTileSize( {8, 8} ); ssimValue2dAlgo.setRangeMode( SsimValue2d::RangeMode::DATA_TYPE_RANGE ); ssimValue2dAlgo.setRange( 255 ); ssimValue2dAlgo.setK1( 0.01 ); ssimValue2dAlgo.setK2( 0.03 ); ssimValue2dAlgo.execute(); std::cout << "ssim: " << ssimValue2dAlgo.outputMeasurement()->ssim( 0 ) ;
Function Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto polystyrene_gaussian_noise = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_gaussian_noise.vip" ); auto result = ssimValue2d( polystyrene, polystyrene_gaussian_noise, {8, 8}, SsimValue2d::RangeMode::DATA_TYPE_RANGE, 255, 0.01, 0.03 ); std::cout << "ssim: " << result->ssim( 0 ) ;