Wednesday, December 7, 2016

Activity X - Menipulation of histogram

Activity $Tenenene \, nene \quad Tenenene \, nenen$
I will really die alone now.


Pictures are a technological marvel. They show you things as they were. They are infallible reconstructions of what was. OR SO THEY WANT US TO BELIEVE!

Do not be fooled. Pictures are lying bad boys. Everything they show is real, true but we can still easily be fooled. It is all about framing and lighting. By showing us some parts and hiding others behind the shadow, we arrive at the wrong conclusion.
Ahem media ahem

It is time to rise against the pictures!
Wha...?
It is time to shed light to the truth. To bring the real issues out of the shadows!
Like seriously what?

These lying pieces of PICS, have been hiding information from us all along. And we will need the power of Dr. Soriano's SEA-men.
(I feel a 5.0 coming)
You're lucky if you don't get disciplinary action broh.



Dahell? Who wrote the previous section... Definitely not me! Anyway...

Look at this picture of Dr. Soriano's team in action at the sea.
Bruh!

Look at that nice lady to the left. Can you see anything behind her?
Umm no...? Uhh maybe... I kinda umm... I don't know
What about the guy in blue. Is his right foot also wearing slippers?
Uhh it kinda looks like it but... uhh I'm not sure broh.
Exactly.

Now look at this
Holy mama. Where'd those lines come from? Wait whut, her shirt had wrinkles? I did not notice that. And yup that guy is totally wearing slippers on both feet. Ha... How?

Well my friend this is a simple case of
Science?
No! Stop interrupting me...
$SCIE...$ uhh.. i mean $HISTOGRAM \, MANIPULATION$

This is how it works.
For simplicity let's do it in grayscale.
First we get the histogram (pdf) of the grayscale values. It will look like this.
Then we get the cumulative distribution function (cdf). Like so.
See that sharp increase at the end suggest that some of the brighter features are highlighted while others are downplayed. 
So here's what we're gonna do. We're gonna think of an "ideal" version of the cdf. And then we're gonna force our image to conform. 

Histogram manipulation for idiots.
1. Get cdf of image
For each pixel in the image:
  2. Get cdf value of pixel
  3. Match to cdf value in desired cdf
  4. Take the corresponding pixel value of that that cdf value

This image illustrates what's happening


Remember that "improved image" before. I used a Gaussian cdf for that.
Here's a few more results using Gaussian cdf's with different standard deviation values.

Actually, the best looking improvement I got was using a uniform pdf. Or well that's going to look like a linear cdf. 
Yes treat all information equally!
This is how it looks like using a linear cdf (uniform pdf)
$GREAT$

Of course we all know what the next step is. COLORED!
To make things easier, we are gonna convert the image into rg chromaticity coordinates.
I'm not gonna explain that here. Go back to activity 7 :)
Basically we do the same thing we did for the grayscale image on the Intensity or I channel of the rgI converted image. Then we simply put it back on the RGB color space for rendering. $EZ$

 $TENEN$
 And there it is, again using linear cdf. Now we can see more features and the color does not seem way off. Horay!

Uhh lets put them side by side for comparison

Original (left) and Linear cdf reconstruction (right)

Good, good.

Let me just put it here because I can.

Before and after linear cdf reconstruction of a "bright" scene
Wow I can totally see the some of the lightbulb case pattern.
Yeahp. $GG$



Hohoho that's over with.
Of course histogram manipulation is far from the results of using High Dynamic Range imaging. Using HDR is going to show a lot more features but requires a multiple pictures of a scene under different exposures. Histogram manipulation needs just that one and can totally be used on those 'noob' pictures in your collection.

Good job me.
Hmm not bad. Not bad at all. 
For this I give myself a solid...
Ten!
What? 
10/10! That's right. Look at me. I give the grades now.

Special Thanks to Dr. Maricor Soriano and her team for the image.

No comments:

Post a Comment