image focus calculation

Posted by Oren Mazor on Stack Overflow See other posts from Stack Overflow or by Oren Mazor
Published on 2010-01-25T19:20:49Z Indexed on 2010/03/20 22:01 UTC
Read the original article Hit count: 571

Hi folks,

I'm trying to develop an image focusing algorithm for some test automation work. I've chosen to use AForge.net, since it seems like a nice mature .net friendly system.

Unfortunately, I can't seem to find information on building autofocus algorithms from scratch, so I've given it my best try:

take image. apply sobel edge detection filter, which generates a greyscale edge outline. generate a histogram and save the standard dev. move camera one step closer to subject and take another picture. if the standard dev is smaller than previous one, we're getting more in focus. otherwise, we've past the optimal distance to be taking pictures.

is there a better way?

update: HUGE flaw in this, by the way. as I get past the optimal focus point, my "image in focus" value continues growing. you'd expect a parabolic-ish function looking at distance/focus-value, but in reality you get something that's more logarithmic

© Stack Overflow or respective owner

Related posts about computer-vision

Related posts about c#