Saving JPEG 2000 and JPX Images in Lossless Mode
Lossless compression is used in sensitive applications, such as legal or medical. Lossless compression provides lower compression rates than even the maximal quality lossy compression. However, JPEG 2000 lossless compression outperforms comparable lossless image compression techniques like LZW and TIFF. The format also allows storing several quality levels in an image, and in particular, using lossy compression for the lower quality levels and lossless compression for the highest quality layer.
The following actions are necessary to save a lossless JPEG 2000 or JPX image:
- Set WAVELET_FILTER control parameter to IG_JPEG2K_FILTER_REVERSIBLE to use the reversible color transform.
- Specify the maximum compression quality, by one of the following:
- Set RATE_BYTES control parameter to 0, and QUALITY_LAYERS control parameter to NULL, or
- Use the QUALITY_LAYERS control parameter, and set the last entry in the array passed to it to 0.0. This results in an image where the first several layers are lossy, and the last layer is lossless.
If the maximum compression quality is used, the value of QUANT_STEP parameter is ignored, as no quantization takes place.
See JPEG 2000 and JPX file format descriptions for details on the control parameters mentioned above.