# ssim

Structural similarity (SSIM) index for measuring image quality

## Description

calculates the SSIM, using name-value pairs to control aspects of the
computation.`ssimval`

= ssim(`A`

,`ref`

,`Name,Value`

)

## Examples

## Input Arguments

## Output Arguments

## More About

## Tips

## Algorithms

The 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(x,y)={[l(x,y)]}^{\alpha}\cdot {[c(x,y)]}^{\beta}\cdot {[s(x,y)]}^{\gamma}$$

where

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

where μ_{x}, μ_{y},
σ_{x},σ_{y}, and σ_{xy}
are the local means, standard deviations, and cross-covariance for images *x,
y*. If α = β = γ = 1 (the default for `Exponents`

), and
C_{3} = C_{2}/2 (default selection of
C_{3}) the index simplifies to:

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

When you specify a noninteger value for `"Exponents"`

, the
`ssim`

function prevents complex valued outputs by clamping the
intermediate luminance, contrast, and structural terms to the range [0,
`inf`

].

## References

[1] Zhou, W., 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, Issue 4, April 2004, pp.
600–612.

## Extended Capabilities

## Version History

**Introduced in R2014a**

## See Also

`psnr`

| `immse`

| `multissim`

| `multissim3`

### Topics

- Compare Image Quality at Various Compression Levels
- List of Functions with dlarray Support (Deep Learning Toolbox)
- Define Custom Training Loops, Loss Functions, and Networks (Deep Learning Toolbox)