Understanding Bilinear Interpolation
Bilinear interpolation is a method for estimating function values at any point within a rectangle bounded by four known data points. Given four corner points—(x₁, y₁), (x₁, y₂), (x₂, y₁), and (x₂, y₂)—with corresponding function values Q₁₁, Q₁₂, Q₂₁, and Q₂₂, you can determine the value P at any interior point (x, y).
Unlike simple linear interpolation that works in one dimension, bilinear interpolation extends the concept to two dimensions. The method systematically interpolates first along one axis, then along the perpendicular axis. This produces a smooth, continuous surface estimate across the rectangular region without requiring additional data points.
Common applications include:
- Digital image resizing and resampling
- Elevation mapping and terrain generation
- Texture mapping in 3D graphics
- Scientific data interpolation on regular grids
The Bilinear Interpolation Formula
The formula for bilinear interpolation combines weighted contributions from all four corner values. The weighting factors depend on the relative position of the interpolation point (x, y) within the rectangle.
P = [Q₁₁ × (x₂ − x) × (y₂ − y) + Q₂₁ × (x − x₁) × (y₂ − y) + Q₁₂ × (x₂ − x) × (y − y₁) + Q₂₂ × (x − x₁) × (y − y₁)] ÷ [(x₂ − x₁) × (y₂ − y₁)]
P— The interpolated value at point (x, y)Q₁₁, Q₁₂, Q₂₁, Q₂₂— Function values at the four corners of the rectanglex₁, x₂— X-coordinates of the rectangle boundariesy₁, y₂— Y-coordinates of the rectangle boundariesx, y— Coordinates of the point where you want to estimate the function value
Step-by-Step Calculation Example
Consider an unknown function with these corner values:
- At (0, 1): value = 12
- At (4, 1): value = 0
- At (0, 3): value = −4
- At (4, 3): value = 8
To find the estimated value at (1, 2):
Step 1: Identify your parameters: x₁ = 0, x₂ = 4, y₁ = 1, y₂ = 3, Q₁₁ = 12, Q₂₁ = 0, Q₁₂ = −4, Q₂₂ = 8, x = 1, y = 2
Step 2: Calculate the denominators: (x₂ − x₁) = 4, (y₂ − y₁) = 2, product = 8
Step 3: Compute each weighted term using the formula above, then sum and divide by 8. The result is approximately 1.
Key Properties and Behaviour
The bilinear interpolation formula exhibits several important mathematical characteristics:
- Linearity in values: The result is a weighted linear combination of the four corner values, ensuring that doubling all inputs doubles the output.
- Linear along axes: If you move horizontally (y constant) or vertically (x constant) across the rectangle, the interpolated value changes linearly.
- Quadratic in position: As a function of both x and y simultaneously, the interpolation becomes quadratic. This produces a smooth, curved surface rather than a flat plane.
- Weighted averaging: Each corner value contributes proportionally to its distance from the target point. Points closer to a corner have greater influence from that corner's value.
Practical Considerations and Common Pitfalls
When applying bilinear interpolation, several practical issues warrant attention.
- Stay within bounds — Bilinear interpolation is strictly an interpolation method, not extrapolation. Attempting to estimate values outside the rectangular region bounded by your four corners can produce unreliable or nonsensical results. Always ensure your target point (x, y) lies within or on the rectangle.
- Grid orientation matters — Verify that your four corner points actually form a rectangle with sides parallel to the x and y axes. If your data points are scattered or form a rotated rectangle, bilinear interpolation as described here will not work correctly. Consider alternative interpolation schemes for irregular grids.
- Data quality affects smoothness — Bilinear interpolation works best when your corner values are consistent and well-behaved. Extreme outliers or noise at the corners can create unrealistic estimates at interior points. If your data is noisy, consider preprocessing or using robust interpolation methods.
- Resolution and discretisation — When interpolating raster data like images, the spacing between grid points influences accuracy. Very widely spaced corner points may miss fine detail. Conversely, over-sampling can introduce computational overhead without improving accuracy if the underlying data resolution is coarse.