Lecture6 (2)
Lecture6 (2)
1. Give the code 0 to the highest probability and the code 1 to the lowest
probability in the present node.
2. Go backwards through the tree and add 0 to the highest and 1 to the
lowest probability in each node until all gray levels have a unique code.
Lavg assuming Huffman coding:
Example:
1. The Huffman code results in unambiguous code.
2. The code is reversible without loss.
3. The table for the translation of the code has to be stored together with the
coded image.
4. The Huffman code does not take correlation between adjacent pixels into
Consideration.
2. Run-Length coding (RLC).
Every code word is made up of a pair (g, l) where g is the gray level, and l is
the number of pixels with that gray level (length, or “run”).
Example:
56 56 56 82 82 82 83 80
56 56 56 56 56 80 80 80
Creates the run-length code (56, 3)(82, 3)(83, 1)(80, 4)(56, 5).
The code is calculated row by row. Very efficient coding for binary data.
Important to know position, and the image dimensions must be stored with
the coded image. Used in most fax machines
Example of combined difference code and Huffman coding
𝐋 𝐚𝐯𝐠 = 𝟑. 𝟏
H.W: how we get L avg = 3.1 and what is the value of RD =?