interpolation - computer graphicsgraphics.stanford.edu/.../interpolation.pdf · nearest-neighbor...
TRANSCRIPT
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation
CS 205A:Mathematical Methods for Robotics, Vision, and Graphics
Justin Solomon
CS 205A: Mathematical Methods Interpolation 1 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
So Far
Tools for analyzingfunctions:
Roots, minima, ...
CS 205A: Mathematical Methods Interpolation 2 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Common Situation
The function is theunknown.
CS 205A: Mathematical Methods Interpolation 3 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Examples
I Image processingI ML and statistics
CS 205A: Mathematical Methods Interpolation 4 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Input/Output
~xi 7→ yi
Holds exactly
Contrast with regression
CS 205A: Mathematical Methods Interpolation 5 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Initial Problem
f : R→ R
xi 7→ yi
CS 205A: Mathematical Methods Interpolation 6 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Initial Problem
f : R→ Rxi 7→ yi
CS 205A: Mathematical Methods Interpolation 6 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
The Problem
{f : R→ R}is a huge set.
CS 205A: Mathematical Methods Interpolation 7 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Common Strategy
Restrict search to a basis φ1, φ2, . . .
f(x) =∑i
aiφi(x)
~a unknown.
CS 205A: Mathematical Methods Interpolation 8 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Common Strategy
Restrict search to a basis φ1, φ2, . . .
f(x) =∑i
aiφi(x)
~a unknown.
CS 205A: Mathematical Methods Interpolation 8 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Monomial Basis
p0(x) = 1
p1(x) = x
p2(x) = x2
p3(x) = x3
......
f(x) = a0 + a1x+ a2x2 + · · ·+ ak−1x
k−1
CS 205A: Mathematical Methods Interpolation 9 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Vandermonde System
1 x1 x21 · · · xk−11
1 x2 x22 · · · xk−12...
...... · · · ...
1 xk−1 x2k−1 · · · xk−1k−1
a0a1...
ak−1
=
y0y1...
yk−1
Basis looks similar on [0, 1]!
CS 205A: Mathematical Methods Interpolation 10 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Vandermonde System
1 x1 x21 · · · xk−11
1 x2 x22 · · · xk−12...
...... · · · ...
1 xk−1 x2k−1 · · · xk−1k−1
a0a1...
ak−1
=
y0y1...
yk−1
Basis looks similar on [0, 1]!
CS 205A: Mathematical Methods Interpolation 10 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Lagrange Basis
φi(x) ≡∏
j 6=i(x− xj)∏j 6=i(xi − xj)
Still polynomial!
CS 205A: Mathematical Methods Interpolation 11 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Useful Property
φi(x`) =
{1 when ` = i0 otherwise.
CS 205A: Mathematical Methods Interpolation 12 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation in Lagrange Basis
f (x) ≡∑i
yiφi(x)
O(n2) time.
Numerical issues.
CS 205A: Mathematical Methods Interpolation 13 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation in Lagrange Basis
f (x) ≡∑i
yiφi(x)
O(n2) time.
Numerical issues.CS 205A: Mathematical Methods Interpolation 13 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Compromise: Newton Basis
ψi(x) =
i−1∏j=1
(x− xj)
ψ1(x) ≡ 1
CS 205A: Mathematical Methods Interpolation 14 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Evaluating in Newton
f (x1) = c1ψ1(x1)
f (x2) = c1ψ1(x2) + c2ψ2(x2)
f (x3) = c1ψ1(x3) + c2ψ2(x3) + c3ψ3(x3)... ...
CS 205A: Mathematical Methods Interpolation 15 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Triangular System
ψ1(x1) 0 0 · · · 0ψ1(x2) ψ2(x2) 0 · · · 0ψ1(x3) ψ2(x3) ψ3(x3) · · · 0
......
... · · · ...ψ1(xk) ψ2(xk) ψ3(xk) · · · ψk(xk)
c1c2...ck
=
y1y2...yk
CS 205A: Mathematical Methods Interpolation 16 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Important Point
All three methods yield thesame polynomial.
CS 205A: Mathematical Methods Interpolation 17 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 18 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 18 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 18 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Fourier Analysis
cos(kx)
sin(kx)
CS 205A: Mathematical Methods Interpolation 19 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Problem with Polynomials
Local change can have global effect.
Compact support
A function g(x) has compact support if there
exists C ∈ R such that g(x) = 0 for any x with
|x| > C.
CS 205A: Mathematical Methods Interpolation 20 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Problem with Polynomials
Local change can have global effect.
Compact support
A function g(x) has compact support if there
exists C ∈ R such that g(x) = 0 for any x with
|x| > C.
CS 205A: Mathematical Methods Interpolation 20 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Polynomials
I Piecewise constant: Find xi minimizing |x− xi|and define f(x) = yi.
I Piecewise linear: If x < x1 take f(x) = y1, and ifx > xk take f(x) = yk. Otherwise, findx ∈ [xi, xi+1] and define
f(x) = yi+1 ·x− xixi+1 − xi
+ yi ·(1− x− xi
xi+1 − xi
).
CS 205A: Mathematical Methods Interpolation 21 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Constant Basis
φi(x) =
{1 when
xi−1+xi2 ≤ x <
xi+xi+12
0 otherwise
CS 205A: Mathematical Methods Interpolation 22 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Linear Basis:“Hat” Functions
ψi(x) =
x−xi−1xi−xi−1
when xi−1 < x ≤ xixi+1−xxi+1−xi
when xi < x ≤ xi+1
0 otherwise
CS 205A: Mathematical Methods Interpolation 23 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Observation
Extra differentiability ispossible and may look nicer
but can be undesirable.
CS 205A: Mathematical Methods Interpolation 24 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Multidimensional Problem
f : Rn→ R
~xi 7→ yi
CS 205A: Mathematical Methods Interpolation 25 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Multidimensional Problem
f : Rn→ R~xi 7→ yi
CS 205A: Mathematical Methods Interpolation 25 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Nearest-Neighbor Interpolation
Definition (Voronoi cell)
Given S = {~x1, ~x2, . . . , ~xk} ⊆ Rn, the Voronoi cellcorresponding to ~xi is
Vi ≡ {~x : ‖~x− ~xi‖2 < ‖~x− ~xj‖2 for all j 6= i}.
That is, it is the set of points closer to ~xi than to anyother ~xj in S.
CS 205A: Mathematical Methods Interpolation 26 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Voronoi Cells
http://en.wikipedia.org/wiki/File:Euclidean_Voronoi_Diagram.png
CS 205A: Mathematical Methods Interpolation 27 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Barycentric Interpolation
n+ 1 points in Rn
∑i
ai~xi = ~x∑i
ai = 1
f(~x) =∑i
ai(~x)yi
CS 205A: Mathematical Methods Interpolation 28 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Barycentric Interpolation
n+ 1 points in Rn
∑i
ai~xi = ~x∑i
ai = 1
f(~x) =∑i
ai(~x)yi
CS 205A: Mathematical Methods Interpolation 28 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Generalized Barycentric Coordinates
http://www.cs.technion.ac.il/~weber/Publications/Complex-Coordinates/
CS 205A: Mathematical Methods Interpolation 29 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Localized Barycentric Interpolation:Triangle Hat Functions
K. Crane, Caltech CS 177, “Discrete Differential Geometry”
CS 205A: Mathematical Methods Interpolation 30 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation on a Grid
CS 205A: Mathematical Methods Interpolation 31 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Linear Algebra of Functions
〈f, g〉 ≡∫ b
a
f(x)g(x) dx
Measures “overlap” of functions!
CS 205A: Mathematical Methods Interpolation 32 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Orthogonal Polynomials
I Legendre: Apply Gram-Schmidt to
1, x, x2, x3, . . .
I Chebyshev: Same, with weighted inner
product
w(x) =1√
1− x2Nice oscillatory properties; minimizes ringing.
CS 205A: Mathematical Methods Interpolation 33 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Question
What is the least-squaresapproximation of f in a set
of polynomials?
CS 205A: Mathematical Methods Interpolation 34 / 35
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Polynomial Error
I Piecewise constant:
O(∆x)
I Piecewise linear:
O(∆x2)
Next
CS 205A: Mathematical Methods Interpolation 35 / 35