Huffman encoding represents symbols with variable-length, prefix-free bit codes: frequent symbols receive shorter codes, while every code remains immediately decodable. It reduces storage when a distribution is uneven, but can perform worse than fixed-rate coding when symbols are equally probable. section 6.2
| G(reen) = 0 |
The prefix code assigns the most frequent color one bit and less frequent colors progressively longer codes. section 6.2
Compressing a 4 × 4 image
For 12 green, 2 red, 1 blue, and 1 yellow pixels, codes of lengths 1, 2, 3, and 3 require 22 bits, or 1.375 bits per pixel, versus 32 bits with two-bit fixed coding. A balanced four-color image instead requires 36 bits, or 2.25 bits per pixel. section 6.2



