Sunday, 11 August 2013

Activity 9 - Color Image Segmentation

Image segmentation, by definition and by my experience after performing this activity, is the partitioning of images into parts for the purpose of identifying objects and/or other relevant information. Segmentation can also be done by thresholding, as shown in Activity 4, but sometimes this does not suffice. Thus in this activity color image segmentation will be performed. 

As color can be perceived in different shades and brightness, it would be efficient to represent colors in terms of chromaticity and brightness. One such space is known as the normalized chromaticity coordinates. As the name suggests, each pixel coordinate is normalized:


where R, G, and B are the matrix representing the red, green, and blue channel of the image, respectively. Here I = R + G + B and r+g+b = 1, where r,g and b can only have values from 0 to 1 and b is independent of r and g. Thus we can represent chromaticity in terms of r and g and brightness is given by I. In the NCC space; where r and g is zero, corresponds to the coordinate, blue, while where r = 1 and g = 1 corresponds to pure red and green, respectively.

Figure 1. NCC model


There are two techniques in which the image can be segmented, either parametric or non-parametric probability distribution estimation.

In Parametric probability distribution estimation (PPDE), as is in non-parametric, we first select from the image a region which belongs to a color distribution of interest (CDOI). In the image shown in Figure 2, that would be the red coloration in the kite. From this region of interest (ROI) we can compute the probability of each individual pixel in the image of being part of the color distribution of interest. 

Figure 2. Image taken of a Kite during an Arras Fieldwork

Figure 3. ROI


Since NCC is represented in r and g, the joint probability from each channel is calculated. Thus for each channel a Gaussian distribution is assumed, represented as:



where µ  and σ are the mean and standard deviation derived from the ROI, and r and g are pixel coordinates from the image. Thus by taking joint probability per pixel, the application of PPDE to the image is complete.

Figure 4. Image Color Segmentation Result after application of PPDE

In Non-Parametric probability distribution estimation (NPPDE) histogram backprojection is used. This method is similar to that of Activity 6 except in this activity this is performed in 2D. After normalizing the r and g channels we can compute its histogram by implementing this code:

BINS = 32;
rint = round( r*(BINS-1) + 1);
gint = round (g*(BINS-1) + 1);
colors = gint(:) + (rint(:)-1)*BINS;
hist = zeros(BINS,BINS);
for row = 1:BINS
    for col = 1:(BINS-row+1)
        hist(row,col) = length( find(colors==( ((col + (row-1)*BINS)))));
    end;
end;
scf(2);
imshow(hist,[]);

where hist coordinates are given by rint and gint given as (rint, gint) but since images are represented in row and column, the rint coordinates would be located along the y-axis and the gint coordinates along the x-axis while the origin is now located at the top left corner. As shown in Figure 5, the resulting histogram of the ROI from Figure 3 agrees with the NCC model.

Figure 5. Comparison of NCC model and histogram of Figure 3

Thus by converting each pixel from Figure 2 into rint and gint coordinates and performing histogram backprojection, the image is segmented.

Figure 6. Image Color Segmentation Result after application of NPPDE

Comparing the two results,

Figure 7. Comparison of results PPDE (left) and NPPDE (right)

we can see that NPPDE detects more of the CDOI compared to PPDE, which neglected most of the pixels in the shadowy region. Thus overall, NPPDE has a faster and less complicated application and a more accurate result compared to PPDE.

In this activity I give myself a grade of 10 for being able to implement the tasks given and for being able to understand the steps involved.

Acknowledgement
I would like to thank Anjali Tarun for teaching me what was wrong in my NPDDE code.

Reference:
[1] M. Soriano. "Color Image Segmentation" Applied Physics 186 2013. University of the Philippines

No comments:

Post a Comment