Bilinear Interpolation
Bilinear interpolation is a method for Interpolation in two dimensions that performs Linear Interpolation sequentially in each direction.
Problem Setup
Given four points forming the corners of a rectangle:
- where
- where
- where
- where
We want to find for a point inside the rectangle, where and .
Method
Bilinear interpolation is performed in two steps:
Step 1: Interpolate in the X-direction
First, interpolate at and :
Step 2: Interpolate in the Y-direction
Then interpolate between and :
Combined Formula
Substituting Step 1 into Step 2 gives the full bilinear interpolation formula:
This can be expanded and written in matrix form:
Order of Interpolation
The order doesn’t matter - interpolating first in then in gives the same result. This is because:
- Linear interpolation is a linear operation
- The order of linear operations doesn’t affect the result
Properties
- Bilinearity: The function is linear in each variable when the other is held constant
- Exactness: For bilinear functions , bilinear interpolation is exact
- Continuity: Result is continuous across rectangle boundaries
- Not smooth: Generally not differentiable at grid points
Special Case: Unit Square
For a unit square with corners at , the formula simplifies to:
This shows the weighted average interpretation, where weights are the areas of opposite rectangles.
Advantages
- Simple and fast: Only requires four function evaluations
- Smooth: Produces continuous (but not necessarily differentiable) results
- Natural extension: Direct generalization of Linear Interpolation to 2D
- Exact for bilinear functions: Perfect for functions of form
Limitations
- Limited accuracy: Only captures linear and bilinear behaviour
- Non-smooth: Derivatives discontinuous at grid boundaries
- Rectangular grid required: Needs data on a regular grid
- Poor for highly curved surfaces: Cannot capture complex curvature
Applications
-
Image processing:
- Resizing/scaling images
- Texture mapping in computer graphics
- Digital zoom
-
Scientific computing:
- Temperature/pressure field interpolation
- Geographical data interpolation
- Finite element analysis
-
Computer graphics:
- Texture mapping
- Anti-aliasing
- Mipmap generation
Python Implementation
def bilinear_interpolation(x_target, y_target, x1, x2, y1, y2,
f_x1_y1, f_x1_y2, f_x2_y1, f_x2_y2):
"""
Perform bilinear interpolation on a rectangular grid.
Parameters
----------
x_target : float
Target x-coordinate for interpolation
y_target : float
Target y-coordinate for interpolation
x1, x2 : float
Lower and upper x-coordinates of rectangle
y1, y2 : float
Lower and upper y-coordinates of rectangle
f_x1_y1, f_x1_y2, f_x2_y1, f_x2_y2 : float
Function values at the four corners
Returns
-------
float
Interpolated value at (x_target, y_target)
"""
# Interpolate in x direction at y=y1 and y=y2
f_x_y1 = ((x2 - x_target) / (x2 - x1)) * f_x1_y1 + \
((x_target - x1) / (x2 - x1)) * f_x2_y1
f_x_y2 = ((x2 - x_target) / (x2 - x1)) * f_x1_y2 + \
((x_target - x1) / (x2 - x1)) * f_x2_y2
# Interpolate in y direction
result = ((y2 - y_target) / (y2 - y1)) * f_x_y1 + \
((y_target - y1) / (y2 - y1)) * f_x_y2
return resultExtensions
- Trilinear interpolation: Extension to 3D
- Bicubic interpolation: Uses cubic polynomials for smoother results
- Higher-order: Biquadratic, biquartic, etc.
Related Methods
- Linear Interpolation: 1D equivalent
- Spline Interpolation: Smoother alternative
- Interpolation: General concept