Histogram equalization using C++: Image Processing

Theory

The histogram equalization is an approach to enhance a given image. The approach is to design a transformation T such that the gray values in the output are uniformly distributed in [0, 1].

Algorithm

Compute a scaling factor, α= 255 / number of pixels
Calculate histogram of the image
Create a look-up table LUT with
    LUT[0] =  α * histogram[0]
for all remaining grey levels, i, do
    LUT[i] = LUT[i-1] + α * histogram[i]
end for
for all pixel coordinates, x and  y, do
    g(x, y) = LUT[f(x, y)]
end for

Source Code : C++

Output
Original Image and Histogram

Equalized Image and Histogram

 

SHARE Histogram equalization using C++: Image Processing

You may also like...

13 Responses

  1. ZickkrosS says:

    i have some problems with visual studio 2013 , please help , anybody ?

  2. Anonymous says:

    actually you use opencv too in:
    histogram[(int)image.at(y,x)]++;

  3. This comment has been removed by the author.

  4. Unknown says:

    i have a question. In my case equalize image is only about one third of the mine, and the remaining two thirds of the original image appears I don't know what is wrong.

  5. 陳威廷 says:

    Is there a mistak at the line 126
    I think it should be:
    final[i] = cvRound(PsSk[i] * 255.0 * 255.0);

  6. can i call this as , the algorithm of histogram equalization ,which is working on grayscale image and single channel of colour image?
    if not,I need a coding for this particular thing

  7. can i say this is the answer for, implementation of algorithm of histogram equalization which works on grayscale image and single channel of color image.
    if not,i would like to get an answer for this please

  8. Unknown says:

    am using Code::BLocks and it isnt running

  9. Anonymous says:

    You have to install OpenCV in code::block first..Hop this helps

Leave a Reply

Your email address will not be published. Required fields are marked *

Share