The problem of 3-D shape recovery from image focus can be described as the problem of determining the shape of the focused image surface (FIS)—the surface formed by the best focused points. The shape from focus (SFF) methods in the literature are fast but inaccurate because of the piecewise constant approximation of FIS. The SFF method based on FIS has shown better results by exhaustive search of FIS shape using a planar surface approximation at the cost of a considerably higher number of computations. We present a method to search FIS shape as an optimization problem, i.e., maximization of focus measure in the 3-D image volume. Each image frame in the image volume (sequence) is divided into subimage frames, and the whole image volume is divided into a number of subimage volumes. A rough depth map at only the central pixel of each subimage frame is determined using one of the traditional SFF methods. A few image frames around the image frame, whose image number in the image volume is obtained from the rough depth at the central pixel of subimage frame, are selected for the subimage volumes. The search of FIS shape is now performed in the subimage volumes using a dynamic programming optimization technique. The final depth map is obtained by collecting the depth map of the subimage volumes. The new algorithm considerably decreases the computational complexity by searching FIS shape in subimage volumes and shows better results.