The classical approach to depth from defocus uses two
images taken with circular apertures of different sizes. We
show in this paper that the use of a circular aperture
severely restricts the accuracy of depth from defocus. We
derive a criterion for evaluating a pair of apertures with respect
to the precision of depth recovery. This criterion is
optimized using a genetic algorithm and gradient descent
search to arrive at a pair of high resolution apertures. The
two coded apertures are found to complement each other in
the scene frequencies they preserve. This property enables
them to not only recover depth with greater fidelity but also
obtain a high quality all-focused image from the two captured
images. Extensive simulations as well as experiments
on a variety of scenes demonstrate the benefits of using the
coded apertures over conventional circular apertures.