I=imread('cameraman.tif');
F1=fft2(I);
F2=fftshift(fft2(I));
%cfnormal1=mat2gray(log(1+abs(F1)));
cfnormal=mat2gray(log(1+abs(F2)));
[x,y]=meshgrid(-128:127,-128:127);
z=sqrt(x.^2+y.^2); % D(u,v) apo Gonzalez and Woods
%Filters
%c=(z<30);  % lowpass ideal filter at Do
%c=1-c;   %highpass ideal filter at Do
%c=1./(1+(z./25).^2);  %lowpass Butterworth filter Do=25, n=1
%c=1-c;   %highpass Butterworth filter Do=15, n=1
%figure, imshow(b)
%figure, surf(double(b)), shading interp, colormap jet
c=e.^(- 0.5*((x.^2+y.^2)/25^2 )); %Gaussian lowpass Do=30
c=1-c;
%figure, surf(double(c)), shading interp, colormap jet
% Filtering at the Frequency domain
cF=F2.*c;
IcF=ifft2(cF);
subplot(2,2,1), imshow(I), title('Original Image');
subplot(2,2,2), imshow(cfnormal), title('DFT Image shifted');
subplot(2,2,3), imshow(mat2gray(log(1+abs(cF)))); 
subplot(2,2,4), imshow(mat2gray(abs(IcF)))