Huffman Code Charts

I didn't understand what the Huffman Jpeg tables contain, can anyone explain this to me? Thanks

+3
source share
2 answers

Huffman encoding is a variable length data compression method. It works by assigning the most common values ​​in the input stream to the encodings with the smallest bit length.

For example, an input Seems every eel eeks elegantly.may encode a letter eas binary 1and all other letters as various other longer codes, starting with 0. Thus, the resulting bit stream will be less than if each letter was fixed. As an example, consider the magnitudes of each symbol and build a tree that puts the common ones at the top.

Letter  Count
------  -----
e          10
<SPC>       4
l           3
sy          2
Smvrkgant.  1
<EOF>       1

EOF , . .

                                 __________#__________
                ________________/______________       \
       ________/________                   ____\____   e
    __/__             __\__             __/__       \
   /     \           /     \           /     \     / \
  /       \         /       \         /      SPC  l   s
 / \     / \       / \     / \       / \
y   S   m   v     /   k   g   \     n   t
                 /\          / \
                r  .        a  EOF

, , , . . , ( EOF ) 248 .

, , , , , :

Section      Encoding
----------   --------
Seems<SPC>   00001 1 1 00010 0111 0101                    (20 bits)
every<SPC>   1 00011 1 001000 00000 0101                  (22 bits)
eel<SPC>     1 1 0110 0101                                (10 bits)
eeks<SPC>    1 1 00101 0111 0101                          (15 bits)
elegantly    1 0110 1 00110 001110 01000 01001 0110 00000 (36 bits)
.<EOF>       001001 001111                                (12 bits)

115 , 120, , .

, , , (a) , , , , , .

, Huffman JPEG , .

JPEG ( , , ..), , , .


(a) , - :

Size of length section (8-bits) = 3 (longest bit length of 6 takes 3 bits)
Repeated for each byte:
    Actual length (3 bits, holding value between 1..6 inclusive)
    Encoding (n bits, where n is the actual length)
    Byte (8 bits)
End of table marker (3 bits) = 0 to distinguish from actual length above

, :

00000011             8 bits

 n  bits   byte
--- ------ -----
001 1      'e'      12 bits
100 0101   <SPC>    15 bits
101 00001  'S'      16 bits
101 00010  'm'      16 bits
100 0111   's'      15 bits
101 00011  'v'      16 bits
110 001000 'r'      17 bits
101 00000  'y'      16 bits
101 00101  'k'      16 bits
100 0110   'l'      15 bits
101 00110  'g'      16 bits
110 001110 'a'      17 bits
101 01000  'n'      16 bits
101 01001  't'      16 bits
110 001001 '.'      17 bits
110 001111 <EOF>    17 bits

000                  3 bits

264 , . , , , .

, , Adaptive Huffman. .

EOF , .

, .

, , , / , ( , , , 1K , 10K , , ).

, (), EOF .

, , ( ) , , ( ).

, . , , , , , , .

+13

DHT , . . .

, , huffman , .

0

Source: https://habr.com/ru/post/1791138/


All Articles