There is are three popular functions in Adobe® Photoshop® called Auto Contrast, Auto Tone and Auto Color. I have to admit that I haven't done any real research on how the underlying algorithms work, I rather played around a bit with them and here is an idea on how you can achieve similar results:

- Calculate histogram of input image
- Find color values where about 99% of all pixels lie above
- Find another color value where about 99% of all pixels lie below
- Normalize all color values within those two boundaries

The difference between Auto Contrast and Auto Tone are on how this algorithm is applied to multiple channels. If the boundaries are determined globally, that is over all channels, it results in an Auto Contrast behavior, while performing the same task for each color channel independently it results in an Auto Tone behavior.

You can also achieve similar results by using histogram equalization, nevertheless the algorithm described above appears to be closer to the original Photoshop behavior.

An example of my own Auto Tone is shown below.



UPDATE Just noticed that the described approach is also referred to as Min-max linear stretch gray level mapping.