Google Answers Logo
View Question
Q: Autofocus program or algorithm ( No Answer,   3 Comments )
Subject: Autofocus program or algorithm
Category: Computers > Algorithms
Asked by: dgarber1-ga
List Price: $10.00
Posted: 24 Jan 2005 07:54 PST
Expires: 23 Feb 2005 07:54 PST
Question ID: 462450
I work with holography, and we generate a large number of images of
the same object, focused at different distances from the camera. Just
like if you took your camera and manually focused it at many many
different depths and took a picture each time.

My problem is selecting which one of these images has the object most
in-focus. I am looking for a computer program that can select the
in-focus image from a list of images.

I have searched online and found various research papers on different
autofocus methods, but none provide the actual program or a very
complete algorithm. Many are tied to the actual movements of a lens
system, which is not what I want- I am only interested in computer
processing to select the in-foucs image.

If you cannot find a program (although many have been written it seems
few people are willing to share their work!) then I am looking for
links that provide an understandable description of their autofocus

Thank you for your effors, I will reply to any questions posted!

p.s. [not to send you off on a rabit trail, but cameras that use
'passive' autofocus actually use computer processing of the image to
decide if it is in-focus, whereas 'active' autofocus cameras bounce a
signal off the target like radar. I thought I might be able to find
one of these 'passive' autofocus programs online, or at least a
complete description of the method, but no luck so far. The best I
found was here:
There is no answer at this time.

Subject: Re: Autofocus program or algorithm
From: guzzi-ga on 24 Jan 2005 19:44 PST
Do you want to know how passive works? Zooming in and out, it locks
onto the point of maximum high frequency content. This is relatively
easy to implement in software. So for your purpose, run a standard
Fourier analysis on the image.

Subject: Re: Autofocus program or algorithm
From: lalelale-ga on 06 Feb 2005 05:31 PST
A naive but simple and fast method for finding which image is in-focus
in a set of similar images (with equal sizes, and representing roughly
a similar scene), is to JPEG-compress (which identical conmpression
quality) every image and take the one which results in the bigger

I can produce a simple script to do that (in shell environment, using
only open source and well known tools) if you need.

Another method would be calculating the gradient for each image, then
taking the image for which the maximum magnitude of the gradient is
the highest.
Subject: Re: Autofocus program or algorithm
From: dgarber1-ga on 07 Feb 2005 08:25 PST
That is an interesting idea with the jpeg compression... I doubt my
boss would like it very much but it may be worth a try.

Currently we draw a line across the object of interest in the image
and then take the derivative of the intensities along this line. The
in-focus image is the one with the maximum intensity variation. It
works ok, but not well enough on noisy images.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy