TIFF 6.0 Specification
Final—June 3, 1992
Section 14: Differencing Predictor
This section defines a Predictor that greatly improves compression ratios for some
images.
Predictor
Tag
= 317 (13D.H)
Type = SHORT
N
=1
A predictor is a mathematical operator that is applied to the image data before an
encoding scheme is applied. Currently this field is used only with LZW (Com-
pression=5) encoding because LZW is probably the only TIFF encoding scheme
that benefits significantly from a predictor step. See Section 13.
The possible values are:
1=
No prediction scheme used before coding.
2 = Horizontal differencing.
Default is 1.
The algorithm
Make use of the fact that many continuous-tone images rarely vary much in pixel
value from one pixel to the next. In such images, if we replace the pixel values by
differences between consecutive pixels, many of the differences should be 0, plus
or minus 1, and so on. This reduces the apparent information content and allows
LZW to encode the data more compactly.
Assuming 8-bit grayscale pixels for the moment, a basic C implementation might
look something like this:
char
int
image[ ][ ];
row, col;
/* take horizontal differences:
*/
for (row = 0; row < nrows; row++)
for (col = ncols - 1; col >= 1; col--)
image[row][col] -= image[row][col-1];
If we don’t have 8-bit components, we need to work a little harder to make better
use of the architecture of most CPUs. Suppose we have 4-bit components packed
two per byte in the normal TIFF uncompressed (i.e., Compression=1) fashion. To
find differences, we want to first expand each 4-bit component into an 8-bit byte,
so that we have one component per byte, low-order justified. We then perform the
horizontal differencing illustrated in the example above. Once the differencing
has been completed, we then repack the 4-bit differences two to a byte, in the
normal TIFF uncompressed fashion.
64
Index Bookmark Pages Text
Previous Next
Pages: Index All Pages
This HTML file was created by VeryPDF PDF to HTML Converter product.