Documente Academic
Documente Profesional
Documente Cultură
Image Compression:
How Math Led to the JPEG2000 Standard
Basic JPEG
Wavelets and JPEG2000 Home
Introduction/History
Digital Image Basics
In 1992, JPEG became an international standard for compressing digital still images. The acronym JPEG
comes from the Joint Photographic Experts Group. JPEG was formed in the 1980's by members from the Compression in a Nutshell
International Organization for Standardization (ISO) and the International Telecommunications Union (ITU).
According to a 2000 article by Maryline Charrier et. al., over 80% of all images that are transmitted via the Basic JPEG
internet are stored using the JPEG standard. Despite the popularity of the standard, JPEG members quickly The Discrete Cosine Tranformation
identified some issues with the format and also compiled a list of enhancements that should be included in the
Quantization
next generation of the format. In this section, we will describe a very basic JPEG algorithm, show how it works
Color Images
on an example, discuss the inversion process, and then identify issues and problems with the format.
Wavelet Transformations
Basic Algorithm
The Haar Wavelet Transformation
The JPEG algorithm has many features that are not covered
here. It is our intent to provide a very basic idea of how General Wavelet Transformations
JPEG can be used to compress a digital still image. There Wavelet Transformations used by
JPEG2000
are four basic steps in the algorithm - preprocess,
transformation, quantization, encoding. We have already JPEG2000
talked about Huffman coding and JPEG uses a more
Features/Enhancements
sophisticated version of Huffman coding to perform coding.
We will not discuss the advanced coding methods used by Quantization
To explain the steps of the algorithm, we will use as a running example, the image above. The dimensions of
the image 160 x 240 pixels.
Step 1 - Preprocessing
If we wish to compress a color image in the JPG format, the first step is to convert the red, green, blue color
channels to YCbCr space. After that, everything we do for a grayscale image is done to the Y, Cb, and Cr
channels.
-122 49 66 41 41 43 40 38
-121 49 31 45 35 50 41 24
-122 40 45 105 31 -66 18 87
-94 52 42 47 -122 -122 8 51
-119 -23 53 51 45 70 61 42
-64 -122 -25 -26 33 15 6 12
-76 -80 -64 -122 53 64 38 -122
-78 -74 -84 -122 57 43 41 -53
Pixel intensity values less 127 in block row 4, block column 28.
Step 2 - Transformation
The preprocessing has done nothing that will make the coding portion of the algorithm more effective. The
transformation step is the key to increasing the coder's effectiveness. The JPEG Image Compression Standard
relies on the Discrete Cosine Transformation (DCT) to transform the image. The DCT is a product C = U B U^T
where B is an 8 x 8 block from the preprocessed image and U is a special 8 x 8 matrix. More mathematical
details about the DCT can be found in the subsection The Discrete Cosine Transformation. Loosely speaking,
the DCT tends to push most of the high intensity information (larger values) in the 8 x 8 block to the upper left-
hand of C with the remaining values in C taking on relatively small values. The DCT is applied to each 8 x 8
block. The image at left shows the DCT of our highlighted block while the image at right shows the DCT applied
to each block of the preprocessed image.
DCT of the example block. DCT applied to each block. Fullsize version
As you can see, most of the intensities in the discrete cosine transformed image are quite small and at first
glance, one might think that the Huffman coding scheme would work very well with the this image. But there are
still some problems. Let's have a look at the values (rounded to three digits) of the DCT of our example block:
Step 3 - Quantization
The next step in the JPEG algorithm is the quantization step. Here we will make decisions about values in the
transformed image - elements near zero will converted to zero and other elements will be shrunk so that their
values are closer to zero. All quantized values will then be rounded to integers.
Quantization makes the JPEG algorithm an example of lossy compression. The DCT step is completely
invertible - that is, we applied the DCT to each block B by computing C = U B U^T. It turns out we can recover
B by the computation B = U^T C U. When we "shrink" values, it is possible to recover them. However,
converting small values to 0 and rounding all quantized values are not reversable steps. We forever lose the
ability to recover the original image. We perform quantization in order to obtain integer values and to convert a
large number of the values to 0. The Huffman coding algorithm will be much more effective with quantized data
and the hope is that when we view the compressed image, we haven't given up too much resolution. For
applications such as web browsing, the resolution lost in order to gain storage space/transfer speed is
acceptable.
Let's have another look at the DCT of our original block and the values that comprise it:
-2 -19 -15 -6 -4 -1 -1 0
14 4 -2 -13 0 0 -1 -2
-2 -2 -2 7 -1 -1 0 1
2 -3 -2 2 0 0 1 0
1 0 1 -1 -1 0 0 0
-3 2 1 -1 0 0 0 0
0 0 0 -1 1 0 0 0
1 0 -1 0 0 0 0 0
DCT applied to each block. Fullsize version DCT and quantization applied to each block. Fullsize version
Step 4 - Encoding
The last step in the JPEG process is to encode the transformed and quantized image. The regular JPEG
standard uses an advanced version of Huffman coding. We will use the basic Huffman coding algorithm
described in the Compression in a Nutshell section. The original image has dimensions 160 x 240 so that
160*240*8 = 307,200 bits are needed to store it to disk. If we apply Huffman coding to the transformed and
quantized version of the image, we need only 85,143 bits to store the image to disk. The compression rate is
about 2.217bpp. This represents a savings of over 70% of the original amount of bits needed to store the
image!
The images below shows the original image at left and the JPEG compressed image at right. Recall that the
image at right requires over 70% less storage space than that of the original image!
A digital grayscale image. Fullsize version The compressed grayscale image. Fullsize version
Finally, we compare our example of block row 4, block column 28 with the compressed version of the block.
Upper right hand corner of original image. Fullsize version Upper right hand corner of compressed image. Fullsize
version
The quantization step makes the JPEG Image Compression Standard an example of lossy compression. For
some applications, such as web browsing, the loss of resolution is acceptable. For other applications, such as
high resolution photographs for magazine advertisements, the loss of resolution is unacceptable.
As you will see in the Features/Enhancements subsection of the JPEG2000 section, researchers have found a
better transformation and quantization methods to address the problems encountered by the JPEG standard.
Copyright © 2011 Society for Industrial and Applied Mathematics. All Rights Reserved.