Thursday, July 10, 2008

A7 – Enhancement in the Frequency Domain


The Fourier Transform (FT) of a signal gives the spatial frequency distribution of
that signal. Essentially, the Fourier Theorem states that any image or signal can be
expressed as a superposition of sinusoids. Unique to the 2D FT (as compared to
the 1D FT) is the fact that rotation of the sinusoids result to the rotation of their
FT's.


For this activity we have three tasks:
A. Anamorphic Property of Fourier Transform
B. Ridge Enhancement
C. Line Removal


7A. A Anamorphic property of the Fourier Transform


Create a 2D sinusoid using Scilab in the X direction.

nx = 100; ny = 100;
x = linspace(-1,1,nx);
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y);
f = 4;
z = sin(2*%pi*f*X);
imshow(z,[]);

The image is like a corrugated roof. The image is a sine function.

Then we will get the fourier transform of the image.

I = imread('roof.bmp');
Igray = im2gray(I);
FIgray = fft2(Igray);
imshow(fftshift(abs(FIgray)),[]);
xset("colormap", hotcolormap(255));

The image shows two dots at the center of the image.The dots represent the frequency of the sine function. There are no pixels in the x-direction, because the image is the same everywhere in that direction.


When we increase the frequency, we will see that

f = 10

We can see that the number of lines increases and the dots are near the edges of the image.

As the frequency increases, the dots go farther from each other.

When we create a 2-D sinusoid in the X- direction,the dots are in Y-direction.

Then we will rotate the sinusoid,

f = 4;
theta = 30;
z = sin(2*%pi*f*(Y*sin(theta) + X*cos(theta)));

In the FT image, the dots are in the X- direction and the second dot is tilted, at the same degree as the sinusoid is rotated.

Using different values of theta


We will then create a pattern. I used the pattern given in the manual
z = sin(2*%pi*4*X).*sin(2*%pi*4*Y); this is a product of two corrugated roofs, one running in the X-direction, the other in Y.

f = 4;
z = sin(2*%pi*4*X).*sin(2*%pi*4*Y);

We can see that the resulting image is a checkered black and white image. The image 2D cosine with both horizontal and vertical components. They have 4 cycles horizontally and vertically. And the FT image has for dots forming a square near the center of the image.

fx = 4;
fy = 8
z = sin(2*%pi*fx*X).*sin(2*%pi*fy*Y);

The dots in the FT image correspond to the frequency of the stripes in the original image.

Activity 7.B Fingerprints : Ridge Enhancement

For this activity, we will use fingerprint.

img = imread('finger.jpg');
scf(1)
imshow(img)
img = im2gray(img);
image =img-mean(img);
scf(2);
imshow(image);

im=fft2(image);

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

//Transfer function
filter=mkfftfilter(image,'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));

Using the image in the Activity 7 manual

Using my own image(c/0 Julie D.)


Activity 7.C Lunar Landing Scanned Pictures : Line removal

Using the same commands we used in the previous activity for getting the fft and using filters.

// getting the FT of original image
im = imread('moon.jpg');
imgray = im2gray(im); // convert to grayscale
Fimgray = fft2(imgray);// Fourier Transform
scf(1);
imshow(fftshift(abs(Fimgray)),[]);
xset("colormap", hotcolormap(255));// using colormap

// getting the enhanced image by filtering
b = imread('filter.jpg');
a= imread('moon.jpg')
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, [ ]);



The lines in the filter corresponds to the line in the original image which we want to remove.

Acknowledgements:
http://www.cs.unm.edu/~brayer/vision/fourier.html
http://student.kuleuven.be/~m0216922/CG/fourier.html

Julie D. - for the scanned fingerprint
Aiyin and Beth - for answering my questions

Grade:
10/10
- because I did what the activity asks to do.

0 comments:

 
template by suckmylolly.com