RoweTalkMSCS BiCubic

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 93

MU MSCS Spring 2018

BiLinear, Bicubic, and In Between


Spline Interpolation
Daniel B. Rowe
Program in Computational Sciences
Department of Mathematics, Statistics, and Computer Science
Marquette University

Department of
Biophysics

February 15, 2018

D.B. Rowe 1
MU MSCS Spring 2018

1.
Goal of Interpolation
1D Interpolation 1D Interpolation 2D Interpolation
2. Linear
3. Cubic
4. Cubic Spline
2D Interpolation
5.
BiLinear
6.
BiCubic
7.
BiCubic Spline MRI Example

8.
MRI Example

D.B. Rowe 2
MU MSCS Spring 2018

1. Goal of Interpolation
How do you determine how to get from one point to another?

Can we estimate a path to


traverse through the points,
then interpolate intermediate
values along our path?

D.B. Rowe 3
MU MSCS Spring 2018

1. Goal of Interpolation
How do you determine how to get from one point to another?

Not complicated like this!

D.B. Rowe 4
MU MSCS Spring 2018

1. Goal of Interpolation
How do you determine how to get from one point to another?

But some smooth progression


through the points.

true curve

D.B. Rowe 5
MU MSCS Spring 2018

2. 1D Linear Interpolation
Easiest to draw straight lines between points and use values
along the lines.

Interpolate: f (4.5)
Two points define a line. f (2.5) f (4)

Find the equation of the


f (3)
line between points. f (2)
f (3.5)
f (1)

f (1.5)

axis change

D.B. Rowe 6
MU MSCS Spring 2018

2. 1D Linear Interpolation
Easiest to draw straight lines between points and use values
along the lines.

Normalization: f (0), f (1)


For regularly spaced points.

f (0)
f (1)

axis change

D.B. Rowe 7
MU MSCS Spring 2018

2. 1D Linear Interpolation
Easiest to draw straight lines between points and use values
along the lines.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1
x  0,1

f (0)
f (1)

D.B. Rowe 8
MU MSCS Spring 2018

2. 1D Linear Interpolation
Easiest to draw straight lines between points and use values
along the lines.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1
x  0,1
Solve: (a0 , a1 )
f (0)  a0 (1)  a1 (0)
f (0)
f (1)  a0 (1)  a1 (1) f (1)

D.B. Rowe 9
MU MSCS Spring 2018

2. 1D Linear Interpolation
System of Equations: 2 equations, 2 unknowns f (0)  a0 (1)  a1 (0)
f (1)  a0 (1)  a1 (1)

System of Equations System of Equations


 f (0)  1 0   a0 
 f (1)   1 1   a  two points y  Xa
    1
y  X a
Solution Solution
 a0   1 0   f (0)  a  X 1 y
 a    1 1   f (1) 
 1   
a  X 1 y

D.B. Rowe 10
MU MSCS Spring 2018

2. 1D Linear Interpolation
Easiest to draw straight lines between points and use values
along the lines.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1
x  0,1
Solve: (a0 , a1 )

Interpolate: .5 f (0)
f (1)

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 13
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1
x  0,1
Solve: (a0 , a1 ) f (1)

Interpolate: .5

f (0)

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 14
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1)


f (1)
Model: f ( x)  a0 x  a1 x
0 1

x  0,1
Solve: (a0 , a1 )
f (0)
Interpolate: .5

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 15
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1)


f (0)
Model: f ( x)  a0 x  a1 x
0 1

x  0,1
f (1)
Solve: (a0 , a1 )

Interpolate: .5

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 16
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1
f (0)
x  0,1
Solve: (a0 , a1 )
f (1)
Interpolate: .5

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 17
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1)

Model: f ( x)  a0 x 0  a1 x1 f (1)
x  0,1
Solve: (a0 , a1 )
f (0)
Interpolate: .5

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 18
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
values between.

Normalization: f (0), f (1) f (1)

Model: f ( x)  a0 x 0  a1 x1
x  0,1 f (0)
Solve: (a0 , a1 )

Interpolate: .5

f (.5)  a0 (.5)0  a1 (.5)1

D.B. Rowe 19
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
all values between.

If we need more interpolated


Values, then use more than
just .5.

Interpolate at 0<x<1

f ( x)  a0 x 0  a1 x1

D.B. Rowe 20
MU MSCS Spring 2018

2. 1D Linear Interpolation
Repeat the process between all pairs of points to interpolate
all values between.

But regardless of how many


points we interpolate, the
intrinsic curvature through
the points is not captured!

D.B. Rowe 21
MU MSCS Spring 2018

3. 1D Cubic Interpolation
Using adjacent points, we can estimate a cubic (third order
polynomial) between points.

Interpolate: f (4.5)
Four points define a f (2.5) f (4)
cubic equation.
f (3)
f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (2)
f (3.5)
Find the coefficients of the
f (1)
cubic eqn. between points.
f (1.5)

D.B. Rowe 22
MU MSCS Spring 2018

3. 1D Cubic Interpolation
Using adjacent points, we can estimate a cubic (third order
polynomial) between points.

Normalization: f (0), f (1)


For regularly spaced points. f (2)

f (1)

f (1)

f (0)

D.B. Rowe 23
MU MSCS Spring 2018

3. 1D Cubic Interpolation
Using adjacent points, we can estimate a cubic (third order
polynomial) between points.

Normalization: f (0), f (1)


f (2)
Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
x  1,0,1, 2
f (1)

f (1)

f (0)

D.B. Rowe 24
MU MSCS Spring 2018

3. 1D Cubic Interpolation
Using adjacent points, we can estimate a cubic (third order
polynomial) between points. 4 equations, 4 unknowns

Normalization: f (0), f (1)


f (2)
Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
x  1,0,1, 2
Solve: (a0 , a1 , a2 , a3 )
f (1)

f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3 f (1)


f (0)  a0 (0)0  a1 (0)1  a2 (0) 2  a3 (0)3
f (0)
f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3
f (2)  a0 (2)0  a1 (2)1  a2 (2) 2  a3 (2)3

D.B. Rowe 25
MU MSCS Spring 2018 f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3
f (0)  a0 (0)0  a1 (0)1  a2 (0) 2  a3 (0)3
3. 1D Cubic Interpolation f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3
f (2)  a0 (2)0  a1 (2)1  a2 (2) 2  a3 (2)3
System of Equations: 4 equations, 4 unknowns

System of Equations Solution


 f (1)  1 1 1 1  a0  previous point
 f (0)  1 0 0 0   a  y  Xa
    1  current points
 f (1)  1 1 1 1   a2 
      next point
 f (2)  1 2 4 8   a3 
Solution Solution
 a0   0 6 0 0   f ( 1) 
a 
1
 2 3 6 1  f (0)  a  X 1 y
  
1  
 a2  6  3 6 3 0   f (1) 
    
 3
a  1 3 3 1  f (2) 

recycle matrix

D.B. Rowe 26
MU MSCS Spring 2018

3. 1D Cubic Interpolation
System of Equations: 4 equations, 4 unknowns

Solution Solution
 a0   0 6 0 0   f ( 1) 
a   2 3 6 1  f (0)  a  X 1 y
  
1 1  
 a2  6  3 6 3 0   f (1) 
    
 3
a  1 3 3 1  f (2) 
Interpolate at 0<x<1 Interpolate at 0<x<1
 a0 
f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 a 
f ( x)  [ x 0 , x1 , x 2 , x 3 ]  1 
 a2 
 
 a3 

D.B. Rowe 27
MU MSCS Spring 2018

3. 1D Cubic Interpolation
System of Equations: 4 equations, 4 unknowns

Interpolate at 0<x<1 Interpolate at 0<x<1


 a0 
f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 a 
f ( x)  [ x 0 , x1 , x 2 , x 3 ]  1 
 a2 
 
 a3 
Interpolate at .5 Interpolate at .5
 a0 
f (.5)  a0 .50  a1.51  a2 .52  a3 .53 a 
3  1
f (.5)  [.5 ,.5 ,.5 ,.5 ]
0 1 2
 a2 
 
 a3 

D.B. Rowe 28
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


f (2)
Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
x  1,0,1, 2
Solve: (a0 , a1 , a2 , a3 )
f (1)
Interpolate:
f (.5)  a0 .50  a1.51  a2 .52  a3 .53 f (1)

f (0)

D.B. Rowe 29
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (1)
x  1,0,1, 2 f (2)
Solve: (a0 , a1 , a2 , a3 )
Interpolate: f (0)
f (.5)  a0 .50  a1.51  a2 .52  a3 .53
f (1)

D.B. Rowe 30
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (0) f (2)
x  1,0,1, 2
Solve: (a0 , a1 , a2 , a3 ) f (1)
f (1)
Interpolate:
f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 31
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (1)
x  1,0,1, 2 f (0) f (2)
Solve: (a0 , a1 , a2 , a3 )
Interpolate: f (1)

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 32
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1) f (2)

Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (1)
x  1,0,1, 2 f (1)
Solve: (a0 , a1 , a2 , a3 )
Interpolate: f (0)

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 33
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Return to unnormalized axis.

interpolation
not done
Interpolation not done
-ends of cubic
-linear ends
-quadratic ends

D.B. Rowe 34
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Cubic still “kinky” at points.

width
disparity interpolation
“kink” not done

D.B. Rowe 35
MU MSCS Spring 2018

3. 1D Cubic Interpolation
This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

But much better than linear!

width
disparity interpolation
“kink” not done

D.B. Rowe 36
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


With two points and two derivatives we can fit a cubic
polynomial between points.

Interpolate: f (4.5)
Two points plus two f (2.5) f (4)
derivatives. No “kinks?”
f (3)
Smooth transition through. f (2)
f (3.5)
Find the equation of the
f (1)
cubic eqn. between points. Only use two points
and their derivatives.
f (1.5)

D.B. Rowe 37
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


With two points and two derivatives we can fit a cubic
polynomial between points.

Normalization: f (0), f (1)


For regularly spaced points.

f (1)

f (0)

D.B. Rowe 38
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


With two points and two derivatives we can fit a cubic
polynomial between points.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
x  1,0,1, 2 f (1)

f (0)

D.B. Rowe 39
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


With two points and two derivatives we can fit a cubic
polynomial between points. 4 equations, 4 unknowns

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2 f (1)
0 1 2 3

f (0)  a0 (0)0  a1 (0)1  a2 (0) 2  a3 (0)3


f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3
f '(0)  a1 (0)0  2a2 (0)1  3a3 (0) 2 f (0)
f '(1)  a1 (1)0  2a2 (1)1  3a3 (1) 2

D.B. Rowe 40
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


With two points and two derivatives we can fit a cubic
polynomial between points. 4 equations, 4 unknowns

Need time series discrete


derivatives at x=0,1.

Derivative at x=0:
f (1)
f (1)  f (1)
f '(0) 
2
Derivative at x=1:
f (2)  f (0) f (0)
f '(1) 
2

D.B. Rowe 41
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation f (0)  a (0)  a1 (0)1  a2 (0) 2  a3 (0)3


0
0
f (1)  a0 (1)0  a1 (1)1  a2 (1) 2  a3 (1)3
System of Equations: 4 equations, f '(0)  a1 (0)0  2a2 (0)1  3a3 (0) 2
f '(1)  1a1 (1)0  2a2 (1)1  3a3 (1) 2
4 unknowns
note: don’t use f(-1) and f(2)!
If did, 6 eqn. 4 unknown,
interpolation not through points.

System of Equations y  Xa Derivatives y  Df


 f (0)  1 0 0 0   a0   f (0)   0 2 0 0   f (1) 
 f (1)  1 1 1 1   a   0 0
   1
 f (1) 
 1
  2 0   f (0) 
 f (0)  0 1 0 0   a2   f (0)  2  1 0 1 0   f (1) 
         
 
 f (1)   0 1 2 3   a3   f (1)   0 1 0 1   f (2) 
Solution a  X 1 y  X 1Df
 a0   1 0 0 0   0 2 0 0   f (1)   0 2 0 0   f (1) 
 a   0 0 1 0  0 0 2 0   f (0)  1  1 0 1 0   f (0) 
 1   1 
 a2   3 3 2 1 2  1 0 1 0   f (1)  2  2 5 4 1  f (1) 
         
 3 
a 2 2 1 1   0 1 0 1   f (2)   1 3 3 1  f (2) 

recycle matrix

D.B. Rowe 42
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


System of Equations: 4 equations, 4 unknowns

Solution for cubic spline Solution for cubic


 a0   0 2 0 0   f (1)   a0  0 6 0 0   f ( 1) 
a   1 0 1 0   f (0)  a   2 3 6 1  f (0) 
  
1 1     
1 1
 a2  2  2 5 4 1  f (1)   a2  6  3 6 3 0   f (1) 
         
 3
a  1 3 3 1  f (2)   3
a  1 3 3 1   f (2) 
Interpolate at 0<x<1
f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
Interpolate at .5
f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 43
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2 f (1)
0 1 2 3

Interpolate: .5

f (.5)  a0 .50  a1.51  a2 .52  a3 .53 f (0)

D.B. Rowe 44
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


f (1)
Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2 f (0)
0 1 2 3

Interpolate: .5

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 45
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


f (0)
Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2 f (1)
0 1 2 3

Interpolate: .5

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 46
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2 f (0)
0 1 2 3
f (1)
Interpolate: .5

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 47
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Normalization: f (0), f (1)


Model: f ( x)  a0 x 0  a1 x1  a2 x 2  a3 x 3 f (1)
f '( x)  1a1 x 0  2a2 x1  3a3 x 2
Solve: (a , a , a , a ) x  1,0,1, 2
0 1 2 3
f (0)
Interpolate: .5

f (.5)  a0 .50  a1.51  a2 .52  a3 .53

D.B. Rowe 48
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Return to unnormalized axis.

interpolation
not done

D.B. Rowe 49
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Cubic Spline no “kinks.”

interpolation
not done
no “kink”

D.B. Rowe 50
MU MSCS Spring 2018

4. 1D Cubic Spline Interpolation


This involves 4 unknowns and 4 points to estimate them, then
points along the polynomial.

Cubic Spline better at points!

interpolation
not done
no “kink”

D.B. Rowe 51
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

f (1,0)

f (0,0) f (1,1)

f (0,1)

array/image coordinate system

D.B. Rowe 54
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

Interpolate:
f (1,0)
Find the equation of the
plane between points.
f (0,0) f (1,1)

f (0,1)

D.B. Rowe 55
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1) f (1,0)

f (0,0) f (1,1)

f (0,1)

D.B. Rowe 56
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1) f (1,0)
1 1
Model: f ( x, y )   aij x i y j
j 0 i 0 f (0,0) f (1,1)
x  1,0,1, 2
f (0,1)
f ( x, y )  a00  a10 x  a01 y  a11 xy
x, y  1,0,1, 2

D.B. Rowe 57
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1) f (1,0)
1 1
Model: f ( x, y )   aij x i y j
j 0 i 0 f (0,0) f (1,1)
x  1,0,1, 2
f (0,1)
Solve: aij
f (0,0)  a00
f (1,0)  a00  a10
f (1,0)  a00  a01
f (1,1)  a00  a10  a01  a11

D.B. Rowe 58
MU MSCS Spring 2018

5. 2D BiLinear Interpolation f (0,0)  a00


System of Equations: 4 equations, 4 f (1,0)  a00  a10
unknowns
f (1,0)  a00  a01
f (1,1)  a00  a10  a01  a11

System of Equations y  Xa Image


 f (0,0)  1 0 0 0   a00  0 1
 f (1,0)  1 1 0 0   a 
    10  0
 f (0,1)  1 0 1 0   a01 
     1
 f (1,1)  1 1 1 1   a11 
1
Solution a  X y Interpolate
 a00   1 0 0 0   f (0,0)  f ( x, y )  a00  a10 x  a01 y  a11 xy
 a   1 1 0 0   f (1,0) 
 10    0<x<1, 0<y<1
 a01   1 0 1 0   f (0,1) 
    
 a11   1 1 1 1   f (1,1) 

recycle matrix

D.B. Rowe 59
MU MSCS Spring 2018

5. 2D BiLinear Interpolation f (0,0)  a00


System of Equations: 4 equations, 4 f (1,0)  a00  a10
unknowns
f (1,0)  a00  a01
f (1,1)  a00  a10  a01  a11

Solution a  X 1 y Interpolate
0 1
 a00   1 0 0 0   f (0,0)  f ( x, y )  a00  a10 x  a01 y  a11 xy
 a   1 1 0 0   f (1,0)  0
 01    0<x<1, 0<y<1
 a10   1 0 1 0   f (0,1)  1
    
 a11   1 1 1 1   f (1,1) 
 f (.5,0)  1 .5 0 0
Interpolate one pixel yint  X int a  f (1,.5)  1  a00 
   1 .5 .5   
f (.5,0)  [1,.5,0,0]a  a01 
 f (.5,.5)   1 .5 .5 .25 
More rows to interpolate more pixels.      a10 
 f (0,.5)  1 0 .5 0   
 f (.5,1)  1 .5 1 .5   a11 

D.B. Rowe 60
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Easiest to draw planes between points and use values within
the planes.

Once we’ve solved for the


f (1,0)
coefficients, we interpolate. f (1,.5)
f (.5,0)

f (0,0) f (.5,.5)
f (1,1)
f ( x, y )  a00  a10 x  a01 y  a11 xy f (0,.5)
f (.5,1)
f (0,1)
f (.5,0) f (1,.5)
f (.5,.5)
f (0,.5) f (.5,1)

D.B. Rowe 61
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Example: 8×8 interpolate 1 to 15×15

Low Resolution Expanded BiLinear Interpolated

D.B. Rowe 62
MU MSCS Spring 2018

5. 2D BiLinear Interpolation
Example: 8×8 interpolate 1001 to 7015×7015
Expanded

Low Resolution Expanded BiLinear Interpolated

can’t see original pixels note “kinks” between patches

D.B. Rowe 63
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Interpolate:
Sixteen points define a
2D bicubic surface.
Find the equation of the
surface between 4 points
using neighbors.

D.B. Rowe 64
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)

f (1,0)
f (0,0) f (1,1)
f (0,1)

D.B. Rowe 65
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)
3 3
Model: f ( x, y ) 
 ij y
a x i j

j 0 i 0
f (1,0)
f (0,0) f (1,1)
x  1,0,1, 2 f (0,1)

D.B. Rowe 66
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)
3 3
Model: f ( x, y ) 
 ij y
a x i j

j 0 i 0
f (1,0)
f (0,0) f (1,1)
x  1,0,1, 2 f (0,1)

Solve: aij

D.B. Rowe 67
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Interpolate:
Find the equation of the
surface between 4 points f (1,0)
f (0,0) f (1,1)
using neighbors and f (0,1)

and determine aij’s.

D.B. Rowe 68
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
System of Equations: 16 equations, 16 unknowns

-1 0 1 2
System of Equations y  Xa Image I ( x, y )
-1
16 equations from f ( x, y )
3 3
0
f ( x, y )   aij x i y j
i 0 j 0
1
x,y=-1,0,1,2
2
Simply insert all x,y combinations to get 16 equations.

D.B. Rowe 69
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Values from polynomial.
y  Xa
 f (1, 1)  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   a00 
 f (0, 1)  1
   0 0 0 1 0 0 0 1 0 0 0 1 0 0 0   a10  3 3
 f (1, 1)  1
  
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  a20 
 
f ( x, y )   aij x i y j
 f (2, 1)  1 2 4 8 1 2 4 8 1 2 4 8 1 2 4 8   a30  i 0 j 0
 f (1,0)  1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0   a01 
     x,y=-1,0,1,2
 f (0,0)  1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   a11 
 f (1,0)  1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0   a21 
    
 f (2,0)  1 2 4 8 0 0 0 0 0 0 0 0 0 0 0 0   a31 
 f (1,1)   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  a02 
    
 f (0,1)  1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0   a12 
    
 f (1,1)  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   a22 
 f (2,1)  1 2 4 8 1 2 4 8 1 2 4 8 1 2 4 8   a32 
    
 f (1, 2)  1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8  a03 
 f (0, 2)  1 0 0 0 2 0 0 0 4 0 0 0 8 0 0 0   a13 
    
 f (1, 2)  1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8   a23 
 f (2, 2)  1
   2 4 8 2 4 8 16 4 8 16 32 8 16 32 64   a33 

D.B. Rowe 70
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Estimate coefficient values. Almost Money Slide
a  X 1I
 a00  0 0 0 0 0 36 0 0 0 0 0 0 0 0 0 0   I (1, 1) 
a  0 0 0 0 12 18 36 6 0 0 0 0 0 0 0 0   I (0, 1) 
 10  
 a20  0 0 0 0 18 36 18 0 0 0 0 0 0 0 0 0   I (1, 1) 
    
 a30  0 0 0 0 6 18 18 6 0 0 0 0 0 0 0 0   I (2, 1) 
 a01   0 12 0 0 0 18 0 0 0 36 0 0 0 6 0 0   I (1,0) 
    
 a11  4 6 12 2 6 9 18 3 12 18 36 6 2 3 6 1   I (0,0) 
a   6 12 6 0 9 18 9 0 18 36 18 0 3 6 3 0   I (1,0) 
 21    
 a31  1  2 6 6 2 3 9 9 3 6 18 18 6 1 3 3 1  I (2,0) 
 a   36  0 18 0 0 0 36 0 0 0 18 0 0 0 0 0 0   I (1,1) 
 02    
 a12   6 9 18 3 12 18 36 6 6 9 18 3 0 0 0 0   I (0,1) 
    
 a22   9 18 9 0 18 36 18 0 9 18 9 0 0 0 0 0   I (1,1) 
 a32   3 9 9 3 6 18 18 6 3 9 9 3 0 0 0 0   I (2,1) 
    
 a03   0 6 0 0 0 18 0 0 0 18 0 0 0 6 0 0   I (1, 2) 
a  2 3 6 1 6 9 18 3 6 9 18 3 2 3 6 1  I (0, 2) 
 13    
 a23   3 6 3 0 9 18 9 9 9 18 9 0 3 6 3 0   I (1, 2) 
a   1 3 3 1 3 9 9 9 3 1 3 3 1   I (2, 2) 
 33   9 3 3

recycle matrix

D.B. Rowe 71
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Estimate coefficient values.
a  X 1I

Interpolate pixel values.


3 3
f ( x, y )   aij x i y j 0<x<1, 0<y<1
j 0 i 0

Can do biquadratic in corners and linear-quadratic on sides.

D.B. Rowe 72
MU MSCS Spring 2018

6. 2D BiCubic Interpolation
Example: 8×8 interpolate 1001 to 7015×7015
Expanded

* bilinear edges
Low Resolution Bilinear Interpolated BiCubic Interpolated

still “kinky” between patches

D.B. Rowe 73
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Interpolate:
Will use 4 points and 12
derivatives at those points
to define a bicubic surface.

array/image coordinate system

D.B. Rowe 74
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)

f (1,0)
f (0,0) f (1,1)
f (0,1)

D.B. Rowe 75
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)
3 3
Model: f ( x, y ) 
 ij y
a x i j

j 0 i 0
f (1,0)
f (0,0) f (1,1)
f (0,1)

D.B. Rowe 76
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Need to use adjacent points, estimate surfaces, and use values
within the surfaces.

Normalization: f (0,0), f (1,0)


f (0,1), f (1,1)
3 3
Model: f ( x, y ) 
 ij y
a x i j

j 0 i 0
f (1,0)
f (0,0) f (1,1)
f (0,1)

Solve: aij

D.B. Rowe 77
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Need to use adjacent points, estimate surfaces, and use values
within the surfaces.
Interpolate:
Will use 4 points and 12
derivatives to define a
f (1,0)
bicubic splined surface and f (0,0) f (1,1)

and determine aij’s.


f (0,1)

D.B. Rowe 78
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


System of Equations: 16 equations, 16 unknowns

-1 0 1 2
System of Equations y  Xa Image I ( x, y )
-1
4 equations from f ( x, y )
3 3
0
f ( x, y )   aij x i y j
i 0 j 0
1
x,y=0,1
f (0,0)  a00 2
f (1,0)  a00  a10  a20  a30
f (0,1)  a00  a01  a02  a03
f (1,1)  a00  a10  a01  a11

D.B. Rowe 79
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


System of Equations: 16 equations, 16 unknowns

-1 0 1 2
System of Equations y  Xa Image I ( x, y )
 -1
4 equations from f x ( x, y )  f ( x, y )
x 0
3 3
f x ( x, y )   aij ix i 1 y j
j  0 i 1 1
x,y=0,1
f x (0,0)  a10 2
f x (1,0)  1a10  2a20  3a30
f x (0,1)  a10  a11  a12  a13
f x (1,1)  1a10  2a20  3a31  1a11  2a21  3a31
 1a12  2a22  3a32  1a13  2a23  3a33

D.B. Rowe 80
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


System of Equations: 16 equations, 16 unknowns

-1 0 1 2
System of Equations y  Xa Image I ( x, y )
 -1
4 equations from f y ( x, y )  f ( x, y )
y 0
3 3
f y ( x, y )   aij jx i y j 1
j 1 i  0
1
x,y=0,1
f y (0,0)  a01 2
f y (1,0)  a01  a11  a21  a31
f y (0,1)  1a01  2a02  3a03
f y (1,1)  1a01  1a11  1a21  1a31
 2a02  2a12  2a22  2a32
 3a03  3a13  3a23  3a33

D.B. Rowe 81
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


System of Equations: 16 equations, 16 unknowns

-1 0 1 2
System of Equations y  Xa Image I ( x, y )
2 -1
4 equations from f xy ( x, y )  f ( x, y )
yx 0
3 3
f xy ( x, y )   aij ijx i 1 y j 1
j 0 i 0
1
x,y=0,1
f xy (0,0)  a11 2
f xy (1,0)  1a11  2a21  3a31
f xy (0,1)  1a11  2a12  3a13
f xy (1,1)  1a11  2a21  3a31
 2a12  4a22  6a32
 3a13  6a23  9a33

D.B. Rowe 82
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


System of Equations: 16 equations, 16 unknowns

-1 0 1 2
Need Image and Derivatives Image I ( x, y )
f ( x, y )  I ( x, y ) -1

f x ( x, y )  [ I ( x  1, y )  I ( x  1, y )] / 2 0

f y ( x, y )  [ I ( x, y  1)  I ( x, y  1)] / 2 1
f xy ( x, y )  [ I ( x  1, y  1)  I ( x  1, y )  I ( x, y  1)  I ( x, y )] / 4 2
x,y=0,1
i.e. at (0,0)
Use the graph to reason out the derivatives. f x (0,0)  [ I (1,0)  I ( 1,0)] / 2
Only using surrounding points for derivatives. f y (0,0)  [ I (0,1)  I (0, 1)] / 2
f xy (0,0)  [ I (1,1)  I (1,0)  I (0, 1)  I (0,0)] / 4

D.B. Rowe 83
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Values from polynomial.

y  Xa 3 3
f ( x, y )   aij x i y j
 f (0,0)  1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   a00 
 f (1,0)  
  1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0   a10 
i 0 j 0
 f (0,1)  1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0   a20 
    
 f (1,1)  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   a30 
3 3
 f x (0,0)  0
  
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0   a01 
  f x ( x, y )   aij ix i 1 y j
 f x (1,0)  0 1 2 3 0 0 0 0 0 0 0 0 0 0 0 0   a11 
 f (0,1)  0 j  0 i 1
1 0 0 0 1 0 0 0 1 0 0 0 1 0 0   a21 
 x     3 3
 f x (1,1)  0 3   a31 
f y ( x, y )   aij jx i y j 1
1 2 3 0 1 2 3 0 1 2 3 0 1 2
 f (0,0)   
 y  0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0   a02 
 
 f y (1,0)  0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0   a12  j 1 i  0
    
 f y (0,1)  0 0 0 0 1 0 0 0 2 0 0 0 3 0 0 0   a22  3 3
 f y (1,1)  0
  
0 0 0 1 1 1 1 2 2 2 2 3 3 3 3   a32  f xy ( x, y )   aij ijx i 1 y j 1
 
 f xy (0,0)  0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0   a03  j 0 i 0
 f (1,0)  0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0   a13 
 xy    
 f xy (0,1)  0 0 0 0 0 1 0 0 0 2 0 0 0 3 0 0   a23 
 f (1,1)  0 9   a33 
 xy   0 0 0 0 1 2 3 0 2 4 6 0 3 6
x,y=0,1

D.B. Rowe 84
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Values from image.

y  DI
 f (0,0)  0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0   I (1, 1) 
 f (1,0)  0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0   I (0, 1) 
f ( x, y )  I ( x, y )
  
 f (0,1)  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   I (1, 1) 
    
 f (1,1)  0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0   I (2, 1) 
 f x (0,0)  0 0 0 0 2 0 2 0   I (1,0) 
  
0 0 0 4 0 0 0 0
  f x ( x, y )  [ I ( x  1, y ) 
 f x (1,0)  0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0   I (0,0) 
 f (0,1) 
 x 
0 0 0 0 0 0 0

0 2 0 2 0 0 0 0 0   I (1,0) 
 
I ( x  1, y )] / 2
 f x (1,1)  1 0 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0   I (2,0) 
 f (0,0)   
0   I (1,1)  f y ( x, y )  [ I ( x, y  1)
 y  4 0 2 0 0 0 0 0 0 0 2 0 0 0 0 0
 
 f y (1,0)  0 0 2 0 0 0 0 0   I (0,1) 
  
0 0 0 2 0 0 0 0
   I ( x, y  1)] / 2
 f y (0,1)  0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0   I (1,1) 
 f y (1,1) 
 
0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0   I (2,1)  f xy ( x, y )  [ I ( x  1, y  1)
  
 f xy (0,0)  0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0   I (1, 2) 
 f (1,0)  0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0   I (0, 2)   I ( x  1, y )
 xy    
 f xy (0,1) 
 f (1,1) 
0 0 0 0 0 1 0
0 0 0 0 0 0 1
0 1 1 0 0 0 0 1 0   I (1, 2)   I ( x, y  1)
 xy   0 0 1 1 0 0 0 0 1   I (2, 2) 
x,y=0,1  I ( x, y )] / 4

D.B. Rowe 85
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Estimate coefficient values.
The Money Slide
a  X 1DI
 a00  0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0   I (1, 1) 
a  0 0 0 0 8 0 8 0 0 0 0 0 0 0 0 0   I (0, 1) 
 10  
 a20  0 0 0 0 16 40 32 8 0 0 0 0 0 0 0 0   I (1, 1) 
    
 a30  0 0 0 0 8 24 24 8 0 0 0 0 0 0 0 0   I (2, 1) 
 a01  0 8 0 0 0 0 0 0 0 8 0 0 0 0 0 0   I (1,0) 
    
 a11  0 4 0 0 4 4 0 0 0 0 4 0 0 0 0 0   I (0,0) 
a  0 32 20 0 8 4 4 0 0 24 16 4 0 0 0 0   I (1,0) 
 21    
 a31  1 0 20 12 0 4 0 4 0 0 16 12 4 0 0 0 0   I (2,0) 
 a   16 0 16 0 0 0 40 0 0 0 32 0 0 0 8 0 0   I (1,1) 
 02    
 a12  0 8 0 0 32 4 24 0 20 4 0 0 0 0 4 0   I (0,1) 
    
 a22  0 64 40 0 64 96 68 24 40 68 16 16 0 24 16 0   I (1,1) 
 a32  0 40 24 0 32 52 52 24 20 40 16 16 0 16 12 0   I (2,1) 
    
 a03  0 8 0 0 0 24 0 0 0 24 0 0 0 8 0 4   I (1, 2) 
a  0 4 0 0 20 0 16 0 12 4 12 0 0 0 4 4   I (0, 2) 
 13    
 a23  0 32 20 0 40 52 40 16 24 52 52 12 0 24 16 4   I (1, 2) 
a  0 20 12 0 20 28 32 16 12 32 40 12 0 16 12 4   I (2, 2) 
 33  

recycle matrix

D.B. Rowe 86
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Estimate coefficient values.
a  X 1DI

Interpolate pixel values.


3 3
f ( x, y )   aij x i y j 0<x<1, 0<y<1
j 0 i 0

Can do biquadratic in corners and linear-quadratic on sides.

D.B. Rowe 87
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Example: 8×8 interpolate 1001 to 7015×7015
Expanded

* biquadratic corners, linear-quadratic sides


Low Resolution Bilinear Interpolated BiCubic Spline Interpolated

smooth between patches


Toggle Forward

D.B. Rowe 88
MU MSCS Spring 2018

7. 2D BiCubic Spline Interpolation


Example: 8×8 interpolate 1001 to 7015×7015
Expanded

* bilinear edges
Low Resolution Bilinear Interpolated BiCubic Interpolated

still “kinky” between patches


Toggle Backward

D.B. Rowe 89
MU MSCS Spring 2018

8. MRI Example

Original 64×64

Bilinear
Cubic Spline
Cubic

Original 256×256

D.B. Rowe 90
MU MSCS Spring 2018

8. MRI Example
Original 256×256 Original 64×64

D.B. Rowe Toggle Forward 91


MU MSCS Spring 2018

8. MRI Example
6301
Original 256×256 BiLinear 99

D.B. Rowe Toggle Forward/Back 92


MU MSCS Spring 2018

8. MRI Example
6301
Original 256×256 BiCubic 99

D.B. Rowe Toggle Forward/Back 93


MU MSCS Spring 2018

8. MRI Example
6301
Original 256×256 BiCubic Spline 99

D.B. Rowe Toggle Back 94


MU MSCS Spring 2018

8. MRI Example
-Original 256
●Original 64
-BiLinear
-BiCubic
-BiCubic Spline

“kink”

D.B. Rowe 95
MU MSCS Spring 2018

BiLinear, Bicubic, & BiCubic Spline Interpolation:


- To estimate between known pixel values
- BiLinear fits a linear polynomial with cross term.
- BiCubic fits a third order piecewise polynomial.
- BiCubic Spline fits third order smooth polynomial
using discrete derivatives
- BiCubic Spline captures curvature through pixels.

D.B. Rowe 96
MU MSCS Spring 2018

Thank You!
Questions?

1D 2D Example

D.B. Rowe 97

You might also like