Cubic interpolation constructs a degree-three polynomial that matches four specified values. It is useful when a straight or projective transformation cannot represent curvature, such as a bent book page. section 8.1.3
A practical single-variable construction follows these steps:
- Place four input values at x = 0, 1/3, 2/3, and 1. section 8.1.3
Unbending a photographed page
A scanning app maps a flat page to a standard square and then maps that square onto a manually outlined, curved page. Cubic interpolation supplies curvature along the bent direction while retaining linear behavior along the normally straight direction. section 8.1.3
Listing 8.3 Getting coefficients for a generic cubic interpolation formula
from sympy import *
z1, z2, z3, z4, a, b, c, d = symbols('z1 z2 z3 z4 a b c d')
print(solve([
d - z1,
a * 1./27. + b * 1./9. + c * 1./3. + d - z2,
a * 8./27. + b * 4./9. + c * 1./3. + d - z3,
a + b + c + d - z4,
], (a, b, c, d)))
The SymPy listing turns four interpolation constraints into generic cubic coefficients, making the algebra directly testable. section 8.1.3
