Monday, December 5, 2016

Activity 10 - Enhancement by Histogram Manipulation

The sem's almost over! One more activity after this and I'm done with blogging for AP 186. One more activity after this and then AP 186 exam. Although, an exemption from taking the final exam is possible, and I do hope I qualify.

On to the activity! Activity 10 is about enhancement of  features in an image by manipulation of its histogram. Take for example a grayscale image. First, we take the probability distribution function (PDF) of the grayscale intensities, by taking the histogram of the grayscale intensities and normalizing it by the total number of pixels. We then take the cumulative distribution function (CDF) from the PDF (refer to the link for CDF information https://onlinecourses.science.psu.edu/stat414/node/98). To manipulate the histogram, we backproject the grayscale intensities with a desired CDF of ours. Following the discussion in out manual (thank you ma'am Jing), if we for example have \( A(x) \) as the CDF of our image, and \( B(y) \) is our desired CDF, then for each pixel intensity in out image, we transform it to \( y = B^{-1}(A(x)) \). In other words, if we have a pixel intensity \(x\), we determine its corresponding CDF value \( A(x) \), then determine the corresponding \(y\) value that produces \( B(y) = A(x) \).

Let's take for example the image shown below. We first convert this image to grayscale, which is also shown below. 


Image A

Image A in grayscale
We then manipulate the histogram of this image. The PDF and CDF of this image is shown below. We backproject this CDF using a linear CDF, which runs from (0,0) to (255,1). This equalizes the histogram of the image. The resulting image is shown below. 


PDF of image A in grayscale
CDF of image A in grayscale

Grayscale image A after histogram equalization
The colored image can also be enhanced by histogram manipulation. If we convert the \(RGB\) values to \(rgI\) values, histogram manipulation can be done on the \( I \) values. The \(I\) values were normalized with respect to the maximum value \(I_{max}\), then the histogram was obtained. The PDF as well as the CDF were then obtained, which are shown below. Backprojection was also done using a linear CDF, and the resulting image is shown below.


PDF of colored image A
CDF of colored image A

Colored image A after histogram equalization
Note that upon histogram equalization, features in the dark portions of the original image are now enhanced. Observe the differences of the encircled portions from the original image, which can also be observed in the equalized grayscale image. The distinction between legs can now be observed, and the features of the bag are more enhanced.

The image below was also histogram equalized, both the colored image and the grayscale image.

Image B

Image B in grayscale

Grayscale image B after histogram equalization

Colored image B after histogram equalization

Note that from the original image where my face was dark, the features of the face are now enhanced. The eyes and the ears are now more visible than the original image, as observed in the grayscale and colored images.

I would give myself a grade of 10 for this activity since I think I have successfully performed histogram manipulation to enhance the features in the image. 

No comments:

Post a Comment