Thursday, July 28, 2011

eight

For a better understanding of how I did this activity, refer to the Supplementary Information Section where the important parts of the codes I used are shown.

In the world of image processing, the Fourier Transform is the star quarterback.  Well, I’m not really sure about that but the Fourier Transform pops up a lot.  This activity studies the enhancement within the frequency domain through (you guessed it) the Fourier Transform.

First off, we look into the Convolution Theorem.  The Fourier Transform of an image comprising of two dots located along the x-axis was taken.  The said Fourier Transform resembles a sinusoid of sorts.

final_a_1_pixel
Figure 1. (A) Two dots and (B) their Fourier Transform.

Now, we replace those two dots with circles, squares and Gaussians whose radii, width and variance values are varied. 

final_a_2_circles
Figure 2. Circles of radii (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

final_a_2_circles_ft
Figure 3. Fourier Transforms of circles of radii (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

final_a_3_sqr
Figure 4. Squares of width (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

final_a_3_sqr_ft
Figure 5. Fourier Transforms of squares of width (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

final_a_4_gauss
Figure 6. Gaussians with variance of (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

final_a_4_gauss_ft
Figure 7. Fourier Transforms of Gaussians with variance of (A) 0.01, (B) 0.05, (C) 0.10, (D) 0.15, (E) 0.20 and (F) 0.25

As you can see, when the radii, width and variance values are increased, the area spanned by their Fourier Transforms shrinks.  Mathematically, an area of let’s say A  is mapped as 1/A in the Fourier space.  So in  a way, there was no need for the panic and confusion I went through.

When convolving a pattern onto ten randomly distributed points, what I found was that the points’ positions remain the same but the points themselves take on the appearance of the pattern.

final_a_5
Figure 8. (A) Ten randomly distributed dots, (B) a pattern and (C) the result of their convolution.

Lastly (for this section), we investigate the effect of distances between dots on the Fourier Transform of images.  What I observed here was similar to the phenomena with the increased radii, etc.  The greater separation distance (and/or density) of dots in the image, the space that is occupied by the Fourier Transform increases too.

final_a_6_grid
Figure 9. Grids with spacing of (A) 10, (B) 25, (C) 50, (D) 75, (E) 100 and (F) 125.

final_a_6_grid_ft
Figure 10. Fourier transforms of grids with spacing of (A) 10, (B) 25, (C) 50, (D) 75, (E) 100 and (F) 125.

We now go into Ridge Enhancement and whaddayaknow, we study something I’ve been all too familiar with since my grade school days when I started to watch CSI.  I’ve always known that the technology they show in these criminal periodicals isn’t really at par with the technology that us mere mortals have to wrestle with.  But in the next part, I experience this face-to-face (and I seriously wish I hadn’t).

final_b_1
Figure 11. (A) Gray scale image of an unbinarized fingerprint image and (B) its Fourier Transform.

final_b_2
Figure 12. (A) The mask used and the (B) masked Fourier Transform.

final_b_3
Figure 13. (A) The filtered fingerprint image and (B) its binarized version.

This is definitely not CSI material.  I mean, you wouldn’t have narrowed your suspect pool by a lot using this print.  Out of curiosity, I even realized that this could be my left thumb print which, if it were really the case, I just caught myself.  (What?)

For the Line Removal section, we use an image that I should have gotten from here but their website was uncooperative.  After a slight complaint on Twitter though, BA e-mailed me the picture.  Nevertheless, the result turned out pretty well if I do say so myself..

final_c_1
Figure 14. (A) Gray scale image and (B) its corresponding Fourier Transform.

final_c_2
Figure 15. (A) The mask used, (B) masked Fourier Transform and (C) the resulting image.

Lastly, the Canvas Weave Modeling and Removal section tasked us to remove the canvass patterns in an image which – honestly, I tried everything – I was not able to do.  What follows are the best results I got.  I think the crappiness of my results has much to do with my mask.  I originally saved it as .PNG then converted it to .BMP and life hasn’t been the same since then.  Sigh.

final_d_1
Figure 16. (A) Original and (B) gray scale images with (C) the corresponding Fourier Transform.

final_d_2
Figure 17. (A) The mask used, (B) the masked Fourier Transform and (C) the resulting image.

final_d_3
Figure 18. (A) Inverse of the mask and (B) the corresponding Fourier Transform.

In an attempt to lighten the mood, Figure 18. B. has the pattern/looks of a dri-fit shirt.

And yeah, I know this activity is late but I think my results make up for the lateness so that’s worth a 8.5/10 … right?

SUPPLEMENTARY INFORMATION:
code_a_1
Figure S1. Part of the code for the investigation of the Convolution Theorem.

code_a_2
Figure S2. Part of the code for the investigation of the Convolution Theorem.

code_a_3
Figure S3. Part of the code for the investigation of the Convolution Theorem.

code_b
Figure S4. Code for Ridge Enhancement.

code_c
Figure S5. Code for Line Removal.

code_d
Figure S6. Code for Canvas Weave Modeling and Removal.

SOURCES:
Fingerprint Image http://fingerprint-security.net/wp-content/uploads/2011/06/fingerprint.jpg
Apollo Image (Mr. Bernard Allan Racoma)

nine

A little forewarning before we dive into the figures down below.  If you’re a loyal reader of this blog, you might notice later on that figure numbers aren’t present here.  Forgive me for that but I really wasn’t in the mood to keep track of such a large number.  I also thought it wouldn’t be pretty to have a Figure 24 (hypothetically).  Also, I’m not including a copy of my Scilab codes for this report because (i) there are too many figures as it is and (ii) it’s quite simple and not an object of awe.

The morphology of an object refers to its shape or structure.  From the name itself, morphological operations are operations that vary the structure of an object.  Binary images are composed of pixels that may only have two possible values – 0 and 1.  The former refers to the background of an image while the latter refers to the foreground. 

For this activity, we first give an extensive look into the dilate and erode morphological operations.  These two, mathematically, can be stated as:

equations
Equations for Dilation and Erosion, respectively.

Basically, the results of a dilation is an image that is the union of two images with respect to the origin of the second image.  On the other hand, the erosion is looks similar to the first image just with the intersections (again with respect to the second image’s origin) removed.  Four images were to be dilated and eroded by five different structuring elements.  For each pairing, we were tasked to give a prediction before using the corresponding Scilab functions. 

A
Four binary images to be dilated and eroded.  A (A1) 5x5 square, (A2) a triangle with base 4 and height 3, (A3) a hollow 10x10 square with a 2 pixel thickness and (A4) a 5x5 cross

BB_vertex
Four structuring elements to be used in the dilation and erosion process.  
From left to right, a (B1) 2x2, (B2) 2x1, (B3) 1x2, (B4) 3x3 cross and (B5) diagonal matrix of 1’s.

Before you get confused, the two rows of structuring elements represent the two methods I used in my predictions.  I’d like to call the first a non-origin-based prediction and the second, an origin-based prediction.  The non-origin based prediction allows any of the structuring element’s points to interact with the binary image whilst the opposite was set for the origin-based prediction.  I have two methods because the first was taught by Mr. Timothy Joseph Abregana which I followed for a while.  Upon seeing that my results varied from Ms. Eloise Anguluan’s, I asked her to explain her process to me.  Because these two methods gave different results, I wanted to see which one gave the right (or at least closest to the right) results.  From the results below the non-origin based prediction (a.k.a. Method 1) is less accurate as compared to the origin-based prediction (a.k.a. Method 2). 

For the predictions, the light blue represents the original image while the purple pixels represent the areas changed by the morphological operation.  In the case of dilation, the purple pixels are added to the image as a whole and thus, the final image a person should see was the combination of the two color pixels.  On the other hand, the erosion predictions are quite different.  The person should only see the light blue pixels as the purple pixels – the ones changed by the said morphological operation – are removed from the image itself.  I attempted to aid the visibility for the Scilab results by placing them all in front of a light blue background (because it goes with the colors for the prediction and we can’t have clashing colors now, can we?).

D1 M1D1 M2D1
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A1 and the corresponding results for the dilation with B1, B2, B3, B4 and B5, respectively.

D2 M1D2 M2D2
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A2 and the corresponding results for the dilation with B1, B2, B3, B4 and B5, respectively.

D3 M1D3 M2D3
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A3 and the corresponding results for the dilation with B1, B2, B3, B4 and B5, respectively.

D4 M1D4 M2D4
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A4 and the corresponding results for the dilation with B1, B2, B3, B4 and B5, respectively.

E1 M1E1 M2E1
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A1 and the corresponding results for the erosion with B1, B2, B3, B4 and B5, respectively.

E2 M1E2 M2E2
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A2 and the corresponding results for the erosion with B1, B2, B3, B4 and B5, respectively.

E3 M1E3 M2E3
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A3 and the corresponding results for the erosion with B1, B2, B3, B4 and B5, respectively.

E4 M1E4 M2E4
From top to bottom, predictions using Method 1 and 2 and the results of the Scilab simulation. 
From left to right, the original image A3 and the corresponding results for the erosion with B1, B2, B3, B4 and B5, respectively.

I mentioned earlier that there were two other morphological operations that this activity asked us to look into.  If you ask me, the skel function makes things more groovy and the thin function makes things look like they were drawn by a two-year-old.  Kidding! Those morphological operations don’t really do that.  As you can see below, the skel function draws the skeleton of an image using numerous lines and the thin function reduces an image to minimally connected strokes.

circles
Image to undergo skel and thin morphological operations.

circles_skel
From top to bottom and left to right, Result of skel morphological operation – exterior, interior and both.

circles_4_thin
Result of thin morphological operation.

I honestly spent most of yesterday (July 27) on this and even though I had the whole day to finish it, I wasn’t able to do so.  Most of that had to do with my complete shading of my predictions for both methods and with that, I have to thank Ms. Aven Perez (Hi, roommate!) for volunteering to shade.  With all the effort I placed into this activity, I think I deserve an eleven out of a ten, yes?

SOURCES:
A9 – Morphological Operations 2011, Applied Physics 186 Manual
Scilab Help