I'm reading opencv tutorials and I'm diving into histogram equalization. i have looked in wikipedia, there is a nice example that sums up exactly the problem:


enter image description here


enter image description here

but for getting this result i would take a different approach:

  1. find the minimum and maximum in the original

  2. normalize (remap) everything upon it.

no histogram, no cumulative distribution function. for sure a more stupid approach but i can't see the difference.. why use histogram equalization? can someone can help me in make the reason out?


The difference is that with your method, if you imagine the histogram, you're simply going to stretch it to span from 0 to 255, but its shape will be preserved. Histogram equalization not only stretches your histogram, but also tries to make it flat, so that you get an approximately even distribution of pixels of every shade of gray.

In terms of why one is better for certain applications than others, that's application specific.


Here are some examples from Bruzed:

Contrast stretching (your method):

enter image description here

Histogram equalization:

enter image description here

As you can see, the bulk of the pixels in the original image was gray, represented by a large peak in the middle. When you do contrast stretching, the peak is still there, even though your darkest pixel is now black and you brightest pixel is now white. By contrast (pun intended), using histogram stretching you get a much flatter histogram response. This actually increases the overall contrast of the image.

  • $\begingroup$ can you provide some example? $\endgroup$ – nkint Jul 17 '12 at 17:46
  • $\begingroup$ @nkint Example of applications or example of how the two are different? $\endgroup$ – Phonon Jul 17 '12 at 17:47
  • $\begingroup$ how the two are different! $\endgroup$ – nkint Jul 17 '12 at 17:48
  • 2
    $\begingroup$ To complement on Phonon's answer, here is a situation where the two are different. You have an underexposed photograph - dark and dark grey everywhere (say values are restricted in 0 the 55 range). Yet, because of a sensor problem, there is a lone hot pixel at 255. Histogram normalization will yield a correctly exposed image, with some loss of dynamic range of course. Your suggest approach will not change anything because the minimum in the input is 0 and the maximum is 255. $\endgroup$ – pichenettes Jul 17 '12 at 18:16
  • 1
    $\begingroup$ Also, instead of using min an max as references for normalization, one can use percentiles, for example 10th and 90th percentile. $\endgroup$ – heltonbiker Jul 17 '12 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.