How JPEG Quantization Discards Frequencies

JPEG image compression reduces file size by identifying and eliminating visual information that the human visual system is least likely to notice. The quantization table serves as the primary mechanism for this lossy compression step. By applying mathematical division and rounding to frequency coefficients generated by the Discrete Cosine Transform (DCT), the quantization table systematically reduces high-frequency image details to zeros, which are then permanently discarded during the encoding process.

The Conversion to Frequency Data

Before quantization can occur, an image is divided into 8x8 blocks of pixels and converted from the spatial domain into the frequency domain using the Discrete Cosine Transform (DCT).

This transformation produces an 8x8 matrix of 64 DCT coefficients for each block:

The Role of the Quantization Table

The quantization table is an 8x8 matrix of predefined integers corresponding directly to the 8x8 matrix of DCT coefficients. Because the human eye is sensitive to slight variations in broad areas (low frequencies) but struggles to detect subtle variations in rapid textures (high frequencies), the values in a quantization table are not uniform.

The numbers in the table scale progressively:

How Frequencies Are Reduced to Zero

Quantization is the only step in JPEG compression where data is permanently lost. The process applies element-by-element integer division of the DCT block by the quantization table using the following formula:

\[\text{Quantized Value} = \text{round}\left(\frac{\text{DCT Coefficient}}{\text{Quantization Value}}\right)\]

When high-frequency details naturally have small amplitudes, dividing them by large quantization divisors results in numbers between -0.5 and 0.5. When rounded to the nearest whole integer, these values become zero.

For example, if a high-frequency DCT coefficient has a value of 18 and its corresponding quantization table entry is 64:

\[\text{round}\left(\frac{18}{64}\right) = \text{round}(0.28125) = 0\]

The original frequency component is effectively erased because the resulting coefficient is zero.

Discarding the Zeros Through Entropy Coding

Once quantization is complete, the 8x8 matrix contains clusters of zeros, particularly in the high-frequency zones. The JPEG algorithm reads the matrix in a zigzag pattern, starting at the top-left DC coefficient and weaving toward the bottom-right.

This zigzag sequence groups the long runs of zeros together at the end of the array. The algorithm then applies Run-Length Encoding (RLE) and Huffman coding to store these runs in a compact format (such as "end of block"), meaning the zeros consume almost no digital storage space. The precision of the original high-frequency details cannot be recovered upon decompression, effectively discarding them from the final image file.