Image Geometry 129
Equation 6.1, then
f(x, y
) = µf (x, y + 1) + (1 − µ)f (x, y)
and
f(x + 1, y
) = µf (x + 1, y + 1) + (1 − µ)f( x + 1, y).
Along the y
column we have
f(x
, y
) = λf (x + 1, y
) + (1 − λ)f(x, y
)
and substituting in the values just obtained produces
f(x
, y
) = λ(µf (x + 1, y + 1) + (1 − µ)f(x + 1, y)) + (1 −λ)(µf (x, y + 1)
+ (1 − µ)f(x, y))
= λµf(x + 1, y + 1) + λ(1 − µ)f(x + 1, y) + (1 −λ)µf (x, y + 1)
+ (1 − λ)(1 − µ)f (x, y)
This last equation is the formula for bilinear interpolation.
Now image scaling can be performed easily. Given our image, and either a scaling factor
(or separate scaling factors for x and y directions), or a size to be scaled to, we first create
an array of the required size. In our example above, we had a 4 ×4 image, given as an array
(x, y), and a scale factor of two, resulting in an array (x
, y
) of size 8 ×8. Going right back
to Figures 6.1 and 6.2, the relationship between (x, y) and (x
, y
) is
(x
, y
) =
1
3
(7x −4),
1
3
(7y − 4)
,
(x, y) =
1
7
(3x
+ 4),
1
7
(3y
+ 4)
.
Given our (x
, y
) array, we can step through it point by point, and from the corresponding
surrounding points from the (x, y) array calculate an interpolated value using either nearest
neighbor or bilinear interpolation.
There’s nothing in the above theory that requires the scaling factor to be greater than
one. We can choose a scaling factor less than one, in which case the resulting image array
will be smaller than the original. We can consider Figure 6.6 in this light: the small closed
circles are the original image points, and the large open circles are the smalle r array on
which we are to find interpolated values.
MATLAB has the function
imresize which does all this for us. It can be called with
imresize(A,k,’method’)
where A is an image of any type, k is a scaling factor, and ’method’ is either ’nearest’ or
’bilinear’ (or another method to be described later). Another way of using imresize is
imresize(A,[m,n],’method’)
where [m,n] provide the size of the scaled output. There is a further, optional parameter
allowing you to choose either the size or type of low pass filter to be applied to the image
before reducing its size—see the help file for details.
Let’s try a few examples. We shall start by taking the head of the cameraman, and
enlarging it by a factor of f our: