SSIM

SSIM (Structural Similarity Index Measurement) is a full reference image quality assessment objective quality metric. It has been most popular and highly cited paper in last 10 Years of IEEE Trans.IP.

It is defined as product of Luminance,Contrast and structural similarity.
It also indicates the localized perceptual distortion and as well as overall score of a test image with respective to its pristine image.

Let assume $x$ and $y$ are two images having same resolution.
\begin{equation}
 SSIM(x,y) = L(x,y) \times C(x,y) \times S(x,y)
\end{equation}

$L(x,y), C(x,y)$ and $S(x,y)$ are Luminance,Contrast and structural similarity respectively,
\begin{equation}
L(x,y)=\frac{2\mu_x\mu_y + c_1}{\mu^2_x + \mu^2_y + c_1} \\
C(x,y)=\frac{2\sigma_x\sigma_y + c_2}{\sigma^2_x + \sigma^2_y + c_2}\\
S(x,y)=\frac{\sigma_{xy} + c_3}{\sigma_x \sigma_y + c_3}
\end{equation}

where $c_1,c_2$ and $c_3$ are small constants to avoid $\frac{0}{0}$ problem.

$SSIM(x,y) = \left[ l(x,y)^\alpha \cdot c(x,y)^\beta \cdot s(x,y)^\gamma \right]$
Setting the weights $\alpha,\beta,\gamma$to 1, the formula can be reduced to the form shown at the top of this section.


Images x = pristine image and y = distorted image
Matlab code:

[Score,Dist_map] =  ssim(x,y);

Score is in the range of 0 to 1
Dist_map gives the distortion map of image.