Source Coding Theory: TSBK01 Image Coding and Data Compression
Source Coding Theory: TSBK01 Image Coding and Data Compression
Jrgen Ahlberg Div. of Sensor Technology Swedish Defence Research Agency (FOI)
Outline
1. Coding & codes 2. Code trees and tree codes 3. Optimal codes
The source coding theorem
FIVO and VIVO are called variable length codes (VLC). Should be comma-free.
Example
Assume a memoryless source with alphabet A = {a1, , a4} probabilities P(a1) = P(a2) = P(a3) = P(a4) = 1/8. a1 a2 a3 a4 FIFO: 00 01 10 11 FIVO: 0 01 110 111
a1 a2 a3 a4
0 0 0 0
0 010 01 10
10 0 Decoding probem: 010 could 00 10 mean a1a4 or a2 or a3a1. 11 110 110 111 All codes
Non-singular codes Decoding probem: 1100000000000000001 is uniqely decodable, but the first symbol (a3 or a4) cannot be decoded until the third 1 arrives (Compare 11010 and 110010). Uniqely decodable
Instantaneous
Data Compression
Efficient codes utilize the following properties:
Uneven symbol probability Inter-symbol dependence (memory source) Acceptable distortion
Examples:
The FIVO example Theres always an a3 after a1. Dont care whether its a3 or a4.
Krafts Inequality
For a uniqely decodable code with codeword lengths li we have
Conversely, if this is valid for a given set of codeword lengths, it is possible to construct a code tree.
l1 l2 l4 l3
Place l1 in the tree. Then 2lmax l1 leaves disappear... ..and 2lmax 2lmax l1 = 2lmax (1 2-l1) leaves remain. Place l2 in the tree. Then 2lmax (1 2-l1 2-l2) leaves remain. After placing N codeword lengths, 2lmax (1 2-l1) leaves remain.
But what about the integer constraints? li = log pi is not always an integer!
In Practice
Two practical problems need to be solved:
Bit-assignment The integer contraint
Instead, use, e.g., the Huffman algorithm (D.Huffman, 1952) to create an optimal tree code!
Summary
Coding: Assigning binary codewords to (blocks of) source symbols. Variable-length codes (VLC) and fixed-length codes. Instantaneous codes Uniqely decodable codes Non-singular codes All codes Tree codes are instantaneous. Tree code , Krafts Inequality. The Source Coding Theorem.