We (and I mean WE) usually go out at nights to have fun.. One of the ways to remember the day is by taking a picture. Imagine taking a LOT of pictures and it turns out to be VERY DARK. What to do?
What you DO NOT do is delete the image immediately. You can basically modify the image so that the information (details, namely faces, or even the background).
Histogram Manipulation (using Scilab)
Now, what we are trying to do is enhance the image (manually or through coding), like what cameras and image editing software can do..
So first of all, you get the normalized histogram of the grayscale image of your choice. For example, the histogram is the PDF (As shown in the figure below. Now we get the Cumulative distribution function (CDF) of the PDF. You can wasily do this by using the cumsum() function in Scilab where it adds up the values cumulatively. The corresponding CDF of the PDF is also shown below.
 |
PDF and CDF of a grayscale image |
Now, what you want to do is to make the CDF of your image similar to that of any CDF you want (for example the figure below) for which the original PDF is a normalized Gaussian graph.
 |
Desired CDF (from a PDF: normalized Gaussian curve) |
In order to do this, we employ the method of BACKPROJECTION. So you have to CDFs, the original CDF (oCDF) and the desired CDF (dCDF). You get the y-value of a specific grayvalue of the oCDF, then project it to the dCDF where you find the y-value and identify which x-value of the dCDF this is. Now this is simply summarized in the figure below.
 |
Steps (1 to 4) on altering the grayscale distribution of image. |
Now, you basically do this for every pixel in the image where you place the new x-value (gray value) with that of the corresponding x-value from the dCDF.
Applying on images
This is a Street 3D art (from www.arrestedmotion.com/2011/11/joe-hill-x-reebok-worlds-largest-3d-street-artwork/) which is a 1,160.4 metres square artwork.
 |
Street 3D Painting by Reebok CrossFit with London-based street art duo 3D Joe and Max |
 |
Grayscale image's PDF (left) and CDF (right) |
For the images, I employed multiple manipulations where the desired CDFs (dCDFs) function are as follows:
*** Linear
*** Quadratic
*** Cubic
*** Tanh
The desired CDFs are shown in the figure below.
 |
Desired CDFs to be used for the histogram manipulation |
Using the method described earlier, we notice distinct variation in the shading of the colors (some became lighter, some darkens).
Linear
 |
Manipulated image (above) with its new PDF (below left) and linear CDF (below right) |
Quadratic
 |
Manipulated image (above) with its new PDF (below left) and quadratic CDF (below right) |
Cubic
 |
Manipulated image (above) with its new PDF (below left) and cubic CDF (below right) |
Tanh
 |
Manipulated image (above) with its new PDF (below left) and Tanh CDF (below right) |
All the images together:
 |
Original grayscale of the image |
 |
Manipulated images (clockwise from upper left): cubic, linear, tanh, and quadratic |
Notice that from tha images, the image with a cubic CDF give the brightest image white the tanh CDF give the darkest.
Now, for another image (note that this is a grayscale of a High-dynamic range image (HDR).
 |
Grayscale (above) with its original PDF (below left) and CDF (below right) |
All the images:
 |
Manipulated images (clockwise from upper left): cubic, linear, tanh, and quadratic
|
Corresponding PDFs and CDFs
 |
PDFs and CDFs of the images (left to right): cubic, linear, quadratic, and tanh |
Using GIMP
Using Gimp, you can also manipulate the histogram. So first, I converted the image to grayscale (Mode>>Grayscale), and using a function in Gimp manipulated the histogram (Colors>>Curves). Here are some samples of the manipulation I made for the 3D street art image.
 |
Manipulated images with corresponding histograms (beside the image) |
I give myself a grade of 10 for this activity for successfully producing the required results. It was fascinating how the images were changed just by changing the histogram. I could see how specific colors (in the grayscale) were enhanced while others are dimmed leaving only specific parts to be emphasized. This would be a great tool for enhancing specific parts of images.
Thanks Tin, Gino for insights and the talks. And I also thanks again Kirby for introducing me on using GIMP, such a great software. :P
References:
1 'Enhancement by Histogram Manipulation', 2010 Applied Physics 186 manual by Dr. Maricor Soriano
2 3D street art: www.arrestedmotion.com/2011/11/joe-hill-x-reebok-worlds-largest-3d-street-artwork/
3 HDR image: hazelsteel.wordpress.com
ReplyDeleteNice article. Thanks for sharing.
Artificial Intelligence Courses Online
Artificial Intelligence Training in Hyderabad
Artificial Intelligence Online Training Institute
Artificial Intelligence Training
Artificial Intelligence Training in Ameerpet
Artificial Intelligence Course in Hyderabad
Artificial Intelligence Online Training
AI Training In Hyderabad
AI Online Training