Lossless JPEG Predictor Functions Explained

The original JPEG standard (ITU-T T.81 / ISO/IEC 10918-1) defines a fully lossless mode of operation based on Differential Pulse Code Modulation (DPCM) instead of the traditional Discrete Cosine Transform (DCT). In this lossless mode, the encoder predicts the value of each pixel using the values of up to three neighboring, previously reconstructed pixels, and then encodes only the difference (prediction error) using Huffman or arithmetic coding. The standard defines eight distinct predictor selection values—ranging from 0 to 7—giving encoders flexibility to optimize compression depending on image characteristics.

The Neighboring Sample Layout

Predictors calculate the estimated value of the current sample, denoted as \(X\), using up to three neighboring reconstructed samples:

The Eight Predictor Functions

The JPEG specification designates the predictor via a 3-bit selection value (Ss) in the scan header:

Boundary Conditions

For edges where neighboring pixels do not exist, the standard defines specific fallbacks. For the first pixel in an image, a fixed baseline value determined by the sample precision is used (e.g., \(2^{P-1}\) where \(P\) is precision). For the remainder of the first row, predictor 1 (\(A\)) is enforced because samples \(B\) and \(C\) are unavailable. For the first column of subsequent rows, predictor 2 (\(B\)) is enforced because samples \(A\) and \(C\) do not exist.