Compression Huff Merged
Compression Huff Merged
Image Compression.
JPEG
Size-270 KB Size-22 KB
Storage
Ease of Transmission
Compression Fundamentals
Source Channel
F(x, y) Encoder Encoder
Channel/
Store
Source Channel
F’(x, y)
Decoder Decoder
▪ JPEG-Based on DCT
⚫ Huffman coding
⚫ Arithmetic Coding
⚫ Run Length Coding
Huffman Coding
35
Efficiency=H/Lavg x 100 %
Algorithm
Presentation
z
▪ Definition
▪ Simulation
▪ Application
▪ Advantage/Disadvantage
z
Definition
▪ Huffman Coding is a lossless data compression
algorithm. The idea is to assign variable-length codes
to input characters, lengths of the assigned codes are
based on the frequencies of corresponding
characters.
C 67 01000011
• For 1 Letter We need 8 bits
D 68 01000100
• For 20 Letters We need 8×20=160 bits
E 69 01000101
z
Simulation
Message : BCCABBDDAECCBBAEDDCC
Letter Count
D 4
E 2
5
A 3
Then between the root node 5
and counts take the minimum
B 5
and add them up . Here 5 and 4
are minimum so we add them
C 6
and make 9 as root node so
9 continue the process.
D 4
E 2
5
A 3
20
B 5
C 6
9 D 4
11 E 2
5
11
5 1
0 0 1
1
B 10
For A we need 3 C 11
20
bits ,B 2 bits , C 2
0 bits , D 2 bits, E 3 D 01
bits
1
E 000
9
0 For A,
Count =3
11 So total bits 3*3=9 bits
5 1 And so on
0 0 1
1
A 3 001 3×3=9
B 5 10 5×2=10
20
0 C 6 11 6×2=12
1
D 4 01 4×2=8
9
0
E 2 000 2×3=6
11
5 1 Total=45 bits
0 0 1
1 As we see first we do need 160
bits and now we need 45 bits
now we have compressed the
E-2 A-3 D-4 B-5 C-6
cost and size.
z Application
Generic File Compression:
❖ Files: GZIP, BZIP, 7Z
❖ Archives : 7z
❖ File System : NTFS,FS+,ZFS
Multimedia :
❖ Image : GIF, ZPEG
❖ Sound : Mp3
❖ Video : MPEG, HDTV
Communication :
❖ ITU-T T4 Group 3 Fax
❖ V.42 Bis modem
❖ Skype
Databases : Google,Facebook,…
z
Advantages/Disadvantages
Advantages :
The Huffman Coding has the minimum average length.
Easy to implement and fast.
Disadvantages :
Requires two passes over the two input (one to compute frequencies, one for
coding),thus encoding is slow.
Requires storing the Huffman codes(or at least character frequencies)in the
encoded file, thus reducing the compression benefit obtained by encoding.
z
Thank You