Auto-focus estimation?
Images in focus have sharper edges, so applying an edge detector and measuring the energy of the output puts you on the right track.

A simple technique is to compute the sum of the laplacian over the images, possibly center-weighted if you deal with everyday photographs (people tend to put the object of interest in the center, so it's better to have the center in focus than the borders)

This criterion is for example what is used in many "Stack focusing" applications for macro photography.

There are other approaches used in de-hazing or tone-mapping... Search for "Local contrast measures".