Entropy Encoding
The block codes from the DPCM and run-length models can be further
compressed using entropy encoding. For the baseline JPEG method, the Huffman coder
is used to reduce entropy. One reason for using the Huffman coder is that it is easy
to implement by means of a lookup table in hardware. To compress data symbols, the
Huffman coder creates shorter codes for frequently occurring symbols and longer codes
for occasionally occurring symbols. Many applications may use predefined Huffman
tables. Therefore, the baseline encoder can operate as a one-pass or two-pass system.
In the one-pass system, predetermined Huffman tables are used, whereas in the two-pass
system, Huffman tables are created that are specific to the image to be encoded.
The first step in creating the Huffman codes is to create a table assigning a frequency
count to each symbol. Symbols with a higher probability are assigned shorter codes
than the less frequently occurring symbols.