code request – Shape-from-shading algorithms?

Before I go to the effort of writing my own code, I was wondering if there is code available for shape-from-shading algorithms. These take an image (such as a black-and-white image, such as this) and infer the three-dimensional depth map based on the lightness at a point and constraints such as smoothness of the inferred surface, or properties of the light source (e.g., a point source from a known direction).