uclouvain / openjpeg

Official repository of the OpenJPEG project
Other
955 stars 455 forks source link

Lossless compression on PNG #1056

Open proyb6 opened 6 years ago

proyb6 commented 6 years ago

After compression from PNG to JP2, does it produce 100% exact details as PNG? From what I have tried to compare lossless JP2 produces more artificial (Affinity Photo with Contrast Negate filter - see those orange) while Lossless JPEG produces less artificial.

boxerab commented 6 years ago

It should be 100% identical. Can you post a link to a PNG image whose JP2 compressed version doesn't match ? Keep in mind that if there is an ICC profile in the PNG, then it will not be stored in the JP2 file, so this might explain visual differences.

proyb6 commented 6 years ago

My test isn't standard and may be flaw, how do you compare both images in your process?

boxerab commented 6 years ago

I use Graphics Magick:

http://www.graphicsmagick.org/

gm compare FOO.png BAR.png -metric PSNR

You should get 1.#J for all values of PSNR if the files are truly equal.

proyb6 commented 6 years ago

Do you mean .png and j2k? gm compare FOO.png BAR.j2k -metric PSNR

comstock commented 6 years ago

If you apply the same ICC profile found in your source image to your output JP2 and overlay them in Photoshop or, I assume, GIMP, the pixel values should be identical, provided you used losselss JP2 compression.

Here is blog post on how to compare images: http://bit.ly/2EPOroZ

boxerab commented 6 years ago

@proyb6 graphics magick doesn't have the best support for jpeg 2000, as it uses the obsolete Jasper library. The best approach in my experience is to do a round-trip encode/decode: take a PNG, encode to J2K, then decode yourself back to PNG or TIF, and compare with original using Graphics Magick.

Why don't you link to the PNG file ? That would be the easiest way of sorting this out.

proyb6 commented 6 years ago

@boxerab I have deleted my test sometime ago and will retest tomorrow since it's quite last in Asia. Will take note of your advice. Thanks!