% Ex4_4
f=imread('TestPattern.tif');
f=im2double(f);
imshow(f,[ ]);pause

[M N]=size(f);
P=2*M; Q=2*N;
[U V]=dftuvTN(P,Q);
F=fft2(f,P,Q);
D0=0.05*N;
D=U.^2+V.^2;
H=exp(-D/(2*(D0^2)));
g=dftfiltTN(f,H);

figure,imshow(fftshift(H),[]);pause
figure,imshow(log(1+abs(fftshift(F))),[]);pause
figure,imshow(g,[ ]);pause

close all