Huwebes, Setyembre 22, 2011

Activity 5 Enhancement by Histogram Manipulation

Histogram Manipulation

A grayscale image’s histogram is the graylevel probability distribution function(PDF) when normalized by the total number of pixels. Manipulating an image’s histogram has been a means of improving its quality. One way to do this is by the method called backprojection. Backprojection is the manipulation of an image’s cumulative distribution function(CDF) to obtain a desired distribution. The CDF  can be obtained by collectively adding up the y values of the PDF for every x.

I chose this dark looking image for this activity.  

Figure 1. A dark image

I loaded it into Scilab and converted it to a grayscale image. Then I obtained the histogram and the CDF of the image.

Figure 2. The converted to a grayscale image  Figure 1

Figure 3. Histogram of Figure 2  

Figure 4. CDF of Figure 2
  Our desired CDF for the first part is linear. It was a line with slope 1.   Below is the code used to obtain the resulting image.   
Figure 5. Desired linear CDF



  

  

Figure 6. Resulting image after Histogram Manipulation with a desired linear CDF

Figure 7. The histogram of figure 6
Figure 8. Histogram of Figure 6.

Notice that the resulting iimage become brighter, but some of the information was lost. Also we can see that the CDF of the image is very similar to our desired CDF.  
The second part our desired CDF was something non-linear like a normal distribution for the histogram. Here is the resulting image and the histograms.    

Figure 9.   . Resulting image after Histogram Manipulation with a desired non-linear CDF  


Figure 10. Histogram of Figure 9




Figure 11. CDF of  Figure 9





Notice that the histogram resembles a normal distribution. The resulting imae though is too bright and the image was not really enhanced well.
The next thing I did was load the image in figure 1 to an image editing software called GIMP. I converted it to a grayscale image then go to Colors and choose Curves. HEre you can easily manipulate the histogram of the image. A snapshot of GIMP software in use is shown below.





I would give myself a grade of 7//10 for posting it this late. Actually I hit a mental block here and the activity on image segmentation helped me finish this.

References:

2. Soriano M. Enhancement by Histogram Manipulation AP 186 2011

Miyerkules, Setyembre 14, 2011

Activity 14 – Color Image Segmentation

Color Image Segmentation

Image segmentation is a process in which a region of interest(ROI) is selected and isolated from the image so that further things can be done on it. This is done by using the unique features of the region of interest to distinguish it from the insignificant parts.

For grayscale images, image segmentation can be done through thresholding. But this could not be done for other types of images.  One feature that was used to segment some images is its color but this is sometimes problematic since 3D objects have varying shades of the same color because of the shadow formed by light. So it is better to utilize something that can divide brightness and color information.
Normalized chromaticity coordinates or NCC is a color space that can separate brightness and color information.

Image segmentation that uses the color as a distinguishing feature is used by finding the probability that a pixel falls within a distribution of interest. This can be done in two ways, parametric segmentation and non-paramagnetic segmentation.

Parametric segmentation derives the Gaussian Probability Distribution Function (PDF) of the r and g values for the ROI then segments the whole image. Non-parametric segmentation obtains the histogram of the ROI first, and then the histogram itself is used to segment the image using histogram projection. 

In this activity we would perform both color-based segmentation on an image and compare the results. First, I selected this image of the National Basketball Association (NBA) trophy.

Figure 1. Image of the NBA trophy (source:http://nba-news-alex.blogspot.com/2011_02_01_archive.html)

I cropped a part of it and saved the image.


Figure 2. Cropped part from the image in Figure 1



Then I performed parametric segmentation on it using Scilab. The code is shown below.




Here the RGB values are transformed to NCC then we obtain the probability that a pixel with color r belongs to ROI. To do this we obtained the mean and standard deviation of the r and g for the Gaussian PDF. Then we obtained their joint probability by multiplying their individual probability. The result is shown in figure 3.

Figure 3.Parametric segmentation for the NBA trophy



Next thing I did is perform nonparametric segmentation on the image. First we obtain the 2D histogram of the r and g values using Scilab. The code is shown below: 




The output of this is shown below: 

Figure 4. 2D histograms of the r and g values of the ROI



Then this is rotated for the NCC.

Figure 5. Rotated image of figure 4.




Figure 6. Normalized Chromacity space


. Using the histogram we performed histogram backprojection using Scilab. The code is shown below.




The resulting image from non-parametric segmentation is shown below.

Figure 7. Non-parametric segmentation of the NBA trophy

Looking at both images it can be seen that the parametric segmentation was able to yield the better result compared to non-parametric segmentation. In non-parametric segmentation, some of the background were segmented together with the ROI while in parametric segmentation, the edges are well-defined. 

I would give myself a grade of 9/10 for doing this on my own.

References 
1. Soriano, Color Image Segmentation 2011, Applied Physics 186