We introduce a novel algorithm for local contrast enhancement. The algorithm exploits a background image which is estimated with an edge-preserving filter. The background image controls a gain which enhances important details hidden in underexposed regions of the input image. Our designs for the gain, edge-preserving filter and chrominance recovery avoid artifacts and ensure the superior image quality of our results, as extensively validated by user evaluations. Unlike previous local contrast methods, ours is fully automatic in the sense that it can be directly applied to any input image with no parameter adjustment. This is because we exploit a trainable decision mechanism which classifies images as benefiting from enhancement or otherwise. Finally, a novel windowed TRC mechanism based on monotonic regression ensures that the algorithm takes only 0.3 s to process a 10 MPix image on a 3GHz Pentium.