  This paper present the mathematical fundaments and experimental study of an
algorithm used to find the optimal position for the camera lens to obtain a
maximum of details. This information can be further applied to a appropriate
system to automatically correct this position. The algorithm is based on the
evaluation of a so called resolution function who calculates the maximum of
gradient in a certain zone of the image. The paper also presents alternative
forms of the function, results of measurements and set up a set of practical
rules for the right application of the algorithm.
