This paper restates the shape from shading problem regarding both surface modeling and optimization. We combine the use of a B-spline as 3D model for the scene surface and the use of stochastic optimization, through simulated annealing. The proposed method overcomes successfully the main difficulties usually encountered in shape from shading. Experiments are presented on both synthetic and real images.