Specifications

Interpolation in Geometric Transformation Functions
B-5
B
Cubic Interpolation
The cubic interpolation algorithm (see Figure B-2) uses source image
intensities at sixteen pixels in the neighborhood of the point (x
S
,y
S
)inthe
source image:
x
S0
= int(x
S
) - 1 x
S1
= x
S0
+1 x
S2
= x
S0
+2 x
S3
= x
S0
+3
y
S0
= int(y
S
) - 1 y
S1
= y
S0
+1 y
S2
= y
S0
+2 y
S3
= y
S0
+3.
First, for each y
Sk
the algorithm determines four cubic polynomials F
0
(x),
F
1
(x), F
2
(x), and F
3
(x):
F
k
(x)=a
k
x
3
+ b
k
x
2
+ c
k
x + d
k
0 k [3,
such that
F
k
(x
S0
)=S(x
S0
,y
Sk
), F
k
(x
S1
)=S(x
S1
, y
Sk
), F
k
(x
S2
)=S(x
S2
,y
Sk
), F
k
(x
S3
)=S(x
S3
,y
Sk
).
In Figure B-2, these polynomials are shown by solid curves.
Then, the algorithm determines a cubic polynomial F
y
(y) such that
F
y
(y
S0
)=F
0
(x
S
), F
y
(y
S1
)=F
1
(x
S
), F
y
(y
S2
)=F
2
(x
S
), F
y
(y
S3
)=F
3
(x
S
).
The polynomial F
y
(y) is represented by the dashed curve in Figure B-2.
Finally, the sought-for intensity D(x
D
,y
D
)issettothevalueF
y
(y
S
).
To use the cubic interpolation, set the parameter
interpolate
to
IPL_INTER_CUBIC.
For images with 1-bit and 8-bit unsigned color channels, the functions
iplWarpAffine, iplRotate,andiplShear compute the coordinates
(x
S
,y
S
) with the accuracy 2
–16
= 1/65536. For images with 16-bit unsigned
color channels, these functions compute the coordinates with floating-point
precision.