- Lossless JPEG
The
Joint Photographic Experts Group , in addition to their well-knownlossy image compression techniques,JPEG andJPEG 2000 , also have three standards forlossless compression (of which JPEG-LS has a lossy mode).Lossless JPEG
Lossless JPEG was developed as a late addition to JPEG in 1993, using a completely different technique from the lossy JPEG standard. It uses a predictive scheme based on the three nearest (causal) neighbors (upper, left, and upper-left), and entropy coding is used on the prediction error. It is not supported by the standard Independent JPEG Group libraries, although Ken Murchison of Oceana Matrix Ltd. wrote a patch that extends the IJG library to support Lossless JPEG. Lossless JPEG has some popularity in medical imaging, and is used in DNG and some digital cameras to compress raw images, but otherwise was never widely adopted.
Lossless Mode of Operation
Lossless JPEG [W. B. Pennebaker and J. L. Mitchell, JPEG Still Image Data Compression Standard. New York: Van Nostrand Reinhold, 1993.] is actually a mode of operation of
JPEG . This mode exists because theDiscrete Cosine Transform (DCT ) based form cannot guarantee that encoder input would exactly match decoder output since the Inverse DCT is not rigorously defined. Unlike the lossy mode which is based on theDCT , the lossless coding process employs a simple predictive coding model called differential pulse code modulation (DPCM ). This is a model in which predictions of the sample values are estimated from the neighboring samples that are already coded in the image. Most predictors take the average of the samples immediately above and to the left of the target sample.DPCM encodes the differences between the predicted samples instead of encoding each sample independently. The differences from one sample to the next are usually close to zero. A typical DPCM encoder is displayed in Fig.1. The block in the figure acts as a storage of the current sample which will later be a previous sample.The main steps of the lossless operation mode are depicted in Fig.2. In the process, the predictor combines up to three neighboring samples at A, B, and C shown in Fig.3 in order to produce a prediction of the sample value at the position labeled by X. The three neighboring samples must be already predicted samples. Any one of the predictors shown in the table below can be used to estimate the sample located at X [ITU-T. ISO DIS 10918-1 Digital compression and coding of continuous-tone still images (JPEG). Recommendation T.81.] . Any one of the eight predictors listed in the table can be used. Note that selections 1, 2, and 3 are one-dimensional predictors and selections 4, 5, 6, and 7 are two-dimensional predictors. The first selection value in the table, zero, is only used for differential coding in the hierarchical mode of operation.Once all the samples are predicted, the differences between the samples can be obtained and entropy-coded in a lossless fashion using
Huffman coding orarithmetic coding .Typically, compressions using lossless operation mode can achieve around 2:1 compression ratio for color images [C. K. Wallace. The
JPEG still picture compression standard. Communications of the ACM, 34(4):31-44, 1991.] . This mode is quite popular in medical imaging field, but generally it is not very widely used.JPEG-LS
JPEG-LS is a simple and efficient baseline algorithm which consists of two independent and distinct stages called modeling and encoding. JPEG-LS was developed with the aim of providing a low-complexity "near-lossless" image compression standard that could offer better compression efficiency than
lossless JPEG . It was developed because at the time, theHuffman coding -basedJPEG lossless standard and other standards were limited in their compression performance. Totaldecorrelation cannot be achieved by first order entropy of the prediction residuals employed by these inferior standards. JPEG-LS, on the other hand, can obtain good decorrelation. [M. J. Weinberger, G. Seroussi, and G. Sapiro, “LOCO-I: A low complexity, context-based, lossless image compression algorithm,” in Proc. 1996 Data Compression Conference, Snowbird, UT, Mar. 1996, pp. 140–149.] [M. Weinberger, G. Seroussi, and G. Sapiro, “The LOCO-I lossless image compression algorithm: Principles and standardization into JPEG-LS,” IEEE Trans. Image Processing, vol. 9, no. 8, pp. 1309–1324, Aug. 2000, originally as Hewlett-Packard Laboratories Technical Report No. HPL-98-193R1, November 1998, revised October 1999. Available from [http://www.hpl.hp.com/loco/] .] Part 1 of this standard was finalized in 1999; and when released, Part 2 of this standard will introduce extensions such asarithmetic coding . The core of JPEG-LS is based on the [http://www.hpl.hp.com/loco/HPL-98-193R1.pdf LOCO-I algorithm] , that relies on prediction, residual modeling and context-based coding of the residuals. Most of the low complexity of this technique comes from the assumption that prediction residuals follow a two-sidedgeometric distribution (also called a discreteLaplace distribution ) and from the use of Golomb-like codes, which are known to be approximately optimal for geometric distributions. Besides near lossless compression, JPEG-LS also provides a lossy mode where the maximum absolute error can be controlled by the encoder. Compression for JPEG-LS is generally much faster than JPEG 2000 and much better than the original lossless JPEG standard.LOCO-I algorithm
Prior to encoding, there are two essential steps to be done in the modeling stage:
decorrelation (prediction) anderror modeling .Decorrelation/Prediction
In LOCO-I algorithm, primitive
edge detection of horizontal or vertical edges by examining the neighboring pixels of the current pixel X as illustrated in Fig.3. The pixel labeled by B is used in the case of a vertical edge while the pixel located at A is used in the case of a horizontal edge. This simple predictor is called theMedian Edge Detection (MED) predictor [Nasir D. Memon, Xiaolin Wu, V. Sippy, and G. Miller, “Interband coding extension of the new lossless JPEG standard,” Proc. SPIE Int. Soc. Opt. Eng., vol. 3024, no. 47, pp.47-58, January 1997.] or LOCO-I predictor. The pixel X is predicted by the LOCO-I predictor according to the following guesses:The three simple predictors are selected according to the following conditions: (1) it tends to pick B in cases where a vertical edge exists left of the X, (2) A in cases of an horizontal edge above X, or (3) A + B – C if no edge is detected.Context Modeling
The JPEG-LS algorithm estimates the conditional expectations of the prediction errors using corresponding sample means within each context "Ctx". The purpose of context modeling is that the higher order structures like texture patterns and local activity of the image can be exploited by context modeling of the prediction error. Contexts are determined by obtaining the differences of the neighboring samples which represents the local
gradient :The local gradient reflects the level of activities such as smoothness and edginess of the neighboring samples. Notice that these differences are closely related to the statistical behavior of prediction errors. Each one of the differences found in the above equation is then quantized into roughly equiprobable and connected regions. For JPEG-LS, the differences g1, g2, and g3 are quantized into 9 regions and the region are indexed from -4 to 4. The purpose of the quantization is to maximize the mutual information between the current sample value and its context such that the high-order dependencies can be captured. One can obtain the contexts based on the assumption that After merging contexts of both positive and negative signs, the total number of contexts is contexts. A bias estimation could be obtained by dividing cumulative prediction errors within each context by a count of context occurrences. In LOCO-I algorithm, this procedure is modified and improved such that the number of subtractions and additions are reduced. The division-free bias computation procedure is demonstrated in [http://www.hpl.hp.com/loco/] . Prediction refinement can then be done by applying these estimates in a feedback mechanism which eliminates prediction biases in different contexts.Coding Corrected Prediction Residuals
In regular mode of JPEG-LS, the standard uses
Golomb Rice codes (seeGolomb coding ) which are a way to encode nonnegative run lengths. Its special case with the optimal encoding value 2^k allows simpler encoding procedures.Run Length Coding in Uniform Areas
Since
Golomb Rice codes is quite inefficient for encoding low entropy distributions because the coding rate is at least one bit per symbol, significant redundancy may be produced because the smooth regions in an image can be encoded at less than 1 bit per symbol. To avoid having excess code length over the entropy, one can use alphabet extension which codes blocks of symbols instead of coding individual symbols. This spreads out the excess coding length over many symbols. This is the “run” mode of JPEG-LS and it is executed once a flat or smooth context region characterized by zero gradients is detected. A run of west symbol “a” is expected and the end of run occurs when a new symbol occurs or the end of line is reached. The total run of length is encoded and the encoder would return to the “regular” mode.JPEG 2000
JPEG 2000 includes a lossless mode based on a special integerwavelet filter (biorthogonal 3/5). JPEG 2000's lossless mode runs more slowly and has often worse compression ratios than JPEG-LS on artificial and compound images [http://www.jpeg.org/public/wg1n1816.pdf] [http://itohws03.ee.noda.sut.ac.jp/~matsuda/mrp/] . JPEG 2000 fares better than the UBC implementation of JPEG-LS on digital camera picturesFact|date=February 2007. JPEG 2000 is also scalable, progressive, and more widely supported.External links
* [http://www.jpeg.org/public/wg1n1816.pdf JPEG 2000 still image coding versus other standards]
* [http://itohws03.ee.noda.sut.ac.jp/~matsuda/mrp JPEG2000, JPEG-LS and other lossless codecs on greyscale images]
* [http://www.jpeg.org/jpeg/jpegls.html JPEG-LS home page]
* [http://www.hpl.hp.com/loco/ LOCO-I home page]
* [http://www.hpl.hp.com/loco/JPEGLSTerms.htm Licensing terms for HP's LOCO technology in JPEG-LS (free reg. req.; not sublicensable; available only to companies)]
* [http://kt.ijs.si/aleks/jpeg-ls/index.htm Links to Various Implementations]
* [http://www.dclunie.com/jpegls.html Single-tone/grayscale JPEG-LS encoder algorithm]References
Wikimedia Foundation. 2010.