Quiz: the JPEG pipeline, artefacts and quality metrics
Before this unit: Transform coding, the DCT and the KLT (previous unit); Day 7: Wavelets.
See also: Day 3: Bit depth and noise; Day 46: Colour; Day 18: Moments.
Short questions to test your understanding. Try each on paper first, then open the answer. Pipeline: Y′CbCr and 4:2:0 → 8 × 8 blocks → DCT → quantise q = \operatorname{round}(c/Q) → zigzag → DC difference, (run, size) symbols, Huffman.
Q1. Which steps of JPEG lose information, and which are exactly reversible?
Which steps round or throw away values?
Lossy: chroma subsampling (4:2:0 averages colour over 2 × 2 pixels) and quantisation (rounding c/Q). Reversible: the colour conversion (up to tiny rounding), cutting into blocks, the DCT, zigzag order and the entropy coding.
Q2. Why are the quantisation steps larger at the bottom right of the table than at the top left?
Which frequencies does the eye notice least?
The bottom right holds the highest frequencies: fine detail that the eye barely sees, and that natural images contain little of. Large steps there turn most of those coefficients into zeros, which cost almost nothing to store, while the low frequencies (the visible shading) keep fine steps.
Q3. A coefficient has the step Q = 24. What is the largest error it can have after decoding? And the block’s pixels?
Rounding error, and the DCT is orthonormal.
At most Q/2 = 12 for the coefficient. Its basis image has unit length, so the squared pixel error caused by this coefficient is at most 12^2 = 144, summed over the 64 pixels of the block; spread over the block it is a pattern with an amplitude of a few grey levels.
Q4. Why is the DC coefficient coded as the difference from the previous block?
How different are the averages of two neighbouring blocks, usually?
Neighbouring blocks have similar averages, so the differences are small numbers with a narrow histogram: they cost fewer bits than the DC values themselves. It is the prediction of the lossless unit, applied to block averages.
Q5. At low quality, the sky in a photograph turns into a mosaic of squares. Explain in two sentences.
What survives quantisation in a smooth block, and is the next block coded with it?
In a smooth block only the DC (the block average) survives a coarse quantisation, so the block decodes as a flat square. Each block is quantised on its own, so neighbouring squares have different rounded averages and meet with a visible step: blocking.
Q6. Image A has a brightness shift of 10 grey levels, image B has random noise with standard deviation 10. Compare their PSNR and SSIM.
What is the MSE of each? What does SSIM compare?
Both have MSE 100 and PSNR 28.1 dB. SSIM of A is close to 1 (the local structure is unchanged, only the mean differs slightly); SSIM of B is clearly lower, because the noise destroys local structure, most of all in flat areas. PSNR cannot tell them apart.
Q7. You save a JPEG at quality 75, open it, and save it again at quality 75 without changes. Then you crop 4 pixels from the left and save again. Which save loses more?
Where are the 8 × 8 blocks after the crop?
The second save (same grid, same table) loses almost nothing: the decoded image is already nearly on the quantisation grid. After the crop the 8 × 8 grid lies in a different place, the new blocks’ coefficients are not quantised yet, and the save loses again: generation loss.
Q8. (math) Show that halving all quantisation steps improves the PSNR by about 6 dB.
The error variance of a uniform quantiser with step \Delta is \Delta^2/12.
The MSE (the same in coefficients and pixels, by Parseval) goes from \Delta^2/12 to \Delta^2/48 per coefficient: a factor 4. \Delta\text{PSNR} = 10\log_{10} 4 = 6.02 dB. (Coefficients that were quantised to 0 and stay 0 do not improve; hence “about”.)