We show how the focus longitudinal error z can be deduced from the obs
erved image. This deduction requires some digital image processing. On
ce the focus error z is known, one may compensate for it either by shi
fting the lens or by deblurring the image digitally. We have studied s
ystems with a circular or with a rectangular aperture. In the former c
ase, the defocus causes some dark rings in the frequency spectrum of t
he image. With a rectangular aperture, the defocus creates a set of st
raight, orthogonal dark Lines. These dark zones provide a quantitative
diagnosis of the focus error. Some experimental evidence supports our
concept. (C) 1997 Optical Society of America.