Chapter Presentation
Chapter Presentation
1
3.2 Compression principles
2
3.2.1 Source encoder and destination
decoders
Figure 3.1
3
3.2.2 Lossless and lossy compression
Run-length encoding
When the source information comprises long
substrings of the same character or binary
digit.
Insteadof transmitting these directly, they
are sent in the form of a string of codewords,
each indicating both the bit - 0 or 1 - and the
number of bits in the substring
0000000111111111110000011… 5
3.2.3 Entropy encoding
This could be represented as:0,7,1,10 0,5,1,2…
Alternatively, if
we ensure the first substring
always comprises binary 0s, then the string
could be represented as 7,10,5,2…
Statistical encoding
Statisticalencoding exploits this property by
using a set of variable length codewords with
the shortest codewords used to represent the
most frequently occurring symbols
6
3.2.3 Entropy encoding
N
i 1
i Pi
8
3.2.3 Entropy encoding
Example 3.1
-- Comprises only the six different characters
M,F,Y,N,0 AND 1
-- Frequency of occurrence of 0.25, 0.25, 0.125,
0.125, 0.125, and 0.125
-- If the encoding algorithm under following
set of codewords:
M=10, F=11, Y=010, N=011, 0=000,1=001
9
3.2.4 Source encoding
Differential encoding
-- Instead of using a set of relatively large
codewords to represent the amplitude of
each value/signal, a set of smaller codewords
can be used each of which indicates only the
difference in amplitude between the current
value/signal being encoded
-- For example, 12 bits to obtain the required
dynamic range but the maximum difference
in amplitude between successive samples of
the signal requires only 3-bits 10
3.2.4 Source encoding
Transform encoding
-- As we scan across a set of pixel locations
-- The rate of change in magnitude will vary
from zero, if all the pixel values remain the
same
-- A high rate of change it each pixel magnitude
changes from one location to the next
-- The rate of change in magnitude as one
traverses the matrix gives rise to a term
known as spatial frequency 11
3.2.4 Source encoding
-- Figure 3.2
12
3.2.4 Source encoding
-- The human eye is less sensitive to the higher
spatial frequency components
-- If we can transform the original spatial
form of representation into an equivalent
representation involving spatial frequency
components, then we can more readily
identify and eliminate those higher
frequency components which the eye cannot
detect thereby reducing the volume of
information
13
3.2.4 Source encoding
14
3.3 Text compression
Static coding
Dynamic or adaptive coding
15
3.3.1 Static Huffman coding
16
3.3.1 Static Huffman coding
Figure 3.3
17
3.3.1 Static Huffman coding
listing
the resulting weights of all the leaf and
branch nodes in the tree starting with the smallest
weight and proceeding from left to right and from
bottom to top
4 × 1 + 2× 2 + 1×3 + 1×3 = 14 bits
Example 3.2
Figure 3.4
Huffman codewords have the unique property that
a shorter codeword will never form the start of a
longer codeword prefix property
18
3.3.1 Static Huffman coding
Figure 3.5
19
3.3.2 Dynamic Huffman coding
20
3.3.2 Dynamic Huffman coding
Figure 3.6
21
3.3.2 Dynamic Huffman coding
24
3.3.3 Arithmetic coding
Arithmeticcoding yields a single codeword
for each encoded string of characters
Thefirst step is to divide the numeric range
from 0 to 1 into a number of different
characters present in the message to be sent
The size of each segment by the probability
of the related character
Thefirst character to be encoded w is in the
range 0.8 To 0.9
25
3.3.3 Arithmetic coding
Figure 3.7
26
3.3.3 Arithmetic coding
The segment for the character e, is from 0.8 to
0.83(0.8 + 0.3× 0.1)
Character n from 0.83 to 0.86 (0.83 + 0.3× 0.1)
The character e has a range from 0.8 to 0.809 (0.8+
0.3× 0.03), the character n from 0.809 to 0.818 (0.809
+ 0.3× 0.03)
P136之解釋
29
3.3.5 Lemple-Ziv-Welsh coding
Figure 3.8
30
3.3.5 Lemple-Ziv-Welsh coding
The encoder prior to sending each word in
the form of single characters, first checks to
determine if the word is currently stored in
its dictionary and, if it is, it sends only the
index for the word
Theavailable space become full, then the
number of entries is allowed to increase
incrementally
31
3.4 Image compression
3.4.1 Graphic interchange format(GIF)
The resulting table of colors therefore
consists of 256 entries, each of which
contains a 24-bit color value
Figure 3.9
GIF also allow an image to be stored and
subsequently transferred over the network
in an interlaced mode
The first contains 1/8 of the total
compressed image data, the second a further
1/8, the third a further 1/4 , and the last the
remaining 1/2 32
33
3.4.1 Graphic interchange format
Figure 3.9
34
3.4.1 Graphic interchange format
Figure 3.10
35
3.4.2 Tagged image file format
36
3.4.4 Digitized pictures
3.4.5 JPEG
-- There are five main stages associated with
this mode:image/block preparation, forward
DCT, quantization, entropy encoding, and
frame building
37
3.4.5 JPEG
-- Figure 3.14
38
3.4.5 JPEG
Image/block preparation
-- Once the source image format has been
selected and prepared
-- Block preparation
-- It would be too time consuming to compute
the DCT of the total matrix in a single step
so each matrix is first divided into set of
smaller 8× 8 submatrics as a block
39
3.4.5 JPEG
-- Figure 3.15
40
3.4.5 JPEG
Forward DCT
-- Each pixel value is quantized using 8 bits
which produces a value in the range 0 to 255
for the intensity/luminance values-R,G,B or Y
- and a value in the range -128 to +127 for the
two chrominance values-Cb and Cr
-- All the values are first centered around zero
by subtracting 128
-- The input 2-D matrix is represented by :P[x,y]
and the transformed matrix by F[i, j]
41
3.4.5 JPEG
Figure 3.16
42
3.4.5 JPEG
Quantization
45
3.4.5 JPEG
An example set of threshold values is given in the
quantization table , it can conclude a number of
points:
-- The computation of the quantized coefficients
involves rounding the quotients to the nearest
integer value
-- The threshold values used, increase in magnitude
with increasing spatial frequency
-- The DC coefficient in the transformed matrix is
largest
-- Many of the higher-frequency coefficients are zero
46
3.4.5 JPEG
Entropy encoding
four steps:vectoring, differential encoding, run-
length encoding, and Huffman encoding
Vectoring
48
3.4.5 JPEG
Differential encoding
-- the first element in each transformed block
is the DC coefficient which is a measure of
the average color/luminance/chrominance
-- the DC coefficient varies only slowly from
one block to the next
-- differential encoding since this encodes only
the difference between each pair of values
-- for example, if the sequence of DC
coefficeints in consecutive quantized blocks-
one per block –was: 12, 13, 11, 11, 10, … 49
3.4.5 JPEG
Huffman encoding
53
3.4.5 JPEG
Frame building
-- The frame builder is to encapsulate all the
information relating to an encoded
image/picture in this format
-- Figure 3.20
54
3.4.5 JPEG
-- Figure 3.20
55
3.4.5 JPEG
Jpeg decoding
-- Figure 3.21
56
Exercises
Section 3.2 -- 3.3
Section 3.3 -- 3.8 3.11
Section 3.4 -- 3.25 3.31
57