Beruflich Dokumente
Kultur Dokumente
Lecture 7 – Basics of
Compression (Part 2)
Klara Nahrstedt
Spring 2011
P(B) = 0.51
P(CE) = 0.20
P(DA) = 0.29
0 1
P(CE) = 0.20
P(DA) = 0.29
0 1
0 1
0 1
P(CE) = 0.20
P(DA) = 0.29
0 1
0 1
B 0.30
C 0.12
D 0.15
E 0.18
Characteristics of Solution
Symbol (S) Code
A 01
B 11
C 100
D 101
E 00
B 11
C 100
Decode “0101100”
D 101
E 00
H = 2.24 bits
Average Codeword Length
N
L p( si )codelength( si ) Symbol P(S) Code
i 1 A 0.25 01
= .25(2) + B 0.30 11
.30(2) + C 0.12 100
.12(3) +
.15(3) + D 0.15 101
.18(2) E 0.18 00
L = 2.27 bits
Code Length Relative to
Entropy
N N
L p( si )codelength( si ) H p( si ) log 2 p( si )
i 1 i 1
L = .01(1) +
.99(1)
=1
B 0.2
Build Huffman tree
C 0.4
D 0.2
Compute average
E 0.1
code length
Code “BCCADE”
CS 414 - Spring 2011
Limitations
Diverges from lower limit when probability
of a particular symbol becomes high
always uses an integral number of bits
B 1 P(B) = 0.51
B 01 P(B) = 1/3
C 011 P( C) = 0.09
C 001 P(C ) = 1/6
RLE, Huffman
Arithmetic
Coding
CS 414 - Spring 2011
Picture Preparation
Generation of appropriate digital
representation
Image division into 8x8 blocks
Fix number of bits per pixel (first level
quantization – mapping from real numbers
to bit representation)
Quantization
Reduction of precision, e.g., cut least
significant bits
Quantization matrix, quantization values
Entropy Coding
Huffman Coding + RLE
CS 414 - Spring 2011
Audio Compression and Formats
(Hybrid Coding Schemes)
MPEG-3
ADPCM
u-Law
Real Audio
Windows Media (.wma)
Sun (.au)
Apple (.aif)
Microsoft (.wav)
CS 414 - Spring 2011
Image Compression and
Formats
RLE
Huffman
LZW
GIF
JPEG / JPEG-2000 (Hybrid Coding)
Fractals
B 0.2 110
D 0.2 111
Compute code length E 0.1 101
L = 2.2 bits