clc clear all %Load image I=imread('cameraman.tif'); I = double(I): FI=fftshift(fft2(I)); [m,n]=size(I); [X,Y]=meshgrid(1:n,1:m); X=X-(n+1)/2; Y=Y-(m+1)/2; D=sqrt(X.^2+Y.^2); imshow(I); % --------------------Smoothing---------------------------------------------------------------- %---------------------Ideal LPF---------------------------------------------------------------- ILPF=D<60; figure J=ifft2(fftshift(FI.*ILPF)); imshow(abs(J),[]);title('Ideal LPF') %-------------------Gaussian LPF-------------------------------------------------------------- D0=30; GLPF=exp(-D.^2/(2*D0^2)); figure; J=ifft2(fftshift(FI.*GLPF)); imshow(abs(J),[]);title('Gaussian LPF') %-------------------Chebyshev LPF------------------------------------------------------------ cutoff=60; n=1; %order 1 BLPF = 1 ./ (1.0 + (D./ cutoff).^(2*n)); figure; J=ifft2(fftshift(FI.*BLPF)); imshow(abs(J),[]);title('Butterworth LPF') %------------------------------------------------------------------------------------------------ %-------------------Sharpening------------------------------------------------------------------ %-------------------Ideal HPF------------------------------------------------------------------- IHPF=D>60; figure J=ifft2(fftshift(FI.*IHPF)); imshow(abs(J),[]);title('Ideal HPF') %------------------Gaussian HPF---------------------------------------------------------------- D0=30; GHPF=1-exp(-D.^2/(2*D0^2)); figure; J=ifft2(fftshift(FI.*GHPF)); imshow(abs(J),[]);title('Gaussian HPF') %-----------------Butterworth HPF-------------------------------------------------------------- cutoff=60; n=1; %order 2 BHPF= 1 ./ (1.0 + (cutoff ./ D).^(2*n)); figure; J=ifft2(fftshift(FI.*BHPF)); imshow(abs(J),[]);title('Butterworth HPF')