% INF2310 - Ukeoppgaver 8, oppgave 1.

N = 256;
i = (0:N-1)';

im = double(imread('car.png'));
IM = fft2(im);

figure(1);  imagesc( log( abs(fftshift(IM)) + 1) );  colorbar;
figure(2);  imagesc( angle(IM) );  colorbar;

fprintf(' b)\n');
IM(1,1)
sum(im(:))

fprintf(' c)\n');
u = 5;
v = 7;
b = sin( -2*pi*(u.*repmat(i,1,N) + v.*repmat(i',N,1))/N );

figure(3);  imagesc(b);  colormap gray;

fprintf(' d)\n');
sum( im(:) .* b(:) )
imag(IM(u+1,v+1))

fprintf(' e)\n');
b_r = cos( -2*pi*(u.*repmat(i,1,N) + v.*repmat(i',N,1))/N );
sum( b_r(:) .* b(:) )

fprintf(' f)\n');
u2 = 11;
v2 = 5;

b2 = sin( -2*pi*(u2.*repmat(i,1,N) + v2.*repmat(i',N,1))/N );
sum( b2(:) .* b(:) )

