Lossless Compression
Lossless Compression
2
Compression
How is compression possible?
– Redundancy in digital audio, image, and video data
– Properties of human perception
Digital audio is a series of sample values; image
is a rectangular array of pixel values; video is a
sequence of images played out at a certain rate
Neighboring sample values are correlated
Classification
Lossless compression
– lossless compression for legal and medical documents,
computer programs
– exploit only data redundancy
Lossy compression
– digital audio, image, video where some errors or loss can
be tolerated
– exploit both data redundancy and human perception
properties
Constant bit rate versus variable bit rate coding
Data Compression- Entropy
• Entropy is the measure of information content in a
message.
Messages with higher entropy carry more information than messages
with lower entropy.
• How to determine the entropy
Find the probability p(x) of symbol x in the message
The entropy H(x) of the symbol x is:
H(x) = - p(x) • log2p(x)
• The method can be more efficient if the data uses only 2 symbols (0s and
1s) in bit patterns and 1 symbol is more frequent than another.
Huffman coding
• In Huffman coding, you assign shorter codes
to symbols that occur more frequently and
longer codes to those that occur less
frequently.
• For example:
Character A B C D E
------------------------------------------------------
Frequency 17 12 12 27 32
Table 15.1 Frequency of characters
Figure 15-4
Huffman coding
Figure 15-5
Huffman encoding
Figure 15-7
Huffman decoding
Huffman coding
• The beauty of Huffman coding is that no code in the
prefix of another code.
• There is no ambiguity in encoding.
• The receiver can decode the received data without
ambiguity.
• Huffman code is called instantaneous code because
the decoder can unambiguously decode the bits
instantaneously with the minimum number of bits.
Lempel Ziv encoding
• LZ encoding is an example of a category of
algorithms called dictionary-based encoding.
• The idea is to create a dictionary (table) of
strings used during the communication
session.
• The compression algorithm extracts the
smallest substring that cannot be found in the
dictionary from the remaining non-
compressed string.
Figure 15-8:Part I
JPEG process
Reading
the table
Video compression--MPEG
• MPEG method
– Spatial compression
• The spatial compression of each frame is done
with JPEG.
– Temporal compression
• The temporal compression removes the
redundant frames.
• MPEG method first divides frames into three
categories: I-frames, P-frames, B-frames.
Figure 15-16
MPEG frames
MPEG frames
ce
en
MPEG frame construction
qu
se
ut
p
In
e
en c
u
seq
EG
MP
Hatem ZAKARIA, 24th February 2013 36