Category

Bilinear Interpolation Calculator — 2D Interpolation on a Rectangle

Estimate the value of an unknown function at any point inside a rectangle from its four corner values using bilinear interpolation. Enter the corner coordinates (x1, y1, x2, y2), the values Q11, Q12, Q21, Q22, and the target point (x, y) to get P with a full step-by-step solution. Supports plain numbers, currencies (USD, RUB, EUR…), metric and US/Imperial units.

0 calculations

Calculator Parameters

Enter the Data

Enter the four corner points, their values, and the target point to compute the bilinear interpolation P.

Welcome to CalcuGo's bilinear interpolation calculator! Are you a bilinear interpolation professional? Or rather wondering what bilinear interpolation is all about? Here you can find a brief overview of the bilinear interpolation method as well as a detailed explanation and derivation of the formula for bilinear interpolation. As a bonus, we provide an example of how to perform bilinear interpolation by hand.

What is a bilinear interpolation?

Bilinear interpolation is a popular method for two-dimensional interpolation on a rectangle. That is, we assume that we know the values of some unknown function at four points that form a rectangle. Let these points equal (x₁, y₁), (x₁, y₂), (x₂, y₁) and (x₂, y₂), and the values of the function are the following:

  • The value at (x₁, y₁) is Q₁₁;
  • The value at (x₁, y₂) is Q₁₂;
  • The value at (x₂, y₁) is Q₂₁; and
  • The value at (x₂, y₂) is Q₂₂.

Using bilinear interpolation, we can estimate this function's value at any point (x, y) inside this rectangle. We will denote this unknown value by P.

This interpolation scheme is widespread and has many applications, in particular in computer vision and image processing (for example, when resizing or rotating images). It is based on a much simpler and widely taught procedure of linear interpolation. It's worth knowing that the data required for bilinear interpolation is often collected in the form of a small table with the four corner values.

How to use this bilinear interpolation calculator?

Using this calculator is straightforward:

  1. Choose the unit of the values (a plain number, a currency, or an imperial/metric unit). The mathematics is identical no matter which you pick — the unit is only used to label the result.
  2. Enter the coordinates of the base points of interpolation: x₁, y₁, x₂, y₂ (the corners of the rectangle).
  3. Enter the four values at these corners: Q₁₁, Q₁₂, Q₂₁, Q₂₂.
  4. Enter the point x, y at which you want to interpolate the unknown function.

That's it! Our bilinear interpolation calculator returns the result, i.e., the value of P at (x, y), together with a full step-by-step solution. A piece of cake, isn't it? 🍰

Bilinear interpolation formula

The general idea of the bilinear interpolation method is the following:

  • Start by performing two linear interpolations in the x-direction (horizontal): first at (x, y₁), then at (x, y₂).
  • Next, perform a linear interpolation in the y-direction (vertical): use the interpolated values at (x, y₁) and (x, y₂) to obtain the interpolation at the final point (x, y).

Step 1. The linear interpolation of the function at (x, y₁), using Q₁₁ and Q₂₁:

R₁ = [(x₂ − x)/(x₂ − x₁)]·Q₁₁ + [(x − x₁)/(x₂ − x₁)]·Q₂₁

Step 2. The linear interpolation of the function at (x, y₂), using Q₁₂ and Q₂₂:

R₂ = [(x₂ − x)/(x₂ − x₁)]·Q₁₂ + [(x − x₁)/(x₂ − x₁)]·Q₂₂

Step 3. Finally, the linear interpolation at (x, y), using R₁ and R₂:

P = [(y₂ − y)/(y₂ − y₁)]·R₁ + [(y − y₁)/(y₂ − y₁)]·R₂

Substituting R₁ and R₂ and getting rid of the intermediate values, we obtain the compact bilinear interpolation formula for P:

P = [ (x₂−x)(y₂−y)·Q₁₁ + (x−x₁)(y₂−y)·Q₂₁ + (x₂−x)(y−y₁)·Q₁₂ + (x−x₁)(y−y₁)·Q₂₂ ] / [ (x₂−x₁)(y₂−y₁) ]

Using vectors and matrices, the same formula can be written compactly as a product of a row vector in x, the 2×2 matrix of corner values, and a column vector in y — a handy form when you reach for a matrix multiplication tool.

Bilinear interpolation example

That was lots of theory, wasn't it? If you feel a bit overwhelmed, don't worry! In this section, we'll solve an example to show you how to use the bilinear interpolation formula in practice.

Assume that an unknown function has:

  • Value 12 at (0, 1);
  • Value −4 at (0, 3);
  • Value 0 at (4, 1); and
  • Value 8 at (4, 3).

We want to estimate the value of this function at (1, 2). Let's begin by writing down the data. For the rectangle corners:

x₁ = 0, x₂ = 4, y₁ = 1, y₂ = 3

The respective function values are:

Q₁₁ = 12, Q₂₁ = 0, Q₁₂ = −4, Q₂₂ = 8

The point at which we perform the bilinear interpolation is x = 1, y = 2. Let's calculate the terms that appear in the formula for P:

  • (x₂ − x₁) × (y₂ − y₁) = (4 − 0) × (3 − 1) = 8
  • (x₂ − x) × (y₂ − y) = (4 − 1) × (3 − 2) = 3
  • (x − x₁) × (y₂ − y) = (1 − 0) × (3 − 2) = 1
  • (x₂ − x) × (y − y₁) = (4 − 1) × (2 − 1) = 3
  • (x − x₁) × (y − y₁) = (1 − 0) × (2 − 1) = 1

Let's put those values together into the formula for P:

P = 3/8 × Q₁₁ + 1/8 × Q₂₁ + 3/8 × Q₁₂ + 1/8 × Q₂₂

It's time to substitute the values Q₁₁, Q₂₁, Q₁₂, and Q₂₂:

P = 3/8 × 12 + 1/8 × 0 + 3/8 × (−4) + 1/8 × 8

Finally, we have:

P = 9/2 − 3/2 + 1 = 4

Properties of bilinear interpolation

Let's look once again at the final formula for P and point out some of its properties:

  • It reduces to linear interpolation. If the point lies exactly on one edge of the rectangle (e.g., y = y₁), the formula collapses to ordinary linear interpolation in the remaining direction.
  • It reproduces the corner values. Plugging in any corner (for instance, x = x₁, y = y₁) returns exactly the value at that corner (Q₁₁). The interpolant passes through all four data points.
  • The weights are a convex combination. When (x, y) is inside the rectangle, the four coefficients are non-negative and sum to 1, so P always lies between the smallest and largest corner value.
  • It is not linear, but bilinear. Along any horizontal or vertical line the result is linear, yet along a diagonal it varies as a quadratic (there is an xy cross term). This is why it is called bilinear.
  • Order doesn't matter. Interpolating first in x then in y gives the same result as interpolating first in y then in x.

Metric vs. US (Imperial) units and currencies

Bilinear interpolation is unit-agnostic — the arithmetic is identical regardless of what the four corner values represent. This calculator therefore lets you tag the values with:

  • A plain number (dimensionless);
  • A currency — the US dollar, the Russian ruble, the euro, and many more — handy when interpolating prices or costs across a 2D grid;
  • Metric units (mm, cm, m, km, °C, kPa); or
  • US / Imperial units (in, ft, yd, mi, °F, psi).

Just keep all four corner values in the same unit, and the interpolated result P will be expressed in that same unit.

FAQ

What if my point is outside the rectangle?
The same formula still returns a value, but it is then an extrapolation rather than an interpolation, and it may be less reliable. The calculator flags this case with a note.
Why must x₁ ≠ x₂ and y₁ ≠ y₂?
If the two x-coordinates (or two y-coordinates) coincide, the rectangle degenerates to a line or a point and the denominator (x₂−x₁)(y₂−y₁) becomes zero, so the formula is undefined.
Does the order in which I enter the corners matter?
Each Q must match its corner: Q₁₁ at (x₁, y₁), Q₁₂ at (x₁, y₂), Q₂₁ at (x₂, y₁), and Q₂₂ at (x₂, y₂). As long as the pairing is correct, the result is the same.
How is this different from linear interpolation?
Linear interpolation works along a single dimension (between two points). Bilinear interpolation extends the idea to two dimensions (between four points on a rectangle) by chaining three linear interpolations.

Calculation History

Loading...