Activity 6.A – Familiarization with discrete FFT
First we made a 128 x 128 image of a circle using paint
Using scilab, we will convert the image to grayscale and apply Fourier transform.
im = imread('circle.bmp');
imgray = im2gray(im); // convert to grayscale
Fimgray = fft2(imgray);// Fourier Transform
scf(1);
imshow(abs(Fimgray),[]);
xset("colormap", hotcolormap(255)); // using colormap
applying fftshift
scf(2);
imshow(fftshift(abs(Fimgray)),[]);
xset("colormap", hotcolormap(255));// using colormap
The result is an airy disc.
applying Fourier transform again
scf(3);
imshow(abs(fft2(Fimgray)),[]);
The resulting image is the original image but the circle is shifted from the center to the left.
The next task is to apply the coomands to a letter A.
im = imread('A.bmp');
imgray = im2gray(im); // convert to grayscale
Fimgray = fft2(imgray);// Fourier Transform
scf(1);
imshow(abs(Fimgray),[]);
xset("colormap", hotcolormap(255)); // using colormap
applying fftshift
scf(2);
imshow(fftshift(abs(Fimgray)),[]);
xset("colormap", hotcolormap(255));// using colormap
applying Fourier transform again
scf(3);
imshow(abs(fft2(Fimgray)),[]);
The resulting image is an inverted letter A.
Activity 6.B Simulation of an imaging device.
I created an image "VIP" using paint.
This will be the "object".
Using the commands
b = imread('circle.bmp');
a= imread('vip.bmp')
bgray = im2gray(b);
agray = im2gray(a);
Fb = fftshift(rgray);
Fa = fft2(agray);
FRA = Fb.*(Fa);
IRA = fft2(FRA); //inverse FFT
FImage = abs(IRA);
imshow(FImage, [ ]);
xset("colormap", hotcolormap(255));
We will use different radii of circles. The circles will be the "lens".
radius 1:
The resulting image will be
radius 2:
The resulting image will be:
radius3:
The resulting image will be:
A smaller lens aperture will results in a blurred image. Comparing this with the bigger aperture, the image is sharper and most closely resembles the original.
Activity 6.C Template Matching using correlation
Template Matching is a pattern recognition technique suitable for finding exactly identical patterns in a scene such as in the case of finding a certain word in a document.
We made two images.
First, with the words "THE RAIN IN SPAIN STAYS MAINLY IN THE PLAIN."
Second, the letter A.
Using the commands
im = imread('rain.bmp');
img = imread('A2.bmp');
imgray = im2gray(im);
imggray = im2gray (img);
Fim = fft2(imgray);
Fimg = fft2(imggray);
FRA = Fimg.*conj(Fim);
IRA = fft2(FRA);
FImage = abs(IRA);
imshow(fftshift(FImage), [ ]);
xset("colormap", hotcolormap(255));
will produce the image below:
In the image, there are 5 dots which corresponds to the 5 A's in the sentence.
The A's are from words "rain", "spain", "stays", "mainly", "plain".
Activity 6.D Edge detection using the convolution integral
Edge detection can be seen as template matching of an edge pattern with an image
Using the commands,
hor = [-1 -1 -1; 2 2 2; -1 -1 -1]; //horizontal pattern
ver = [-1 2 -1; -1 2 -1; -1 2 -1]; //vertical pattern
spot = [-1 -1 -1; -1 8 -1; -1 -1 -1]; //spot pattern
pattern = spot;
vip = gray_imread('vip.png');
im = imcorrcoef(vip, pattern);
imshow(im);
The image that will appear in horizontal pattern is
For vertical pattern:
And for spot pattern:
The edges are more prominent depending on what kind of pattern the image was convolved with.
Acknowledgements:
Mark Leo
Aiyin
Beth
- for answering my questions
Grade: 10/10
because I know I did well and I did what the activity needed.
Tuesday, July 8, 2008
A6 - Fourier Transform Model of Image Formation
Posted by anarica at 8:50 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment