Activity 11: Color Image Segmentation

September 11, 2012

If from our previous activity we isolated certain features in the image through the simple thresholding and a little bit of morphological operations, this time… we are to try and isolate certain features of a specific color.

In drawing anime or sketching… a factor that makes these art pieces realistic is through its shading. There will be portions in an object where it’ll appear darker or brighter, depending on the location of your light sources.This is the reason why in taking an image of a 3D object, we won’t end up with a matrix having exactly the same values per R,G,B layers. Hence, the first step in color image segmentation would be to pick out the ‘Region of Interest (ROI)‘.

For this activity, I made use of two different images to be able to observe the effectiveness of the technique. The images are as seen below:

where my chosen ROI’s are the cropped portions as seen below:

Seeing that simply making use of the RGB values of our ROI’s would lead to the segmentation of only a small region, the determination of the rgI values is desired. This is so because the normalized chromaticity coordinates has a separate component for the color purity (chromaticity) and brightness of a shade. The conversion is done through the use of the equations below:

What you’ll do with these rgI coordinates depends on your preference. Two methods are available in color segmenting images: Parametric and non-parametric.

Parametric Segmentation

The main concept in the parametric segmentation is to calculate the probability that a pixel in the image is still within the range of the pixels from our region of interest. Taking the mean (through the mean()  function) and standard deviations (stdev() function) of the r-g coordinates in our region of interest and making use of the Gaussian distribution with r and g coordinates of each pixel in the actual image:

The resulting product of the r and g Gaussian distributions (p(r)p(g)) yields our final image.

As for my spices image, I ended up with these two images:

It is clear that having a larger ROI results to more portions of the image of a specific shade to be included. This is so because we are considering a larger mean and standard deviation values.

On the other hand, the iced tea image with its corresponding ROI produced:

Seeing that we have used a small ROI as well as the gradient of the ‘light blue shade’ is very large… only the bottom portion of glass of iced tea was included.

Nevertheless, we have managed to segment our images! Cool right?

Non-parametric segmentation:

Unlike that of the parametric segmentation, this method won’t be making use of any distribution whatsoever. What we’ll basically do here is to look at the 2D histogram of the r-g coordinates of our ROI. We then make use of what we’ve learned from Activity 5: Enhancement by Histogram Manipulation. What makes things a tad bit more complex is that we now consider 2-Dimensional backprojection.

The 2D histogram of the r-g coordinates should give an output image that kind of resembles that of the NCC diagram when rotated. Below are the 2D histogram for each of the images I’ve used:

From inspection, we can clearly see that the coordinates correspond to the red region. Also, the difference in the shades of our two ROI’s is apparent here as the larger ROI gave out even more points in our histogram. On the other hand, the iced tea ROI gave out the histogram:

Since we have a very small ROI for our iced-tea image and through visual inspection it really appears as if it’s monochromatic, the resulting histogram appeared to be a single pixel! Nevertheless, for both cases… the location of  the 1’s of our histograms was able to correspond to the colors of the ROI’s successfully.

Now taking note of the r-g coordinates of our original image and replacing their y-values with their corresponding y-values in the histogram of the ROI, we end up with the segmented images:

There is an evident difference between the end-products of the two methods. The non-parametric segmentation appeared to have considered more points as the iced tea image no longer have the ‘gradient’ effect at the center like that of the parametric segmented image. Again, this is due to the usage of a Gaussian distribution where indeed gradients should then be expected. Personally, I liked the parametric method much better. I like its effect to the image where it looks a bit more 3D as compared to the non-parametric image looking like a simply binary image.

Note: For this activity, I would give myself a grade of 10 😀 I’ve managed to do the activity and at the same time enjoyed it XD. I can’t wait to make use of this to our next activity (face recognition?) XD.

Random Blabbers: I remember when I was searching for an image to use, I was struggling as I’m very much in love with images of different colors… I had to find an image containing a significant amount of certain colors with a distinct feature. In the end I managed to enter my Photonics picnic album and it was at around 2am then. I seriously scanned through mouthwatering images of BBQ’s and shrimps that my tummy rumbled in annoyance ToT. Thankfully, there was this peaceful image of spices that I ended up with. Lesson learned? Never open an album full of food in the middle of the night XD

Can you feel my annoyance as well? 😀

One Response to “Activity 11: Color Image Segmentation”

  1. Jing said

    (Grumble-grumble)

Leave a comment