See details of dark images by manipulating histograms

Dark images are not at all dark. In fact, the details are captured by the camera but our eyes just do not see it. In this activity we show how we can manipulate the histogram of an image so that our eyes can see the details in the dark.


Image Histogram, Probability Distribution Function, Cumulative Distribution Function

An image in gray scale would have pixel values from 0-255. We can construct a histogram from it by counting the number of pixels having the same value. Normalizing this histogram would give us its distribution function p(r).

For every distribution function p(r)  (be it discrete or continuous), there is a corresponding cumulative distribution function called T(r). These two are related with each other by


It is this cumulative distribution function that we’ll be using to manipulate the histogram values and as well as the pixel values of an image.



Manipulating the histogram actually means manipulating the cumulative distribution function of the image. To do this, we must establish first the ideal histogram (called the desired CDF) that we want. For my case, I used both linear and sigmoidal CDF. Linear CDF comes from a uniform PDF while the sigmoidal CDF comes from a bell-curve like distributions (not necessarily gaussian).

Here’s how it works. On the left is the original CDF while on the right is the Desired CDF. From the figure, all pixels having gray scale value of r=100 would change its value to around z=140 by satisfying the condition that T(r) = G(z) or T(100) = G(140).

Image from Maam Jing’s manual



Histogram Manipulation of Grayscale images using Linear and Sigmoidal CDFs

The linear and sigmoidal functions used as my CDF is of the form

linear CDF
sigmoidal CDF

For the linear CDF, m=255 to satisfy normalization. For the sigmoidal CDF, z_0 refers to sigmoids midpoint, while refers to the steepness of the curve. For my case, I used z_0=50 and k=1/10. The graph of the two functions is shown below.

I have two images here with dark regions. Both pictures are from my younger (band pic) and older brother (dinner pic). I have chosen to use there pics after realizing that I’m tired seeing my face (but not in a very mean way). My younger brother is the one playing the red guitar while my older brother is the one seated at the far right beside his girlfriend (ate Kat hehe).

We show here how the images transform as we adjust their original CDFs into linear adn sigmoidal.

Result after backprojection using the linear CDF

Result after backprojection using the sigmoidal CDF

For both CDFs, we see new details from the dark regions of the two images. We now know that the stage has stairs in front (image 1) and that the wall at the dark background is not flat but has posts that protrude (image 2). However, we see that there was more contrast in the resulting images using the linear CDF than the sigmoidal CDF. As we can see in the sigmoidal CDF, all very low and very high gray values are converted to the middle values. Although we see the details, the image appears foggy.



Histgram Manipulation for Colored Images

We now show here how we can still use the method above to colored images. This can be achieved by transforming the RGB channels into new coordinates rgI defined as

I = R + G + B

r = R/I

g = G/I


I have already used this change of coordinates in my previous blog “color segmentation”. The color information is stored in r and g while the intensity stored in I. Instead of the gray scale image values, we manipulate the I component of the image. However, there would a slight change in the desired CDFs since our I value has a range of [0,765]. A value I=0  means R=G=B=0 and the color is black while a value of I=765 means R=G=B=255 and the color is white.

I have only used the linear CDF since from the above results, it showed the best quality. Below shows the comparison between the original and enhanced images.

Similar to the gray images, the details in the dark were also observed in the colored images. This shows that by manipulating only the I component, we can enhance color images.





Author: klguial

undergraduate physics student

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s