Thursday, September 23, 2010

AP 186 Activity 14: Image Compression

Eigenvalues and eigenvectors remind me of our Mathematical Physics series, especially 112. I sometimes miss doing just math, without any big idea in mind just solving away.



Fig 1. Original image


Fig 2. Reconstructed images with different eigenvalues:(a) 1, (b) 10, (c) 30, (d) 50, (e) 80.

--
AP 186 handout
Wiki
--
I give myself 8.

AP 186 Activity 13: Color Image Segmentation

I've been meaning to use a picture of my brother Miguel for a long time, just for fun. In this activity, I finally did. I like this picture of him because he's annoyed and laughing at the same time, plus it's quite perfect for image segmentation because a number of colors in the image really stand out. For this activity, let's focus on the corn he's holding. This was taken using my cellphone camera, at 2MP. I love you dear K770i.

Fig 1. My brother Miguel.

Let's have an overview first of the two segmentation techniques we'll be using in this activity. First is Parametric Segmentation; it's basically getting a region of interest (ROI) in the image then transform its color RGB into normalized chromaticity coordinates using the equation below:



Then the probability function of r and g is solved to test the likelihood that a pixel belongs to the ROI. We used the Gaussian function to compute these probabilities.
As for Non-Parametric Segmentation, the 2d histogram of the image was taken and then using this we back project to segment the image. The results are below:

Fig 2. Parametric (left) and Non-Parametric (right) segmentation.

I observed that Parametrically segmented images are cleaner, and the matching parts in the image with regards to the ROI really shine. On the other hand, Non-Parametrically segmented images have a lot of noise and unwanted data. However since I used a colorful picture, and colors all have red, green and blue, the Non-Parametric method was more sensitive to the presence of the hues in the ROI that were present in the image itself.

--
AP 186 handout

--
I give myself 10 for this activity because I think I understood well the concept of these two techniques of color segmentation, plus I got to use a picture of my brother.

AP 186 Activity 12: Color Image Processing

A few days earlier, I became so giddy because of an LX3 promo I saw at Trinoma. For a while, I've wanted to buy a Panasonic Lumix LX3 (may LX5 na, hehe) but I've had fluctuating discipline in saving money and then my Tio gave me a point and shoot. So for this activity, hurrah goes to my Lumix FS8 and its six white balance configurations.

Below are the original images captured using the six white balance setups in the camera. These were captured around lunchtime, with ambient light as the governing light source.
Fig 1. From a-b: white set, auto white balance, daylight, cloudy, shade, halogen

Before processing, I cropped the images to lessen the size as well as to limit the image with the parts we only want to see. There are two white balancing techniques used in this activity, the White Patch Algorithm (WPA) and the Gray World Algorithm (GWA). The WPA makes use of a known white object as a basis for sort of normalizing the whole image. The GWA on the other hand assumes the that the average color of the world is gray. By getting the average RGB value for each pixel, we can use it as the balancing constant.

Fig 2. From a-b: auto white balance, daylight, cloudy, whiteset, shade, halogen.

Then in another setup, we utilize an inept white balance setting and process the images using the two algorithms, shown below. I think, though, that my WPA is a failure. :/
Fig 3. In the halogen white balance setting, for colors red, blue, green and yellow.

--
Thanks to BA and the AP 186 handout :)

--
I give myself 9/10 because I think my White Patch Algorithm did not give me the best results

AP 186 Activity 11: Playing notes by image processing

The first hindrance for me in this activity is that I can't read notes. I think we were taught how to read back in highschool but I don't quite remember. I'm not that much musically inclined, my relationship with music is basically me being able to hear and knowing the tunes that I like. I wish it were more, but oh well.

So here, we are to extract the notes in a simple score and play it using Scilab. Seems pretty easy, until I realized there is so much in a musical score. First, I binarized the image of the score through thresholding, and I inverted the values. Also took samples of the notes, a half note and a quarter note, from the score music and binarized and inverted it as well. My idea is to clean these images by morphological operations and then segment them and take out the notes as needed.

Fig 1. Line from Are You Sleeping musical score (top) then binarized and inverted (bottom).


Fig 2. Segmented musical score.


Fig 3. Quarter notes (above) and half notes (below)

I turned the image clockwise to get the index of the notes in order. I fished out the next quarter notes and the half notes to give them their respective durations. I also thought about using template matching for this but I think this is also a good alternative in determining notes using image analysis.


--
Thanks to BA, I got ideas from discussions with him
AP 186 manual

--
I give myself 9/10 for this because I think my method is too crude. There are more eloquent ways to solve this.



AP 186 Activity 8: Enhancement in the Frequency Domain

Sometimes there are unwanted things present in our work, and it is of course better to have only the things we need to be there. Noise reduction  makes a sample more pure, assumptions that can be made more valid, or just make things more beautiful. In this activity, we will be using the ubiquitous Fourier Transform to tone down unwanted specks and enhance the parts we want, err need.

First, we need to understand convolution. Mathematically, it is defined as below.
If f(x) and g(x) are two functions with Fourier transforms F(u) and G(u), then the Fourier transform of the convolution f(x)*g(x) is simply the product of the Fourier transforms of the two functions, F(u) G(u).
Now,  let us understand this through these examples.
Figure 1.

Figure 2.

Figure 3.

Figure 4.

Figure 5.


Finger print



Finger print
FT of finger print in log scale



--
convolution
http://www.cs.cf.ac.uk/Dave/Vision_lecture/node19.html

finger print
http://archgraphics.pbworks.com/f/finger%20print_blue%20copy.jpg
http://www.cogs.susx.ac.uk/courses/acv/matlab_demos/fft_image_demo.html

--
I'd give myself 7 for this activity because I didn't get to finish it.

Wednesday, September 22, 2010

AP 186 Activity 10: Binary Operations





This is a culminating activity of all the methods we have learned so far. We are to get the area of normal cells and be able to discriminate cancer cells (which are really just abnormal cells) as very important application of image processing.


First, a little practice. We are given an image with punched circles. This is to measure the average size of a punched circle.The image is segmented and binarized for simplicity. However, there are still unwanted specks in the image. We use the morphological operations opening and closing to remove these unwanted attributes.

Fig 1. Counterclockwise from top left: original segment, black and white conversion, 
cleaning by morphological operators, cleaning using bwlabel.

To keep track of the blobs, we use bwlabel. It turns out that this function is very useful in not only identifying the number of blobs in the image but also in indexing these blobs. I used the sample code in the bwlabel Help article to get rid of other smaller (those left from opening and closing perhaps) and larger (stacks of cells) articles in the image.
Fig 2. The same segment as in Fig. 1 but here the blobs are filtered and labeled.






From the counted an indexed blobs, the cell areas were tallied. My computed average circle area is: 575.31 pixels. This is now used to isolate the 'cancer' cells in the given image Cells_with_cancer.jpeg.

Fig 3. Image of cells with cancer cells (left) and image of isolated cancer cells (right).

--
Thanks to BA and Che, my 'seatmates' in 186. :)
AP 186 Handout
Scilab Help
--
I give myself 10 in this activity because I did what has to be done and I enjoyed making this activity.