B=imread('lenna.jpg');
A=double(rgb2gray(B));
subplot(1,2,1);
imshow(A,[]);
title('Original Image');
%imshow(C,[]);
[m n]=size(A);
F=zeros(m,n,'double');
F=A;
C=fft2(A);
D=fftshift(C);
%imshow(uint8(C));
%[th r]=cart2pol(real(C),imag(C));
limit=15;
for u=1:m
for v=1:n
D1(u,v)=sqrt(((u-(m/2))^2)+((v-(n/2))^2));
if D1(u,v)<=limit
H=1;
else
H=0;
end
I1(u,v)=H*D(u,v);
end
end
% F1=ifft2(I1);
F1=ifftshift(I1);
F2=ifft2(F1);
subplot(1,2,2);
imshow(F2,[]);
title('Ideal LowPass');
%Y=fftshift();
%imshow(uint8(Y));