clc
close all
clear all

% Read the image, resize it to 256 x 256
% Convert it to grey image and display it

mygrayimg = imresize(rgb2gray(mygrayimg),[256 256]);
subplot(2,2,1);
imshow(mygrayimg),title('Original Image');

% Find FFT
% Use the command fft2() to get FFT of the image
% The log scale of FFT image is displayed

myfftimage = fft2(mygrayimg);

% Take logarithmic scale for display

tmp = abs(myfftimage);
mylogimg = log(1+tmp);

subplot(2,2,2);
imshow(mat2gray(mylogimg));
title('FFT Image');

% Find size
[M,N] = size(myfftimage);

% Create Filter array

% The cut off frequency 20 is used here

low = 62;
band1 = 15;
band2 = 60;

% create ideal high pass filter mask

% Create matrix of size equals original matrix

% Generate values for ideal high pass mask

for u = 1:M
for v = 1:N

tmp = ((u-(M+1))/2)^2 +(v-(N+1)/2)^2;

end

end
end
end

% Shift the spectrum to the centre

% Apply the filter H to the FFT of the Image
resimage1 = myfftimage.*f1;
resimage3 = myfftimage.*f3;

% Apply the Inverse FFT to the filtered image

% Display the low pass filtered image
r1 = abs(ifft2(resimage1));
subplot(2,2,3);
imshow(r1,[]),title('Low Pass filtered image');

% Display the band pass filtered image

r3 = abs(ifft2(resimage3));
subplot(2,2,4);
imshow(r3,[]),title('Band Pass filtered image');

MATLAB CODES - FFT Image , Low pass Filtered Image , Band Pass Filtered Image Reviewed by Suresh Bojja on 9/11/2018 03:26:00 AM Rating: 5

## Subjects & Labs

AC (6) ADS (2) ATMEL (6) AWP (5) C- Language (3) CAO (5) CDAC (1) CMC (6) CN (10) Control Sys (2) CVSM (2) DBMS (1) DC (5) DIP (17) DLD (10) DS (4) DSD&DICA (9) DSP (6) EDC (45) Embedded (7) EMWTL (6) ENERGY AUDIT (1) Engg.Chemistry (11) Faculty Labs (1) Fuzzy (3) II MID (1) LICA (1) Linux OS (1) Materials (1) MATLAB (27) MCU IDE 8051 (1) MEMS (4) MPMC (57) MTECH (6) MWE (2) OC (1) PDC (9) Projects (8) RADAR (1) Research (9) RVSP (3) SC (1) Softwares (1) SS (2) STLD (19) TCSS (1) TSSN (1) TV Engg (1) VHDL (4) VLSI (8) WCN (1) WSN (2)