Specifications

Interpolation in Geometric Transformation Functions
B-3
B
Mathematical Notation
In this appendix we’ll use the following notation:
(x
D
,y
D
) pixel coordinates in the destination image
(integer values)
(x
S
, y
S
) the computed coordinates of a point in the source
image that is mapped exactly to (x
D
,y
D
)
S(x, y) pixel value (intensity) in the source image
D(x, y) pixel value (intensity) in the destination image.
Nearest Neighbor Interpolation
This is the fastest and least accurate interpolation mode. The pixel value in
the destination image is set to the value of the source image’s pixel closest
to the point (x
S
,y
S
): D(x
D
,y
D
)=S(round(x
S
),round(y
S
)).
To use the nearest neighbor interpolation, set the parameter
interpolate
to IPL_INTER_NN.
Linear Interpolation
The linear interpolation is slower but more accurate than the nearest
neighbor interpolation. On the other hand, it is faster but less accurate than
cubic interpolation. The linear interpolation algorithm uses source image
intensities at the four pixels (x
S0
,y
S0
), (x
S1
,y
S0
), (x
S0
,y
S1
), (x
S1
,y
S1
) which are
closest to (x
S
,y
S
) in the source image:
x
S0
= int(x
S
), x
S1
= x
S0
+1, y
S0
= int(y
S
), y
S1
= y
S0
+1.
First, the intensity values are interpolated along the x-axis to produce two
intermediate results I
0
and I
1
(see Figure B-1):
I
0
= S(x
S
, y
S0
)=S(x
S0
, y
S0
)*(x
S1
- x
S
)+S(x
S1
, y
S0
)*(x
S
x
S0
)
I
1
= S(x
S
, y
S1
)=S(x
S0
, y
S1
)*(x
S1
- x
S
)+S(x
S1
, y
S1
)*(x
S
x
S0
).