Wednesday, July 23, 2008

Activity 7: Enhancement in the Frequency Domain

A. Anamorphic Property of Fourier Transform

Using the codes below, a 2D sinusoid was created and its Fourier Transform(FT) was shown.

nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4 //frequency
z = sin(2*%pi*f*X);
scf(1);
imshow(z,[]);
fftz = fft2(z);
scf(2);
imshow (abs(fftz), []); // FT modulus

The following images have frequencies of 2, 4 and 24. It can be observed that as the
frequency is increased the farther the points are from each other.





//Rotation
theta = 30;
z1 = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));
fftz1 = fft2(z1);
scf(3);
imshow (abs(fftz1), []);

The following were rotated at 30, 45, and 60 degrees. The FT of the image is tilted just like
the original image is.
//combination
z2 = sin(2*%pi*4*X).*sin(2*%pi*4*Y);
fftz2 = fft2(z2);
scf(4);
imshow (abs(fftz2), []);



B. Ridge enhancement
Using the code below, the fingerprint was enhanced. This was done by using a high pass filter.
img = imread('C:\Users\nez\Desktop\activity 7 final\finger.jpg');
imgray = im2gray(img);
pic =imgray-mean(img);
scf(1);
imshow(pic);

im=fft2(pic);

ff=real((im).*conj(im));
scf(3);
imshow(fftshift(log(ff+1)),[]);
xset('colormap',jetcolormap(64));

//Transfer function
filter=mkfftfilter(pic,'exp',30);
scf(4);
imshow(filter);

//High-pass filter
IM=im.*fftshift(1-filter);
IMAGE=real(fft2(IM));
scf(5); imshow(IMAGE);

scf(6);
imshow(abs(fftshift(fft2(IMAGE))), []);
xset('colormap', jetcolormap(64));


(clockwise from top left: original image; mean centered image; FFT of mean centered image; FFT of enhanced image; enhance image; filter)


C. Line Removal

This was done using the code below. A filter was used to remove the lines from the original image.
img = imread("C:\Users\nez\Desktop\activity 7 final\hi_res_vertical_lg.gif");
imgray = im2gray(im);
Fimgray = fft2(imgray);

scf(1);
imshow(fftshift(abs(Fimgray)),[]);

//filtering
b = imread('C:\Users\nez\Desktop\activity 7 final\filter2.bmp');
a = imread('C:\Users\nez\Desktop\activity 7 final\hi_res_vertical_lg.gif');

bgray = im2gray(b);
agray = im2gray (a);
Fb = fftshift(bgray);
Fa = fft2 (agray);
FRA = Fb.*(Fa);
IRA = fft2 (FRA); //inverse FFT
FImage = abs(IRA);
imshow(FImage, [ ]);

Grade: 6/10 - It was passed late.

No comments: