Professional Documents
Culture Documents
Lossless
Encoder
Lossless
Decoder
Dequantizer
Inverse
Transform
Example: 20 Questions
1 (=yes)
B C
0
1
1 0
1 C D 0
B C
DE
F G
Intuition:
Optimum balanced code trees, i.e., with equally likely outcomes, can
be pruned to yield unbalanced trees with unequal probabilities.
The unbalanced code trees such obtained are also optimum.
1
log 2 bits
p
Alphabet X { 0 ,1 , 2 ,..., K 1}
PMF f X x P X x
for each x X
hX x log 2 f X x
H X E hX X f X x log 2 f X x
x
Unit: bits
Bernd Girod: EE398A Image and Video Compression
Information hX x 0
Information hX(x) strictly increases with decreasing
probability fX(x)
Boundedness of entropy
0 H ( X ) log 2
Equality if only one
outcome can occur
p log2 p 0 for p 0 or p 1
Bernd Girod: EE398A Image and Video Compression
H X
0.9
0.8
Equally
likely
0.7
0.6
0.5
0.4
0.3
deterministic
0.2
0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Redundancy of a code:
RH X 0
X with alphabet
and
0 10 11 0 01
01 0 11 0 01
cx
Prefix Decoder
Shift register
to hold longest
code word
...
Input buffer
Advance
||cx|| bits
Code
word LUT
...
Code
word length
LUT
cx
0
0
00
1
1
01 10
1
1
1100
1101
111
3 22 2 24 23 1
1
1
1
1
2 l
2
1
0
l 1
l 1
2 l
21 21 1
Entropy and Lossless Coding no. 16
Example
R H(X )
requires all individual code
word lengths
lk log 2 f X k
f X ( k ) 2
lk
H X 1.75 bits
R 1.75 bits
0
Entropy and Lossless Coding no. 17
Huffman Code
R fixed 4 bits/symbol
Fixed length coding:
RHuffman 2.77 bits/symbol
Huffman code:
Entropy
H( X ) 2.69 bits/symbol
Redundancy of the Huffman code:
0.08 bits/symbol
Bernd Girod: EE398A Image and Video Compression
H X R H X 1
f X x 1 log 2 f X x
H X 1
Bernd Girod: EE398A Image and Video Compression
1
H X R H X
m
Backward adaptation
Unary coding
Geometric source
Alphabet
0,1,...
PMF f X x 2 x 1 , x 0
1
PMF f X x 1 , with 0 ; x 0
2
x
Unary code is still optimum prefix code (i.e., Huffman code), but
not redundancy-free
Golomb coding
x
xq
m
Distribution of new random variables
x mxq xr
with
m 1
f X q xq f X mxq i
xr x mod m
and
mxq
i 0
m 1
f i
i 0
1 xr
f X r xr
for 0 xr m
1 m
X q and X r statistically independent.
Golomb coding
1
2
m
Choose integer divisor
ka log2 m
kb log2 m
.
.
.
Unary
Code
10
11
Constant
010
011
length code
0010
0011
00010
00011
000010
m=2
000011
Unary
0000010
Code
0000011
00000010
00000011
.
.
.
100
101
110
111
0100
0101
0110
0111
00100
00101
00110
00111
000100
000101
000110
000111
Constant
length code
m=4
.
.
.
E X 1 x
x
x 0
Approximation for E X 1
E X
1 E X
m
1
EX 2
1
EX
2
1
k max 0, log 2 E X
2
EX
1 E X
Rule for optimum
performance of
Golomb code
m 2k
Reasonable setting,
even if E X 1
does not hold
Initial estimate
of mean
Initialize A x and N 1
For each n 0,1, 2,
A
Set k max 0, log 2
2
N
Code symbol xn using Golomb code with parameter k
If N N max
Set A
A / 2 and N
N / 2
Update A
A xn and N
N 1
Avoid overflow
and slowly
forget the past