Enabling Reversible Integer Transforms in JPEG 2K Encoder

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Tormaid
Posts: 3
Joined: 2013-12-31T21:18:40-07:00
Authentication code: 6789

Enabling Reversible Integer Transforms in JPEG 2K Encoder

Post by Tormaid » 2013-12-31T21:41:04-07:00

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"

snibgo
Posts: 12299
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Post by snibgo » 2013-12-31T22:15:42-07:00

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.
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 11077
Joined: 2003-05-31T11:32:55-07:00

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Post by magick » 2014-01-01T09:35:23-07:00

FYI, we have an OpenJPEG coder in development. It should be ready to release late this month.

Tormaid
Posts: 3
Joined: 2013-12-31T21:18:40-07:00
Authentication code: 6789

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Post by Tormaid » 2014-01-01T11:11:56-07:00

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.

Tormaid
Posts: 3
Joined: 2013-12-31T21:18:40-07:00
Authentication code: 6789

Re: Enabling Reversible Integer Transforms in JPEG 2K Encode

Post by Tormaid » 2014-01-07T12:42:47-07:00

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.

Post Reply