Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall...

30
Engineering Research Center for Computer Integrated Surgical Systems and Technolog 1 600.445 Fall 2000; Updated: March 25, 2022 Copyright © R. H. Taylor Interpolation and Deformations A short cookbook

Transcript of Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall...

Page 1: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology1 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Interpolation and DeformationsA short cookbook

Page 2: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology2 600.445 Fall 2000; Updated: April 19, 2023

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

Page 3: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology3 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Linear Interpolation

1

1

10 15 20T

p

q a

2

2

40 30 20T

p

q b

3

3

20 20 20

???

T

p

q

13 a b a

Page 4: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology4 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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 p

p p p p

Page 5: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology5 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Bilinear Interpolation

, 1i ju 1, 1i j u

1,i ju

1

1

1

,i ju

Page 6: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology6 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Bilinear Interpolation

,i ju

, 1i ju 1, 1i j u

1,i ju

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

Page 7: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology7 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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

Page 8: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology8 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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

Page 9: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology9 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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 p

p p

Page 10: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology10 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Barycentric Interpolation

1p 2p

3p

, ???? p 3 1 3 2 3

1 2 3

, ( )

(1 )

p p p p p p

p p p

3 1 3 2 3

1 2 3

1 2 3

, ( )

(1 )

, , 1 where

p p p p p p

p 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 p

p p p

p p p p

1A

2A

3A

Page 11: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology11 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Barycentric Interpolation

1p 2p

3p

31 2

1 1 1 1

pp pp

1A

2A

3A

Page 12: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology12 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Barycentric Interpolation

1 2

1

, , 1

, ,

BarycentricInterpolate( , )

1

Let

= , with 0

be a set of interpolation parameters, and let

be a set of constants. Then we define:

N

N k

N

k kk

A A

A

A

A A

( ) ( , , ) BarycentricInterpolate( , )1

NOTE: Sometimes in this situation we will use notation

NOTE: This is a special case of barycentric Bezier

polynomial interpolations (here,

N N N

A A A

st 1 degree)

Page 13: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology13 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Interpolation of functions

v

( )y v

01

Page 14: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology14 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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.

Page 15: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology15 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

v

01

N,k

,

Note that many forms of polynomial may be used

for the P ( ). One common (not very good) choice

is the power basis:

( )

Better choices are the Bernstein plynomials and the

b-spline basis functi

kN k

v

P v v

ons, which we will discuss in

a moment

1-D Interpolation

0 0

0

0 ,0

Given set of known values ( ),..., ( ) ,

find an approximating polynomial ( ,..., ; )

( ,..., ; ) ( )

m m

N

N

N k N kk

y v y v

y P c c v

P c c v c P v

Page 16: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology16 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

1-D Interpolation

0 0

0

0 ,0

,0 0 , 0 0

,0 ,

Given set of known values ( ),..., ( ) ,

find an approximating polynomial ( ,..., ; )

( ,..., ; ) ( )

To do this, solve:

( ) ( )

( ) ( )

m m

N

N

N k N kk

N N N

N m N N m m

y v y v

y P c c v

P c c v c P v

P v P v c

P v P v c

0

m

y

y

Page 17: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology17 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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

00

,0

,

, , ; 1

( )

( ) 1

NN k N

N kk

N

k N kk

N k kN k

NP c c v c v v

k

c B v

Nwhere B v v v

k

Page 18: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology18 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Barycentric Bezier Polynomials

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

conventional power basis

00

,0

,

, , ; ,

( , )

( , ) u+v=1

N

N k NN k

k

N

k N kk

N k kN k

NP c c u v c u v

k

c B u v

Nwhere B u v u v

k

Page 19: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology19 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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

Page 20: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology20 600.445 Fall 2000; Updated: April 19, 2023

Copyright © 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 c

b v b vb

��������������

����������������������������

��������������

0

c

1

c

3

c

2

c

1 vv

v

v

1 v 1 v

Page 21: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology21 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Iterative Form of deCasteljau Algorithm

1

0

Step 1: for 0

Step 2 : for 1 step 1 until do

for 0 step 1 until do

(1 )

Step 3: return

j j

j j j

b c j N

k k N

j j N k

b v b vb

b

Page 22: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology22 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Advantages of Bezier Curves

• Numerically very robust• Many nice mathematical properties• Smooth

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

Page 23: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology23 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

B-splines

0 1

0 2 2 1

1 1

Given

coefficient values { , , }

"knot points" { , , } with

D = "degree" of desired B-spline

Can define an interpolated curve ( , ; ) on

Then

(

L D

L D i i

D L D

c c

u u u u

P u u u u

P

C

u

C u

1

0

; ) ( )

where ( ) are B-spline basis polynomials (discussed

later)

L DD

j jj

Dj

u c N u

N u

C

Page 24: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology24 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

deBoor Algorithm

1

1

0

Given , , as before, can evaluate ( , ; )

recursively as follows:

Step 1: Determine index such that

Step 2: Determine multplicity r such that

Step 3: Det for 1

i i

i r i r i

j j

D P u

i u u u

u u u

d c i D j

u c c u

1

11 1j 1

1 1

1

Step 4: Compute ( , ; ) recursively, where

d

D ri

j D k jk k kj j

j D k j j D k j

i

P u d

u u u ud d

u u u u

c u

Page 25: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology25 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

B-spline basis functions

1

0

10

1 1 11

1 1

Given , , D as before

( , ; ) ( )

where

1( )

0 Otherwise

( ) ( ) ( ) for 0

L DD

j jj

j jj

j j kk k kj j j

j k j j k j

P u c N u

u u uN u

u u u uN u N u N u k

u u u u

C u

C u

Page 26: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology26 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

Some advantages of B-splines

• Efficient

• Numerically stable

• Smooth

• Local

Page 27: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology27 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

2D Interpolation

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 v

A u A u

c c B v

A 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

Page 28: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology28 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

2D Interpolation: Finding the best fit

0

0

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

( , ), left hand side basis functions ( ), , ( ) and right hand side

basis functions ( ), , ( ) , the goal is to find the

s s s

s s m

n

u v

u v A u A u

B v B v

y

00

01

0 0 0 1

matrix of

coefficients .

To do this, solve the least squares problem

( , ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

ij

s s s s s s s i s j s m s n sij

mn

u v A u B v A u B v A u B v A u B v

C

c

c

c

yc

c

Page 29: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology29 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

2D Interpolation: Finding the best fit

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

X

X

X X X

X 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 o

v v v

n m

n m

n n mn

N N n N

j jn

B v B v

B v B v B v

B v B v B v

c c c

c c c

c c c

c c

nly 1 SVD or

similar matrix computation.

Page 30: Engineering Research Center for Computer Integrated Surgical Systems and Technology 1 600.445 Fall 2000; Updated: 12 September 2015 Copyright © R. H. Taylor.

Engineering Research Center for Computer Integrated Surgical Systems and Technology30 600.445 Fall 2000; Updated: April 19, 2023

Copyright © R. H. Taylor

2D Interpolation: Finding the best fit

• 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