Colour Histogram Equalisation (CHE) is the ‘flattening’ of a histogram, which usually leads to a global contrast gain. This often leads to more vibrant colours, and allows for you to provide a way to make images look better without having to play around with contrast and brightness sliders. Check it out below, applied on two images of Bangor Univerity’s main arts campus.


Test Equalistaion

To apply this, we need to firstly retrieve the red, green and blue values for each pixel in the image. This is so that we can calculate the Luma, a measure of the images intensity.


We can then process the Luma channel alone.

Luma 1

And recover the colour from the colour ratios:

Luma 2

Note: The histogram for your image will currently look something like the following:

Histogram 1

Then compute the cumulative distribution function:

Cumulative Distribution Function

Then use the function to assign new pixel values, leaving our resulting histogram to look something like the following:

Histogram 2

And there we have it, histogram equalisation – but now the question is: how do we do this in code? I have written a simple image processing application, and all of the source can be viewed / downloaded from here, or you can just jump right to the histogram equalisation method. All code is in C++, and the project has been created in Qt Creator using the QtSDK for the GUI and OpenCV for Image Processing.

Update (2016): A long time ago, I deleted the above repository from GitHub and it’s apparently gone forever. However, it looks like I saved the project in an archive; you can download it from here.