Thursday, July 7, 2011

five

For grayscale images, their histogram is the normalized (by the total number of pixels) graylevel probability distribution function (PDF).  Because of this, the grayscale PDF can be modified.  One way of going this is to use histogram manipulation mainly to improve image quality, enhance image features of mimic different imaging system responses.  This modification is done, given the cumulative distribution function (CDF) of a desired PDF, by backprojecting the grayscale values using the CDF.

The PDF of an image can be described by p1(r) where r represents the different grayscale values of the image and consecutively, the CDF can be described by this mathematical relationship.

t
Figure 1. Equation for the image CDF

However, it is our goal to alter the image in some way and so we use a CDF described below where z, in this case, represents the different graylevels in the image. 

g
Figure 2. Equation for the desired CDF

This is where the backprojection method comes in and as a result, we may be able to obtain the new value that each pixel should have.

z
Figure 3. Mathematical representation of the backprojection method

As in other fields of physics, we must make sure that these theories can be applied to the real world.  For this, I used a picture of one of my adorable nieces – who, because she is a minor, I shall not name – taken by Mr. John Joan A. Mende. 

gasa_picgasa_grayscale
Figure 4. (top) Original Image (bottom) Grayscale version of original image

histplot_originalhistplot_normalized
Figure 5. (top) Original Histogram (bottom) Normalized Histogram

The main difference in the original and normalized histograms lie in the x-axis values.  For the original histogram, these values range from 0 to 1 while the values for the normalized histogram range from 0 to 255 (despite what the image tells you).

I found that the Scilab function tabul proved to be very helpful in computing for the CDF.  It took quite a bit of Google-ing to figure this out but it was worth it.  Note that I’m just showing snippets of my code since the previous parts have already been performed in activities before this.  Also, my code shows comments made rather unnecessarily to myself because I have the short term memory of Dory (from Finding Nemo) and I have to have something there to make sure I know what the code does.  In regards to the CDF of the original image, I have to be amazed at the smoothness of the curve.  My uncle must be that great of a photographer.

code 1
Figure 6. Scilab Code used to determine and plot the original and linear CDF.

cdf_origcdf_linear
Figure 7. (top) Original CDF (bottom) Desired linear CDF

Finally, we get into the whole backprojecting mania and of course the results obtained from it.

gasa_enhancedhistplot_enhancedcdf_enhanced
Figure 8. (top) Enhanced image and its (middle) PDF and (bottom) CDF

In comparison to the original image, the enhanced image seems lighter – you can distinguish the girl’s features better in the enhanced image.  As expected, its CDF  is the same as the desired CDF.

I manipulated the image using the Color Curves feature of GIMP, and with a exponential-looking CDF, the image looks darker and a damped oscillation-like CDF, the image looks extremely grainy. 

exponentialoscillation
Figure 9. (top) Exponential and (bottom) damped oscillation CDF manipulation
using GIMP

In this activity, we were told to use and/or compare similar color curve manipulation techniques using other free image editing software.  I really don’t know of any other free editing software and since I had Adobe Photoshop installed on my computer upon buying it, I decided to make use of it.  I obtained similar results as those above but we do have to consider that I used the same types of CDF manipulation.  All in all, I give myself a 10 for this activity.  Doing this for me was entertaining.  I leave the following images to say my goodbyes for me.

exponential PSoscillation PS
Figure 10. (top) Exponential and (bottom) damped oscillation CDF manipulation
using Adobe Photoshop CS5

REFERENCES:
Enhancement using Histogram Manipulation, Applied Physics 186 Manual

No comments:

Post a Comment