# Lesser bins histogram looks more equalised than higher bins histogram after histogram equalisation?

I tried to do a histogram equalisation on an image, and then display its histogram. I realise that when I show the histogram with 10 bins, it looks more "equalised" than when I show the histogram with 256 bins. Here's is an image of the 10-bin and 256-bin histograms of the same image after running a histogram equalisation:

So again, in the image above, clearly, the histogram with 10 bins looks more equalised than the histogram with 256 bins. Since both the histograms reflect the colour pixels for the same image, is there reason as to why the 10-bin histogram looks more equalised than then 256-bin histogram?

## 1 Answer

I'm not sure if this is the best answer to your question out there, but I would disagree that your 256-bin histogram isn't equalized. Think of it this way.

1. Each bin represents the count of pixels of a certain intensity. When you're performing histogram equalization, you're moving that bin to a new intensity value, according to the empirical distribution (i.e. histogram of the original image). You're shifting all of those pixels to a new value, which means that if 30% of all your pixels had a certain value, all 30% will again be in the same bin, just with a different value.

2. Histogram equalization tries to equalize the density of pixel values within any neighborhood. For example, since that huge bin with 30% of all pixels cannot be made smaller (all values of those pixels change to the same new value), equalization will try to move all other bins away from it, so that that neighborhood around the big bin frees up a bit. This is exactly what happens in the picture on the right. Notice that all tall bins have large spacing between them, while all short bins are stuck close together. This ensures that on average you have the same amount of pixels "per unit length of histogram's x-axis" if you will. This brings us to the last point.

3. When you're using less bins, (10 in your case), you're basically summing or averaging bins of your high-resolution histogram into a low-resolution histogram. Remember that the amount of pixels in a certain intensity neighborhood is what's really equalized, and that really manifests itself when you're summing or averaging components in one of those neighborhoods. Because taller bins have more space between them, and shorter bins have less spacing, you're getting approximately equal height bins when you sum or average. This shows that histogram equalization works as intended.

Hope this helps.