Title: Module 25 Lossy Data Compression
1Module 25Lossy Data Compression
2- Textbook sections
- Topics
- JPEG
- Discrete Cosine Transform (DCT)
- Quantization
- Lossless Compression
31. JPEG
- JPEG
- JPEG stands for the Joint Photographic Experts
Group. It is referred as a joint group
because this committee is sanctioned by the CCITT
and the ISO, two prominent international
standards groups. - JPEG refers both to the committee and their work
in progress a compression standard that will
define a method for compressing photographic
images. Images compressed with the JPEG
algorithm undergo a lossy compression.
4JPEG Lossy Compression
8x8 block
Lossless Compression
DCT
Quantization
- The JPEG compression process is a three-step
procedure. - Discrete Cosine Transformation (DCT) DCT is a
lossless transformation that does not actually
perform compression. It prepares for the lossy
or quantization, step of the process. - Quantization Quantization is the process of
reducing the number of bits needed to store an
integer value by reducing the precision of the
integer. - The JPEG algorithm outputs the elements using
an entry encoding mechanism. The output has
RLE built into it as an integral part of the
coding mechanism.
51. JPEG - DCT
- Why use DCT to transform from spatial
representation to spectral representation? - After the transformation, there are still just as
many points as before. It would be much more
impressive if the DCT took an N-by-N matrix of
data and transformed it to an N/2 by N/2 matrix. - The DCT transformation identifies pieces of
information in the signal that can be effectively
thrown away without seriously compromising the
quality of the image. - Most graphical images on our computer screens are
composed of low-frequency information. The
components found in row and column 0 (the DC
components) carry more useful information about
the image than the higher-frequency components.
As we move farther away form the DC components in
the picture, we find that the coefficients not
only tend to have lower values, but they become
far less important for describing the picture. - It is hard to imagine how we would do this with a
picture that hadnt been transformed. With the
image still described in spatial terms, using
pixels, a program would have a difficult time
figuring out which pixels are important to the
overall look of the picture and which arent.
61. JPEG - DCT
- DCT takes an 8 x 8 pixel values as input and
outputs an 8 x 8 matrix of frequency
coefficients. - DC coefficient
- The first frequency coefficients, at location
(0,0) in the output matrix, is called the DC
coefficient. Intuitively, we can see that the DC
coefficients is a measure of the average value of
the 64 input pixels. - AC coefficients
- The other 63 elements of the output matrix are
called the AC coefficients. They add the
higher-spatial-frequency information to this
average value. - Thus, as you go from the first frequency
coefficient toward the 64th frequency
coefficient, you are moving from the broad
strokes of the image to finer and finer detail. - These higher-frequency coefficients are
increasingly unimportant to the perceived quality
of the image.
71. JPEG - DCT
- Why choose blocks of 8x8 pixel values?
- The calculation time required for each element in
the DCT is heavily dependent on the size of the
matrix - One of the consequence of this is that it is
virtually impossible to perform a DCT on an
entire image. The amount of calculation needed
to perform a DCT transformation on even a
256-by-256 gray-scale block is prohibitively
large. To get around this, DCT implementations
typically break the image down into small, more
manageable blocks. The JPEG selected an 8-by-8
block for the size of their DCT calculation
8LG Figure 12.26 One-dimensional and
two-dimensional DCTs
1-D DCT
X(f)
(a)
x(t)
(time)
(frequency)
(b)
2-D DCT
80 10 3 2 0 8 2 1 0
.. 2 0 0 .. 0 0 ... 0
...
100 95 85 .. 102 99 70.. 101 80 70.. 95 77 65..
(n,m) Space
(u,v) Frequency
91. JPEG - DCT
Input Pixel matrix
DCT
Output DCT matrix
101. JPEG - DCT
- The Discrete Cosine Transformation (DCT)
- DCT(i,j) (1 / (2N)1/2) C(i)C(j) S S pixel(x,y)
COS(2x1)ip)/2NCOS(2y1)jp)/2N - The Inverse Discrete Cosine Transformation (IDCT)
- pixel(i,j) (1 / (2N)1/2) S S C(i)C(j) DCT(i,j)
COS(2x1)ip)/2NCOS(2y1)jp)/2N -
-
N-1
N-1
X0
y0
C(x) (1 / (21/2) if x is 0, else 1 if xgt0
N-1
N-1
j0
i0
C(x) (1 / (21/2) if x is 0, else 1 if xgt0
111. JPEG - Quantization
- Quantization
- The process of reducing the number of bits needed
to store an integer value by reducing the
precision of the integer - The JPEG algorithm implements quantization using
a quantization matrix - For every element position in the DCT matrix, a
corresponding value in the quantization matrix
gives a quantum value. - The quantum value indicates what the step size is
going to be for that element in the compressed
rendition of the picture - The quantum values range from one to 255.
121. JPEG - Quantization
- The basic quantization equation is
- Quantized Value(i,j) (DCT(i,j) / Quantum(i,j)
Rounded to nearest integer -
- The decompression is defined as
- DCT(i,j) Quantized Value(i,j) x Quantum (i,j)
131. JPEG - Quantization
Quantization matrix
DCT Matrix before Quantization
DCT Matrix after Quantization
DCT Matrix after Dequantization
141. JPEG - Quantization
- Selecting a Quantization Matrix
- An enormous number of schemes could be used to
define values in the quantization matrix. - ISO has developed a standard set of quantization
values supplied for use by implementers of JPEG
code - By choosing extraordinarily high step sizes for
most DCT coefficients (values of the elements in
the quantization matrix), we get excellent
compression ratios and poor picture quality. - By choosing low step sizes, compression ratios
will begin to reduce, but picture quality should
be excellent.
151. JPEG Lossless Compression
LG Figure 12.28 Zigzag scanning process
In image and video coding, the picture array is
divided into 8x8 pixel blocks which are coded
separately.
180 150 115 100 100 100 100 100 250 180 128 100
100 100 100 100 190 170 120 100
100 100 100 100 160 130 110 100
100 100 100 100 110 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100
100 100 100 100 100 100
111 22 15 5 1 0 0 0 14 17 10 4 1 0 0 0 2 2
1 0 0 0 0 0 -4 -4 -2 -1 0 0 0 0 -3 -3 -1
0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
DCT
8x8 block of 8-bit pixel values
Quantized DCT Coefficients
161. JPEG Lossless Compression
- Instead of relying of Huffman to compress the
zero values, they are coded using a Run-Length
Encoding (RLE) - One way to increase the length of runs is to
recording the coefficients in the zig-zag
sequence. - Instead of compressing the coefficients in
row-major order, as a programmer would probably
do, the JPEG algorithm moves through the block
along diagonal paths, selecting what should be
the highest value elements first, and working its
way toward the values likely to be lowest.