6. Compression

Painting detail by Louis Peyré (1923–2012). About the paintings.
Compression must turn a small set of transform coefficients into a short binary description without introducing excessive reconstruction error. This requires controlling both the loss from quantization and the cost of recording coefficient values and locations. We derive error and bit-rate bounds for transform coding, explain how probability models reduce coding costs, and describe the wavelet and entropy-coding stages of JPEG-2000.
6.1 Transform Coding¶
6.1.1 Coding¶
Choose an orthonormal basis, such as a wavelet basis, and write the coefficients as
Quantization maps each coefficient to an integer using a step size :
This quantizer has a zero bin of width : coefficients in are set to zero.
Like hard thresholding (5.4), quantization discards coefficients smaller than in magnitude. It also rounds the retained coefficients, introducing an additional error; see Figure 6.1.
Figure 6.1. Hard thresholding and quantization as functions of the input coefficient.
The integer coefficients are encoded in a binary stream of length bits. Sections 6.1.3 and 6.2 describe two approaches to encoding these integers. The goal is to minimize for an acceptable distortion.
6.1.2 Decoding¶
The decoder retrieves the integers from the binary file and reconstructs coefficient values using
Each nonzero symbol is reconstructed at the center of its quantization bin; zero is reconstructed as zero:
Illustration. Unnumbered illustration: quantization bins
The decoded signal or image is reconstructed as
where and . This produces a reconstruction error .
Let and let retain the coefficients indexed by without quantizing them. This is the approximation (5.3), with equality at the threshold retained here. Orthogonality gives . The following bound separates the approximation error from the additional error caused by rounding.
6.1.3 Support Coding¶
To express the error bound (6.3) in terms of a bit budget, we must relate and to the cost of encoding the coefficients.
At high compression ratios, only a small number of the coefficients remain nonzero. Their support
can be encoded separately from the nonzero values for .
The following theorem gives a rate bound for this support-and-value coding strategy.
The theorem links compression rates to nonlinear approximation rates and motivates choosing a basis adapted to the signal model .
A practical compression algorithm operates on a discrete signal or image of size . It computes transform coefficients from these data. Section 4.4 describes the discrete wavelet transform and gives a compatibility condition (4.5) under which these discrete coefficients coincide with the continuous inner products.
Figure 6.2. Image compression using wavelet support coding.
6.2 Entropy Coding¶
Entropy coding exploits the uneven distribution of the quantized coefficients to reduce the expected file size: zeros are frequent, while large values are rare. Shannon’s coding theory [30] quantifies the resulting savings.
We refer to Section 3.1 for the theoretical foundations of the methods described below.
Probabilistic modeling.
The quantized coefficients take values in an alphabet of elements. A code maps the coefficient sequence to a binary string:
We first model the as independent draws from a known probability distribution:
Huffman code.
A Huffman code assigns a variable-length binary string to each symbol:
where is the codeword length. Codeword lengths are assigned so that a less probable symbol receives no shorter a codeword than a more probable symbol. Huffman coding minimizes the expected length among binary prefix codes. Shannon’s construction gives lengths for positive-probability symbols, so optimality of Huffman’s code implies
where is the entropy of the distribution, defined as
Figure 6.3 illustrates how entropy depends on the distribution. Concentrated distributions have low entropy, as is often the case for quantized wavelet coefficients because many are zero.
Symbol-by-symbol Huffman coding uses an integer number of bits per symbol. This constraint can cause a substantial gap above entropy when one symbol is very probable. Arithmetic coding encodes whole sequences and can achieve an expected length close to , with a small overhead, under the assumed probability model.
Figure 6.3. Three different probability distributions on the same alphabet of symbols. Entropy is measured in bits.
6.3 JPEG-2000¶
JPEG-2000 is a family of still-image compression standards based on wavelet transform coding and adaptive entropy coding. Its irreversible transform uses the biorthogonal CDF 9/7 filters; its reversible transform uses integer-to-integer 5/3 lifting for lossless coding. Symmetric boundary extension limits edge artifacts. Because the transform is biorthogonal, the orthonormal energy identities above are replaced by bounds involving the synthesis operator.
Figure 6.4. JPEG-2000 coding architecture.
Figure 6.4 outlines the JPEG-2000 architecture, and Figure 6.5 compares its reconstructions with those of JPEG. JPEG uses a blockwise DCT and can exhibit visible block boundaries at low bit rates. JPEG-2000 uses a wavelet transform and supports features such as regions of interest, which allow selected parts of an image to be encoded more accurately.
Figure 6.5. JPEG and JPEG-2000 reconstructions of the flower (first pair) and mandrill (second pair), at matched target bit rates.
Progressive coefficient refinement.
Bit-plane coding progressively reveals the binary digits of the quantized coefficient magnitudes. We describe this refinement schematically using thresholds : each new bit plane resolves coefficient values at a finer scale.
Rate allocation and quality layers.
The coder processes coefficient blocks independently, producing embedded streams . The encoder selects coding-pass truncation points within these streams to balance rate against estimated distortion, then organizes the retained data into quality layers. Decoding additional layers improves image quality. This construction supports progressive transmission, with truncation at valid codestream boundaries. The allocation uses an additive distortion model; it does not guarantee the smallest reconstruction error for every possible bit budget.
Bit-plane coding.
At threshold , consider a coefficient at scale , orientation , and position . Three types of bits describe its significance, sign, and magnitude. We suppress in the notation for these bits.
If , the coefficient was not significant at bit-plane . The encoder writes a significance bit indicating whether .
If , the coefficient has just become significant, and the encoder writes its sign as a bit .
For every position that was previously significant, meaning , the encoder writes a refinement bit giving the next binary digit of the coefficient magnitude, namely .
Context modeling.
The bits for are compressed using context-adaptive arithmetic coding to form the streams . Contexts exploit spatial dependence, especially near edges, where large wavelet coefficients tend to cluster. The scan proceeds through stripes four samples high, visiting each stripe column by column.
For a coefficient at position , the context index summarizes its coding state and those of coefficients in its neighborhood
The relevant states include whether neighboring coefficients have become significant, their known signs, and the coefficient’s refinement history. Only information already available to the decoder may enter the context. The precise context rules differ for significance, sign, and refinement bits.
An adaptive arithmetic coder estimates the conditional probability and uses it to encode . Informative contexts can reduce the conditional entropy and hence the expected number of bits.