While you can apply bilinear interpolation to various applications, this tutorial uses an image processing example. In this case, function values correspond to pixel values in the range [0, 255]. Single precision, floating-point numerical format is assumed for interpolated pixel values and interpolation coordinates \((x_q,y_q)\).
A reference image generates a lookup table which provides input to the AI Engine. An input image with resolution \(x_{res} \times y_{res}\) is assumed to have pixels defined on a grid with unit spacing. You can combine the \(x\) and \(y\) pixel coordinates using the equation \(I = x \times y_{res} + y\) to derive a LUT index \(I\), as shown in the following figure.
Figure 4 - Image as a Lookup Table
For any query point, \((x_q,y_q)\), the floating point coordinates can separate into integer and fractional parts, where \(x_q = x_{int}.x_{frac}\) and \(y_q = y_{int}.y_{frac}\). The integer parts extract pixel values used in the interpolation equation. The four values required for interpolation derive from the LUT using the following relations:
The preceding figure shows an example of LUT indexing using the pixels marked with X. When the four pixel values required for interpolation are obtained, the integer parts of the coordinates \((x_q,y_q)\) are no longer needed and you can assume these to be zero. This simplifies the interpolation equation to
or expressed as an inner product