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


im = double(imread( 'mona.tif'));
[nr,nc] = size(im);
nr = floor(nr/2) * 2;
nc = floor(nc/2) * 2;
im = 0.25*(im(1:2:nr,1:2:nc) + im(2:2:nr,1:2:nc) + ...
   im(1:2:nr,2:2:nc) + im(2:2:nr,2:2:nc));
colormap(gray(256));
subplot(1,1,1);  image( im + 1 );  axis image;

pause;

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

x = colcoords( size(im) );
y = rowcoords( size(im) );
xc = nc / 4;
yc = nr / 4;

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

im_ = resample( im, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause

im_ = resample( im_, x_, y_ );
subplot(1,1,1);  image( im_ + 1 );  axis image;
pause




