Thursday, August 26, 2010

AP 186 Activity 9: Morphology




Above is the first image you shall see in Wiki's mathematical morphology page, the shape in blue is the input image and the resulting morphological erosion with a diamond shaped structuring element is in yellow and dilation in green . I used this to open this entry because, maybe like the people who created the page, I think it's a pretty illustration and it draws you to this idea of morphology. 

In image morphology, an input image and a structuring image are compared, the result of this operation is the output image. The foundation of morphology is basically Set Theory, where operations are used to compare and contrast different sets.

I had a hard time applying the concept of dilation and erosion, but thanks to Google I found several helpful sites (plus having helpful friends) that made me understand how I should use these two. The rest can be found in the acknowledgement section and the most helpful was from a lecture at Brigham Young University. First, there are two things that need to be set clear: the object and the structuring element. The object is the image to be operated upon, while the structuring element is the shape that will operate on the former. From this aforementioned lecture, it explained erosion and dilation as translations of each of the pixels of the structuring element, shown below:
Fig 1. Structuring elements

Fig 2. Objects

For example, the structuring element of a square of four pixels against an image of a square that is of 5x5 pixels, the image is translated for every pixel in the structuring element. To get the dilated image, the union of these translations is taken. Consequently, the intersection of these translations is taken to get the erosion of the image. I must say that this process is tedious, but this is the clearest explanation I've seen yet. And I do believe that it's better to go slowly but surely rather than being too nonchalant and not understanding things thoroughly.

After predicting the results, we used Scilab to check our guesses. Below are the results of erosion and dilation of four shapes, a cross, a square, a triangle, and a hollow square (first column of Fig. 3 and 4).

Fig 3. Erosion

Fig 4. Dilation

There are several other methods used in morphology. Some of them are:
1. Opening
2. Closing
3. Skeletonization
4. Thinning

--
Thanks are in order!
BA
wiki http://en.wikipedia.org/wiki/Mathematical_morphology
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/morph1.pdf
http://www.mathworks.com/help/toolbox/images/f18-12508.html;jsessionid=4pkLMBrfWQfNyYSR1352k82kQyJxh3pSrRJvZkrtyLhPJpw3Fc9V!974718655

--
It took me a long time to complete this, but I think I deserve a 10.

Tuesday, August 10, 2010

AP 187 Activity 7: Properties of the 2D Fourier Transform

Our household WiFi is called FFT. Wala lang. I set it up, and I wanted to use a name that sticks but is not really common. That was two years ago, when I first encountered the Fourier Transform, and also the Fast Fourier Transform. Now, what was then a mathematical tool is now being realized as a very flexible means in image analysis.

This activity is a foray into the properties of the 2D FT. First, we were asked to get the FTs of basic 2D patterns.


Next we observed the anamorphic properties of the Fourier Transform.

Figure 1. FT of sinusoids

In the figure above it is shown that the higher frequency,  the more distant the dots of the FTs became. While when the patterns were rotated, below left with theta being 30 degrees and below right with theta being 30 degrees with the addition of another sinusoid. The change in theta caused a shift of the FT, in these cases to the left.
Figure 2. Rotated patterns

On the other hand, when two sinusoids are mulitplied their FT is an addition of their separate FT.
Figure 4. multiplication of multiple sinusoids


Figure 5. Addition of sinusoids


--
Some help:
http://how-to.wikia.com/wiki/How_to_plot_in_Scilab

--
10

Sunday, August 8, 2010

AP 186 Activity 6: Familiarization with Discreet FFT

The Fourier tranform has ubiquitous applications, and in this activity we apply it to image processing. In any typical tansformation, the FT is in the frequency domain. According to wiki, the domain of the new function is typically called the frequency domain, and the new function itself is called the frequency domain representation of the original function. A more preferred method of FT is the fast Fourier Transform (FFT).

To familiarize with FFT, we observe its effect on a centered circle. Going clockwise, the topmost left is the original circle, then applied fft2 then shifted, then taken the inverse fft.
 For the image of the text A, the same procedure was done. Notice that the last image (topmost right) is inverse of the original image (topmost left). The FT has rendered its matrices shifted, resulting to an inverted image.

Next we consider the FT in terms of viewing an object. Let circles of different sizes be the apertures, and the image of the text 'VIP' be the object. As can be expected, the larger the aperture size, the sharper the image.


Another feature of the FT is the ability to compare a template and an image. In this example, a text image was correlated with the text image of a single letter 'A'. This will be to determine which letters in the text image check out with the 'A' template.

The bright spots in the transformed image (right) are the points where A is present in the text image, note that the transformed image is flipped though.

Lastly, the FT was used for edge detection.
 Horizontal pattern
Vertical pattern

Spot pattern

--
186 handout
BA

-- 
10