% resampledemo.m - demonstrate bi-linear interpolation by rotating an image

clear

im = double(pnmread( 'im.000001.pgm' ));
[nr,nc] = size(im);
colormap(gray(256));
image( im + 1 );
pause

cs = cos( 10 * pi / 180.0 );
sn = sin( 10 * pi / 180.0 );

[x, y] = meshgrid( 1:nc, 1:nr );
xc = nc / 2;
yc = nr / 2;

x_ =  cs * (x-xc) + sn * (y-yc) + xc;
y_ = -sn * (x-xc) + cs * (y-yc) + yc;


im_ = im;
for i = 0:36
    im_ = resamplenn( im_, x_, y_ );
    if rem(i,3) == 0 
        image( im_ + 1 );
        pause;
    end
end


