Mulitimedia Computing: Online Lecture-6 Instructor-in-Charge Dr. Mukesh Kumar Rohil
Mulitimedia Computing: Online Lecture-6 Instructor-in-Charge Dr. Mukesh Kumar Rohil
Table 1:
Char A B C D E F G H
Freq 90 60 50 20 12 8 7 3
Huffman Codes:
A B C D E F G H
00 01 10 111 1101 11001 110000 110001
11 10 01 000 0010 00110 001111 001110
250
/ \ Char A B C D E F G H
150 100 Freq 90 60 50 20 12 8 7 3
/ \ / \
A B C 50 00 01 10 111 1101 11001 110000 110001
/ \ Huff-
30 D man
/ \ Code
18 E
/ \
10 F
/ \
G H
C.R. = (250*8) / (2*90 + 2*60 + 2*50 + 3*20 + 4*12 + 5*8 + 6*7 + 6*3) = 3.29
WILPD, B.I.T.S., PILANI EA ZC473
Wednesday, December 8, 2021 4
Multimedia Computing On-Line Lecture-6
Q2. Find Huffman code-words and the achieved compression ratio using
Huffman coding, for the data given in Table 2. Assume originally a character is
stored using 8-bit.
Table 2:
Char C E T B V S U N R
Code:
C.R. = (392*8) / (2*130 + 2*120 + 2*58 + 4*30 + 4*22 + 5*10 + 5*9 + 5*8 + 5*5) = 3.187
WILPD, B.I.T.S., PILANI EA ZC473
Wednesday, December 8, 2021 5
Multimedia Computing On-Line Lecture-6
Decompression - Huffman Codes
A B C D E F G H
00 01 10 111 1101 11001 110000 110001
11 10 01 000 0010 00110 001111 001110
LOW = 0.0
HIGH = 1.0
While not end of input stream
get next CHARACTER
RANGE = HIGH – LOW
HIGH = LOW + RANGE * high range of CHARACTER
LOW = LOW + RANGE * low range of CHARACTER
End While
output LOW
get NUMBER
Do
find CHARACTER that has HIGH > NUMBER
and LOW < NUMBER
set HIGH and LOW corresponding to
CHARACTER
output CHARACTER
RANGE = HIGH – LOW
NUMBER = NUMBER – LOW
NUMBER = NUMBER / RANGE
Until no more CHARACTERs
13
Discrete Cosine Transform (DCT)
Where
1/ √2 for =0
C()=
1 for >0
Where
1/ √2 for =0
C( )=
1 for >0