Page 1 of 1

Enabling Reversible Integer Transforms in JPEG 2K Encoder

Posted: 2013-12-31T21:41:04-07:00
by Tormaid
Since IM's JPEG 2000 encoder does not have an option to enable reversible color transforms (RCT), its lossless mode isn't truly lossless because there will be errors resulting from the RGB conversion. I went and did some reading online and none of the archiving professions invested in JPEG 2000 recommend ImageMagick for this reason (this article in particular, and this follow-up).

I would like to be able to write .jp2 sequences piped from Avisynth; ImageMagick is the only command-line imaging tool that will allow me to do this, so I'm very interested in getting higher-quality results from your encoder. Have you considered the Open JPEG libraries? Consensus seems to lean in their favor as being the highest-quality JPEG 2K encoder.

Here is an example of a "lossless" .jp2 file overlaying the original image and set to "difference" in Photoshop. I boosted the brightness to make it easier to see, though it's still quite apparent without. Photoshop's own JPEG 2000 encoder created a completely-lossless file.

Here is the command line input I used:
avs2yuv.exe -raw "LRGB_Test.avs" -o - | convert -limit memory 1GiB -limit map 2GiB -depth 16 -size 1920x1080 -set colorspace RGB -colorspace RGB -quality 100 rgb:- "JP2K_Test_%06d.jp2"

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Posted: 2013-12-31T22:15:42-07:00
by snibgo
Have you tried a more recent version of IM? With the current v6.8.8-0 on Windows 8, in my initial experiments JP2 is lossless, as measured by:

Code: Select all

convert a.tiff a.jp2
compare -metric RMSE a.tiff a.jp2 NULL:
where a.tiff is a 16-bit/channel photograph or 8-bit/channel graphic. Mind you, it only saves about 25% of the space needed for the zip-compressed tiff, and reading/writing JP2 is quite slow.

Still, I'm happy that we now have a better lossless compression for 16-bit photos.

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Posted: 2014-01-01T09:35:23-07:00
by magick
FYI, we have an OpenJPEG coder in development. It should be ready to release late this month.

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Posted: 2014-01-01T11:11:56-07:00
by Tormaid
snibgo wrote:Have you tried a more recent version of IM? With the current v6.8.8-0 on Windows 8, in my initial experiments JP2 is lossless, as measured by:

Code: Select all

convert a.tiff a.jp2
compare -metric RMSE a.tiff a.jp2 NULL:
where a.tiff is a 16-bit/channel photograph or 8-bit/channel graphic. Mind you, it only saves about 25% of the space needed for the zip-compressed tiff, and reading/writing JP2 is quite slow.

Still, I'm happy that we now have a better lossless compression for 16-bit photos.
I tried the latest version. Oddly, my test with IM's compare tool yielded the same results in both RMSE and PSNR modes. I guess there's something wrong with the way I did the test in Photoshop...
magick wrote:FYI, we have an OpenJPEG coder in development. It should be ready to release late this month.
That's great news! I was going to follow up by asking if any work and been done lately on IM's JPEG 2000 encoder. I'm looking forward to it. It also seems like the current encoder still meets my needs for the time being. Thank you both for your help.

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Posted: 2014-01-07T12:42:47-07:00
by Tormaid
Also, the fnord Jpeg2000 plugin for After Effects is able to render lossless 16-bit RGB J2K sequences at ~1.7mb per image (1920 x 1080). How on earth is it able to do this? Imagemagick's files are 7mb in lossless mode.

Edit: Never mind; I had the floating-point option enabled, which doesn't allow reversible transforms and isn't actually lossless.