Segmentation and estimation of spatially varying illumination