google / butteraugli

butteraugli estimates the psychovisual difference between two images
Apache License 2.0
1.96k stars 137 forks source link

No error when comparing images with transparent areas #14

Open khavishbhundoo opened 7 years ago

khavishbhundoo commented 7 years ago

When you compare images of different formats , the output is a value.I think an error should be displayed in such a situation.

robryk commented 7 years ago

Can you explain what do you mean by a format?

khavishbhundoo commented 7 years ago

@robryk i mean different image types.For example if you compare a JPG with a PNG there is no error.

robryk commented 7 years ago

Why do believe there should be? Image format is just a way of storing an image, similarly a filesystem is just a way of storing files. Would you expect an error if I wanted to compare two JPEGs that reside on different filesystems?

khavishbhundoo commented 7 years ago

Would you expect an error if I wanted to compare two JPEGs that reside on different filesystems?

Certainly not

My logic is that PNG supports transparency unlike JPG.It seems like an unfair comparison to me.For e.g take a PNG image that isn't transparent , convert it to jpg.Then when you compare the original PNG with the JPG.

I certainly didn't look at it with the file systems perspective thought

robryk commented 7 years ago

Ah, I see. So as far as I understand, the issue is that if the PNG uses transparency, the results might be different than expected, whatever we choose them to be. Please correct me if I misunderstood.

Still, there's lots of cases when one has a PNG without transparency and wishes to compare it with a JPEG. I'd very much like to preserve this possibility.

Right now, whenever we (both in Butteraugli and Guetzli) read a PNG with alpha channel, we overlay it on black. What would your alternate proposal be? Report an error if there's an alpha channel and it's not all-opaque?

khavishbhundoo commented 7 years ago

Still, there's lots of cases when one has a PNG without transparency and wishes to compare it with a JPEG.

Can you enlighten me on this by giving some example use case.

Right now, whenever we (both in Butteraugli and Guetzli) read a PNG with alpha channel, we overlay it on black. What would your alternate proposal be? Report an error if there's an alpha channel and it's not all-opaque?

Exactly ....report an error if alpha channel exist and image isn't opaque.A flag say --ignore-transparency-warning for those who wants to overlay it on black

robryk commented 7 years ago

Can you enlighten me on this by giving some example use case.

I have a PNG (it's a PNG because I want a lossless format). I encode it as a JPEG using some tool. I then want to see how well does the tool do on this image (and maybe, I intend to adjust the quality level to achieve some Butteraugli score at lowest possible cost).

Exactly ....report an error if alpha channel exist and image isn't opaque.

One nit: an image might have an all-opaque alpha channel. We should treat it the same as a similar image with no alpha channel.

I am fine with such a change (even without the flag; adding flag handling here is likely going to be very annoying). I won't have time to do that in the near future, but would welcome PRs.

khavishbhundoo commented 7 years ago

I have a PNG (it's a PNG because I want a lossless format). I encode it as a JPEG using some tool. I then want to see how well does the tool do on this image (and maybe, I intend to adjust the quality level to achieve some Butteraugli score at lowest possible cost).

Its an interesting use case and it give me an idea.We could have a function say QualityForButteraugliScore in butteraugli that get called when user uses a flag say --target-score=X where X is a butteraugli score and output the quality setting.Then the user just need to use that quality in a tool of their choice.

One nit: an image might have an all-opaque alpha channel. We should treat it the same as a similar image with no alpha channel.

Yup

I am fine with such a change (even without the flag; adding flag handling here is likely going to be very annoying). I won't have time to do that in the near future, but would welcome PRs.

Very annoying in terms of time usage or because the tool is quite popular and would annoy people