jterrace / pyssim

A Python module for computing the Structural Similarity Image Metric (SSIM)
MIT License
339 stars 62 forks source link

ssim value > 1? #9

Closed ilteroi closed 8 years ago

ilteroi commented 9 years ago

I have several pairs of images here which return a ssim value > 1, mostly only very slightly above 1, but still. in one instance, the value is 11.8 (for reference, the PSNR is 45). i'm using parameters sigma=0.5 and kernel size = 5.

i don't think that's supposed to happen!

can provide images on request ...

jterrace commented 9 years ago

Sample images would be really helpful.

ilteroi commented 9 years ago

hello again and thanks for the quick reply.

i'm getting the following values for the attached images:

NAME PSNR SSIM waterski 40.076 1.009 navigation 45.004 11.801

navigation_a navigation_b waterski_a waterski_b

w-m commented 9 years ago

Tried to reproduce this (Mac OS X 10.7, python 2.7 or 3.4, pyssim 0.2):

wget --no-check-certificate https://cloud.githubusercontent.com/assets/1358966/3987503/98b28d90-28a6-11e4-8b5e-3710e94769c3.png -O navigation_1.png
wget --no-check-certificate https://cloud.githubusercontent.com/assets/1358966/3987506/98b967a0-28a6-11e4-97ac-c9e3d49f3cf7.png -O navigation_2.png
wget --no-check-certificate https://cloud.githubusercontent.com/assets/1358966/3987505/98b6a556-28a6-11e4-897d-e0d10d501bf0.png -O waterski_1.png
wget --no-check-certificate https://cloud.githubusercontent.com/assets/1358966/3987504/98b42b64-28a6-11e4-80d0-16fb3494becd.png -O waterski_2.png
pyssim navigation_1.png navigation_2.png
pyssim waterski_1.png waterski_2.png

The SSIM results are 0.994545 and 0.990383.

Can you give more details as to how you are computing the erroneous values?

jterrace commented 9 years ago

Same here from master branch:

$ PYTHONPATH="." python -m ssim ~/Downloads/98b28d90-28a6-11e4-8b5e-3710e94769c3.png \
 ~/Downloads/98b967a0-28a6-11e4-97ac-c9e3d49f3cf7.png 
0.994545
$ PYTHONPATH="." python -m ssim ~/Downloads/98b6a556-28a6-11e4-897d-e0d10d501bf0.png \
 ~/Downloads/98b42b64-28a6-11e4-80d0-16fb3494becd.png 
0.990383
ilteroi commented 9 years ago

i just tested it using the following script. with sigma==0.5 i see the problem with all kernel sizes.

from ssim import compute_ssim
from itertools import product

testsets = (
    ("navigation_a.png","navigation_b.png"),
    ("waterski_a.png","waterski_b.png"),
    )

kernelsize = (3,5,7,9,11,13)
sigma = (0.5,1,1.5,2.5,3)

for t in testsets:
    for p in product(sigma,kernelsize):
        ssim = compute_ssim(t[0],t[1],p[0],p[1])
        if ssim>1:
            print( "(%.2f,%.2f) -> %.3f" % (p[0],p[1],ssim) )