The conventional shape from focus (SFF) methods have inaccuracies because o
f piecewise constant approximation of the focused image surface (FIS). We p
ropose a more accurate scheme for SFF based on representation of three-dime
nsional FIS in terms of neural network weights. The neural networks are tra
ined to learn the shape of the FIS that maximizes the focus measure.