Interpolation and Deformations A short cookbook

23
1 Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 5 October 2021 Copyright © R. H. Taylor Interpolation and Deformations A short cookbook 1 Engineering Research Center for Computer Integrated Surgical Systems and Technology 2 600.445 Fall 2000; Updated: 5 October 2021 Copyright © R. H. Taylor Linear Interpolation [ ] 1 1 10 15 20 5 T ρ = = p ! [ ] 2 2 40 30 20 20 T ρ = = p ! [ ] 3 3 20 20 2 0 T ρ = = p ! 10 2

Transcript of Interpolation and Deformations A short cookbook

Page 1: Interpolation and Deformations A short cookbook

1

Engineering Research Center for Computer Integrated Surgical Systems and Technology1 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Interpolation and DeformationsA short cookbook

1

Engineering Research Center for Computer Integrated Surgical Systems and Technology2 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Linear Interpolation

[ ]1

1

10 15 205

T

ρ==

p!

[ ]2

2

40 30 2020

T

ρ==

p!

[ ]3

3

20 20 2??

0?

T

ρ==

p!

10

2

Page 2: Interpolation and Deformations A short cookbook

2

Engineering Research Center for Computer Integrated Surgical Systems and Technology3 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Linear Interpolation

[ ]1

1

10 15 20 T==

pq a

!

! !

[ ]2

2

40 30 20 T=

=

p

q b

!

!!

[ ]3

3

20 20 20???

T==

pq

!

! ( )13+ −a b a!! !

3

Engineering Research Center for Computer Integrated Surgical Systems and Technology4 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Linear Interpolation

2 2, Ap!

1 1, Ap!

( )3 1 2 1

3 ???Aλ= + −

=p p p p! ! ! !

1

λ

( )1 2 1A A Aλ= + −

( ) 1 21 A Aλ λ= − +

( ) ( )( ) ( )

3 1 2 1

2 1 2 1

λ− • −

=− • −

p p p pp p p p

! ! ! !! ! ! !

4

Page 3: Interpolation and Deformations A short cookbook

3

Engineering Research Center for Computer Integrated Surgical Systems and Technology5 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Linear Interpolation (Barycentric Form)

2 2, Ap!

1 1, Ap!

!p3 = µ!p1 + λ!p2 where λ+µ=1

A3 = µA1 + λA2

1

λ

( ) ( )( ) ( )

3 1 2 1

2 1 2 1

λ− • −

=− • −

p p p pp p p p

! ! ! !! ! ! !

µ

5

Engineering Research Center for Computer Integrated Surgical Systems and Technology6 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bilinear Interpolation

, 1i j+u! 1, 1i j+ +u!

1,i j+u!

( )1 λ−λ

( )1 λ−λ

( )1 µ−

µ

,i ju!

6

Page 4: Interpolation and Deformations A short cookbook

4

Engineering Research Center for Computer Integrated Surgical Systems and Technology7 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bilinear Interpolation

,i ju!

, 1i j+u! 1, 1i j+ +u!

1,i j+u!

( )1 λ−λ

( )1 µ−

µ

( )1 µ−

µ

( )( ) ( ) ( )( )( ) ( ) ( )1, 1 1, , 1 ,

, 1, , , 1 , 1, 1 ,

( , ) 1 1 1i j i j i j i j

i j i j i j i j i j i j i j

λ µ λ µ µ λ µ µ

λ µ λµ+ + + +

+ + + +

= + − + − + −

= + − + − + −

u u u u u

u u u u u u u

! ! ! ! !

! ! ! ! ! ! !

7

Engineering Research Center for Computer Integrated Surgical Systems and Technology8 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bilinear Interpolation

, ,,i j i jAu!

, 1 , 1,i j i jA+ +u! 1, 1 1, 1,i j i jA+ + + +u!

1, 1,;i j i jA+ +u!

( ) { }{ }, 1, 1, 1 , 1, interpolate( , , , , , )i j i j i j i jλ µ λ µ + + + +=u u u u u! ! ! ! !

( ) { }{ }, 1, 1, 1 , 1, interpolate( , , , , , )i j i j i j i jA A A A Aλ µ λ µ + + + +=

8

Page 5: Interpolation and Deformations A short cookbook

5

Engineering Research Center for Computer Integrated Surgical Systems and Technology9 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

N-linear Interpolation

{ }

{ }

( )

1 2

, , 1

, ,

NlinearInterpolate( , )

1 Nli

1

Let = , with 0 be a set of interpolation parameters, and let

be a set of constants. Then we define:

N

N N k

N

N

A A

Λ λ λ ≤ λ ≤

=

Λ =

− λ

A

A

{ }{ }

1

1

1 1 2

1 2 1 2

nearInterpolate( , , , )

NlinearInterpolate( , , , )

( ) ( , , )NlinearInterpolate( , )

1

NOTE: Sometimes in this situation we will use notation

N

N N

N

N N

N N

N

A A

A A

A A

− +

Λ

+ λ Λ

Λ = λ λ= Λ A

9

Engineering Research Center for Computer Integrated Surgical Systems and Technology10 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Interpolation

1p!

2p!

2 1λ −p p! !

( ) 2 11− λ −p p! !

( ) ( ) 2 11λ = − λ + λp p p! ! !( ) ( ) 2 1

1 2

1

1

λ = − λ + λ= λ + µ

λ + µ =

p p pp p

! ! !

! !

10

Page 6: Interpolation and Deformations A short cookbook

6

Engineering Research Center for Computer Integrated Surgical Systems and Technology11 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Interpolation

1p! 2p

!

3p!

( ), ????λ µ =p! ( ) ( )3 1 3 2 3

1 2 3

, ( )(1 )

λ µ = + λ − + µ −= λ + µ + − λ −µ

p p p p p pp p p

! ! ! ! ! !

! ! !( ) ( )

( )

3 1 3 2 3

1 2 3

1 2 3

, ( )(1 )

, , 1 where

λ µ = + λ − + µ −= λ + µ + − λ −µ

λ µ ν = λ + µ + ν λ + µ + ν =

p p p p p pp p p

p p p p

! ! ! ! ! !

! ! !

! ! ! !

( ) ( )

( )( )

3 1 3 2 3

1 2 3

1 2 3

1 2 3

, ( )(1 )

, , 1

, ,

where

A A A A

λ µ = + λ − + µ −= λ + µ + − λ −µ

λ µ ν = λ + µ + ν λ + µ + ν =

λ µ ν = λ + µ + ν

p p p p p pp p p

p p p p

! ! ! ! ! !

! ! !

! ! ! !

1A2A

3A

11

Engineering Research Center for Computer Integrated Surgical Systems and Technology12 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Interpolation

1p! 2p

!

3p!

31 2

1 1 1 1

λ⎡ ⎤⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥ = µ⎣ ⎦ ⎣ ⎦ ⎢ ⎥ν⎢ ⎥⎣ ⎦

pp pp !! !!1A

2A

3A

12

Page 7: Interpolation and Deformations A short cookbook

7

Engineering Research Center for Computer Integrated Surgical Systems and Technology13 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Interpolation

{ }

{ }

1

1 2

, , 1 1

, ,

BarycentricInterpolate( , )

N

N

N k kk

A A

=

Λ λ λ ≤ λ ≤ λ =

=

Λ =

A

A

!…

!…

!!

1

Let

= , with 0 and

be a set of interpolation parameters, and let

be a set of constants. Then we define:

1

( ) ( , , ) BarycentricInterpolate( , )

N

k kk

N N N

A=

Λ = λ

Λ = λ λ = Λ

∑A

A A A

!!i

…1

NOTE: Sometimes in this situation we will use notation NOTE: This is a special case of barycentric Bezier polynomial interpo stlations (here, 1 degree)

13

Engineering Research Center for Computer Integrated Surgical Systems and Technology14 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric InterpolationGiven n+1 n-dimensional points

!a0!

"an and a test point

!atest find

barycentric coordinates !λ=[λ0,...λn ] such that

!atest = λk

!akk∑

and λk =1.k∑

Solve!a0

1!!

"an1

⎢⎢⎢

⎥⎥⎥

λ0

!λn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=!atest

1

⎢⎢⎢

⎥⎥⎥

14

Page 8: Interpolation and Deformations A short cookbook

8

Engineering Research Center for Computer Integrated Surgical Systems and Technology15 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Interpolation (projection case)Given only n n-dimensional points

!a1!"an and a test point

!atest find

barycentric coordinates !λ=[λ0,...λn ] such that

!atest = λk

!akk∑

and λk =1.k∑

Solve!a1

1!!

"an1

⎢⎢⎢

⎥⎥⎥

λ0

!λn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

≈!atest

1

⎢⎢⎢

⎥⎥⎥

in a least-squares sense.

Note that this is useful in many cases where you want to store a pseudo-inverse for a triangle, tetrahedron, or other low-dimensional object for repeated interpolations.

1p! 2p

!

3p!

1A2A

3A

!p

!pproj

15

Engineering Research Center for Computer Integrated Surgical Systems and Technology16 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Interpolation of functions

v

( )y v

01

16

Page 9: Interpolation and Deformations A short cookbook

9

Engineering Research Center for Computer Integrated Surgical Systems and Technology17 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Fitting of interpolation curves• The discussion below follows (in part)

G. Farin, Curves and surfaces for computer-aided geometric design, a practical guide, Academic Press, Boston, 1990, chapter 10 and pp 281-284.

17

Engineering Research Center for Computer Integrated Surgical Systems and Technology18 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

v

01

Note that many forms of polynomial may be usedfor the PN,k (ν ). One common (not very good) choice

is the power basis:

PN,k (ν ) = ν k

Better choices are the Bernstein polynomials and the B-spline basis functions, which we will discuss ina moment

1-D InterpolationGiven set of known values y0(ν0),...,ym(νm){ },

find an approximating polynomial y ≈ P(c0,...,cN;ν )

P(c0,...,cN;ν ) = ckPN,k (ν )k=0

N

18

Page 10: Interpolation and Deformations A short cookbook

10

Engineering Research Center for Computer Integrated Surgical Systems and Technology19 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

1-D Interpolation

Given set of known values y0(ν0),...,ym(νm){ },

find an approximating polynomial y ≈ P(c0,...,cN;ν )

P(c0,...,cN;ν ) = ckPN,k (ν )k=0

N

To do this, solve:

PN,0(ν0) ! PN,N(ν0)

! " !PN,0(νm) ! PN,N(νm)

⎢⎢⎢⎢

⎥⎥⎥⎥

c0

!cN

⎢⎢⎢⎢

⎥⎥⎥⎥

y0

!ym

⎢⎢⎢⎢

⎥⎥⎥⎥

19

Engineering Research Center for Computer Integrated Surgical Systems and Technology20 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bezier and Bernstein Polynomials

• Excellent numerical stability for 0<v<1• There exist good ways to convert to more

conventional power basis

P c0,…,cN;v( ) = ckNk

⎛⎝⎜

⎞⎠⎟

1−v( )N−kvk

k=0

N

= ckBN,k (v)k=0

N

where BN,k (v) = Nk

⎛⎝⎜

⎞⎠⎟

1−v( )N−kvk

20

Page 11: Interpolation and Deformations A short cookbook

11

Engineering Research Center for Computer Integrated Surgical Systems and Technology21 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Barycentric Bezier Polynomials

• Excellent numerical stability for 0<u,v<1• There exist good ways to convert to more

conventional power basis

P c0,…,cN;u,v( ) = ckNk

⎛⎝⎜

⎞⎠⎟

uN−kvk

k=0

N

= ckBN,k (u,v)k=0

N

where BN,k (u,v) = Nk

⎛⎝⎜

⎞⎠⎟

uN−kvk u+v=1

21

Engineering Research Center for Computer Integrated Surgical Systems and Technology22 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bezier Curves

( )0 ,0

Suppose that the coefficients are multi-dimensional

vectors (e.g., 2D or 3D points). Then the polynomial

, , ; ( )

computed over the range 0 1 generates a Bezier

curve w

j

N

N k N kk

c

P c c v c B v

v=

=

≤ ≤

!!"

!!" !!" !!"…

ith control vertices .jc!!"

0c

1c

3c

2c

22

Page 12: Interpolation and Deformations A short cookbook

12

Engineering Research Center for Computer Integrated Surgical Systems and Technology23 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Bezier Curves: de Casteljau Algorithm

( )0 0

0

1 11

Given coefficients , Bezier curves can be generated

recursively by repeated linear interpolation:

, , ;

(1 )

j

NN

j jk k kj j j

c

P c c v b

where

b cb v b vb− −

+

=

== − +

!!"

!!" !!"…

!!"

0!c

1!c

3!c

2!c

( )1 v−v

vv

( )1 v−( )1 v−

23

Engineering Research Center for Computer Integrated Surgical Systems and Technology24 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Iterative Form of deCasteljau Algorithm

1

0

Step 1: for 0

Step 2 : for 1 step 1 until dofor 0 step 1 until do

(1 )

Step 3: return

j j

j j j

b c j Nk k Nj j N kb v b vbb

+

← ≤ ≤

← =← = −← − +

24

Page 13: Interpolation and Deformations A short cookbook

13

Engineering Research Center for Computer Integrated Surgical Systems and Technology25 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Advantages of Bezier Curves

• Numerically very robust• Many nice mathematical properties• Smooth

• “Global” (may be viewed as a disadvantage)

25

Engineering Research Center for Computer Integrated Surgical Systems and Technology27 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

B-splines

Given coefficient values C = {

!c0,",

!cL+D−1}

"knot points" u = {u0,",uL+2D−2 } with ui ≤ ui+1

D = "degree" of desired B-splineCan define an interpolated curve P(C,u; u) on uD−1 ≤ u < uL+D−1

Then

P(C;u) =!c j

j=0

L+D−1

∑ NjD (u)

where NjD (u) are B-spline basis polynomials (discussed later)

27

Page 14: Interpolation and Deformations A short cookbook

14

Engineering Research Center for Computer Integrated Surgical Systems and Technology28 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

B-Spline Polynomials

Some useful references include• http://en.wikipedia.org/wiki/B-spline• http://vision.ucsd.edu/~kbranson/research/bsplines/bsplines.pdf• http://scholar.lib.vt.edu/theses/available/etd-100699-171723/• https://www.cs.drexel.edu/~david/Classes/CS430/Lectures/L-

09_BSplines_NURBS.pdf• http://www.stat.columbia.edu/~ruf/ruf_bspline.pdf

28

Engineering Research Center for Computer Integrated Surgical Systems and Technology29 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

B-spline polynomials & B-spline basis functions

Given C,u,D as before

P(C,u;u) =!c j

j =0

L+D−1

∑ NjD (u)

where

Nj0(u) =

1 uj −1 ≤ u ≤ uj

0 Otherwise

⎧⎨⎪

⎩⎪

Njk (u) =

u − uj −1

uj +k−1 − uj −1

Njk−1(u) +

uj +k − uuj +k − uj

Nj +1k−1(u) for k > 0

29

Page 15: Interpolation and Deformations A short cookbook

15

Engineering Research Center for Computer Integrated Surgical Systems and Technology30 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

B-Spline Polynomials

For a B-spline polynomial

P(C,u; t) =!c j

j=0

L+D−1

∑ NjD (u, t)

the basis functions NjD (u, t) are a function of the degree of the polynomial

and the vector u = u0 ,",un⎡⎣ ⎤⎦ of "knot points". The polynomial is "uniform" if

the distance between knot points is evenly spaced and "non-uniform" otherwise.

30

Engineering Research Center for Computer Integrated Surgical Systems and Technology31 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

deBoor Algorithm (Farin)

Given u, c, D as before, can evaluate P(c,u;u)recursively as follows:

Step 1: Determine index i such that ui ≤ u < ui+1

Step 2: Determine multplicity r such that

ui−r = ui−r+1 =! = ui

Step 3: Set "d j

0 = c j for i −D +1≤ j ≤ i +1

Step 4: Compute P(c,u;u) = di+1D−r recursively, where

"dj

k =uj+D−k − u

uj+D−k − uj−1

"d j−1

k−1+u − uj−1

uj+D−k − uj−1

"d j

k−1 =α j

k "d j−1k−1

γ jk

+β j

k "d jk−1

γ jk

31

Page 16: Interpolation and Deformations A short cookbook

16

Engineering Research Center for Computer Integrated Surgical Systems and Technology32 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

deBoor Algorithm: Example D=3, r=0

!dj

k =uj+D−k − u

uj+D−k − uj−1

!d j−1

k−1 +u − uj−1

uj+D−k − uj−1

!d j

k−1 =α j

k !d j−1k−1

γ jk

+β j

k !d jk−1

γ jk

!di+1

3−0 =!p( ",

!ci ,"{ },3;u)

= α i+13 !

di2 + βi+1

3 !di+1

2( ) γ i+13 = ui+1 − u( ) !di

2 + (u − ui )!di+1

2( ) (ui+1 − u i )!di+1

2 = α i+12 !

di1 + βi+1

2 !di+1

1( ) γ i+12 = ui+2 − u( ) !di

1 + (u − ui )!di+1

1( ) (ui+2 − u i )!di

2 = α i2!di−1

1 + βi2!di

1( ) γ i2 = (u i+1 − u)

!di−1

1 + (u − ui−1)!di

1( ) (ui+1 − ui−1)!di+1

1 = α i+11 !

di0 + βi+1

1 !di+1

0( ) γ i+11 = ui+3 − u( ) !di

0 + (u − ui )!di+1

0( ) (ui+3 − u i )!di

1 = α i1!di−1

0 + βi1!di

0( ) γ i1 = (u i+2 − u)

!di−1

0 + (u − ui−1)!di

0( ) (ui+2 − ui−1)!di−1

1 = α i−11 !

di−20 + βi−1

1 !di−1

0( ) γ i−11 = (u i+1 − u)

!di−2

0 + (u − ui−2)!di−1

0( ) (ui+1 − ui−2)

32

Engineering Research Center for Computer Integrated Surgical Systems and Technology33 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

deBoor Algorithm (alternative formula)

Given u, c, D as before, can evaluate P(c,u;u)recursively as follows:

Step 1: Determine index i such that ui ≤ u < ui+1

Step 2: Determine multplicity r such that

ui−r = ui−r+1 =! = ui

Step 3: Set "d j

0 = c j for i −D +1≤ j ≤ i +1

Step 4: Compute P(c,u;u) = di+1D−r recursively, where

"dj

k = (1−αk, j )"d j−1

k−1+αk, j"d j

k−1 where αk,i =u − uj

uj+D+1−k − uj

An alternative formulation from Wikipedia is given as:

Source: https://en.wikipedia.org/wiki/De_Boor%27s_algorithm

33

Page 17: Interpolation and Deformations A short cookbook

17

Engineering Research Center for Computer Integrated Surgical Systems and Technology39 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Uniform B-Spline Polynomials

Third degree uniform B-spline P(C,u; t) =!c jNj

2 (u, t)j∑ with t j = j

Nj3 (u, t) =

16

(t − j )2 if j ≤ t < j +1

16

−3 t − j −1( )3+ 3 t − j −1( )2

+ 3 t − j −1( ) +1⎡⎣⎢

⎤⎦⎥

if j+1≤ t < j+ 2

16

3 t − j −1( )3− 6 t − j −1( )2

+ 4⎡⎣⎢

⎤⎦⎥

if j+ 2 ≤ t < j+ 3

16

1− t − j −1( )⎡⎣ ⎤⎦3

if j+ 3 ≤ t < j+ 4

0 otherwise

⎪⎪⎪⎪⎪

⎪⎪⎪⎪⎪

http://vision.ucsd.edu/~kbranson/research/bsplines/bsplines.pdf

39

Engineering Research Center for Computer Integrated Surgical Systems and Technology40 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Some advantages of B-splines• Efficient• Numerically stable • Smooth• Local

40

Page 18: Interpolation and Deformations A short cookbook

18

Engineering Research Center for Computer Integrated Surgical Systems and Technology41 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

2D Interpolation (tensor form)

0 0

00 0 0

0

0

Consider the 2D polynomial

( , ) ( ) ( )

( )[ ( ), , ( )]

( )

where ( ) and ( ) can be arbitrary

functions (good choices Bernstein polynom

m n

ij i ji j

n

m

m mn n

i j

P u v c A u B v

c c B vA u A u

c c B vA u B v

= =

=

⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥= ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

∑∑!

! " # " "!

ials or B-Spline basis functions. Suppose that we have samples

( , ) for 0,...,We want to find an approximating polynomial P.

s s su v s N= =sy y

41

Engineering Research Center for Computer Integrated Surgical Systems and Technology42 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

2D Interpolation: Finding the best fit

Given a set of sample values ys (us,vs ) corresponding to 2D coordinates

(us,vs ), left hand side basis functions A0(u),!,Am(u)⎡⎣ ⎤⎦ and right hand side

basis functions B0(v),!,Bn(v)⎡⎣ ⎤⎦ , the goal is to find the matrix C of

coefficients cij .

To do this, solve the least squares problem

"ys (us,vs )

"

⎢⎢⎢

⎥⎥⎥≈

"A0(us )B0(vs )

"

"A0(us )B1(vs )

"

!"

Ai (us )Bj (vs )

"

!"

Am(us )Bn(vs )

"

⎢⎢⎢

⎥⎥⎥•

c00

c01

"cij

"cmn

⎢⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥⎥

42

Page 19: Interpolation and Deformations A short cookbook

19

Engineering Research Center for Computer Integrated Surgical Systems and Technology43 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

2D Interpolation: Sampling on a regular grid

{ } { }{ }

0 0

0

A common special case arises when the ( , ) form a regular grid. In this

case we have , , and , , . For each value

, , solve the row least squares problem

( , )

u v

v

s s

s N s N

j N s

s s j

u v

u u u v v v

v v v N

u v

∈ ∈

⎡⎢⎢⎣

y

! !

!

"

"

0

0

00 01 0 0 0

10 11 1

0 1

( ) ( )

for the unknown m-vector . Then solve m n-variable least squares problems

( )

v v v

j

s m s

jm

m

m

N N N m

A u A u

B v

⎡ ⎤⎤ ⎡ ⎤⎢ ⎥⎥ ⎢ ⎥≈ • ⎢ ⎥⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎦ ⎣ ⎦ ⎣ ⎦

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥

≈⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

j

X

XX

X X XX X X

X X X

" ! "! "

" ! "

!!

" " "" " # "" " "

!

1 0 0 00 10 0

0 1 1 1 1 01 11 1

0 1

0 1

0

( ) ( )( ) ( ) ( )

( ) ( ) ( )

for the vectors , , . Note that this latter step requires ov v v

n m

n m

n n mn

N N n N

j jn

B v B vB v B v B v

B v B v B v

⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥•⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥

⎣ ⎦⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

⎡ ⎤⎣ ⎦

c c cc c c

c c c

c c

! !! !

" " " " " # "" " # " !" " "

!

! nly 1 SVD or

similar matrix computation.

43

Engineering Research Center for Computer Integrated Surgical Systems and Technology44 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

2D Interpolation: Sampling on a regular grid• There are a number of caveats to the “grid” method

on the previous slide. (E.g., you need enough data for each of the least squares problems). But where applicable the method can save computation time since it replaces a number of m and n variable least squares problems for one big m x n problem

• Note that there is a similar trick that you can play by grouping all the common ui elements together.

• Note that the y’s and the c’s do not have to be scalar numbers. They can be Vectors, Matrices, or other objects that have appropriate algebraic properties

44

Page 20: Interpolation and Deformations A short cookbook

20

Engineering Research Center for Computer Integrated Surgical Systems and Technology45 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

N-dimensional interpolation

• The methods described earlier generalize naturally to N dimensions.

= =

= =

=

∑ ∑ !

"! ! !

"

1

1 1

1

11 1

0 0

( ) ( , , ) ( ) ( )

where ( ) can be arbitrary functions (good choices are Bernstein polynomials or B-Spline basis functions). Suppose that we have samples

(

N

n NN

m mN

N i i i i Ni i

Ki

P P u u c A u A u

A u

s

u

y y =

!1

) for 0,...,We want to find coefficients of approximating polynomial P.

n

s s

i i

s Nc

u

45

Engineering Research Center for Computer Integrated Surgical Systems and Technology46 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

N-dimensional interpolation

=

⎡ ⎤⎡ ⎤ ⎡ ⎤⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ ≅⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎣ ⎦⎣ ⎦

⎣ ⎦

!

!

!! ! !

!

"!

# #" " " "

!#

##

1 1

1

1

11

00 0

10 000 0 10 0

Define

( ) ( ) ( )

Then solve the least squares problem

( ) ( ) ( )

N N

n

n

Ni i i i N

s s m m s s

m m

F A u A u

cc

F F F

c

u

u u u y

46

Page 21: Interpolation and Deformations A short cookbook

21

Engineering Research Center for Computer Integrated Surgical Systems and Technology47 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Example: 3D Calibration of Distortion

47

Engineering Research Center for Computer Integrated Surgical Systems and Technology48 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Example: 3D Calibration of Distortion

!

F000("us ) # F555(

"us )

!

⎢⎢⎢⎢

⎥⎥⎥⎥

c000x c000

y c000z

! ! !c555x c555

y c555z

⎢⎢⎢⎢

⎥⎥⎥⎥

!

psx ps

y psz

!

⎢⎢⎢⎢

⎥⎥⎥⎥

48

Page 22: Interpolation and Deformations A short cookbook

22

Engineering Research Center for Computer Integrated Surgical Systems and Technology49 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Example: 3D Calibration of Distortion

The correction function will then look like this:

==

∑∑∑

! !

! ! !!

!

min max

5 5 5

, , 5, 5, 5,i=0 j=0 k=0

( ){ ( , , )

return ( ) ( ) ( )

}

i j k i x j y k z

CorrectDistortion

ScaleToBox

B u B u B u

p qu q q q

c

49

Engineering Research Center for Computer Integrated Surgical Systems and Technology50 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Radial Basis Function Interpolation

!f(!x) =

!fkϕ

!x −!xk( )

k=1

n

∑ where !x ∈"d

Sometimes add linear combination of polynomials !γ j (!x) to the method

!f(!x) =

!fkϕ

!x −!xk( )

k=1

n

∑ +!g jγ j (

!x)

j=1

m

∑ where !gkγ k (

!xk ) = 0

k=1

n

Given a set of points !"xk!{ }, solve this system to find the

!fk :

0 ϕ!x2 −

!x1( ) ! ϕ

!xn −

!x1( )

ϕ!x1 −!x2( ) 0 ! ϕ

!xn −

!x2( )

! ! " !ϕ!x1 −!xn( ) ϕ

!x2 −

!xn( ) ! 0

⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥

!f1T

!f2T

!"fnT

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

!x 1

T

!x2

T

!"xn

T

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

50

Page 23: Interpolation and Deformations A short cookbook

23

Engineering Research Center for Computer Integrated Surgical Systems and Technology51 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Radial Basis Function Interpolation

!f(!x) =

!fkϕ

!x −!xk( )

k=1

n

∑ where !x ∈"d

Typical radial basis functions with global support[1]

Example radial basis function with compact support

ϕ(r ) = e− 1

1−(εr )2

⎝⎜⎞

⎠⎟ for 0 ≤ r<1ε

0 otherwise

⎨⎪

⎩⎪

[1] W. du Toit, Radial Basis Function Interpolation,, MS Thesis, University of Stellenbosch, 2008

Note: The choice of constants in design of RBFs is important

51

Engineering Research Center for Computer Integrated Surgical Systems and Technology52 600.445 Fall 2000; Updated: 5 October 2021Copyright © R. H. Taylor

Radial Basis Function Interpolation• As mentioned in the previous slide, the choice of specific RBF

basis and associated parameters is important and is generally problem-specific. The design process typically involves an optimization problem of some sort, trading off accuracy, coverage, and computational efficiency.

• Here are some useful web links to start further exploration:– https://en.wikipedia.org/wiki/Radial_basis_function_interpolation– https://core.ac.uk/download/pdf/37320748.pdf– http://www.scholarpedia.org/article/Radial_basis_function#Compactly_supported_radial_basis_functions

– https://link.springer.com/content/pdf/10.1007/s00500-020-05211-0.pdf– https://www.researchgate.net/publication/340082978_Compactly_supported_radial_basis_functions_how_and_why

52