The two views here have been processed with different amounts of gamma correction. Any stretching operation can be quickly visualized by looking at its effect on the histogram. Taking the stretching process to an extreme, we can force the histogram to have any shape we like. The simplest form is called histogram equalization, and it makes the histogram flat, forcing an equal number of pixels into each brightness level. But we can also make the histogram sloped or curved to better display certain aspects of an image.
Histogram equalization produces an equal number of pixels for each level of brightness in the image.
While this helps display the full range of brightness at one time, the image often appears unnatural and unattractive to the eye. This technique is similar to what teachers do when they grade tests on a curve. A few students typically get extremely high or low test scores, while the majority fall in the middle of the distribution, giving the resulting histogram of test scores a distinctive bell-shaped curve. The teacher then assigns the top student on the list 100 percent, the next 99 percent, and so on producing an even distribution of marks. The final mark depends on a student's rank in the class, not on the actual test score.