Previous Next


                                       75
SECTION 3.3                                                                Filters



LZW and Flate Predictor Functions

LZW and Flate encoding compress more compactly if their input data is highly
predictable. One way of increasing the predictability of many continuous-tone
sampled images is to replace each sample with the difference between that sample
and a predictor function applied to earlier neighboring samples. If the predictor
function works well, the postprediction data clusters toward 0.

Two groups of predictor functions are supported. The first, the TIFF group,
consists of the single function that is Predictor 2 in the TIFF standard. (In the
TIFF standard, Predictor 2 applies only to LZW compression, but here it applies
to Flate compression as well.) TIFF Predictor 2 predicts that each color
component of a sample is the same as the corresponding color component of the
sample immediately to its left.

The second supported group of predictor functions, the PNG group, consists of
the filters of the World Wide Web Consortium’s Portable Network Graphics
recommendation, documented in Internet RFC 2083, PNG (Portable Network
Graphics) Specification (see the Bibliography). The term predictors is used here
instead of filters to avoid confusion. There are five basic PNG predictor
algorithms (and a sixth that chooses the optimum predictor function separately
for each row):

  None        No prediction
  Sub         Predicts the same as the sample to the left
  Up          Predicts the same as the sample above
  Average     Predicts the average of the sample to the left and the sample above
  Paeth       A nonlinear function of the sample above, the sample to the left,
              and the sample to the upper left

The predictor algorithm to be used, if any, is indicated by the Predictor filter
parameter (see Table 3.7), which can have any of the values listed in Table 3.8.

For LZWDecode and FlateDecode, a Predictor value greater than or equal to 10
merely indicates that a PNG predictor is in use; the specific predictor function
used is explicitly encoded in the incoming data. The value of Predictor supplied
by the decoding filter need not match the value used when the data was encoded
if they are both greater than or equal to 10.

Previous Next