6. data compression
TRANSCRIPT
CSN08704
Data, Audio, Video and Imageshttp://asecuritysite.com/comms
Telecommunications
Prof Bill Buchanan
Huffman/Lempel-Ziv Compression Methods
CSN08704
Data, Audio, Video and Imageshttp://asecuritysite.com/comms
Telecommunications
Prof Bill Buchanan
Huffman Coding
Huffman CodingLetter: ‘b’ ‘c’ ‘e’ ‘i’ ‘o’ ‘p’ No. of occurrences: 12 3 57 51 33 20
‘e’ ‘i’ ‘o’ ‘p’ ‘b’ ‘c’ 57 51 33 20 12 3
‘e’ 57
‘i’ 51
‘o’ 33
‘p’ 20
‘b’ 12 [1]
‘c’ 3 [0]
‘e’ 57
‘i’ 51
‘o’ 33
‘p’ 20 [1]
15 [0]
‘e’ 57
‘i’ 57
35 [1]
‘o’ 33 [0]
68
‘e’ 57 [1]
‘i’ 51 [0]
108 [1]
68 [0]
‘e’ 11 ‘i’ 10 ‘o’ 00 ‘p’ 011 ‘b’ 0101 ‘c’ 0100
Link
Huffman CodingHow will the following be decoded:
11000110100100110100
‘e’ 11 ‘i’ 10 ‘o’ 00 ‘p’ 011 ‘b’ 0101 ‘c’ 0100
‘e’
Huffman Coding Example1 goal [34]
0 goals [21]2 goals [15]
3 goals [14]4 goals [5]
5 goals [2]6 goals [1]
1
0
1 goal [34]
0 goals [21]
2 goals [15]3 goals [14]4 goals [5]
[3]
1
0
1 goal [34]
0 goals [21]
2 goals [15]3 goals [14]4 goals [8]
1 goal [34]
[22]
0 goals [21]2 goals [15]1
0
1 goal [34]
[22]
0 goals [21]2 goals [15]
[36]
1 goal [34]
[22] 1
0
1
0
[56]
[36]
1
0Coding:0 goals 011 goal 112 goals 003 goals 1014 goals 10015 goals 100016 goals 10000
1 goal [34]
0 goals [21]2 goals [15]
3 goals [14]4 goals [5]
5 goals [2]6 goals [1]
1
0
1 goal [34]
0 goals [21]
2 goals [15]3 goals [14]4 goals [5]
[3]
1
0
1 goal [34]
0 goals [21]
2 goals [15]3 goals [14]4 goals [8]
1 goal [34]
[22]
0 goals [21]2 goals [15]1
0
1 goal [34]
[22]
0 goals [21]2 goals [15]
[36]
1 goal [34]
[22] 1
0
1
0
[56]
[36]
1
0Coding:0 goals 011 goal 112 goals 003 goals 1014 goals 10015 goals 100016 goals 10000
Link
Huffman Coding (example)Input: peter piper picked a picked pepper [Link]
Symbol Weight Huffman Codee 7 00p 8 10 5 110c 2 0101d 2 0110i 3 1110k 2 0111r 3 1111a 1 01000t 1 01001Coding is: 10 00 01001 00 1111 110 10 1110 10 00 1111 110 10 1110 0101 0111 00 0110 110 01000 110 10 1110 0101 0111 00 0110 110 10 00 10 10 00 1111
CSN08704
Data, Audio, Video and Imageshttp://asecuritysite.com/comms
Telecommunications
Prof Bill Buchanan
Lempel-Ziv Welsh (LZW)
Lempel-Ziv
‘The receiver requires a receipt for it. This is automatically sent when it is received.’
1 1
1
‘The receiver#9#3quires a#20#5pt for it. This is automatically sent wh#6#2 it #30#2#47#5ved.’
Lempel-Ziv Welsh (LZW)ababacdcdaaaaaaef
0000 ‘a’ 0001 ‘b’ 0010 ‘c’ 0011 ‘d’ 0100 ‘e’ 0101 ‘f’ 0110–1111 empty
Initially fill table with characters used:
0000 ‘a’ 0001 ‘b’ 0010 ‘c’ 0011 ‘d’ 0100 ‘e’ 0101 ‘f’ 0110 ‘ab’ 0111–1111 empty
Process “ab” and add to table:
Link
Lempel-Ziv Welsh (LZW)
0000 ‘a’ 0001 ‘b’ 0010 ‘c’ 0011 ‘d’ 0100 ‘e’ 0101 ‘f’ 0110 ‘ab’ 0111 ‘ba’ 1000–1111 empty
0000 0001 0000 0111 0010
‘a’ ‘b’ ‘a’ ‘ba’ ‘c’
ababacdcdaaaaaaef
Lempel-Ziv Welsh (Example)
Cows graze in groves on grass which grows in grooves in groves [Link]
Compressed:['C', 'o', 'w', 's', ' ', 'g', 'r', 'a', 'z', 'e', ' ', 'i', 'n', 260, 'r', 'o', 'v', 'e', 259, 'o', 268, 261, 'a', 's', 259, 'w', 'h', 'i', 'c', 'h', 269, 257, 259, 267, 286, 271, 273, 266, 276, 270, 272, 's']256297
Adding: [256]CoAdding: [257]owAdding: [258]wsAdding: [259]s Adding: [260] gAdding: [261]grAdding: [262]raAdding: [263]azAdding: [264]zeAdding: [265]e Adding: [266] i
CSN08704
Data, Audio, Video and Imageshttp://asecuritysite.com/comms
Telecommunications
Prof Bill Buchanan
Huffman/Lempel-Ziv Compression Methods