Digital method for measuring the focus error.

We show how the focus longitudinal error z can be deduced from the observed image. This deduction requires some digital image processing. Once the focus error z is known, one may compensate for it either by shifting the lens or by deblurring the image digitally. We have studied systems with a circular or with a rectangular aperture. In the former case, the defocus causes some dark rings in the frequency spectrum of the image. With a rectangular aperture, the defocus creates a set of straight, orthogonal dark lines. These dark zones provide a quantitative diagnosis of the focus error. Some experimental evidence supports our concept.