Researchers
Passive camera focus measures should increase when the image is maximally focused and reduce when the image gets blurred. Ideally the measure results in a smooth reponse to allow non-greedy focus adjustment.
We present here a novel measure of focus based on estimating the uniformity of the image spectrum. We assume that when a typical image is out of focus its amplitude spectrum is less uniform than when it is focused. To assess this uniformity we made use of the Bayes entropy. The image is transformed to its spectral representation via an 8X8 discrete cosine transform (8X8 DCT).
Here are examples of estimated spectra of a focused and of a defocused image by DCT.
We assume, that the uniformity of the spectrum reflects how much the image is focused. To quantify the level of uniformity we calculate the Bayes-entropy-measure of the nDCT image. To make the measure more robust to noise, the entropy is calculated only over spectral components whose order is lower than some predefined value– i.e., we ignore the high frequencies.
Thus Given a focusing window, the measure of focus is calculated as follows:
- The focusing window is divided into 8 by 8 pixel sub-windows.
- The focus measure (Bayes entropy of a normalized DCT spectrum) is calculated for each sub-window separately.
- The overall focus measure is calculated by taking a mean value over all sub-windows.
Results
Several objects/pictures were placed in front of the visible-light and thermal camera and for each image a sequence of differently focused images was recorded.
The proposed measure was calculated for each image in the sequence. Some results are shown in the figure below.
Note that since the nDCT is contrast invariant, the proposed measure is contrast invariant as well. The measure behaves well even far away from the optimal focus, thus allowing for the use of optimization to find the optimal focus (in contrast to greedy search). Additional tests with noise have shown that the measure performs well even in presence of severe noise and outperforms several well-known measures. For more results and details as well as further discussion, please see the paper.
Online resources
A Matlab implementation of the proposed camera focus measure is available here.