Friday, October 14, 2011

Activity 17 – Neural Networks

In this activity, we were given the task to classify objects using neural network. As an overview, a neural network is a computational model of how neurons work in the brain and this model can also be used to other networks.

Figure 1 shows the training subjects used. These objects were taken from Activity 15 but there is an additional object used. These training subjects act as the combination of networks and place each class their corresponding number by applying neural network model.

Figure 2 shows the test subjects to be classified if they correspond to their real class.

Figure 3 shows the result of classifying each class from Figure 2. The number 1 corresponds that the test subject is correlated to its corresponding training subject. Another trial was done using different sequence shown in Figure 4. It is seen that the corresponding class does not give the real class of the subject.

I am giving myself a grade of 10. I would like to thank TJ Abregana for helping me do the past 3 activities. Thank you for you time in reading this blog.

Activity 16 – Probabilistic Classification

In this activity, 2 classes from Activity 15 were used, 5 peso coin and cards and a new classification technique was used. The technique is quite tricky but with the help of TJ Abregana, I finally understand how it works. Linear Discriminant Analysis (LDA) is used for linearly separable groups thus these groups can be separated by linear combination of features that describe an object. The formula for LDA is given by:

image

where λjk is the loss from the wrong decision,p(ωk|x) is the probability that a pattern x came from the class ωk and rk is the risk of loss associated with class ωk.

From this classification technique, five out of five test subjects of both cards and 5 peso coin where classified to their proper classes. I guess LDA is a more precise technique in classifying features of one object since it factors a loss from a wrong decision made.

2 more activities and I’m done. I will be giving myself a grade of 9.2 for this activity. Sorry for the late submission of this blog.

Thursday, October 13, 2011

Activity 15 – Pattern Recognition

In this activity, we were given a task to find a pattern depending on the training subjects that we captured. Figure 1 shows the training subjects. These were cropped from a picture taken in class. From these training subjects, the class representative of each type was obtained.

Next figure shows the test subjects. Each test subject were classified using Minimum Distance to know if the test subject belongs a particular class. I have chosen that the test subject is part of one particular class if the Minimum Distance value is the largest value of the 3 class.

Out of the five test subjects of 5-peso coin, three was identified as a 5-peso coin. For the cards, five out of five cards were identified while for the leaves, there were no test subjects identified as part of the class of leaves.

Finally, I have finished blogging this one. Sorry for the late upload. I will rate myself as 8.6. Thank you.

Friday, October 7, 2011

Activity 14 – Color Image Segmentation

In image segmentation, a region of interest (ROI) must be selected before any processing is done. This ROI will be use to segment the whole image based on its feature.

Figure 1 shows an image of the object which is a pair of red shoes.

The ROI for this image was selected and is shown in Figure 2. Below the ROIs are its corresponding histogram. It can be seen that both histograms are different from one another thus the red-ness of the two ROIs are different.

Using the ROIs, the image was reconstructed using Parametric Probability Distribution and Non-Parametric Probability Distribution.

tableTable 1. Comparison between the two techniques

It can be seen in the 2nd column that both images are not the same in terms of the lighting. This is because the two patches were not cropped on the same area so the area where the patches were obtained  was highlighted. For both patches in the 3rd column, both images have a few difference in terms of lighting. Comparing the two techniques, even the non-parametric probability distribution takes time to finish the reconstruction, it produces almost similar reconstruction even though the patches are not taken on the same place.

I know this is too late but still I made it. I give myself a grade of 9.3 for doing this activity. Thank you for your time.

Thursday, September 22, 2011

Activity 12 – Preprocessing of Handwritten Text

I know this is very late but I have managed to finish this activity long ago. This late blogging is due to my laziness from the time this activity was done. Sorry for this one. Anyway. Here it goes.

Figure 1 shows the (a) original image and the (b) rotated image to align the texts horizontally. The rotation was done using mogrify function of scilab.

image

Figure 1. (a)Original image and (b) rotated image

After the rotating the image, the image was cropped shown in Figure 2(a,top) and the horizontal lines found in the cropped image was removed by taking the Fourier Transform of the rotated image and masking the  y – axis of the Fourier plane shown in Figure 2(b,bottom).

image

Figure 2. (top row) (a) cropped image and (b) processed image. (bottom row) FT of the top row of (a) and (b).

The binarized image is shown in Figure 3.

image

Figure 3. Binarized cropped image.

The next tasked was to find another circumstance in the image file that the word DESCRIPTION occurs. It was done by correlating an image that has the word DESCRIPTION with the rotated image. This image is shown in Figure 4.

image

Figure 4. (top) Binarized cropped image of the original image, (middle) template for the word DESCRIPTION and (bottom) the correlation of the first two images

I will give myself of 7.5. Thank you for reading this.

1 activity down, 5 more to go. I hope I can finish blogging the remaining 5 activities tomorrow.

Good Day!

Tuesday, September 6, 2011

Activity 13 – Image Compression

A late submission for a topic that I somewhat did not understand much. Anyway. In this activity, Principal Component Analysis (PCA) were implemented.

The image as shown in Figure 1(a) was gray-scaled, cropped and tiled vertically shown in Figure 1(b).

new text
Figure 1. (a)Original Image and (b)cropped 10x10 image

Next in line was to get the Principal Components (PC) of the image using the function pca of scilab. The eigenvalues and correlation circles are seen in Figure 2.

image
Figure 2. (a) Correlation Circle and (b) Eigenvalue of the PCs

For proper visualization of Figure 1(b), it was tiled into a matrix as shown in Figure 3.

eigen images
Figure 3. Eigen-images of the PCs

The next four images shown in Figure 4 are the reconstruction with the use of 1, 2, 3, and 4 eigenvectors in reconstructing the original image in black & white. The file size of the compressed images were obtained and compared to the file size of the gray-scaled original object.

image

In these four images, only the first image was compressed to 17% of the original image using one eigenimage. The rest of the images becomes bigger in file size using large number of eigenimages due to the white reconstruction along the edges of the object in the image.

I will rate myself with 9.5. This activity was kind of tricky at first but when the code was ok, everything follows.

2 down, 4 to go.. Again, sorry for my laziness because this activity should have been blogged way way before I blogged Activity 12. Thank you for your time. Smile

Thursday, August 18, 2011

Activity 11 – Playing Notes by Image Processing

Its been a week since my last post in here. I think I better do this quickly. In this activity, we were asked to look for music sheet. This music sheet is played with the use of image processing. We need to capture the notes and then convert them into their equivalent tones according to their position in the music sheet. I have chosen the song, London Bridge Is Falling Down shown in figure 1. This was the first image that is short and maybe easy to use.

London Bridge
Figure 1. Original Musical Sheet from www.8notes.com

This image has been cropped and the notes below a quarter/half note were removed also. The cropped version is shown in figure 2.

cropped
Figure 2. Cropped image

When imported in scilab, the black part was converted into white and vice versa. After doing this, a template is produced similar to the notes in the image. A (a) half note and a (b) quarter note was used to capture its position in the image as shown in figure 3.

image
Figure 3. (a) Half-note and (b) quarter note templates

Convolution between the template and the music sheet were done and the resulting image is seen in top row of figure 4 (a and b for half-note and quarter-note templates, respectively). These images were converted into binary images and were added to one another to complete the whole song seen in figure 4(bottom row). The notes were decreased into single point in order to easily distinguish what part of the music line it is seen.

image
Figure 4. (top row) Correlation between the music sheet and (a)half-note template and (b)quarter-note template.(bottom row)Binary image of the images above.

The frequencies for the notes were collected from http://www.phy.mtu.edu/~suits/notefreqs.html. The notes used were G3,A3,B3,C4,D4, and E4. These notes came from the music sheet and the final song can be downloaded in London Bridge.wav.

I will rate myself with 8 points because I passed the required task and uploaded the song that I have created. Thank you for browsing my blog. =)

Saturday, August 6, 2011

Activity 10 - Binary Operations


In this activity, we were taught to use opening and closing operations in binary. These operations are simple. Closing operation is simply taking erosion of the dilation of the image. In this case, the object of interest becomes the dark part while the white part is the background. Opposite of closing operation is the opening operation wherein the object becomes the white and the background is the dark part. Figure 1 shows this difference between the two.
Figure 1. Closing and Opening operation
That was not the only activity that was given to us. It is to estimate the area of the circles in figure 2(a). Figure 2(b) is the cropped version of figure 2(a). The cropped version coincide in the 2nd & 3rd, 5th & 6th, 8th & 9th, and 11th & 12th image. In this part, the use of closing or opening operation were used to isolate the circles seen in the image.
Figure 2. (a)Original image and (b) cropped image using paint.

Figure 3 shows the cropped images that were cleaned with the use of opening operation. It can be observed that some circles are not of the same size as the others. This is due to the conversion used in im2bw function.
Figure 3. Cleaned cropped image with the use of opening operator
Table 1 shows the estimate area of the circles. In counting the number of pixels of the circles, the function bwlabel was used. This function simply tag the objects with increasing numbers. If the objects have similar sizes, they have the same tag.

Table 1.Estimated area of a circle
Area (in pixel)        445      
Finally, the last part of the activity is to detect the enlarged circles seen in figure 4(a). The processed image with the use of opening operator is seen in figure 4(b). In detecting the enlarged circle, the same method were used as above and the area were obtained in pixel. It can be observed that the area of the enlarged circles are smaller than that of the overlapping circles and larger than that of a single circle. Then the final image as shown by figure 5(b) is the five enlarged circles that are seen in the original image.
Figure 4. (a) Original image and (b) processed image with the use of opening operator

Figure 5. (a) Original image and (b) extraction of the enlarged circles


I guess this is all. This is due last Thursday, 4 August 2011. I am late, I know. This is due to my laptop who is slowly dying. I can't work with it anymore. Anyway, I will give myself a score of 8 because of my late submission and my mistake in making the other sub-images a clean image. There are images that did not locate any circles. The mistake I made was the threshold used for subimage 1 was carried out to the rest of the subimages, which is wrong.

Thank you for your time.

Thursday, July 28, 2011

Activity 9 – Morphological Operation


I hope I would finish this by midnight.

Now, we have an activity in which our drawing skills and thinking skills were tested. Hand-drawn images were done in order to predict the outcome of the activity.

Morphological operation is where two objects were differentiated and creating new object based on the object’s structure. It is used to enhance images for further image processing.

Erosion and Dilation are two of the operations that can be applied to an image.
  1. Predict – Observe – Explain
  2. Figure 1 shows the (top) hand – drawn and (bottom) scilab - generated objects (A1 – A4) and the structural elements (B1 – B5). This was drawn in a graphing paper. For the hand-drawn images, the green-colored part is the resulting image for erosion operation while the combination of the two-colored part is the resulting image for dilation operation.
    Figure 1. (top) Hand-drawn and (bottom) scilab-generated objects. B1 - B5 are the structural elements.
    1. A 5x5 square
      Figure 2 shows the dilation (top row) and erosion (bottom row) of object A1 which is done by (a) hand and (b) scilab. It can be observed that only the erosion operation done by two methods were the same to one another. It is also observed in the dilation part that the both are similar but the orientation of the new object were flipped about an axis.
      Figure 2. (top row)Dilation and (bottom row)Erosion of (a)hand-drawn and (b)scilab-generated object, A1
    2. A triangle, base = 4boxes, height = 3 boxes
      Figure 3 also shows the dilation (top row) and erosion (bottom row) of object A2 which is done by (a) hand and (b) scilab. The same observation is seen for dilation. For erosion, the 4th figure for both (a) and (b) is indeed a blank image since there is no way to fit B4 in A2.
      Figure 3. (top row)Dilation and (bottom row)Erosion of (a)hand-drawn and (b)scilab-generated object, A2
    3. A hollow 10x10 square, 2 boxes thick
      Figure 4 also shows the dilation (top row) and erosion (bottom row) of object A2 which is done by (a) hand and (b) scilab. The same observation is seen for dilation. For erosion, the 4th figure for both (a) and (b) has only 4 ones because those pixels/boxes are the only part of A3 that B4 can be fitted in.
      Figure 4. (top row)Dilation and (bottom row)Erosion of (a)hand-drawn and (b)scilab-generated object, A3

    4. A plus sign, one box thick, 5 boxes along each line
      Figure 5 also shows the dilation (top row) and erosion (bottom row) of object A2 which is done by (a) hand and (b) scilab. The same observation is seen for dilation. For erosion, the 1st figure for both (a) and (b) is a blank image since there is no way to fit in a 2x2 image in a plus sign.
      Figure 5. (top row)Dilation and (bottom row)Erosion of (a)hand-drawn and (b)scilab-generated object, A4

  3. Other Morphological Operations

    1. Thin Operation
      Figure 6 shows the application of the thin operation onto the objects A1 - A5. This operation makes a binary object thin. It does not always give good thinned copy of the object if the object is too thick.
      Figure 6. Application of thin operation in (a-d) A1 - A4 scilab-generated objects
    2. Skel Operation
      Figure 7 shows the application of the skel operation onto the objects A1 - A5. This operation, like thin operation, performs thinning of the object but the algorithm it uses is faster than the algorithm that thin operation uses.
      Figure 7. Application of skel operation in (a-d) A1 - A4 scilab-generated objects

So here I am again, thankful that the activity was done smoothly and faster. I don't know what happened to me last week but now I know that I am not productive the week before. I will give myself a score of 12.

Thank you and good day.

Thursday, July 21, 2011

Activity 8 - Enhancement in the Frequency Domain


Good day once more. Another activity has been done but this time, I fail to get the best image. I did not know why I was not able to get a good image but at least I have done the activity. I was a bit disappointed for this activity. I became lazy yet again. Anyway, let me start with the production of binary images with two dots in it.
  1. Convolution Theorem

    Figure 1. Two dots
    In this activity, an image was generated with two dots(one pixel each) symmetric to the y-axis. Figure 1 shows the FT of the two dots. As observed, the modulus of the FT of the image has given a series of vertical lines that also form circular pattern. After this, the two dots were given given a varying radius. Figure 2 shows the FT of the varying dots. The pattern seen are similar with the two dots only that as the radius increases, the pattern shrinks.
    Figure 2. increasing radius of two dots.

    Next is to replace the dots with a Gaussian spots. Shown by figure 3 and its corresponding FT. It is quite tricky but easy to apply. The center is just shifted and all the rest follows. It is then observed that the FT is enlarged as the variance increases.
    Figure 3. Gaussian spot

    After that, a 200x200 array was done and 10 random dots were placed on it and FT was applied, showed in figure 4. Most of the dots seen in the image are still seen on the FT.
    Figure 4. Random dots.

    Next thing is another array with equally spaced 1's. This is shown in figure 5. It is observed that with increasing space, the number of dots seen in the Fourier plane decreases.
    Figure 5. Equally spaced dots.
  2. Fingerprint: Ridge Enhancement

    Figure 6 shows the original fingerprint(left) and its FT(right). I have used a pattern that will easily capture the edges of the ridges. With this filter, the ridges should be enhanced.
    Figure 6. Fingerprint and its FT.  Taken from the PDF file

  3. Lunar Landing Scanned Pictures: Line Removal

    Next is to remove the lines seen in the image of figure 7(left). A filter was created that will remove the lines. The lines are of low frequency along the y-axis so the filter used is a horizontal line that blocks out the low frequency in the y-axis and high frequency in the x-axis.
    Figure 7. Original image(left) and processed image(right)

  4. Canvas Weave Modelling and Removal

    This is the last part of the activity. I was not able to remove the dots seen around the image that is why the original image is only seen.
    Figure 8


After a long and tiring day, I was not able to finish the whole activity on time. I will grade myself with 4 points since I was not able to finish the activity I was supposed to do by tonight. Thank you..

Thursday, July 14, 2011

Activity 7 - Properties of the 2D Fourier Tranform


Hello guys.. I have done the new activity. It is about how Fourier Transform (FT) works or simply, FT's properties.

  1. Familiarization with FT with Different Patterns

    In this part of the activity, we were tasked to create several patterns and then apply FT in each of the patterns and of course, observe what happened.

    1. Square

      Figure 1 shows the pattern(top row) I created with two different sizes with their FT (bottom row). The top-left image has an area of 0.64 and the top-right image has 0.16. Applying FT on both images resulted to the image on the bottom row of Figure 1. As you may observe, the larger the area of the square produces smaller pattern in the Fourier plane.
    2. Figure 1. Square with size of 0.8 (top left) and 0.4 (top right) with their corresponding Fourier Transform
    3. Annulus

      Next pattern is an annulus which is like a donut. Figure 2 shows the object(top row) and their corresponding FT(bottom row). The thickness of the annulus(top-left) is 0.2 while the thickness of the other annulus(top-right) is 0.4. The same observation will be seen with the Square in part A1.
    4. Figure 2. Annulus with thickness of 0.2 (top left) and 0.4 (top right) with their corresponding Fourier Transform
    5. Square Annulus

      This pattern is quite tricky to create but obviously, it is not that hard. Figure 3 shows the object(top row) and their FT(bottom row). The top-left image has an aperture area of 0.36 while the top-right image has an aperture area of 0.04. It is observable that the FT of a smaller aperture area produces sharper image compared to that of a bigger aperture area.
    6. Figure 3. Square Annulus with aperture area of 0.36 (top left) and 0.04 (top right) with their corresponding Fourier Transform
    7. Two Slits along the x-direction

      This pattern is the same with a famous experiment, Young's double slit experiment. Figure 4 shows two parts, with a separation distance of (a)0.1 and (b)0.3. Diffraction patterns are seen in their FT which differs between the slit width and the separation distance of the two slits. When their separation distance are the same and differs in slit width(a,b), more order of diffraction is seen as the slit width increases(a - bottom left to a - bottom right). When their separation distances differs and the same slit width(a - bottom left and b - bottom left), still, more order of diffraction is seen as separation distance increases.
    8. Figure 4. Two slits separated by (a) 0.1 and (b) 0.3 and slit width of (a,b - left) 0.05 and (a,b - right) 0.15 with their corresponding Fourier Transform
    9. Two Dots Symmetric about the Origin

      I encountered some difficulty in creating this dot but fortunately, I managed to create them. Figure 5 shows the objects(top row) and their FT(bottom row). Both all 3 objects are separated by 1.0 with radii, both 0.1 for the 1st image, 0.1 and 0.4 for the middle image, and both 0.4 for the 3rd image. It can be seen the pattern in the Fourier plane decreases in the number of diffraction order as the dot size increases.
    10. Figure 5. Two dots with sizes of 0.1 (top leftmost), 0.1 and 0.4 (top middle), and 0.4 (top rightmost) with their corresponding Fourier Transform
  2. Anamorphic Property of Fourier Transform

    There are many things that are needed to do in this activity but those things are not really that hard but needed a lot of time to do it.

    First in the tasks is to create sinusoid of different frequencies and applying FT on each pattern which is shown in figure 6. It can be seen that the pattern separates as the frequency increases.
    Figure 6. Sinusoid with frequency (top row, leftmost) 4, (top row, middle) 8, and (top row, rightmost) 16 with their corresponding FT

    After that, a constant bias is added to the sinusoid in order to simulate a real image that has no negative values. Figure 7 shows this simulated real image with its FT. Comparing with figure 6, it can be seen that there is an additional information at the center of the image. When a non-constant bias is added to the sinusoid, it is easy to separate the two frequencies by getting its FT and locate the frequency where the maximum value is.

    Figure 7. Biased sinusoid with frequency (top row, leftmost) 4, (top row, middle) 8, and (top row, rightmost) 16 with their corresponding FT

    Figure 8 shows the rotation of the sinusoid and their corresponding FT. It can be seen in the FT figure that the whole figure rotate.
    Figure 8. Rotated sinusoid with frequency 10 and θ = (top row, leftmost) 30°, (top row, middle) 60°, and (top row, rightmost) 90° with their corresponding FT

    Figure 9 shows the (a)combination of two sinusoid along the x- and y-directions together with their corresponding (b)FT. When two sinusoid were added to one another, its FT form a diamond structure where only the edges are seen(b - top row). When two sinusoid were multiplied to one another, its FT form a square structure where only the edges are seen(b - bottom row). After obtaining the sinusoid, a rotated sinusoid were added. Figure 10 shows the (a)combination and their (b)FT. When the rotated sinusoid was added, only the sinusoid that was rotating rotates from 30° to 90°.
    Figure 9. Addition (a,top row) and multiplication (a, bottom row) of sinusoid with frequency (left) 4 and 8, and (right) 10 and their corresponding (b)FT.

    Figure 10. Multiplication of sinusoid of frequency 10 and added to a rotated sinusoid with the same frequency at and angle θ = (top row, left) 30°, (top row, right) 60°, (bottom row, left) 90°, (bottom row, right) 120° with their corresponding FT.
Finally, once again, I have completed this activity. It was not that hard but need some time to work on it. I will rate myself with 12 points. 5 points for the Technical part, 5 points for the Quality part and 2 points for the Initiative part because I compared the patterns in different sizes.

Thank you. :0