Page 1 of 1

PSNR is different for the same images, different formats

Posted: 2014-07-17T03:28:14-07:00
by ritave
OS: Windows 8 Enterprise
Magick Version: 6.8.9
Bug: When calculating PSNR between two images, the PSNR differs depending on the format of the files (but the same content).
Steps to reproduce:
Download reference images: http://www.filedropper.com/refimages

Code: Select all

UTIL_DB_compare_.exe -metric PSNR f00140_ref.png f00140_ref.bmp asd.png
1.#INF // Images reported the same

UTIL_DB_compare_.exe -metric PSNR f00140_ref.png f00140.png p.png
29.6955

UTIL_DB_compare_.exe -metric PSNRf00140_ref.bmp f00140.bmp b.png
28.4461 // But the PSNR differs

UTIL_DB_compare_.exe -metric PSNR p.png b.png total.png
1.#INF // And yet the resulting images dont

Re: PSNR is different for the same images, different formats

Posted: 2014-07-17T06:50:38-07:00
by ritave
I got some more debug info:
This is due to the 1 bit alpha channel in png files.
GetMeanSquaredDistortion@compare.c might be calculated wrongly in some way. When I commented out the calculations for alpha channel as well as harcoded

Code: Select all

distortion[CompositeChannels]/=(double) GetNumberChannels(image,channel);
to

Code: Select all

distortion[CompositeChannels]/=(double) 3;
the results are the same in both file formats

Re: PSNR is different for the same images, different formats

Posted: 2014-07-19T12:39:57-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.9-6 Beta, available by sometime tomorrow. Thanks.

Re: PSNR is different for the same images, different formats

Posted: 2014-10-01T08:37:31-07:00
by jesse1
Can you please explain what this fix means?
I compared images successfully with 6.8.9.5, but with latest version it returns error "image morphology differs". What should I do about it?

update: I updated not to latest but to 6.8.9.7 since it is last available version via brew for mac osx.
and a full error code is: compare: image morphology differs `<path to image>' @ error/compare.c/CompareImageChannels/173

Re: PSNR is different for the same images, different formats

Posted: 2014-10-02T00:28:34-07:00
by jesse1
I found it, it was because of alpha channel which was present in one image but absent in another. After adding option "-alpha Off", it started working again.