Hey there!

My outlet to all things related to physics. Enjoy!

Thursday, July 7, 2011

Raw Egg and Adobong Pusit


Sometimes what we see can be deceiving. When this happens there are instances that our discernment fails and we become deceived. As an example let me tell you a story. During my pre-school to early elementary days the only food i'd eat when I didn't like the food served in our house is raw egg with rice. Yes, RAW EGG!  During meal times I'd ask for a bowl, an uncooked egg, some salt and rice then mix them all together. I remember eating this odd combination for a long period of time (say a few years. HAHA.). I'd happily eat it because, to me then, the other food that the people around me were trying to feed me didn't look delicious. A few years into this raw-egg-with-rice phase of mine I was slowly losing the desire to eat raw egg and I became more and more interested to taste other food. The combination seemed to taste more and more bland. And it finally dawned on me, "What i'm doing is disgusting and it tastes horrible!" (Sorry if I offended any raw egg lovers! :D) I could only remember one of the Sundays where I actually tried to eat something different. It was during a family lunch in my grandmother's house. I dared to eat Adobong Pusit (Squid). I remembered it tasting really good. I didn't know it at that time, but, now that I look back it was a turning point in my life. When I decided to ignore the appearance of what I was about to eat and instead focus on what it was going to taste like. I was going to free myself from years of slavery to the raw egg. For years I had been boxed, never tasting other food only because I considered the appearance more than the taste. I had missed out on the real and good stuff! "Chill Haneka! It's just food." Yeah, it is. But, in our lives we can be like this sometimes. We are boxed because we consider what we see to be more important than what that person/situation/thing really is. We miss out and fail to enjoy.

Yummy! HAHA.
In this activity, we are trying to enhance images in order to see the information captured by the recording instrument. And just like my raw egg dilemma, hopefully we'll be successful to "see" beyond the limitations of what we can see. 

First off, I picked a dark colored image so that I can do some enhancing to it. The said image can be seen below.

Truecolor Image
Source:  http://www.designzzz.com/gorgeous-sunrise-photography/
I then converted the image to a Grayscale image using the gray_imread function in Scilab. The resultant image is shown:

Grayscale Image
Having this image, I got it's histogram using my own code then normalized the histogram to create the Probability Distribution Function (PDF) of the image. The PDF of the image gives us an idea of the probability of a certain gray level to be present in the image. The code, histogram, and PDF can be seen below,

Histogram Code. Pixel Frequency versus Gray level values.
Histogram of the image. the x-axis is the gray level while the y-axis is the
pixel frequency.
Code for the PDF or normalized Histogram of the image.

PDF of the image. x-axis is the gray level while the y-axis is the percentage of pixels.
Moving on, here comes the part where our brain muscles will need a slight programming work out. Breathe in. Breath out. To enhance the image we can manipulate the histogram of the grayscale image. We will be able to do this by creating a desired Cumulative Distribution Function (CDF) for the resulting image. We will then back project the grayscale values using the  CDF in order to modify the PDF of the image. Now that we know that, let's first create the CDF of our image. Using the function cumsum we can easily do this. Both the code and plot can be see below:

Cumulative Distribution Function code
Cumulative Distribution Function plot of the image
Now that we have the CDF, we will create our desired CDF for the enhanced image. I have created to such CDFs. One is linear and the other one is exponential. The CDFs and corresponding codes are given,

Code for Desired CDF (linear)
Desired CDF (linear)
Code for desired CDF (exponential)
Desired CDF (exponential)
We're one step closer to enhancing our image. The next step would be to backproject. Thanks to a great function in Scilab called interp1, we can easily do this. 

Code for backprojecting using a desired CDF that is linear

Code for backprojecting using a desired CDF that is exponential
The next thing to do is to finally apply the changes made to enhance the image. Unfortunately I wasn't able to  finish this part(I wasn't able to figure it out on time :( ).

Other than image enhancement using Scilab, we also got to play around with Gimp. Here I loaded the same image and once again converted it to a grayscale image. After this, I was able to play around with the image using one of the "tools" in Gimp  called curved which can be found in the Colors section of the menu. Below are the images I played with (From simple grayscale to totally odd effects.)

Effects of image manipulation in Gimp
Curve "tool" in Gimp
Curve tool in Gimp

Effects of image manipulation in Gimp

Curve tool in Gimp
Curve tool in Gimp
For my self-evaluation,  i'd give myself a 7 out of 10 since I wasn't able to finish it. Special thanks to Jen-Jen Manuel, Elo Anguluan, Tracy Estella, Kirby Cheng, and Dr. Soriano :)

God bless everyone! :D






1 comment:

  1. I'd rather you submit something complete late than something on time but incomplete. So, I'm giving you a chance to make up for the undelivered output.

    ReplyDelete