Q20Digital Image Processing
Question
What is image compression? Explain the JPEG image compression standard in detail with block diagrams.
Answer
Image compression removes coding, spatial, and psychovisual redundancy; the JPEG standard applies this through color conversion, 8x8 block DCT, quantization, and entropy coding.
Image compression addresses the problem of reducing the amount of data required to represent a digital image by removing redundant data. Three types of redundancy are exploited: coding redundancy (using variable-length codes, shorter for frequent symbols, as in Huffman coding), interpixel/spatial redundancy (neighboring pixels are highly correlated, exploited by predictive or run-length coding), and psychovisual redundancy (the human eye is less sensitive to certain information, which can be discarded with acceptable perceptual loss, as in quantization). Compression is broadly classified as lossless (exact reconstruction, e.g., Huffman, LZW, run-length) or lossy (approximate reconstruction with higher compression ratios, e.g., transform coding).
The JPEG Standard
The JPEG (Joint Photographic Experts Group) standard is a widely used lossy compression method for continuous-tone images, achieving typical compression ratios of 10:1 to 20:1 with minimal perceptible loss.
- Color Space Conversion: RGB is converted to YCbCr (luminance and two chrominance channels), separating brightness from color since the eye is far more sensitive to luminance than chrominance.
- Chroma Subsampling: The Cb and Cr channels are downsampled (commonly 4:2:0, halving resolution in both dimensions) since the eye cannot easily perceive loss of color detail, immediately cutting data by up to 50%.
- Block Division: Each channel is divided into non-overlapping pixel blocks.
- Discrete Cosine Transform (DCT): Each block undergoes a 2D DCT, converting spatial pixel values into 64 frequency coefficients; the top-left DC coefficient captures the average intensity, while AC coefficients capture increasing spatial frequency detail.
- Quantization: Each DCT coefficient is divided by a corresponding entry in a quantization table (higher values for high frequencies, since the eye is less sensitive to them) and rounded, driving many high-frequency coefficients to zero. This is the lossy step and its aggressiveness is controlled by a quality factor.
- Entropy Coding: The quantized coefficients are reordered via a zig-zag scan to group zeros together, then compressed losslessly using Huffman coding (or arithmetic coding), exploiting the coding redundancy.
Decoding reverses these steps: entropy decoding, dequantization, inverse DCT, chroma upsampling, and color space conversion back to RGB. The quantization step introduces the loss of data but provides the most compression, and its coarseness is the primary control over the tradeoff between file size and visual quality.
Compression Ratio and Quality Tradeoff
The JPEG quality factor (typically 1-100) scales the standard quantization tables: a quality of 100 uses minimal quantization step sizes and preserves nearly all AC coefficients, producing large files with almost no visible artifact, whereas a quality of 10 uses very coarse steps that zero out most AC coefficients, producing small files but visible blockiness at block boundaries and ringing near sharp edges (Gibbs phenomenon from truncating high-frequency DCT terms). Because subsampling and quantization operate independently on luminance and chrominance, and the eye is far less sensitive to chrominance detail, JPEG typically allocates a coarser quantization table to the Cb/Cr channels than to the Y channel, extracting further compression with minimal perceptual cost. This is also why JPEG is unsuitable for images with sharp, high-contrast edges such as text or line art, where the DCT block structure and quantization loss are most visually objectionable, and formats using lossless or wavelet-based compression are preferred instead.