next up previous
Next: About this document ... Up: compression Previous: Predictive coding

Transform Coding (lossy) and JPEG Image Compression

The Joint Photographic Experts Group (JPEG) is the working group of ISO, International Standard Organization, that defined the popular JPEG Imaging Standard for compression used in still image applications. The counter part in moving picture is the ``Moving Picture Experts Group" (MPEG).

JPEG_diagram_0.gif

JPEG compression is based on certain transform, either DCT or wavelet transform, due to the essential properties of orthogonal transforms in general:

Check this ACM page for review of DCT vs. wavelet transform used for image compression.

JPEG_diagram_1.gif

Here are the steps of JPEG image compression based on DCT:

  1. Divide the image to form a set of $8 \times 8$ blocks and carry out 2D DCT transform of each block. The computational complexity for 2D DCT of an $N \times N$ image is $O(N^2 log_2 N)$, while the complexity of 2D DCT of all $N/8$ by $N/8$ blocks of image is

    \begin{displaymath}\frac{N^2}{8^2}\;O(8^2 log_2 8)=O(N^2) \end{displaymath}

    The larger the image size $N$, the more saving by sub-block transform. As adjacent pixels are highly correlated, most of energy in an 8 by 8 block is concentrated in the low frequency region of the spectrum (upper-left corner) and the rest transform coefficients are very close to zero.

  2. Threshold all DCT coefficients smaller than a value T to zero, or alternatively, low-pass (either ideal or smooth) filter the 2D DCT spectrum of each sub-image;

    compression_LP_filter.gif

  3. Quantize remaining coefficients (convert floating-point values to integers). First, the elements in each block are divided (element-wise) by the elements in a quantization matrix Q:

    \begin{displaymath}y(i,j)= \left[ \frac{x(i,j)}{Q(i,j)} \right] \end{displaymath}

    where

    \begin{displaymath}Q=\left[ \begin{array}{ccc} ... & ... & ...  ... & q_{ij} & ... \\
... & ... & ... \end{array} \right]_{8\times 8}
\end{displaymath}

    and each of the resulting 8 by 8 elements is rounded to the nearest integer ($[x]$ represents rounding $x$ to the closest integer). At the receiving end, the coefficients are recovered by:

    \begin{displaymath}\hat{x}=Q(i,j) \cdot y(i,j) \end{displaymath}

    Two observations can be made:

    compression_quantization_matrix.gif

    In general, assign smaller numbers around the top-left corner (low frequency components) and larger ones around the lower-right corner (high frequency components). The values are also heuristically determined according to perceptual and psycho-visual tests.

  4. Predictive code all DC components of the blocks (as the DC components are highly correlated);

  5. Scan the rest coefficients in each block in a zigzag way (for higher probability of longer consecutive 0's) to code them by run-length encoding;

    compression_zigzag.gif

  6. Huffman code the data stream;

  7. Store and/or transmit the encoded image as well as the quantization matrix.


next up previous
Next: About this document ... Up: compression Previous: Predictive coding
Ruye Wang 2021-03-28