A. Familiarization with Discrete Fourier Transform:
Discrete Fourier Transform is a specific form of Fourier analysis that transforms one function into another. It evaluates enough frequency components to reconstruct the finite segment that is being analyzed.
To start with the familiarization of DFT, a 128x128 image of a white circle with black background was created using Paint. This image was first converted to grayscale before fourier transform was repeatedly applied to it. The following are the original image, the fft intensity image, the fftshifted image, and the image applied twice with fft respectively.
It can be observed that the fft intensity image (2nd image) contains white parts at its corners. Compared with the fftshifted image (3rd image), which is the correct analytical Fourier transform of the original image(1st image), the white parts of the fft intensity image are the quarters of the 3rd image. Therefore, when FFT was applied twice on the original image, the output is just the inverse of the original image.
I = imread('circle3.bmp');
Igray = im2gray(I);
FIgray = fft2(Igray);
imshow(abs(FIgray),[]);
imshow(abs(fftshift(FIgray)),[]);
imshow(abs(fft2(FIgray)));
Since the inversion of the original image is not obvious in the first part, the process was repeated using "A" as the original image. The following are the original image, the fft intensity image, the fftshifted image, and the image applied twice with fft respectively. Here the inversion of the original image can clearly be seen.
I = imread('A_small.bmp');
Igray = im2gray(I);
FIgray = fft2(Igray);
imshow(abs(FIgray),[]);
imshow(abs(fftshift(FIgray)),[]);
imshow(abs(fft2(FIgray)));
B. Simulation of an Imaging Device:
For the second part of this activity, a 128x128 image of the letters "VIP", and another 128x128 image of a white circle that would serve as the aperture of a circular lens, were created.
The original "VIP" image is shown below, along with images of the circle of varying aperture sizes (large, medium, small respectively).
The outputs for large, medium, and small apertures are respectively shown below.
It can be observed that a large lens aperture results to a sharp inverted image of the text, and decreasing the size of the aperture decreases the sharpness of the image. These outputs are correct because a larger lens aperture could actually collect more light rays reflected by an object, therefore creating a better reconstruction of the image. Whereas, decreasing the size of the aperture, decreases the number of light rays that can be collected for better image reconstruction.
r=imread('circle.bmp');
a=imread('VIP.bmp');
rgray = im2gray(r);
agray = im2gray(a);
Fr = fftshift(rgray);
Fa = fft2(agray);
product= Fr.*(Fa);
Invproduct = fft2(product);
FImage = abs(Invproduct);
imshow(FImage, [ ]);
C. Template Matching using Correlation:
For the third part of the activity, Template Matching which is an image processing technique for finding parts of an image that match a template image, was done using correlation. To do this, an "A" image was created to serve as a template image to a 128x128 text image.
Below are the "A" image, the text image, and the output image respectively.
From the inverted output image, bright dots can be seen where A's are located in the text. Therefore, it was successfully observed here how correlation was used to match the shape of "A" with those A's of the text image.
s=imread('spain.bmp');
a=imread('A.bmp');
sgray = im2gray(s);
agray = im2gray(a);
FTsgray = fft2(sgray);
FTagray = fft2(agray);
product = FTagray.*conj(FTsgray);
Invprod = abs(fftshift(ifft(product)));
imshow(Invprod, [ ]);
D. Edge Detection using the Convolution Integral:
For the last part of this activity, Edge detection which is used to identify points of discontinuity in image brightness, was done using convolution integral. To do this, a "VIP" text image was convolved with a 3x3 edge pattern matrix using "imcorrcoeff()" in Scilab.
The following are the original image, and the images done using vertical, horizontal, and diagonal pattern matrices respectively. It can be observed that the edges of the text image were successfully detected with the specific pattern used to create it.
Img=imread('VIP.bmp');
Imgray = im2gray(Img);
pattern = [-1 -1 -1; 2 2 2; -1 -1 -1]; //horizontal
pattern = [-1 2 -1; -1 2 -1; -1 2 -1]; //vertical
pattern = [2 -1 -1; -1 2 -1; -1 -1 2]; //diagonal
conv = imcorrcoef(Imgray, pattern);
imshow(conv)
rating - 10 because I have demonstrated and explained all parts of the activity.
No comments:
Post a Comment