image processing - Is there a way of programatically detecting whether a photograph is in focus? -


If I was building a web service that uses many photos to clarify the service, in fact It would be useful to find out if the photos are in focus or not.

Is there any way to do this program? (Even better, is there an open source implementation of this type of routine?)

How do you do it Do you know in focus? You definitely recognize the object, but more commonly, because it is expanding in detail, usually, massive changes in color at a short distance of pixels means I'm sure you can find out many edge algorithms through Google. Without a lot of thought:

  edgePixelCount = 0; For each pixel in the image {mixed = pixel.red + pixel.blue + pixel.green; For each adjacent pixel for image.adjacentPixels (pixel) {approximated = adjacent pixel. Red + adjacent pixel.wl + adjacent pixel green; If (stomach (mixed mixed-mixed)> EDGE_DETECTION_THRESHOLD) {edgePixelCount ++; break; }}} If (asexeccelacount & gt; NUMBER_OF_EDGE_PIXELS_THRESHOLD) {focus = true; }  

Note: You probably have to use "adjacent pixels" with some distance, not just the instant edge pixels, even in focus, high resolution images often include gradients Are there.


Comments