Wednesday, March 28, 2012

Frequency Domain Filtering

Frequency Domain Filtering

Frequency Domain Filtering

This program demonstrate the frequency domain filtering techniques like lowpass, high pass, laplacian filtering etc

Contents

Start

clear all;
close all;
clc;

Read the Image

%x1 = imread('broken.jpg');
%x1 = double(rgb2gray(x1))/255;
x1 = imread('cameraman.tif');
%x1 = imread('coins.png');
x1 = double(x1)/255;
%x1 = ones(9,9);

Take the fourier transform

F = fft2(x1);

Filter Design

[x y] = size(F);
d0 = 50;
H = ones(size(F));
for i = 1:x-1
for j =1:y-1
dist = ((i-x/2)^2 + (j-y/2)^2)^.5;
if dist > d0
H(i,j) = 0;
end
end
end

Pass the image through filter

F = fftshift(F);
Fhat = H.*F;
Fhat = fftshift(Fhat);
r = ifft2(Fhat);
r = abs(r/max(max(r)));

Display the result

Original Image
imshow(x1);

Filtered image
figure;imshow(r);
















No comments:

Post a Comment