Autofocus is an interesting problem in itself, so evaluating sharpness from arbitrary images is another level of difficulty.
For sharpening, I suggest this article from Cornell. Their conclusion was that the variance metric provided the best estimate for a given image. And it doesn’t hurt that it is really easy to calculate!
To create a consistent metric on different images, you need a normalization method. The metric can be in units of variance per pixel. You could take advantage of the fact that a lack of focus provides an upper bound for dispersion, so look for clustering at the maximum rate of local dispersion.
Eliot gillum
source share