Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got SSIM = 1 for two quite different images #23

Open
ghost opened this issue Sep 9, 2016 · 3 comments
Open

I got SSIM = 1 for two quite different images #23

ghost opened this issue Sep 9, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 9, 2016

Hi

I have been using the library for SSIM in C# http://www.lomont.org/Software/Misc/SSIM/SSIM.html. Now I want to use this more advanced library that handles both SSIM and CW-SSIM. I have a windows 10 machine with python 2.7, with numpy and scipy. However, by doing some regression, I notice quite a critical difference. For two images that I have been using in my research (solar sunspot two dimensional neural network forecasting), the c# code gives me 0.683600449, while the python one give me 1. Clearly the pictures are different, so it should give SSIM<1.

pyssim magnetic_butterfly_forecast.png magnetic_butterfly_original.png
1

I also tested with option --cw and that seems to work and gives me

pyssim magnetic_butterfly_forecast.png magnetic_butterfly_original.png --cw
0.8519043

I am using:

Windows 10
numpy (1.11.1+mkl)
Pillow (3.3.1)
pip (8.1.1)
pyssim (0.3)
scipy (0.18.0)
setuptools (20.10.1)

I have attached the two images to allow you guys to debug.

Any idea what I am doing wrong or is there any issue?

Thanks

Eurico Covas
magnetic_butterfly_forecast
magnetic_butterfly_original

@ghost
Copy link
Author

ghost commented Sep 9, 2016

Hi

One more thing, my images are 24BPP, does that matter? If reduce to 8 bits and it now works...

Eurico

@ghost
Copy link
Author

ghost commented Sep 14, 2016

Hi @euricocovas ,

I commented out these two lines from ssim/ssimlib.py:

self.img_gray, self.img_alpha = to_grayscale(self.img)
# if self.img_alpha is not None:
#     self.img_gray[self.img_alpha == 255] = 0

Now it outputs 0.8907.

If you construct SSIMImage object with these two lines, the image arrays in grayscale based on the images you supplied are 0s everywhere. Not sure about the reasons yet.

@jterrace
Copy link
Owner

Thanks for the report. Sorry I haven't had a chance to take a look yet. Thanks for looking @jz0627

Can you try running self.img_gray.show() and self.img_alpha.show() after the call to to_grayscale? Is the alpha channel looking correct?

I'm guessing this is a dupe of #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant