Automatic source detection in astronomical images