ImageDev

SsimValue3d

Computes the mean structural similarity (SSIM) index between two three-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(I_{1},I_{2}) = \frac{\left ( 2\mu_{1} \mu_{2} +C_{1}\right )\left ( 2\sigma_{12}+C_{2}\right )}{\left ( \mu_{1}^{2}+ \mu_{2}^{2} +C_{1}\right )\left ( \sigma_{1}^{2}+\sigma_{2}^{2}+C_{2}\right )}$$
Where: 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 ssimValue3d( std::shared_ptr< iolink::ImageView > inputImage1, std::shared_ptr< iolink::ImageView > inputImage2, iolink::Vector3u32 tileSize, SsimValue3d::RangeMode rangeMode, double range, double k1, double k2, SsimValueMsr::Ptr outputMeasurement = nullptr );
This function returns outputMeasurement.
// Function prototype.
ssim_value_3d(input_image1: idt.ImageType,
              input_image2: idt.ImageType,
              tile_size: Iterable[int] = [8, 8, 8],
              range_mode: SsimValue3d.RangeMode = SsimValue3d.RangeMode.DATA_TYPE_RANGE,
              range: float = 255,
              k1: float = 0.01,
              k2: float = 0.03,
              output_measurement: Union[Any, None] = None) -> SsimValueMsr
This function returns outputMeasurement.
// Function prototype.
public static SsimValueMsr
SsimValue3d( IOLink.ImageView inputImage1,
             IOLink.ImageView inputImage2,
             uint[] tileSize = null,
             SsimValue3d.RangeMode rangeMode = ImageDev.SsimValue3d.RangeMode.DATA_TYPE_RANGE,
             double range = 255,
             double k1 = 0.01,
             double k2 = 0.03,
             SsimValueMsr outputMeasurement = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage1
The first input image to compare. Image Grayscale nullptr
input
inputImage2
The second input image to compare. Image Binary, Label, Grayscale or Multispectral nullptr
input
tileSize
The X, Y and Z sizes, in pixels, of the tile used to compute the SSIM for each pixel. Vector3u32 >=1 {8, 8, 8}
input
rangeMode
The way to consider the dynamic range used to compute the regularization constants C1 and C2 of the similarity formula.
DATA_TYPE_RANGE The data range is determined by the theoretical maximum and minimum values of the data type.
OTHER The data range is user-defined by the range parameter.
Enumeration DATA_TYPE_RANGE
input
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
input
k1
The small weight used to compute the regularization constant C1 of the similarity formula. Float64 >0 0.01
input
k2
The small weight used to compute the regularization constant C2 of the similarity formula. Float64 >0 0.03
output
outputMeasurement
The output measurement results containing the SSIM value. SsimValueMsr nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image1
The first input image to compare. image Grayscale None
input
input_image2
The second input image to compare. image Binary, Label, Grayscale or Multispectral None
input
tile_size
The X, Y and Z sizes, in pixels, of the tile used to compute the SSIM for each pixel. vector3u32 >=1 [8, 8, 8]
input
range_mode
The way to consider the dynamic range used to compute the regularization constants C1 and C2 of the similarity formula.
DATA_TYPE_RANGE The data range is determined by the theoretical maximum and minimum values of the data type.
OTHER The data range is user-defined by the range parameter.
enumeration DATA_TYPE_RANGE
input
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
input
k1
The small weight used to compute the regularization constant C1 of the similarity formula. float64 >0 0.01
input
k2
The small weight used to compute the regularization constant C2 of the similarity formula. float64 >0 0.03
output
output_measurement
The output measurement results containing the SSIM value. SsimValueMsr None
Parameter Name Description Type Supported Values Default Value
input
inputImage1
The first input image to compare. Image Grayscale null
input
inputImage2
The second input image to compare. Image Binary, Label, Grayscale or Multispectral null
input
tileSize
The X, Y and Z sizes, in pixels, of the tile used to compute the SSIM for each pixel. Vector3u32 >=1 {8, 8, 8}
input
rangeMode
The way to consider the dynamic range used to compute the regularization constants C1 and C2 of the similarity formula.
DATA_TYPE_RANGE The data range is determined by the theoretical maximum and minimum values of the data type.
OTHER The data range is user-defined by the range parameter.
Enumeration DATA_TYPE_RANGE
input
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
input
k1
The small weight used to compute the regularization constant C1 of the similarity formula. Float64 >0 0.01
input
k2
The small weight used to compute the regularization constant C2 of the similarity formula. Float64 >0 0.03
output
outputMeasurement
The output measurement results containing the SSIM value. SsimValueMsr 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" );

SsimValue3d ssimValue3dAlgo;
ssimValue3dAlgo.setInputImage1( foam );
ssimValue3dAlgo.setInputImage2( foam_gaussian_noise );
ssimValue3dAlgo.setTileSize( {6, 6, 6} );
ssimValue3dAlgo.setRangeMode( SsimValue3d::RangeMode::DATA_TYPE_RANGE );
ssimValue3dAlgo.setRange( 255 );
ssimValue3dAlgo.setK1( 0.01 );
ssimValue3dAlgo.setK2( 0.03 );
ssimValue3dAlgo.execute();

std::cout << "ssim: " << ssimValue3dAlgo.outputMeasurement()->ssim( 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"))

ssim_value_3d_algo = imagedev.SsimValue3d()
ssim_value_3d_algo.input_image1 = foam
ssim_value_3d_algo.input_image2 = foam_gaussian_noise
ssim_value_3d_algo.tile_size = [6, 6, 6]
ssim_value_3d_algo.range_mode = imagedev.SsimValue3d.DATA_TYPE_RANGE
ssim_value_3d_algo.range = 255
ssim_value_3d_algo.k1 = 0.01
ssim_value_3d_algo.k2 = 0.03
ssim_value_3d_algo.execute()

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

SsimValue3d ssimValue3dAlgo = new SsimValue3d
{
    inputImage1 = foam,
    inputImage2 = foam_gaussian_noise,
    tileSize = new uint[]{6, 6, 6},
    rangeMode = SsimValue3d.RangeMode.DATA_TYPE_RANGE,
    range = 255,
    k1 = 0.01,
    k2 = 0.03
};
ssimValue3dAlgo.Execute();

Console.WriteLine( "ssim: " + ssimValue3dAlgo.outputMeasurement.ssim( 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 = ssimValue3d( foam, foam_gaussian_noise, {6, 6, 6}, SsimValue3d::RangeMode::DATA_TYPE_RANGE, 255, 0.01, 0.03 );

std::cout << "ssim: " << result->ssim( 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.ssim_value_3d(foam, foam_gaussian_noise, [6, 6, 6], imagedev.SsimValue3d.DATA_TYPE_RANGE, 255, 0.01, 0.03)

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

SsimValueMsr result = Processing.SsimValue3d( foam, foam_gaussian_noise, new uint[]{6, 6, 6}, SsimValue3d.RangeMode.DATA_TYPE_RANGE, 255, 0.01, 0.03 );

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