Monday, July 20, 2009

Activity 8: Morphological Operations

In this activity we were tasked to explore the properties of dilation and erosion by applying the said operations on a square, a triangle, a circle, a hollow square and a cross. We are to perform the operations using each of the following: 1) 4x4 square, 2) 2x4 rectangle, 3) 4x2 rectangle, 4) a plus sign of width 1 and length 5. My results are listed below. They are arranged in order of the operators above.

DILATION







EROSION







My predictions for the dilations were spot on except for the triangle dilated with a plus sign. I forgot to note that the bottom side should have manifested the plus sign as square 'clips'. As for the erosions, I was correct for all except the hollow squares. I thought the widths of the operators would have been enough to completely erode the corresponding edges. it seems however that except for the last case (the plus sign operator), thin lines still remained.

I give myself a grade of 9/10 because I was able to execute the procedure completely. My predictions were a bit off hence the -1.

Wednesday, July 8, 2009

Activity 6: Properties of the 2D Fourier Transform

We seek to understand the properties of the 2D Fourier Transform by applying it to several test cases. Below are the results I've gathered:

ORIGINAL / FFT







square / square annulus / donut / slits / dots









several cases of the sin function:
3 vertical sin waves of decreasing frequencies /
biased / rotated / sum of sines in x and y / previous case + rotated sines

Both the FT's of the square and the square annulus look like stars/crosses. They only differ in that the latter looks striped such that it jumps over some values. The symmetry of the FTs reflect the symmetry of the squares. The FT of a donut has a strong peak at the center and is surrounded by a symmetric pattern covering some circular area around it. This reflects the circular symmetry of the object. The FT of the slits looks like a vertical interference pattern at the center. It is as if we have recorded the interference pattern after ltting light pass through the slits. This is expected as the diffraction pattern we get from an aperature is the same its FT.

The FT of the two dots look like the superposistion of two airy disks symmetrically off center. We already found in the previous experiment that the FT of a circle is an airy disk. It is expected then that the FT of two circles is simply a superposition of two airy disks.

As the frequency of the sine wave decreases, the point corresponding to the frequency of the sine wave come closer to the center. As expected, the FT is symmetric along the X axis. Adding a bias simply adds a point at the center of the FT. Rotating the sine wave rotates the FT by the same angle. The last FT turned out as expected since it is simply a superposition of the previous FT's. It outlines a circle since we sum up rotations of the same frequencies. In addition, we still retain the four points from the previous FT.

I give myself a grade of 9/10 because I was able to execute the procedure but I feel I could do better in interpreting the results.

Monday, July 6, 2009

Activity 5: Fourier Transform and Correlation

In this activity, we explored the uses of FFT and correlation in image processing. We started by taking the FFT of a circle and a character just to see how the 2D FFT function works in Scilab. I got the following results:




Original/FFT/double FFT

Top: Circle, Bottom: A

These results agree with the analytical expectation: we get an Airy disk for the circle and we inverse the image when the FFT is performed twice.

We then used FFT to convolve an image of an aperature and an image to simulate the effect of an imaging device with limited aperature. I got the following result:



Original image/ Convolution of "VIP" and circular aperature of r=40/30/20/10/5

We get an image of the original object but it is now inverted and less resolved. Decreasing the aperature size causes the image to blur and gain artifacts which somehow resemble the shape of the aperature.

Our next task was to use correlation to find a certain pattern in an image. In this case, we had an image of the line "THE RAIN IN SPAIN STAYS MAINLY IN THE PLAIN" and we had to look for the A's via correlation. Correlating the image and an image of the letter "A", I came up with the following result:



Original image/Correlation of the image and pattern

We find that the peaks of the resulting image correspond to the posistions of the A's in the image thus verifying that the method was correct.

Finally, we attempted to do edge detection by correlating small matrices of either a vertical line, a horizontal line, or a point with a given image. I came up with the following results:


Vertical/horizonal/point edge detection

We can see that the method worked as it highlighted only the parts which correspond to the types of edges being detected.

For this activity I give myself a 10/10 because I was able to complete the tasks completely and efficiently.

Sunday, July 5, 2009

Activity 4

In this activity we were tasked to change the improve the contrast of a grayscale image by tweaking it such that its CDF is converted to some desired curve. To do this we took the CDF of the original image then matched the pixel values with the same value on the original CDF and desired. We then edited the image such that every pixel with a given pixel value on the original image is replaced with its matched pixel value from the desired CDF. Here are my results:

BEFORE:

original image 250x250 grayscale

original PDF

original CDF

AFTER:

resulting image 250x250 grayscale

resulting PDF

resulting CDF

The resulting image had much better contrast. The details of the petals and the background are now much more easily distinguishable. The resulting CDF is quite close to the desired (linear). The few kinks on th curve are probably a result of the limitations of histograms. Since histogram values are discrete it is possible that some values on the original CDF dont have corresponding values on a desired CDF. I give myself a 9/10 for this activity because I was able to execute the procedure properly yet I believe that there is room for improvement in the method such that the resulting CDF may be exact.