% Kap4_2
f=imread('Rectangle.tif');
f=im2double(f);
F=fft2(f);
S=abs(F);
imshow(S,[])
pause

Fc=fftshift(F);
Sc=abs(Fc);
figure; imshow(Sc,[])
pause

g=f;
[M N]=size(g)
for x=1:M
    for y=1:N
        g(x,y)=((-1)^(x+y))*f(x,y);
    end
end
G=fft2(g);
%figure; imshow(abs(G),[])
%pause

S2=1*log(1+abs(Fc));
%figure; imshow(S2,[])
%pause

S3=1.44*log(1+abs(Fc));
%figure; imshow(S3,[])
%pause

f2=imread('building.tif');
f2=im2double(f2);
%figure; imshow(f2)
%pause

[M2 N2]=size(f2)
F2=fft2(f2);
Fc2=fftshift(F2);
Sc2=log(1+abs(Fc2));
%figure; imshow(Sc2,[])
%pause

f2invers=ifft2(F2);
%f2invers=real(ifft2(F2));
%figure; imshow(f2invers)
%pause

BW=imread('B&Wsquare.tif');
BW=im2double(BW);
figure; imshow(BW,[])
pause


BWpad=fft2(BW,512,512);
InvBWpad=real(ifft2(BWpad));
figure; imshow(InvBWpad,[])
pause
close all