  In this paper we present a non-interactive algorithm to estimate a
representative value for the sky background on CCD images. The method we have
devised uses the mode as a robust estimator of the background brightness in
sub-windows distributed across the input frame. The presence of contaminating
objects is detected through the study of the local intensity distribution
function and the perturbed areas are rejected using a statistical criterion
which was derived from numerical simulations. The technique has been
extensively tested on a large amount of images and it is suitable for fully
automatic processing of large data volumes. The implementation we discuss here
has been optimized for the ESO-FORS1 instrument, but it can be easily
generalized to all CCD imagers with a sufficiently large field of view. The
algorithm has been successfully used for the UBVRI ESO-Paranal night sky
brightness survey (Patat 2003).
