Bilinear interpolation

From Wikipedia, the free encyclopedia

In mathematics, bilinear interpolation is an extension of linear interpolation for interpolating functions of two variables. The key idea is to perform linear interpolation first in one direction, and then in the other direction.

The four red dots show the data points and the green dot is the point at which we want to interpolate.
Enlarge
The four red dots show the data points and the green dot is the point at which we want to interpolate.

Suppose that we want to find the value of the unknown function f at the point P = (x, y). It is assumed that we know the value of f at the four points Q11 = (x1y1), Q12 = (x1y2), Q21 = (x2y1), and Q22 = (x2y2).

We first do linear interpolation in the x-direction. This yields

f(R_1) \approx \frac{x_2-x}{x_2-x_1} f(Q_{11}) + \frac{x-x_1}{x_2-x_1} f(Q_{21}) \quad\mbox{where}\quad R_1 = (x,y_1),
f(R_2) \approx \frac{x_2-x}{x_2-x_1} f(Q_{12}) + \frac{x-x_1}{x_2-x_1} f(Q_{22}) \quad\mbox{where}\quad R_2 = (x,y_2).

We proceed by interpolating in the y-direction.

f(P) \approx \frac{y_2-y}{y_2-y_1} f(R_1) + \frac{y-y_1}{y_2-y_1} f(R_2).

This gives us the desired estimate of f(x, y).

f(x,y) \approx \frac{f(Q_{11})}{(x_2-x_1)(y_2-y_1)} (x_2-x)(y_2-y) + \frac{f(Q_{21})}{(x_2-x_1)(y_2-y_1)} (x-x_1)(y_2-y)
+ \frac{f(Q_{12})}{(x_2-x_1)(y_2-y_1)} (x_2-x)(y-y_1) + \frac{f(Q_{22})}{(x_2-x_1)(y_2-y_1)} (x-x_1)(y-y_1).

If we choose a coordinate system in which the four points where f is known are (0, 0), (0, 1), (1, 0), and (1, 1), then the interpolation formula simplifies to

f(x,y) \approx f(0,0) \, (1-x)(1-y) + f(1,0) \, x(1-y) + f(0,1) \, (1-x)y + f(1,1) xy.

Or equivalently, in matrix operations:

f(x,y) \approx \begin{bmatrix} 1-x & x \end{bmatrix} \begin{bmatrix} f(0,0) & f(0,1) \\ f(1,0) & f(1,1) \end{bmatrix} \begin{bmatrix} 1-y \\ y \end{bmatrix}

Contrary to what the name suggests, the interpolant is not linear. Instead, it is of the form

(a_1 x + a_2)(a_3 y + a_4), \,

so it is a product of two linear function. Alternatively, the interpolant can be written as

b_1 + b_2 x + b_3 y + b_4 x y. \,

In both cases, the number of constants (four) correspond to the number of data points where f is given.

The result of bilinear interpolation is independent of the order of interpolation. If we had first performed the linear interpolation in the y-direction and then in the x-direction, the resulting approximation would be the same.

The obvious extension of bilinear interpolation to three dimensions is called trilinear interpolation.

[edit] See also

In other languages