Bilinear Light Field Interpolation
Interpolate color from a light field using bilinear interpolation.
Given a query position between captured camera positions, we interpolate from the four nearest cameras using bilinear weights:
where:
- is the fractional part in s
- is the fractional part in t
- are the colors at the four corner cameras, with corners through
- A corner missing from samples counts as color (this happens when the query lies on the last grid line, where that corner's weight is zero anyway)
This enables smooth transitions between camera positions.
Example
interpolate_lightfield({(0,0): 100, (1,0): 200, (0,1): 150, (1,1): 250}, 0.5, 0.5)175.0
samplesstores the colour captured by each camera on the integer grid: , , , .- The enclosing cell's lower corner is , so and .
- Each corner's weight is the area of the rectangle opposite it: , , and all equal here. The four weights always sum to .
- Blending in first gives the same answer: bottom edge , top edge , then in : .
- The output
175.0is the plain average of the four cameras, since the query is equidistant from all of them. - Notice that at an integer query such as , , so one camera takes all the weight and you get
250; the absent far corners like count as with zero weight.
Constraints
- samples: dict mapping (s, t) integer coordinates to color values
- query_s, query_t: floating-point query position
- Return interpolated color, rounded to 4 decimal places