Optimal detection and estimation of defocus in natural images