Computing Interpolated Values - Computing Interpolated Values - 2025.2 English - XD100

Vitis Tutorials: AI Engine Development (XD100)

Document ID
XD100
Release Date
2026-03-27
Version
2025.2 English

The following figure shows the problem of bilinear interpolation. It is assumed you know the values of a function at points \((x_1, y_1)\), \((x_1, y_2)\), \((x_2, y_1)\), and \((x_2, y_2)\) defined on a grid, which for practical purposes, can be assumed to be rectilinear. The goal is to estimate the function value at a point with coordinates \((x_q, y_q)\) by using the known values at the surrounding points. In the following figure, green dots represent known values, and the red dot represents the value to be estimated.

figure1

Figure 1 - Bilinear Interpolation Problem

Bilinear interpolation is a two-step process, where linear interpolation is first performed over one dimension then the other. The following figure shows the first step of the process. Here, the function values at the blue dots are computed from the known values at the green dots, using linear interpolation over the variable \(x\).

figure2

Figure 2 - First Linear Interpolation

These two intermediate points can be expressed in terms of the known values as

\[f(x_q,y_1) = \frac{(x_2-x_q)}{(x_2-x_1)}f(x_1,y_1) + \frac{(x_q-x_1)}{(x_2-x_1)}f(x_2,y_1)\]

and

\[f(x_q,y_2) = \frac{(x_2-x_q)}{(x_2-x_1)}f(x_1,y_2) + \frac{(x_q-x_1)}{(x_2-x_1)}f(x_2,y_2).\]

Figure 3 shows the second step of the process, where the desired value at the red dot is derived from the computed values at the blue dots using linear interpolation over the variable \(y\).

figure3

Figure 3 - Second Linear Interpolation

The resulting interpolated point is

\[f(x_q,y_q) = \frac{(y_2-y_q)}{(y_2-y_1)}f(x_q,y_1) + \frac{(y_q-y_1)}{(y_2-y_1)}f(x_q,y_2).\]

Combining equations, the bilinear interpolation formula can be expressed as

\[\begin{split}f(x_q,y_q) = \frac{1}{(x_2-x_1)(y_2-y_1)} \begin{bmatrix} x_2-x_q & x_q-x_1 \end{bmatrix} \begin{bmatrix} f(x_1,y_1) & f(x_1,y_2) \\ f(x_2,y_1) & f(x_2,y_2) \end{bmatrix} \begin{bmatrix} y_2-y_q \\ y_q-y_1 \end{bmatrix}.\end{split}\]