It is obviously more desirable to arbitrarily resize a given image (enlarge
or reduce the image proportionally or non-proportionally). We first consider
converting a one-dimensional m-sample input
into an n-sample output
, where
is the
desired size of the output, which may be either smaller or greater than
,
i.e., the scaling factor
can be either greater or smaller than 1 (for
either enlargement or reduction). The method is essentially a two-step process
of linear interpolation and re-sampling.
Represent each index
of the output as a floating
point number
in the range of
of the input indices:
Find the fraction
and
as shown in the figure:
This method of linear interpolation can be generalized from 1-D to 2-D bilinear interpolation for image resizing.
Similar to the 1D case, we first convert the integer indices of each
pixel of the output image of the desired size into real coordinates
in the range of the input image. Then the corresponding fractions
and
in both horizontal and vertical dimensions can be found:
Find value as the bilinear interpolation of its four immediate neighbors
in the input image, represented by
The bilinear interpolation is carried out in two levels of linear
interpolations. We first find the two interpolations of ,
and
,
along the dimension with index
: