Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Focus Detection using OpenCV

I am trying to identify which parts of a picture are in focus and which are blurred, something like this: Focus Detection

But HOW to do that? Any ideas on how to mesure this? I've read something about finding the high frequencies but how could it produce a picture like those?

Cheers,

like image 580
marcelosalloum Avatar asked Mar 06 '13 23:03

marcelosalloum


1 Answers

Any image will be the sharpest at its optimum focus. Take advantage of that - run the Sobel operator or the Laplace operator, any kind of difference(derivative) filter. Sum the results pixel by pixel, the image with the highest sum is the best focused one.

Edit: There will be additional constraints depending on how much additional information you have, e.g. multiple samples, similarity of objects in the image, etc.

like image 143
Boyko Perfanov Avatar answered Sep 24 '22 15:09

Boyko Perfanov