Professional Documents
Culture Documents
9/17/2014
Overview
Source Coding Techniques
Huffman Coding
Source Coding
jaj
Run Length
Lempel-ziv
Arithmetic
Shannon-Fano
Nikesh Bajaj
nikesh.14730@lpu.co.in JPEG: Image Compression
Asst. Prof., ECE Dept.
Digital Signal Processing
Lovely Professional University 2 By Nikesh Bajaj
Source Coding
Source Coding
Aim ??
Ba
Huffman Coding
David A. Huffman
August 9, 1925 October 7, 1999
Ohio State University, MIT
sh
X xi
1952 paper "A Method for the Construction of
Minimum-Redundancy Codes"
Minimum number of bits that completely
represent the symbol.
Algorithm
1
Information Theory and Coding
9/17/2014
jaj
Average Length R
Efficiency of the code
x1
x2
x3
Probability
0.37
0.33
0.16
Self-Information
1.4344
1.5995
2.6439
Code word
0
10
110
Lossless and Lossy Compression
sh
x4 0.07 3.8365 1110
Other x5 0.04 4.6439 11110
x6 0.02 5.6439 111110
Prefix Code or Instantaneous Codes
x7 0.01 6.6439 111111
H(X)=2.1152
R=2.1700
N=H/R=2.1152/2.1700=0.9747
2
Information Theory and Coding
9/17/2014
jaj
x3 0.2 2.3219 01
For ternary
H(X)=1.4855, R =0.9903, =0.9903 Combine 3 least probabilities rather than 2
Group two symbols and calculate same Assign 3 symbols at 3 nodes as 0, 1, 2 rather than 2
symbols as 1, 0
Conclude whether combining increase the
Use log with base 3 rather than 2
efficiency or not
Similarly Huffman can be extended to n-ary
13 By Nikesh Bajaj 14 By Nikesh Bajaj
Home work to get to know the details
All students are advised to go through detail of
Ba Run Length Coding
It is used when long sequence of Ones and Zeros
comes in the signal
Example
Adaptive Huffman 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1
sh
(7) (0) (3) (1) (6) (0) (0)
Or
11111111111111100000000000000000001111
(15,1), (19,0), (4,1)
(01111,1) , (10011,0), (00100,1)
15 By Nikesh Bajaj 16 By Nikesh Bajaj
ke
Long runs of 0s
Loss less Coding
Case -2
Long runs of 1s
Good for certain applications only
Case -3 Applications
Long runs of 0s and 1s Binary images
Speech coding silence coding in speech communication
Runlength for non-binary source
Video transmission
M=aaaaabbbabaaabbbbbbaabbbbabcbbbbcbad FAX
M=abababababababbababababaabababababa
17 By Nikesh Bajaj 18 By Nikesh Bajaj
3
Information Theory and Coding
9/17/2014
j
No statistics require, 001 1 0001
010 0 0000
011 10 0010
aja
100 11 0011
101 01 0101
110 101 0111
111 010 1010
Abraham Lempel Jacob Ziv Terry A. Welch
- 1011 1101
Black & White image binary image (1 bit/pixel)
Gray scale Image 8bits/pixel
Color Image 24bits/pixel
sh
Color image
4
Information Theory and Coding
9/17/2014
jaj
25 By: Nikesh Bajaj
Transform Coding Ba
JPEG:
Still Image Compression Standard
JPEG: Joint Photographic Experts Group
Formally: ISO/IEC JTC1/SC29/WG1
International
Working Group 1
(JBIG,JPEG)
sh
organization for
Standardization Joint ISO/IEC
Technical Sub-committee 29
International Committee (Coding of Audio,
Electro-technical (Information Picture, Multimedia
Commission Technology) and Hypermedia
information
Work commenced in mid-1980s.
Draft international standard 1991.
Widely used for image exchange, WWW, and digital photography.
ke
5
Information Theory and Coding
9/17/2014
jaj
JPEG: Quantization Table Ba JPEG: Differential coding of DC
sh
ke
Huffman DCT Transform
N 1 M 1
k l
y (k , l ) 4 I (i, j ) cos (2i 1) cos (2 j 1)
i 0 j 0 2N 2M
JPEG standard
For Lossless Compression
For Lossy Compression
6
Information Theory and Coding
9/17/2014
j
x= [ 1123 12]
aja
37 By: Nikesh Bajaj 38 By: Nikesh Bajaj
DCT of an Image
DCT
50
100
B 250
200
150
JPEG: Example
100
sh
150
50
200
7
Information Theory and Coding
9/17/2014
JPEG: Decoding
JPEG: Example
The DC coefficient is DPCM coded (difference
between the DC coefficient of the previous block
and current block)
jaj
The AC coefficients are mapped to run-length
pairs: (run,value)
(0,5),(0, -3),(0, -1),(0,- 2),(0, -3),(0,1),
(0,1),(0, -1),(0, -1),(2,1),(0,2),(0,3),(0, -2),
(0,1),(0,1),(6,1),(0,1),(1,1), EOB
These are then Huffman coded (codes are
specified in the JPEG scheme)
JPEG:
Example Image Compression
Ni
8
Information Theory and Coding
9/17/2014
jaj
artifacts Why zig-zag scanning?
Why differential Coding?
Why DCT transform?
+
P(A) = 0.5 P(B) = P(C) = 0.25
Msg = BACA
sh
51 By Nikesh Bajaj 52 By Nikesh Bajaj
ke
9
Information Theory and Coding
9/17/2014
jaj
Sym
Shannon Fano-Elias Coding
Sym Prob F(x) F(x) F(x)bin l(x) codeword
sh
x1 x1 0.5 0.25 0.01 2 01
x2 ^2 x2 ^2 0.75 0.625 0.101 3 101
x3 ^3 x3 ^3 0.875 0.8125 0.1101 4 1101
x4 ^ 3 x4 ^ 3 1 0.9375 0.1111 4 1111
6 7 8 8
M = ababbaaaabbbccccbbaaabbccccd 6 6 8 8
10