cm=imread('cameraman.tif');
%F1=fft2(I);
%F2=fftshift(fft2(I));
%cfnormal1=mat2gray(log(1+abs(F1)));
%cfnormal=mat2gray(log(1+abs(F2)));
%subplot(1,3,1), imshow(I), title('Original Image');
%subplot(1,3,2), imshow(cfnormal1), title('DFT Image');
%subplot(1,3,3), imshow(cfnormal), title('DFT Image shifted');

s=1+sin(x+y/1.5);
figure, surf(s), shading interp, colormap bone

cp=(double(cm)/128+s)/4;
cpf=fftshift(fft2(cp));
subplot(1,3,1), imshow(cm)
subplot(1,3,2), imshow(cp) 
subplot(1,3,3), imshow(mat2gray(log(1+abs(cpf))))
%d=sqrt((128-88)^2+(128-102)^2)
% Meshgid to compute filter values
[m n]=size(I);
[x,y]=meshgrid(-n/2:n/2-1, -m/2:m/2-1);
 z=sqrt(x.^2+y.^2);
br=(z < 44 | z > 52); figure,imshow(br)

cpfbr=cpf.*br;
figure, imshow(mat2gray(log(1+abs(cpfbr))))

%Fibal Results
IF=ifft2(cpfbr);
subplot(1,4,1), imshow(cm), title('Original')
subplot(1,4,2), imshow(cp), title('Original with periodic noise')
subplot(1,4,3), imshow(mat2gray(log(1+abs(cpf)))), title('Fourier Filter')
subplot(1,4,4), imshow(mat2gray(abs(IF))), title('Filtered Image')