% test est_transrot with tiles function

angle_actual = 1*o;
b_actual=0+0*i;

M=240;     % image size that will be used (de-interlace by undersampling)
N=320;
u=3;       % number of cycles (spatial frequency in cycles/picture
v=3*320/240; % so that same number cyc/pel each dir.

E=tilesabc(u,v,M,N,1,0);   % identity reference image
figure(2)
colormap(gray(200))
subplot(221)
tvs(E)
title('original')
grid

Etransrot=tilesabc(u,v,M,N,exp(i*angle_actual),b_actual);
subplot(222)
tvs(Etransrot)
title('rotated 1 deg')
grid

[b a]=est_transrot(E,Etransrot)
angle_estimated = angle(a);
disp(sprintf('Actual angle=%g deg; estimated angle=%g deg.', angle_actual/o, ...
     angle_estimated/o))

% ------------------------------------
% test est_transrot with image

load lights_wide
subplot(223)
tvs(lights)
title('original image')
grid

lights_transrot=resample(exp(i*angle_actual),lights,b_actual);
subplot(224)
tvs(lights_transrot)
title('image resampled to 1 deg rotation')
grid

[b a]=est_transrot(lights,lights_transrot)
angle_estimated = angle(a);
disp(sprintf('Actual angle=%g deg; estimated angle=%g deg.', angle_actual/o, ...
     angle_estimated/o))

