A class representing bilinear interpolation. The class is marked 'final' so it may be either automatically or manually inlined.
Bilinear interpolation requires a neighborhood extending one pixel to the right and below the central sample. If the fractional subsample position is given by (xfrac, yfrac), the resampled pixel value will be:
(1 - yfrac) * [(1 - xfrac)*s00 + xfrac*s01] + yfrac * [(1 - xfrac)*s10 + xfrac*s11]
A neighborhood extending one sample to the right of, and one sample below the central sample is required to perform bilinear interpolation. This implementation maintains equal subsampleBits in x and y.
The diagrams below illustrate the pixels involved in one-dimensional bilinear interpolation. Point s0 is the interpolation kernel key position. xfrac and yfrac, indicated by the dots, represent the point of interpolation between two pixels. This value lies between 0.0 and 1.0 exclusive for floating point and 0 and 2subsampleBits exclusive for integer interpolations.
Horizontal Vertical s0 . s1 s0 ^ .< yfrac xfrac s1
The diagram below illustrates the pixels involved in two-dimensional bilinear interpolation.
s00 s01 . < yfrac s10 s11 ^ xfrac
The class is marked 'final' so that it may be more easily inlined.