Skip to main content

Activity 11: Color image segmentation

In image segmentation, we want to segment or separate a region of interest (ROI) from the entire image. We usually do this to extract useful information or identify objects from the image. The segmentation is done based on the features unique to the ROI. 

In this activity, we want to segment objects from the background based on their color information. But real 3D objects in images, although monochromatic, may have shading variations. Hence, it is better to use the normalized chromaticity coordinates (NCC) instead of the RGB color space to enable the separation of brightness and pure color information. 

To do this, we consider each pixel and the image and let the total intensity,  I, for that pixel be  I = R + G + B. Then for that pixel, the normalized chromaticity coordinates are computed as:
r = R/I;                g = G/I;                   b = B/I
The sum of all three is equal to unity, so it is enough to express chromaticity using only two coordinates r and g since b is dependent on both (i.e. b = 1- r - g). The r-g color space is shown in Figure 1.


Figure 1. Nomalized chromaticity
space. X-axis is r and y-axis is g.

I. Parametric probability distribution estimation

In the first technique we segment a color by taking the probability that a certain pixel belongs to the color distribution of interest. Pixel membership to a region of interest is determined from the joint probability p(r)p(g) where p(r) and p(g) are independent probability distributions along the r and g, respectively. We assume Gaussian probability distribution functions (PDFs) for both so we can write them as:



The yellow car in the image in Figure 2 is segmented using this technique. 
Figure 2. The yellow car is to be segmented from the entire image.

I tried two different patches and compared the results (Figure 3). The first patch was taken from the hood of the car while the second was taken from its door. Clearly, the second patch gave a better result since the we were able to segment much of the car's body instead of just the outlines as in the first patch. Hence, in selecting a reference region for the ROI it is important to take into account all possible shading variations in the color that we want to segment.



 Figure 3. ROI Segmented from the image using parametric estimation and the corresponding reference patches used where (a) was taken from the hood of the car and (b) was taken from the door.

II. Non-parametric Segmentation
For non-parametric probability distribu, we use the image's 2D histogram to determine the membership of a pixel to the region of interest. To do this, we use histogram back-projection in which we give each pixel location  a value equal to it's histogram value in chromaticity space.

The 2D histogram (32 bins) of the two reference patches in Figure 3  are shown in Figure 4. We know that this is correct since the location of the peaks are in approximately the same region as the observed color for the ROI (i.e. yellow). The histogram of the second reference patch covers a larger area since it has more shade variations.

Figure 4. 2D histogram of the two reference patches for the ROI (a) for the patch taken from the hood and (b) for the patch taken from the door

Again, we try to segment the car in Figure 2 using the same reference patches. The results are shown in Figure 5. Again, the second patch gave better results than the first patch. 



 Figure 5. ROI Segmented from the image using non- parametric estimation and the corresponding reference patches used where (a) was taken from the hood of the car and (b) was taken from the door.


Segmented ROIs using the first method produced images with smoother variations in shade since we used an analytic function to estimate the PDF, giving us continuous values. Segmentation using non-parametric was able to segment more of the car (observe the roof part) but it also included other parts of the image which had yellowish hue such as the portions of land visible through the vegetation. This means that parametric estimation is more selective in pixel-membership tagging compared to non-parametric estimation.

I would like to thank Ms. Maria Isabel Saludares for helpful discussions. 

Finally, I give myself a grade of 10/10 for successfully segmenting a region of interest (ROI) from the background. :)

Reference:
1. M. Soriano, "A11-Color Image Segmentation, " AP 186 Manual, 2012

Comments

Popular posts from this blog

Activity 2: SciLab basics

For the second activity we had a bit of practice in using the SciLab programming language. We had to produce the following synthetic images: a.        Centered square aperture b.       Sine wave along x direction (corrugated roof) c.        Grating along x direction d.       Annulus e.       Circular aperture with graded transparency (Gaussian function) But first we had to follow a sample code given by Dr. Soriano. The code produced a 100 x 100 pixel – image of a centered circular aperture with radius of 35 pixels (Figure 1). Figure 1. Code and synthetic image for centered circular aperture After doing the centered circular aperture I am ready to do the other synthetic images. The easiest was the annulus since you just have to tweak the code for the centered circular aperture. I just replaced line 7 of the code with: A(find(r...

Activity 10 Applications of Morphological Operation 3 of 3: Looping through images

When doing image-based measurements, we often want to separate the region of interest (ROI) from the background. One way to do this is by representing the ROIs as blobs. Binarizing the image using the optimum threshold obtained from the image histogram simplifies the task of segmenting the ROI. Usually, we want to examine or process several ROIs in one image. We solve this by looping through the subimages and processing each. The binarized images may be cleaned using morphological operations.  In this activity, we want to be able to distinguish simulated "normal cells" from simulated "cancer cells" by comparing their areas. We do this by taking the best estimate of the area of a "normal cell" and making it our reference.  Figure 1 shows a scanned image of scattered punched papers which we imagine to be cells examined under the microscope. These will be the "normal cells." Figure 1. Scattered punched paper digitized using flatbe...

Activity 9 Applications Morphological Operations 2 of 3 : Playing Musical Notes though Image Processing

For this activity, we will try to read a sheet music via image processing and play the music using Scilab. A sheet music is basically black and white so it is easy to separate the notes from the background by thresholding and applying morphological operations.  The first task for this is to find a sheet music. I used the song Clementine and the sheet music is found in Figure 1. Figure 1. Sheet music for Celementine To make processing easier we divide the sheet into different lines. In this case we have four lines as shown in Figure 2. Figure 2. The 4 lines in the sheet music of Clementine were separated  (line 1 to 4 from top to bottom) We then binarize the images with a threshold of 0.95 and invert them such that the background is black and the foreground is white. We disregard the area of the image where the clef is located. Using morphological operations, specifically CloseImage(),OpenImage() and ErodeImage() we reduce the notes into small blobs...