TIFF 6.0 Specification
Final—June 3, 1992
If the components are greater than 8 bits deep, expanding the components into 16-
bit words instead of 8-bit bytes seems like the best way to perform the subtraction
on most computers.
Note that we have not lost any data up to this point, nor will we lose any data later
on. It might seem at first that our differencing might turn 8-bit components into 9-
bit differences, 4-bit components into 5-bit differences, and so on. But it turns out
that we can completely ignore the “overflow” bits caused by subtracting a larger
number from a smaller number and still reverse the process without error. Normal
two’s complement arithmetic does just what we want. Try an example by hand if
you need more convincing.
Up to this point we have implicitly assumed that we are compressing bilevel or
grayscale images. An additional consideration arises in the case of color images.
If PlanarConfiguration is 2, there is no problem. Differencing works the same as it
does for grayscale data.
If PlanarConfiguration is 1, however, things get a little trickier. If we didn’t do
anything special, we would subtract red component values from green component
values, green component values from blue component values, and blue compo-
nent values from red component values. This would not give the LZW coding
stage much redundancy to work with. So, we will do our horizontal differences
with an offset of SamplesPerPixel (3, in the RGB case). In other words, we will
subtract red from red, green from green, and blue from blue. The LZW coding
stage is identical to the SamplesPerPixel=1 case. We require that BitsPerSample
be the same for all 3 components.
Results and Guidelines
LZW without differencing works well for 1-bit images, 4-bit grayscale images,
and many palette-color images. But natural 24-bit color images and some 8-bit
grayscale images do much better with differencing.
Although the combination of LZW coding with horizontal differencing does not
result in any loss of data, it may be worthwhile in some situations to give up some
information by removing as much noise as possible from the image data before
doing the differencing, especially with 8-bit components. The simplest way to get
rid of noise is to mask off one or two low-order bits of each 8-bit component. On
our 24-bit test images, LZW with horizontal differencing yielded an average
compression ratio of 1.4 to 1. When the low-order bit was masked from each
component, the compression ratio climbed to 1.8 to 1; the compression ratio was
2.4 to 1 when masking two bits, and 3.4 to 1 when masking three bits. Of course,
the more you mask, the more you risk losing useful information along with the
noise. We encourage you to experiment to find the best compromise for your
device. For some applications, it may be useful to let the user make the final deci-
sion.
Incidentally, we tried taking both horizontal and vertical differences, but the extra
complexity of two-dimensional differencing did not appear to pay off for most of
our test images. About one third of the images compressed slightly better with
two-dimensional differencing, about one third compressed slightly worse, and the
rest were about the same.
65