Digital Image Processing: Practical Approach by Borko Furht & Esad Akar & Whitney Angelica Andrews

Digital Image Processing: Practical Approach by Borko Furht & Esad Akar & Whitney Angelica Andrews

Author:Borko Furht & Esad Akar & Whitney Angelica Andrews
Language: eng
Format: epub
ISBN: 9783319966342
Publisher: Springer International Publishing


With the table established, the next step is to iterate over every character, look up its Huffman code, and pack the bits of the code inside 8-bit bytes. Packing is necessary because the smallest unit of data is the 8-bit byte and if we were to write the Huffman code to our file vector as is without packing, a code that is potentially smaller than 8 bits would get converted in an 8-bit byte (uint8) before being written to the vector, which defeats the purpose of compression. As a result, we need to pack multiple codes into one byte before writing.

To pack a stream of bits, we start with the most significant bit of the byte being written to and record every bit of the code from left to right. Every 8 bits, we write the full byte to the vector and resume writing to a new byte. For the sequence ‘abbcccdddd’, packing is shown in Table 6.4.Table 6.4The bits of the Huffman code are packed together inside bytes



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.