Modified Huffman coding: Difference between revisions
mNo edit summary |
m punct., style |
||
Line 1: | Line 1: | ||
'''Modified Huffman coding''' is used in [[fax]] machines to encode black |
'''Modified Huffman coding''' is used in [[fax]] machines to encode black-on-white images ([[bitmap]]s). It combines the variable-length codes of [[Huffman coding]] with the coding of repetitive data in [[run-length encoding]]. |
||
The basic Huffman coding provides a way to compress files that have much repeating data, like a file containing text where the alphabet letters are the repeating objects. However a single scan line contains only two kinds of elements white pixels and black pixels which can be represented directly as a 0 and 1. |
The basic Huffman coding provides a way to compress files that have much repeating data, like a file containing text, where the alphabet letters are the repeating objects. However, a single scan line contains only two kinds of elements{{snd}} white pixels and black pixels{{snd}} which can be represented directly as a 0 and 1. This "alphabet" of only two [[symbols]] is too small to directly apply the [[Huffman coding]]. But if we first use run-length encoding, we can have more objects to encode. Here is an example taken from the article on [[run-length encoding]]: |
||
A hypothetical scan line, with B representing a black pixel and W representing white, might read as follows: |
A hypothetical scan line, with B representing a black pixel and W representing white, might read as follows: |
||
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW |
|||
With a run-length encoding (RLE) data compression algorithm applied to the above hypothetical scan line, it can be rendered as follows: |
With a run-length encoding (RLE) data compression algorithm applied to the above hypothetical scan line, it can be rendered as follows: |
||
12W1B12W3B24W1B14W |
|||
Here we see that we have, in addition to the two items |
Here we see that we have, in addition to the two items "white" and "black", several different numbers. These numbers provide plenty of additional items to use, so the Huffman coding can be directly applied to the sequence above to reduce the size even more. |
||
==See also== |
==See also== |
||
Line 17: | Line 17: | ||
==External links== |
==External links== |
||
*{{cite web |url=http://www.netnam.vn/unescocourse/computervision/104.htm |archiveurl=https://web.archive.org/web/20020628195336/http://www.netnam.vn/unescocourse/computervision/104.htm |archivedate=2002-06-28 |title=Modified Huffman coding from UNESCO}} |
* {{cite web |url=http://www.netnam.vn/unescocourse/computervision/104.htm |archiveurl=https://web.archive.org/web/20020628195336/http://www.netnam.vn/unescocourse/computervision/104.htm |archivedate=2002-06-28 |title=Modified Huffman coding from UNESCO}} |
||
{{Compression methods}} |
{{Compression methods}} |
||
[[Category:Lossless compression algorithms]] |
[[Category:Lossless compression algorithms]] |
||
{{computer-stub}} |
{{computer-stub}} |
Revision as of 23:19, 26 July 2020
Modified Huffman coding is used in fax machines to encode black-on-white images (bitmaps). It combines the variable-length codes of Huffman coding with the coding of repetitive data in run-length encoding.
The basic Huffman coding provides a way to compress files that have much repeating data, like a file containing text, where the alphabet letters are the repeating objects. However, a single scan line contains only two kinds of elements – white pixels and black pixels – which can be represented directly as a 0 and 1. This "alphabet" of only two symbols is too small to directly apply the Huffman coding. But if we first use run-length encoding, we can have more objects to encode. Here is an example taken from the article on run-length encoding:
A hypothetical scan line, with B representing a black pixel and W representing white, might read as follows:
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
With a run-length encoding (RLE) data compression algorithm applied to the above hypothetical scan line, it can be rendered as follows:
12W1B12W3B24W1B14W
Here we see that we have, in addition to the two items "white" and "black", several different numbers. These numbers provide plenty of additional items to use, so the Huffman coding can be directly applied to the sequence above to reduce the size even more.
See also
External links
- "Modified Huffman coding from UNESCO". Archived from the original on 2002-06-28.