What is the possible output range of "ssim"?

6 visualizaciones (últimos 30 días)
I sometimes get a negative output result from "ssim". What is the exact range of "ssim"?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 18 de Abr. de 2023
The SSIM algorithm is a similar task to calculating the correlation coefficient for two images. As you can see in Wikipedia, the value of SSIM is from -1 to 1. In other words, if the value of SSIM is -1, it means that it is the result of comparing the two anti-correlated images.
Please run the script below to see if SSIM is -1. You will get -0.9767 as the result.
 
rng(1)
A = randi(256, [1000, 1000])-1; % namely, image A
B = 255 - A; % namely, image B
ssimval = ssim(A, B)
What the script does is to compare two inverted uniformly distributed random images with SSIM. SSIM is divided into two parts that use pixel means and parts that use pixel variance, as shown in the equation below, which is available in Wikipedia.
https://en.wikipedia.org/wiki/Structural_similarity
For the part using the pixel mean, the expected value of the pixel mean in images A and B is 255/2, so the result value of the part using the pixel mean should theoretically be 1.
In the part that uses pixel variance, images A and B both use plots from the uniform distribution, so the expected values of the variance in the two plots are the same. Also, since images A and B are completely inverted, covariance has negative value whose absolute value is same as the variances of the figures. Therefore, the result values of all parts using pixel variance should be -1.
Multiplying by two results in an SSIM value of -1.
This process is about SSIM having a value of -1, and if you put two identical images, like "ssim(A, A)", the SSIM result will be 1.

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by