Okay, the picture below is an image of different colors of plastic balls. And guess where I got it: http://gayguidetoronto.com/2009/05/24/big-bold-bouncy-balls/ Yeah. Gay Guide. Hahahaha. :)))) I really haven’t notice that it was a gay site until I copied the link where I got the image. Oh well. It is really an epic picture. The picture above shows the pictures of the balls to be segmented.

Well enough of our giggling. Let’s go back to work! So, what we will do is separate (or segment) the balls according to color. We are going to use two ways in order to do this. In both ways, we are required to represent the color space (not the usual Red-Green-Blue) into pure color information. The normalized chromaticity coordinates (NCC) can be used where the brightness and chromaticity of the picture is well-represented [1].

To represent the color space into NCC:

R = Ic(:,:,1); G = Ic(:,:,2); B = Ic(:,:,3);

Int= R + G + B;

Int(find(Int==0))=1;

rc = R./Int; gc = G./Int;

We first separate the Red, Green and Blue component of the image. Then we get the sum of these components. To prevent the world from destroying, we avoid dividing by zero by assigning all values with zero to 1. Finally, we divide the R component with the sum of the RGB components to get the NCC for red, and by dividing G component with the sum of the RGB component to get the NCC for green. Only two components are needed.

Next is we need a Region of Interest (ROI), where we compare the bigger image. For the image of the balls, a ROI can be a small square of a certain color. Don’t worry, I’ll show more examples later. Aaaand, we are ready! I’ll tell you the two ways for segmentation:

**1) Parametric Segmentation (PS)**

In PS, we shall find the NCC of both the original picture and the ROI first. Let’s call this r_original and g_original for the NCC of the original picture while r_ROI and g_ROI for the NCC of the ROI. The next thing we do it we get the standard deviation and mean of r_ROI. After this step, we get a single value of the standard deviation and the mean. We then substitute it to the Gaussian equation. With r being the r_original (which will be a matrix). After that, we shall do it again for the green NCC. Finally, we multiply the probability distribution of the red and green to get the segmented image.

**2) Non-parametric segmentation(NPS) **

In NPS, we shall first obtain a 2D histogram of the ROI using the NCC. Then, the histogram using the ROI will be back projected to the original image’s NCC. It really sounds simple but its more complicated than that so I’ll just provide the code later.

**RESULTS
**

I’ll try to extend this work by investigating the use of different ROI colors and sizes.
From the figure above, different ROIs were obtained as seen in the figure below. Five colors were used.