Autofocus

Autofocus is a procedure for finding the correct position of the lens for a scene. The autofocus feature can be provided in a system which includes a movable optical element, a motor, an image sensor and a processing unit. The autofocus procedure is done by changing the lense position and image quality measurements in each position. The position that provides the image with the best quality will be used as the best focus.
The image quality may be estimated using image gradients. To speed-up the autofocus procedure, the autofocus is done in two steps: the first run over the full range of the lenses movement with a significant step will provide the estimated position which will be improved in the second run over the small range with a small step. Interpolation between the few best positions may improve the results accuracy.