First of all, this is the result of imhist(f) execution before equalization
Execute g = histeq(f,256) % balance operation
It can be seen that the originally narrow distribution has become very wide.
Here are a few pictures for better understanding
Matrix before operation
Matrix after operation
That is to say, for example, an image with a very narrow distribution (the gray scale is concentrated in a range), but the proportion of each gray scale is indeed different .
We have the transformation formula new gray value = probability of old gray level * 255 (here the number of gray levels is set to 255)
For example, the transformation with the original gray value of 50 is 0.25*255 = 63.75
And because the probability is continuous, but the degree of continuity of the probability is not as dense as the grayscale in the previous image, for example, there are 4 stages in the picture, and the
The difference is still relatively large, so it can achieve the purpose of discretization (the series difference between gray levels becomes larger)
There is no strict mathematical derivation in this article, and it is all about simplifying the understanding process. If there are any mistakes, please correct me.