2023-03-10
Fax image data compression generally involves the following formats:
- MH (Modified Huffman)
- MR (Modified Read)
- MMR (Modified Modified Read)
- JBIG
- JPEG
JPEG is rarely used in fax communications. It’s primarily used to transmit color fax images.
JBIG format is quite different than the other formats, and although it is widely used with some, it is generally not used as frequently as the first three. It is much more tightly compressed than the others in a different format, and thus the following does not apply to JBIG.
MH, MR, and MMR image data formats involve compressing monochrome raster image data (so, a page of dots) through codes that describe horizontal and (in the case of MR and MMR) vertical patterns of black or white dots.
An uncompressed row of monochrome image data could be represented by a series of zeros and ones where zeros represent black dots and ones represent white dots, like this:
00000000001111111111010101010100110011001110001110001111000011110000111110000011111
To compress this data in a method like Modified Huffman we could define codes for patterns of black or white dots. Let’s just say that the codes are defined to be a letter and number pair, the letter “B” for black and the letter “W” for white, and each letter is followed by a number for the number of dots of that color to repeat. So, the uncompressed row of monochrome image data could be compressed with the following:
B10W10B1W1B1W1B1W1B1W1B1W1B2W2B2W2B2W3B3W3B3W4B4W4B4W5B5W5
It’s worth noting that this compression is most effective when there are longer sequences of the same colored dot. “B10” is much tighter (smaller) than “0000000000”.
This isn’t exactly how MH does it, but it is an approximation. MH then repeats this process vertically for every pixel row of image data. MR modifies MH by describing the next few rows of pixels against the ones above it. MMR is the same as MR except that it’s not limited to the next few rows. Basically MR and MMR involve a code describing the number of pixels to repeat. Here let’s call it “R”, followed by the number of pixels to repeat. So, if the following row was identical to the one above it, then it could be represented with a simple code:
R83
MH format is known as 1-D (one dimensional) compression because it compresses horizontally. MR and MMR formats are known as 2-D (two dimensional) compression because they compress both horizontally and vertically.
Sometimes 1-D compression is actually tighter than 2-D. This is particularly true when the pixel rows change considerably moving down the page. For example using our simplified example compression these two uncompressed image rows would not compress any better in 2-D than they would in 1-D since there are no pixels that repeat vertically:
0101010101010101010101010101010101010101
1010101010101010101010101010101010101010
So, MH is most effective when the black or white patterns are long horizontally, and MR and MMR are most effective when the black or white patterns are long both horizontally and vertically.
When color and grayscale images are converted to monochrome they are “dithered” in order to suggest light and dark patterns representing the colors or shade. There are various algorithms used to perform dithering, a common one is known as Floyd-Steinberg. The details of how dithering algorithms work is not important for us now except to know that darker colors and shades will be represented by patterns of black and white dots where black is more dominant, lighter colors and shades will be represented by patterns where white is more dominant, and in the middle between light and dark will be patterns where white and black dots are equally represented.
So, all color images and text, including grayscale text will be converted to monochrome by introducing patterns of black or white dots within the images or text in order to help convey a sense of the lightness or darkness of the portion of the image or text. Therefore, all color or grayscale will not be as efficiently compressed when converted to monochrome as it would be if it had been originally black or white to begin with.
This difference becomes quite significant when it involves fax documents because larger amounts of data require longer periods of time to communicate them. A document that may have taken 30 seconds or so per page to communicate if it had been natively produced as monochrome may take 60 or 90 or more per page. The increased amount of time spent communicating a page of image data increases the risk of some kind of audio disturbance (such as VoIP jitter) occurring during the communication of that page and increases the complexity and tolerances demanded of the equipment involved in that communication.
Thus, incidences of problems with fax communication can be greater than normally expected when the documents are not formatted ideally for efficient monochrome fax communication.
Here are two example fax images: from_color.pdf and from_mono.pdf. The source document for these images was the same, but the first used a gray font color for the text and did not have its contrast and brightness adjusted before converting it to monochrome. The second used black text font and had the brightness and contrast adjusted to reduce dithering effects when converted to monochrome. The first is 38% larger than the second and will, therefore, require 38% more time to communicate. That's 36 versus 22 seconds at a typical fax communication speed.
Perhaps this seems like a small thing, but it does add up. Over a 20-page document the difference in this example would yield a 2.5 minute time difference in communication. Furthermore, the given example image is a mild case of what often happens in the real world when individual pages have multiple photos or logos on them, where the background color behind the font is not white, or where the image originated from a hardcopy scanned in color.
To reduce fax communication times and also fax error rates, careful attention should be paid to fax image formatting.