A provably convergent algorithm for shape from shading