4

I'm using scikit-image SSIM to compare the similarity between two images. The thing is that I get negative values, which are not favorable for my purpose. I understand that the range of SSIM values are supposed to be between -1 to 1, but I need to get a positive value only, and I want this value to reduce as the similarity increases between the two images. I've been thinking of two ways to handle this issue. First, subtracting SSIM value from 1:

Similarity Measure=(1-SSIM)

Now, it gives zero in the case of perfect match (SSIM=1) and 1 when there is no similarity (SSIM=0). But, since SSIM also results into negative values between -1 and 0, I also get values larger than 1, which I don't know how to interpret. In particular, I don't know when SSIM returns negative values, what does it mean. Are the images with SSIM values between -1 and 0 less similar than images with SSIM of 0? Because, if this is not the case then my similarity measure will cause problem (it results into values more than 1 when SSIM is negative, which means less similarity compared to the case of SSIM=0). Another measure that I was thinking to use is structural dissimilarity (DSSIM), which is defined as follows:

DSSIM=(1-SSIM)/2

This will return 0 when the two images are exactly the same, which is what I'm looking for, but DSSIM=1 when SSIM=-1 which corresponds with no similarity at all, and returns 1/2, when SSIM=0. Again, this can only be useful when SSIM of negative values shows less similarity than SSIM=0, which as I mentioned is something that I don't know about and couldn't find anything that explains about the corresponds of each value of SSIM in terms of the level of similarity between the two images. I hope someone could help me with such interpretation or some way to get only values of 0 and 1 for SSIM.

Edit: As I mentioned in the comments SSIM can be negative, and it is caused by the covarience of the two images that can be negative. In the Skimage SSIM source code, Covarience of the two images is represented by vxy, and it can be negative in some cases. As for the interpretation of negative values of SSIM in terms of similarity, I'm not still sure, but this paper states that this happens when local image structure is inverted. Still, I saw this for images that do not look like having inverted structure of each other. But, I guess local is important here, meaning that two images might not look like as inverted version of each other but their structure is inverted locally. Is this a right interpretation?

Miranda
  • 565
  • 1
  • 10
  • 27
  • How about (1 + SSIM) / 2 ? – Stefan van der Walt Jan 30 '17 at 21:00
  • This will return 1 when SSIM=1, and 0, when SSIM=-1. But, I'm looking for something that reduces as similarity increase. This gives the opposite. – Miranda Jan 30 '17 at 21:06
  • Another issue, if I use this, it means images with negative SSIM are less similar than images with SSIM=0. Is that true in reality? Again, what is the interpretation of negative values of SSIM? – Miranda Jan 30 '17 at 21:08
  • 1
    If you want it the other way around: 1 - (1 + SSIM) / 2 – Stefan van der Walt Jan 31 '17 at 01:15
  • Yes, which is equal to (1-SSIM)/2 which is DSSIM that I already mentioned in my question. But, if you refer to my explanation, it returns 1/2 for SSIM=0 and 1 for SSIM=-1, but is similarity of two images with SSIM=-1 less than similarity of two images with SSIM=0? As, I mentioned, I need an interpretation of the meaning of negative values of SSIM, which I couldn't find anywhere. – Miranda Jan 31 '17 at 01:56
  • Can you provide an example of images for which you get a -1 SSIM? – Stefan van der Walt Jan 31 '17 at 06:33
  • Unfortunately, I cannot share any images due to copy right. But, I figured out what causes SSIM to be negative by going through the source code. Actually, covariance of the two images can be negative, which is represented by vxy in the SSIM source code. This results into negative values for SSIM. – Miranda Jan 31 '17 at 21:43
  • As for the interpretation of negative values of SSIM, I will be adding a link to a paper that briefly states that SSIM can be actually negative, when the local image structure is inverted. Although, I get negative values for images that do not necessarily look like a inverted version of each other. – Miranda Jan 31 '17 at 21:49

1 Answers1

3

Yes, the similarity of two images with SSIM = 0 is better than SSIM = -1, so you can use:

1 - (1 + SSIM ) / 2 
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83