Quiz: transform coding, the DCT and the KLT

Short questions to test your understanding. Try each on paper first, then open the answer. Orthonormal transform c = Ax, x = A^\top c; Parseval \|c\| = \|x\|.


Q1. A 64-pixel block becomes 64 DCT coefficients. Where does the compression come from, if not from the transform?

What do most of the 64 coefficients of a smooth block look like?

The transform only rearranges: most of the energy ends up in a few coefficients, the rest are close to zero. Quantisation then turns the small ones into exact zeros and stores the large ones coarsely, and entropy coding stores long runs of zeros in very few bits.


Q2. You drop three DCT coefficients with values 4, −3 and 0 from a block. What is the squared error of the rebuilt block?

Parseval.

4^2 + 3^2 + 0^2 = 25 (summed over the 64 pixels), because the DCT is orthonormal: the error in the coefficients equals the error in the pixels. You do not need to transform back to know it.


Q3. An 8 × 8 block contains a horizontal edge (bright top half, dark bottom half). Which coefficients are non-zero?

Does the block change from left to right?

Each row is constant, so all horizontal frequencies u > 0 are zero: only the left column u = 0 of the coefficient table, i.e. the DC and vertical frequencies. As in the vertical case, only the DC and the odd vertical frequencies v = 1, 3, 5, 7 for an edge exactly in the middle.


Q4. Why is the KLT, the best possible linear transform for compaction, not used in JPEG?

What would the decoder need to know?

The KLT depends on the image: its 64 basis vectors (4096 numbers) would have to be computed (an eigenproblem) and stored in the file, and there is no fast algorithm to apply it. For smooth natural images the fixed DCT is almost as good, needs nothing stored, and is fast.


Q5. Why does the DFT need more coefficients than the DCT for a block that is a smooth ramp?

What does the DFT assume about the signal outside the block?

The DFT treats the block as one period of a periodic signal: the ramp becomes a sawtooth with a jump at each block edge, and a jump needs many frequencies (coefficients fall off like 1/k). The DCT is the DFT of the mirrored block, which has no jump: its coefficients fall off like 1/k^2, and two describe the ramp.


Q6. For pure noise, which transform compacts the energy best: DCT, DFT or KLT?

What does the covariance matrix of independent noise look like?

None of them. Independent noise of equal variance has covariance \sigma^2 I: every orthonormal basis gives coefficients of the same variance \sigma^2, so the energy is spread evenly whatever the basis. Noise cannot be compacted, only removed (which is lossy).


Q7. What is the main price of transforming the image in independent 8 × 8 blocks?

What happens to the errors at the border between two blocks?

Each block is coded on its own, so its errors are independent of the neighbouring block’s: where coefficients are dropped or coarsely quantised, the pixel values jump at the block borders. This is blocking, the typical JPEG artefact at low quality, and it adds an 8-pixel periodic pattern to the image.


Q8. (math) Pairs of pixels have covariance \begin{pmatrix} 1 & \rho \\ \rho & 1 \end{pmatrix}. Show that the 2-point DCT diagonalises it, whatever \rho is.

Apply the matrix to (1, 1) and (1, -1).

\begin{pmatrix} 1 & \rho \\ \rho & 1 \end{pmatrix}\begin{pmatrix} 1 \\ 1 \end{pmatrix} = (1 + \rho)\begin{pmatrix} 1 \\ 1 \end{pmatrix} and \ldots\begin{pmatrix} 1 \\ -1 \end{pmatrix} = (1 - \rho)\begin{pmatrix} 1 \\ -1 \end{pmatrix}: the rows of the 2-point DCT, (1, 1)/\sqrt2 and (1, -1)/\sqrt2, are the eigenvectors for every \rho, so D S D^\top = \operatorname{diag}(1 + \rho, 1 - \rho).