## Developer Reference

• 2021
• 03/26/2021
• Public Content
Contents

# 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
) that 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
Linear Interpolation
):
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
).
Then, the sought-for intensity
D
(
x
D
,
y
D
) is computed by interpolating the intermediate values
I
0
and
I
1
along the
y
-axis:
D
(
x
D
,
y
D
) =
I
0
*(
y
S1
-
y
S
) +
I
1
*(
y
S
-
y
S0
).
To use the linear interpolation, set the
interpolation
parameter to
IPPI_INTER_LINEAR
or use the functions with the
Linear
suffix (pass
interpolation
=
ippLinear
to
GetSize
functions). For images with 8-bit unsigned color channels, the
ippiWarpAffine
and
ippiResizeLinear
functions 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. Linear Interpolation

#### Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.