Sei sulla pagina 1di 44

Bicubic Interpolation

Xiao Shu
1
Electrical and Computer Engineering
McMaster University, Canada
March 25, 2013
1
Email: shux@mcmaster.ca
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 1 / 24
Interpolation
Denition
Interpolation is a method of constructing new data points within the
range of a discrete set of known data points.
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 2 / 24
Interpolation
Denition
Interpolation is a method of constructing new data points within the
range of a discrete set of known data points.
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 2 / 24
Nearest-neighbour Interpolation
Use the value of nearest point
Piecewise-constant function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 3 / 24
Linear Interpolation
Straight line between neighbouring points
Piecewise-linear function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 4 / 24
Linear Interpolation
f ( x)
x
Normalization
Model: f(x) = a
1
x
1
+ a
0
x
0
Solve: a
0
, a
1
_
f(0) =a
1
0 + a
0
1
f(1) =a
1
1 + a
0
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 5 / 24
Linear Interpolation
f ( x)
x 1 1 2
f ( 0)
f ( 1)
Normalization
Model: f(x) = a
1
x
1
+ a
0
x
0
Solve: a
0
, a
1
_
f(0) =a
1
0 + a
0
1
f(1) =a
1
1 + a
0
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 5 / 24
Linear Interpolation
f ( x)
x 1 1 2
f ( 0)
f ( 1)
Normalization
Model: f(x) = a
1
x
1
+ a
0
x
0
Solve: a
0
, a
1
_
f(0) =a
1
0 + a
0
1
f(1) =a
1
1 + a
0
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 5 / 24
Linear Interpolation
f ( x)
x 1 1 2
f ( 0)
f ( 1)
Normalization
Model: f(x) = a
1
x
1
+ a
0
x
0
Solve: a
0
, a
1
_
f(0) =a
1
0 + a
0
1
f(1) =a
1
1 + a
0
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 5 / 24
Linear Interpolation
_
f(0) =a
1
0 + a
0
1
f(1) =a
1
1 + a
0
1
Let y =
_
f(0) f(1)

T
, B =
_
0 1
1 1
_
and a =
_
a
1
a
0

T
Then the equations can be written as y = Ba
Thus f(x) = ba = bB
1
y, where b =
_
x
1
x
0

Example:
f(0.5)=
_
0.5
1
0.5
0

_
0 1
1 1
_
1
y
=
_
0.5 1

_
1 1
1 0
_
y
=
_
0.5 0.5

y
=
1
2
f(0) +
1
2
f(1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 6 / 24
Cubic Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 7 / 24
Cubic Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 7 / 24
Cubic Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 7 / 24
Cubic Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 7 / 24
Cubic Interpolation
f ( x)
x
f ( 1)
f ( 0)
f ( 2)
f (1)
Model: f(x) =
3

i=0
a
i
x
i
= a
3
x
3
+ a
2
x
2
+ a
1
x
1
+ a
0
_

_
f(1) =a
3
(1)
3
+a
2
(1)
2
+a
1
(1)
1
+a
0
(1)
0
f(0) =a
3
0
3
+a
2
0
2
+a
1
0
1
+a
0
0
0
f(1) =a
3
1
3
+a
2
1
2
+a
1
1
1
+a
0
1
0
f(2) =a
3
2
3
+a
2
2
2
+a
1
2
1
+a
0
2
0
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 8 / 24
Cubic Interpolation
Let
y =
_
f(1) f(0) f(1) f(2)

T
B =
_

_
(1)
3
(1)
2
(1)
1
(1)
0
0
3
0
2
0
1
0
0
1
3
1
2
1
1
1
0
2
3
2
2
2
1
2
0
_

_
=
_

_
1 1 1 1
0 0 0 1
1 1 1 1
8 4 2 1
_

_
a =
_
a
3
a
2
a
1
a
0

T
Then the equations can be written as y = Ba
Thus f(x) = ba = bB
1
y, where b =
_
x
3
x
2
x
1
x
0

Example:
f(0.5)=
_
0.5
3
0.5
2
0.5
1
0.5
0

_
0.167 0.5 0.5 0.167
0.5 1 0.5 0
0.333 0.5 1 0.167
0 1 0 0
_

_
y
=
_
0.0625 0.5625 0.5625 0.0625

y
=
1
16
_
1 9 9 1

y
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 9 / 24
Cubic Spline Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 10 / 24
Cubic Spline Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 10 / 24
Cubic Spline Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 10 / 24
Cubic Spline Interpolation
Piecewise-cubic function
f ( x)
x
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 10 / 24
Cubic Spline Interpolation
Model:
f(x) =
3

i=0
a
i
x
i
= a
3
x
3
+ a
2
x
2
+ a
1
x
1
+ a
0
f

(x) =
3

i=1
ia
i
x
i1
= 3a
3
x
2
+ 2a
2
x
1
+ a
1
_

_
f(0) =a
3
0
3
+a
2
0
2
+a
1
0
1
+a
0
0
0
f(1) =a
3
1
3
+a
2
1
2
+a
1
1
1
+a
0
1
0
f

(0) =a
3
3 0
2
+a
2
2 0
1
+a
1
1 0
0
f

(1) =a
3
3 1
2
+a
2
2 1
1
+a
1
1 1
0
_

_
f(0) =f(0)
f(1) =f(1)
f

(0)
1
2
f(1)
1
2
f(1)
f

(1)
1
2
f(2)
1
2
f(0)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 11 / 24
Cubic Spline Interpolation
Let
z =
_
f(0) f(1) f

(0) f

(1)

T
B =
_

_
0
3
0
2
0
1
0
0
1
3
1
2
1
1
1
0
3 0
2
2 0
1
1 0
1
0
3 1
2
2 1
1
1 1
1
0
_

_
=
_

_
0 0 0 1
1 1 1 1
0 0 1 0
3 2 1 0
_

_
a =
_
a
3
a
2
a
1
a
0

T
Then the rst set of equations can be written as z = Ba
Let
y =
_
f(1) f(0) f(1) f(2)

T
C =
_

_
0 1 0 0
0 0 1 0

1
2
0
1
2
0
0
1
2
0
1
2
_

_
Then the second set of equations can be written as z = Cy
Thus Ba = Cy, and a = B
1
Cy
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 12 / 24
Cubic Spline Interpolation
f(x) = ba = bB
1
Cy, where b =
_
x
3
x
2
x
1
x
0

Example:
f(0.5)=
_
0.5
3
0.5
2
0.5
1
0.5
0

(B
1
C)y
=
_
0.125 0.25 0.5 1

_
0.5 1.5 1.5 0.5
1 2.5 2 0.5
0.5 0 0.5 0
0 1 0 0
_

_
y
=
_
0.0625 0.5625 0.5625 0.0625

y
=
1
16
_
1 9 9 1

y
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 13 / 24
Bilinear Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
Model f(x, y) as a bilinear surface
Interpolate f(
1
2
, 0) using f(0, 0) and f(1, 0)
Interpolate f(
1
2
, 1) using f(0, 1) and f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0) and f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 14 / 24
Bilinear Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
Model f(x, y) as a bilinear surface
Interpolate f(
1
2
, 0) using f(0, 0) and f(1, 0)
Interpolate f(
1
2
, 1) using f(0, 1) and f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0) and f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 14 / 24
Bilinear Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
f (
1
2
, 1)
f (
1
2
, 0)
Model f(x, y) as a bilinear surface
Interpolate f(
1
2
, 0) using f(0, 0) and f(1, 0)
Interpolate f(
1
2
, 1) using f(0, 1) and f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0) and f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 14 / 24
Bilinear Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
f (
1
2
, 1)
f (
1
2
, 0)
f (
1
2
,
1
2
)
Model f(x, y) as a bilinear surface
Interpolate f(
1
2
, 0) using f(0, 0) and f(1, 0)
Interpolate f(
1
2
, 1) using f(0, 1) and f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0) and f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 14 / 24
Bilinear Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
Model: f(x, y) =
1

i=0
1

i=0
a
ij
x
i
y
i
= a
11
xy + a
10
x + a
01
y + a
00
_

_
f(0, 0) =a
11
0 +a
10
0 +a
01
0 +a
00
1
f(0, 1) =a
11
0 +a
10
0 +a
01
1 +a
00
1
f(1, 0) =a
11
0 +a
10
1 +a
01
0 +a
00
1
f(1, 1) =a
11
1 +a
10
1 +a
01
1 +a
00
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 15 / 24
Bicubic Spline Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
Interpolate
f(
1
2
, 0) using f(0, 0), f(1, 0),
x
f(0, 0) and
x
f(1, 0)
f(
1
2
, 1) using f(0, 1), f(1, 1),
x
f(0, 1) and
x
f(1, 1)

y
f(
1
2
, 0) using
y
f(0, 0),
y
f(1, 0),
xy
f(0, 0) and
xy
f(1, 0)

y
f(
1
2
, 1) using
y
f(0, 1),
y
f(1, 1),
xy
f(0, 1) and
xy
f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0), f(
1
2
, 1),
y
f(
1
2
, 0) and
y
f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 16 / 24
Bicubic Spline Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
f (
1
2
, 1)
f (
1
2
, 0)
Interpolate
f(
1
2
, 0) using f(0, 0), f(1, 0),
x
f(0, 0) and
x
f(1, 0)
f(
1
2
, 1) using f(0, 1), f(1, 1),
x
f(0, 1) and
x
f(1, 1)

y
f(
1
2
, 0) using
y
f(0, 0),
y
f(1, 0),
xy
f(0, 0) and
xy
f(1, 0)

y
f(
1
2
, 1) using
y
f(0, 1),
y
f(1, 1),
xy
f(0, 1) and
xy
f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0), f(
1
2
, 1),
y
f(
1
2
, 0) and
y
f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 16 / 24
Bicubic Spline Interpolation
f (0,0)
f (1,1)
f (0,1)
f (1,0)
f (
1
2
, 1)
f (
1
2
, 0)
f (
1
2
,
1
2
)
Interpolate
f(
1
2
, 0) using f(0, 0), f(1, 0),
x
f(0, 0) and
x
f(1, 0)
f(
1
2
, 1) using f(0, 1), f(1, 1),
x
f(0, 1) and
x
f(1, 1)

y
f(
1
2
, 0) using
y
f(0, 0),
y
f(1, 0),
xy
f(0, 0) and
xy
f(1, 0)

y
f(
1
2
, 1) using
y
f(0, 1),
y
f(1, 1),
xy
f(0, 1) and
xy
f(1, 1)
Interpolate f(
1
2
,
1
2
) using f(
1
2
, 0), f(
1
2
, 1),
y
f(
1
2
, 0) and
y
f(
1
2
, 1)
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 16 / 24
Bicubic Spline Interpolation
Model:
f(x, y) =
3

i=0
3

j=0
a
ij
x
i
y
j

x
f(x, y) =
3

i=1
3

j=0
ia
ij
x
i1
y
j

y
f(x, y) =
3

i=0
3

j=1
ja
ij
x
i
y
j1

xy
f(x, y) =
3

i=1
3

j=1
ija
ij
x
i1
y
j1
Approximation:

x
f(x, y) = [f(x + 1, y) f(x 1, y)]/2

y
f(x, y) = [f(x, y + 1) f(x, y 1)]/2

xy
f(x, y) = [f(x+1, y+1)f(x1, y)f(x, y1)+f(x, y)]/4
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 17 / 24
Examples
Figure: Nearest Neighbour Interpolation
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 18 / 24
Examples
Figure: Bilinear Interpolation
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 19 / 24
Examples
Figure: Bicubic Spline Interpolation
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 20 / 24
Examples
Figure: Bilinear Interpolation
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 21 / 24
Examples
Figure: Bicubic Interpolation
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 22 / 24
Properties of Linear and Cubic Interpolations
Linear: f
l
(0.5) =
1
2
f(0) +
1
2
f(1)
Cubic: f
c
(0.5) =
1
16
(1) +
9
16
f(0) +
9
16
f(1)
1
16
f(2)
The absolute dierence between the results of linear and cubic
interpolations
|f
c
(0.5) f
l
(0.5)|
=

1
16
f(1) +
1
16
f(0) +
1
16
f(1)
1
16
f(2)

| 0 + 1 + 1 0|
16
= 0.125
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 23 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24
Properties of Linear and Cubic Interpolations
f ( x)
x
1
X. Shu (ECE @ McMaster) Bicubic Interpolation March 25, 2013 24 / 24

Potrebbero piacerti anche