简体   繁体   中英

How to decode a huffman coding without the prefix property

I'm trying to decode a buffer encoded with Modified Huffman Coding .

Here's the beginning of the buffer: 000111100001111011111010001000011101000011101000011110

From looking at the translation table , it looks like the prefix property required for Modified Huffman isn't guaranteed. According to the table, I see that 00011 signifies 7B , but 000111 signifies 1W . In this case, how do I decode the buffer above? Am I reading the table wrong or is there some nuance to the algorithm that I'm missing?

Modified Huffman Coding uses an alternating encoding of White and Black pixels. The encoding always starts with a White pixel. So, in your example, the buffer decodes to 000111=1W , 10=3B , 000111=1W , and so on.

Modified Huffman Coding assumes you start with a run of white pixels, as noted in the translation table in your link. If it doesn't, the code for a run of "0" white pixels is used.

00110101 = 0W
000111   = 1W
and so on...

In your example you start with 1W 000111 then 3B 10 and so on...

As John has pointed out, your translation table is wrong. The correct table can be found here:Correct Modified Huffman Coding Translation Table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM