Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

6. Compression

CNRS & DMA, École Normale Supérieure

Chapter PDF · Complete book

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

am=f,ψmR.a_m = \langle f,\,\psi_m\rangle \in \mathbb{R}.

Quantization maps each coefficient to an integer using a step size T>0T>0:

qm=QT(am)ZwhereQT(x)=sign(x)xT.q_m = Q_T(a_m) \in \mathbb{Z} \quad \text{where} \quad Q_T(x) = \mathop{\mathrm{sign}}(x) \left\lfloor \frac{|x|}{T} \right\rfloor.

This quantizer has a zero bin of width 2T2T: coefficients in (T,T)(-T,T) are set to zero.

Like hard thresholding (5.4), quantization discards coefficients smaller than TT 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 (qm)m(q_m)_m are encoded in a binary stream of length RR bits. Sections 6.1.3 and 6.2 describe two approaches to encoding these integers. The goal is to minimize RR for an acceptable distortion.

6.1.2 Decoding

The decoder retrieves the integers qmq_m from the binary file and reconstructs coefficient values using

a~m=sign(qm)(qm+12)T.(6.1)\tilde a_m = \mathop{\mathrm{sign}}(q_m) \left( |q_m|+\frac{1}{2} \right) T. \tag{6.1}

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

QT(f):=mITa~mψm=mDT(QT(f,ψm))ψm,IT={m:amT},(6.2)\mathcal{Q}_T(f) \mathrel{:=}\sum_{m \in I_T} \tilde a_m \psi_m =\sum_m D_T(Q_T(\langle f,\,\psi_m\rangle))\psi_m,\qquad I_T=\{m:|a_m|\geqslant T\}, \tag{6.2}

where DT(q)=Tsign(q)(q+1/2)D_T(q)=T\mathop{\mathrm{sign}}(q)(|q|+1/2) and sign(0)=0\mathop{\mathrm{sign}}(0)=0. This produces a reconstruction error  ⁣fQT(f) ⁣|\!| f-\mathcal{Q}_T(f) |\!|.

Let M=#ITM=\#I_T and let fMf_M retain the coefficients indexed by ITI_T without quantizing them. This is the approximation (5.3), with equality at the threshold retained here. Orthogonality gives  ⁣ffM ⁣ ⁣fQT(f) ⁣|\!| f-f_M |\!| \leqslant|\!| f-\mathcal{Q}_T(f) |\!|. 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 MM and TT to the cost of encoding the coefficients.

At high compression ratios, only a small number MM of the NN coefficients remain nonzero. Their support

IM={m  ;  a~m0}I_M = \left\{ m \;;\; \tilde a_m \neq 0 \right\}

can be encoded separately from the nonzero values qm0q_m \neq 0 for mIMm \in I_M.

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 Θ\Theta.

A practical compression algorithm operates on a discrete signal or image of size NN. It computes NN transform coefficients {f,ψm}0m<N\{\langle f,\,\psi_m\rangle\}_{0\leqslant m<N} 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 qm{A,,A}q_m \in \{-A,\ldots,A\} take values in an alphabet of Q=2A+1Q=2A+1 elements. A code maps the coefficient sequence to a binary string:

{qm}m{0,1,1,,0,1}{0,1}R.\{q_m\}_m \longmapsto \{0,1,1,\ldots,0,1\} \in \{0,1\}^R.

We first model the qmq_m as independent draws from a known probability distribution:

P(qm=i)=pi[0,1].\mathbb{P}(q_m=i)=p_i \in [0,1].

Huffman code.

A Huffman code assigns a variable-length binary string to each symbol:

qm=i{A,,A}ci{0,1}ciq_m=i \in \{-A,\ldots,A\} \longmapsto c_i \in \{0,1\}^{|c_i|}

where ci|c_i| 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 log2pi\lceil-\log_2p_i\rceil for positive-probability symbols, so optimality of Huffman’s code implies

ER=NipiciN(E(p)+1),\mathbb E R=N\sum_i p_i|c_i|\leqslant N(\mathcal{E}(p)+1),

where E\mathcal{E} is the entropy of the distribution, defined as

E(p)=ipilog2(pi).\mathcal{E}(p) = -\sum_i p_i \log_2(p_i).

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 NE(p)N\mathcal{E}(p), with a small overhead, under the assumed probability model.

Figure 6.3. Three different probability distributions on the same alphabet of Q=7Q=7 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 Ti=2iT0T_i = 2^{-i}T_0: each new bit plane resolves coefficient values at a finer scale.

Rate allocation and quality layers.

The coder processes coefficient blocks SkS_k independently, producing embedded streams cikc_i^k. 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 TiT_i, consider a coefficient djω[n]d_j^\omega[n] at scale jj, orientation ω{V,H,D}\omega\in\{V,H,D\}, and position nSkn\in S_k. Three types of bits describe its significance, sign, and magnitude. We suppress (j,ω)(j,\omega) in the notation for these bits.

Context modeling.

The bits {bis[n]}s=13\{ b_i^s[n] \}_{s=1}^3 for nSkn\in S_k are compressed using context-adaptive arithmetic coding to form the streams cikc_i^k. 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 nSkn\in S_k, the context index vis[n]v_i^s[n] summarizes its coding state and those of coefficients in its 3×33\times3 neighborhood

wn={(n1+ε1,n2+ε2):ε1,ε2{1,0,1}}.w_n = \{(n_1+\varepsilon_1,n_2+\varepsilon_2):\varepsilon_1,\varepsilon_2\in\{-1,0,1\}\}.

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 P(bis[n]vis[n])\mathbb{P}( b_i^s[n] | v_i^s[n] ) and uses it to encode bis[n]b_i^s[n]. Informative contexts can reduce the conditional entropy and hence the expected number of bits.