function ims = scaleit(im, scale, method)
% ims = scaleit(im, scale, method)
% scales im a factor scale(1) in the x direction
% and a factor scale(2) in the y direction.
%
% method can be one of 'p', 'b', 'c', and 's' (spline)

xdim = size(im, 2);
ydim = size(im, 1);
if nargin == 2
    method = 'nearest';
elseif method == 'p'
    method = 'nearest';
elseif method == 'b'
    method = 'linear';
elseif method == 'c'
    method = 'cubic';
elseif method == 's'
    method = 'spline';
else
    error('wrong interpolation method')
end

ims = interp2(im, linspace(1, xdim, round(xdim * scale(1))),...
    linspace(1, ydim, round(ydim * scale(2)))', method);
