image processing - Is there a way of programatically detecting whether a photograph is in focus? -
image processing - Is there a way of programatically detecting whether a photograph is in focus? -
if building web service used number of photos illustrate service, useful observe whether photos in focus or not.
is there way of doing programatically? (even better, there open source implementation of such routine?)
how know in focus? recognize object, of course, more generally, because has detail. detail, typically, means drastic alter in color on short range of pixels. i'm sure can find lot of border detection algorithms out there via google. without giving much thought:
edgepixelcount = 0; each pixel in image { mixed = pixel.red + pixel.blue + pixel.green; each adjacentpixel in image.adjacentpixels(pixel) { adjacentmixed = adjacentpixel.red + adjacentpixel.blue + adjacentpixel.green; if ( abs ( adjacentmixed - mixed ) > edge_detection_threshold ) { edgepixelcount++; break; } } } if (edgepixelcount > number_of_edge_pixels_threshold) { focused = true; }
note: you'd need utilize "adjacent pixels" distance, not immediate border pixels. in focus, high res images have gradients.
image-processing photos
Comments
Post a Comment