histogram stretch Algorithm

In more general fields of data processing, such as digital signal processing, it is referred to as dynamic range expansion. Often, the motivation is to achieve consistency in dynamic range for a set of data, signals, or pictures to avoid mental distraction or fatigue.

histogram stretch source code, pseudocode and analysis