openjpeg icon indicating copy to clipboard operation
openjpeg copied to clipboard

Lossless compression on PNG

Open proyb6 opened this issue 7 years ago • 8 comments

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.

proyb6 avatar Jan 18 '18 08:01 proyb6

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.

boxerab avatar Feb 06 '18 23:02 boxerab

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

proyb6 avatar Feb 08 '18 12:02 proyb6

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.

boxerab avatar Feb 08 '18 12:02 boxerab

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

proyb6 avatar Feb 08 '18 12:02 proyb6

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

comstock avatar Feb 08 '18 13:02 comstock

@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.

boxerab avatar Feb 08 '18 15:02 boxerab

@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!

proyb6 avatar Feb 08 '18 16:02 proyb6

and overlay them in Photoshop or, I assume, GIMP

Photoshop does not even support 16 bits properly, so no. https://community.adobe.com/t5/photoshop/doesn-t-the-color-picker-work-in-16-bit-mode/td-p/10281208?page=1

ValZapod avatar Dec 21 '20 15:12 ValZapod