In some cases contrast stretching or histogram equalization may not work so well. One example is when you have a slowly varying background that takes up a large range of pixel values and a detailed object with a very small range of pixel values. The object will almost blend into the background. However, contrast stretching won't be very effective because the background is already "stretched". The solution is to remove the background and contrast stretch the detailed object. I did this by using an averaging filter. The idea is that the background is low frequency and is ignored by the filter, while the high frequency object is essentially removed. Then I simply subtract the remaining background from the original image. Now I have just the object. Simply contrast stretch it. Here is a very good example where the detail is hidden in the background.
Trend Removal Algorithm