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

Always get a 1.0 value #3

Closed
jossi opened this issue Oct 11, 2013 · 12 comments
Closed

Always get a 1.0 value #3

jossi opened this issue Oct 11, 2013 · 12 comments

Comments

@jossi
Copy link

jossi commented Oct 11, 2013

No matter what two images I use the SSIM returned is always 1.0

@jterrace
Copy link
Owner

Have you tried it with the test images?

@jterrace
Copy link
Owner

Working for me:

$ pyssim test-images/test1-1.png test-images/test1-1.png 
1.0

$ pyssim test-images/test1-1.png test-images/test1-2.png 
0.998107055283

$ pyssim test-images/test1-1.png test-images/test2-1.png 
0.673010007986

$ pyssim test-images/test1-1.png test-images/test2-2.png 
0.648811237728

@jossi
Copy link
Author

jossi commented Oct 11, 2013

I am using 32-bit PNGs so maybe that is the problem? I will try with the test images

@jossi
Copy link
Author

jossi commented Oct 11, 2013

bash-3.2$ pyssim test1-1.png test1-2.png
0.998107055283

that works. But not my images.

@jterrace
Copy link
Owner

Could you post your images?

@jossi
Copy link
Author

jossi commented Oct 11, 2013

car_imagewarp
car_source

Note that the images are visually identical, but not bit-by-bit identical. Using a similarity index ImageMagik script I get an index of 0.99884

http://www.fmwconcepts.com/imagemagick/similar/index.php

@jterrace
Copy link
Owner

I see what's happening. Your images are RGBA and the alpha channel is all 255 values and all transparent pixels are ignored.

@jossi
Copy link
Author

jossi commented Oct 11, 2013

Thanks for the prompt response.
What to do then? Convert the PNGs to another format?

@jossi
Copy link
Author

jossi commented Oct 11, 2013

Converting the PNGs from 32-bit to 24-bit resolves it.

$ pyssim Car_source.png Car_ImageWarp.png
0.996363163123

Thank you!

@jterrace
Copy link
Owner

I just looked up the PNG spec though and it says this:

An alpha value of zero represents full transparency, and a value of (2^bitdepth)-1 represents a fully opaque pixel.

So I'm thinking that we're using the wrong value for transparency. We should treat 0 as transparent and 255 as opaque.

@jossi
Copy link
Author

jossi commented Oct 11, 2013

Indeed...

Sent from my iPad

On Oct 10, 2013, at 8:22 PM, Jeff Terrace [email protected] wrote:

So I'm thinking that we're using the wrong value for transparency. We should treat 0 as transparent and 255 as opaque.

@jterrace
Copy link
Owner

Closing this and opened #5 instead

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

2 participants