Information Technology Reference
In-Depth Information
Data Compression: All of the approaches described so far to
specify image information yield a file or collection of information
about colors. What, then, is the most efficient way to store this in
formation? The simplest approach, of course, is just to store each
piece of data. And, if the data are sufficiently varied, then this might
be best. However, often we can take advantage of special character
istics of the data to help us store image information more efficiently.
Various approaches for storing images compactly are examples of
data compression . Here are a couple of simple approaches that are
adapted for use in actual fax machines.
The data for each color in an image might be specified in rela
tion to the color's frequency. Suppose, for simplicity, that each pixel
on a text document is white, gray, or black, and that the back
ground of the page is white. As we scan along a line, we would first
see white, then parts of a letter, then more white, another letter, and
so on. Breaking down what we see into colored pieces, we have a
block of white, a block of black or gray, another block of white,
more black or gray, an so on. Our next step is to encode the colors,
and because white appears most often, we will choose a short code
in binary. Let's choose the single digit 1. Black and gray appear less
often, so we choose twodigit codes for these: 00 for black and 01
for gray. Note that although the number of binary digits varies from
one color to the next, when we read the code, we will automatically
know each pixel's color. If the first digit is 1, it's the color white. If
the first digit is 0, then the pixel is either black or gray (it cannot be
white), and we must look at the second bit to determine which color
we have. This example illustrates how we can code colors based on
their frequency, with the most common colors having a short code
and less common colors having a longer code. (A common tech
nique for determining such codes is called the Huffman algorithm ,
and such codes are used very commonly in data compression.)
Once a color is identified in our line of information, we could
repeat the color code for each matching pixel on the line. As noted,
however, we can expect a block of pixels of one color and then a
block of the next. Because most colors come in blocks, we can save
space by combining a count with the color, rather than repeating
the color information for each pixel. For example, if the color gray
occurs for 50 pixels in a row, we could say “50 gray” rather than
“gray, gray, gray, . . . , gray” 50 times. As with determining codes,
the details require care, but this approach can provide considerable
Search WWH ::




Custom Search