Nonlinear Stretching

When we do a stretch we can do much fancier things than just subtracting and multiplying numbers. A simple method is called "log rescale". All pixels in the image are put through a logarithm function. This may seem like an arbitrary choice, but there are reasons for choosing it. The astronomical magnitude scale is logarithmic so that it can encompass a wide range of brightness. The human eye itself responds to light in a fashion that is close to logarithmic.

What the log rescale function does is stretch different parts of the images differently. This allows you to see the bright details – at lower contrast – while still seeing the faint details. The logarithm function actually changes the shape of the histogram itself.

On many images log rescale is a bit aggressive – the image will look washed out. In some cases we might even want to do the opposite, highlighting bright objects at the expense of faint details.