Free Bilinear Interpolation Calculator

Rectangle Corners

Corner Values

Interpolation Point

Enter corner coordinates, values, and interpolation point above, then click Calculate

Understanding Bilinear Interpolation

Bilinear interpolation is a key technique in two-dimensional interpolation. It estimates an unknown function's value at a point inside a rectangle using the values at the rectangle's four corners. This method is essential in computer vision, image processing, and many other fields where rectilinear data needs to be approximated.

The Four Corner Points

Assume we know an unknown function's values at the corners of a rectangle defined by coordinates (x1,y1)(x_1, y_1), (x1,y2)(x_1, y_2), (x2,y1)(x_2, y_1), and (x2,y2)(x_2, y_2). The known values are:

  • Q11Q_{11} at (x1,y1)(x_1, y_1)
  • Q12Q_{12} at (x1,y2)(x_1, y_2)
  • Q21Q_{21} at (x2,y1)(x_2, y_1)
  • Q22Q_{22} at (x2,y2)(x_2, y_2)

We want to compute the interpolated value PP at a location (x,y)(x, y) inside this rectangle.

How the Formula Works

We obtain PP through three successive linear interpolations. First, interpolate along the horizontal direction at the top and bottom y-levels:

R1=x2−xx2−x1Q11+x−x1x2−x1Q21R_1 = \frac{x_2 - x}{x_2 - x_1} Q_{11} + \frac{x - x_1}{x_2 - x_1} Q_{21} R2=x2−xx2−x1Q12+x−x1x2−x1Q22R_2 = \frac{x_2 - x}{x_2 - x_1} Q_{12} + \frac{x - x_1}{x_2 - x_1} Q_{22}

Then interpolate vertically between R1R_1 and R2R_2:

P=y2−yy2−y1R1+y−y1y2−y1R2P = \frac{y_2 - y}{y_2 - y_1} R_1 + \frac{y - y_1}{y_2 - y_1} R_2

Replacing R1R_1 and R2R_2 gives the complete bilinear interpolation formula:

P=(x2−x)(y2−y)(x2−x1)(y2−y1)Q11+(x−x1)(y2−y)(x2−x1)(y2−y1)Q21+(x2−x)(y−y1)(x2−x1)(y2−y1)Q12+(x−x1)(y−y1)(x2−x1)(y2−y1)Q22P = \frac{(x_2 - x)(y_2 - y)}{(x_2 - x_1)(y_2 - y_1)} Q_{11} + \frac{(x - x_1)(y_2 - y)}{(x_2 - x_1)(y_2 - y_1)} Q_{21} + \frac{(x_2 - x)(y - y_1)}{(x_2 - x_1)(y_2 - y_1)} Q_{12} + \frac{(x - x_1)(y - y_1)}{(x_2 - x_1)(y_2 - y_1)} Q_{22}

A matrix representation is also available for those familiar with linear algebra.

Using the Bilinear Interpolation Calculator

To use the tool, simply input:

  • The rectangle corner coordinates x1,y1,x2,y2x_1, y_1, x_2, y_2
  • The four known values Q11,Q12,Q21,Q22Q_{11}, Q_{12}, Q_{21}, Q_{22}
  • The target point coordinates x,yx, y

The calculator automatically applies the bilinear interpolation formula and returns the estimated value PP. It's a quick way to perform two-dimensional interpolation without manually computing the weights.

Step-by-Step Example

Suppose we have the following data:

  • Q11=12Q_{11}=12 at (0,1)(0,1)
  • Q12=−4Q_{12}=-4 at (0,3)(0,3)
  • Q21=0Q_{21}=0 at (4,1)(4,1)
  • Q22=8Q_{22}=8 at (4,3)(4,3)

We want the value at (1,2)(1,2).

Set x1=0x_1=0, x2=4x_2=4, y1=1y_1=1, y2=3y_2=3. Compute the necessary products:

(x2−x1)(y2−y1)=4×2=8(x_2 - x_1)(y_2 - y_1) = 4 \times 2 = 8 (x2−x)(y2−y)=3×1=3(x_2 - x)(y_2 - y) = 3 \times 1 = 3 (x−x1)(y2−y)=1×1=1(x - x_1)(y_2 - y) = 1 \times 1 = 1 (x2−x)(y−y1)=3×1=3(x_2 - x)(y - y_1) = 3 \times 1 = 3 (x−x1)(y−y1)=1×1=1(x - x_1)(y - y_1) = 1 \times 1 = 1

Now insert into the formula:

P=38⋅12+18⋅0+38⋅(−4)+18⋅8P = \frac{3}{8} \cdot 12 + \frac{1}{8} \cdot 0 + \frac{3}{8} \cdot (-4) + \frac{1}{8} \cdot 8 P=368−128+88=328=4P = \frac{36}{8} - \frac{12}{8} + \frac{8}{8} = \frac{32}{8} = 4

Therefore, the interpolated value at (1,2)(1,2) is 4.

Important Characteristics

  • Weighted average: The result is a weighted sum of the corner values. The weight for each corner is proportional to the area of the opposite sub-rectangle, meaning closer corners have more influence.
  • Linearity: The formula is linear with respect to the corner values Q11Q_{11} through Q22Q_{22}. It is also linear along any row (constant yy) or column (constant xx).
  • Overall quadratic behavior: When considered as a function of both xx and yy, the interpolation is quadratic due to the presence of the xyxy bilinear term.

These properties make bilinear interpolation a widely used compromise between simplicity and smoothness in two-dimensional tasks like image scaling and data interpolation on rectangular grids.

FAQ

1. What is bilinear interpolation and what are its main applications?

Bilinear interpolation is a two-dimensional interpolation method that estimates a function's value inside a rectangle using the four corner values. It is widely used in computer vision, image processing, image resizing, and numerical analysis.

2. How do I use the bilinear interpolation calculator?

Enter the rectangle corner coordinates (x₁, y₁, x₂, y₂), the four known function values (Q₁₁, Q₁₂, Q₂₁, Q₂₂), and the target point (x, y). The tool automatically calculates the interpolated value using the bilinear interpolation formula.

3. What is the mathematical formula for bilinear interpolation?

P = ((x₂-x)(y₂-y))/((x₂-x₁)(y₂-y₁)) Q₁₁ + ((x-x₁)(y₂-y))/((x₂-x₁)(y₂-y₁)) Q₂₁ + ((x₂-x)(y-y₁))/((x₂-x₁)(y₂-y₁)) Q₁₂ + ((x-x₁)(y-y₁))/((x₂-x₁)(y₂-y₁)) Q₂₂. It can also be expressed in matrix form.

4. What are the key properties of bilinear interpolation?

It is a weighted average of the corner values, linear in the corner values and along horizontal/vertical lines, but quadratic in (x,y) due to the xy term.

How to Use

  1. Enter the coordinates of the rectangle corners: x₁, y₁ (first corner) and x₂, y₂ (second corner).
  2. Enter the known function values at each corner: Q₁₁, Q₁₂, Q₂₁, and Q₂₂.
  3. Enter the interpolation point (x, y) and click Calculate to get the estimated value P using bilinear interpolation.