Documentation

This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

ssim

Structural Similarity Index (SSIM) for measuring image quality

Syntax

``ssimval = ssim(A,ref)``
``````[ssimval,ssimmap] = ssim(A,ref)``````
``___ = ssim(A,ref,Name,Value)``

Description

````ssimval = ssim(A,ref)` computes the Structural Similarity Index (SSIM) value for image `A` using `ref` as the reference image.```

example

``````[ssimval,ssimmap] = ssim(A,ref)``` also returns the local SSIM value for each pixel in `A`. ```
````___ = ssim(A,ref,Name,Value)` computes the SSIM, using name-value pairs to control aspects of the computation.```

Examples

collapse all

Read an image into the workspace. Create another version of the image, applying a blurring filter. Display both images.

```ref = imread('pout.tif'); H = fspecial('Gaussian',[11 11],1.5); A = imfilter(ref,H,'replicate'); subplot(1,2,1); imshow(ref); title('Reference Image'); subplot(1,2,2); imshow(A); title('Blurred Image');```

Calculate the global SSIM value for the image and local SSIM values for each pixel. Return the global SSIM value and display the local SSIM value map.

```[ssimval, ssimmap] = ssim(A,ref); fprintf('The SSIM value is %0.4f.\n',ssimval);```
```The SSIM value is 0.9407. ```
``` figure, imshow(ssimmap,[]); title(sprintf('ssim Index Map - Mean ssim Value is %0.4f',ssimval));```

Input Arguments

collapse all

Image whose quality is to be measured, specified as a 2-D grayscale image or 3-D volume image. Must be the same size and class as `ref`

Data Types: `single` | `double` | `int16` | `uint8` | `uint16`

Reference image against which quality if measured, specified as a 2-D grayscale image or 3-D volume image. Must be the same size and class as `A`

Data Types: `single` | `double` | `int16` | `uint8` | `uint16`

Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `ssim(A,ref,'DynamicRange',100)`

Dynamic range of the input image, specified as a positive scalar. The default value of `DynamicRange` depends on the data type of image `A`, and is calculated as `diff(getrangefromclass(A))`. For example, the default dynamic range is `255` for images of data type `uint8`, and the default is `1` for images of data type `double` or `single` with pixel values in the range [0, 1].

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32`

Exponents for the luminance, contrast, and structural terms, specified as a 3-element vector of nonnegative real numbers, ```[alpha beta gamma]```.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32`

Standard deviation of isotropic Gaussian function, specified as a positive scalar. This value is used for weighting the neighborhood pixels around a pixel for estimating local statistics. This weighting is used to avoid blocking artifacts in estimating local statistics.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32`

Regularization constants for the luminance, contrast, and structural terms, specified as a 3-element vector of nonnegative real numbers of the form ```[c1 c2 c3]```. The `ssim` function uses these regularization constants to avoid instability for image regions where the local mean or standard deviation is close to zero. Therefore, small non-zero values should be used for these constants.

By default,

• `C1 = (0.01*L).^2`, where `L` is the specified `DynamicRange` value.

• `C2 = (0.03*L).^2`, where `L` is the specified `DynamicRange` value.

• `C3 = C2/2`

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `uint8` | `uint16` | `uint32`

Output Arguments

collapse all

Structural Similarity (SSIM) Index, returned as a scalar `double`, except when `A` and `ref` are of class `single`, in which case `ssimval` is of class `single`.

Local values of Structural Similarity (SSIM) Index, returned as a numeric array of class `double` except when `A` and `ref` are of class `single`, in which case `ssimmap` is of class `single`. `ssimmap` is an array of the same size as input image `A`.

collapse all

Structural Similarity Index

An image quality metric that assesses the visual impact of three characteristics of an image: luminance, contrast and structure.

Algorithms

The Structural Similarity (SSIM) Index quality assessment index is based on the computation of three terms, namely the luminance term, the contrast term and the structural term. The overall index is a multiplicative combination of the three terms.

`$SSIM\left(x,y\right)={\left[l\left(x,y\right)\right]}^{\alpha }\cdot {\left[c\left(x,y\right)\right]}^{\beta }\cdot {\left[s\left(x,y\right)\right]}^{\gamma }$`

where

`$\begin{array}{l}l\left(x,y\right)=\frac{2{\mu }_{x}{\mu }_{y}+{C}_{1}}{{\mu }_{x}^{2}+{\mu }_{y}^{2}+{C}_{1}},\\ c\left(x,y\right)=\frac{2{\sigma }_{x}{\sigma }_{y}+{C}_{2}}{{\sigma }_{x}^{2}+{\sigma }_{y}^{2}+{C}_{2}},\\ s\left(x,y\right)=\frac{{\sigma }_{xy}+{C}_{3}}{{\sigma }_{x}{\sigma }_{y}+{C}_{3}}\end{array}$`

where μx, μy, σxy, and σxy are the local means, standard deviations, and cross-covariance for images x, y. If α = β = γ = 1 (the default for `Exponents`), and C3 = C2/2 (default selection of C3) the index simplifies to:

`$SSIM\left(x,y\right)=\frac{\left(2{\mu }_{x}{\mu }_{y}+{C}_{1}\right)\left(2{\sigma }_{xy}+{C}_{2}\right)}{\left({\mu }_{x}^{2}+{\mu }_{y}^{2}+{C}_{1}\right)\left({\sigma }_{x}^{2}+{\sigma }_{y}^{2}+{C}_{2}\right)}$`

References

[1] Zhou, W., A. C. Bovik, H. R. Sheikh, and E. P. Simoncelli. "Image Qualifty Assessment: From Error Visibility to Structural Similarity." IEEE Transactions on Image Processing. Vol. 13, Issue 4, April 2004, pp. 600–612.