I am calibrating the focus on my 35mm film scanner, to do this I am rescanning the same photo repeatedly with different focus configurations and comparing the results to choose the configuration which produced the most in focus scan.

However, it occurred to me that software could probably determine the most in focus of the scans better than I could. Is there any software which can tell me which scan is the most in focus?


2 Answers 2


There are many ways to accomplish this task ranging from the tried-and-true xTF to new and novel deep learning techniques. Here is a simple and accessible way to evaluate focus. This technique is best used when imaging mono-planar content-rich subjects. Scanned negatives definitely meet the former criteria and I recommend setting focus with a negative frame which matches the latter criteria.

Here is how to do it. First setup.

  • Download and install ImageJ. Note that IJ is a standaone executable (unzip and run) but it does require Java. You have the choice of downloading just the platform independent or packaged with your OS' Java. Note that if you use windows and UAC is enabled, it is best to put IJ's folder elsewhere than the "programs" folders. Also note that in most cases ImageJ will not be added to your start menu; you will need to find and double click the .exe file.
  • Download and install the Find Focused Slices plugin. Install instructions are on the linked page. You could also download and extract the file then choose Plugins>>Install.
  • Make sure all of your images are the same size. This is easier in software with built in batch processing than it is in ImageJ

The process to find the best focus:

  1. Launch ImageJ
  2. Open all images to compare (and only images to compare) by dragging them into ImageJ
  3. Once all images are open go to Image>>Stacks>>Images to Stack
  4. With all images now in one stack go to Plugins>>Find focused slices
  5. Check the box for "Edge filter?" and click OK

Check the list (highest number is best) or the selected slice to see the indicated best focus.

If you do not get a clear indication of the best focused image, try one of the following:

  • Disable Edge Filter
  • Add a Variance Threshold
  • adjust (or disable) the maximum variance
  • Try the Stack Focuser plugin instead

As I said there are many different ways to perform this task. IJ is an excellent platform to experiment where you could try Difference of Gaussians or MTF

  • 1
    \$\begingroup\$ I would be inclined to say that this is a duplicate only of the former question. The latter is looking for a cure-all whereas this proposes a specific technical problem. I would argue that this answer is still meritorious since it provides a way to solve the problem using open source, extensible software. \$\endgroup\$ Commented Feb 14, 2018 at 2:48

An easy way to quickly get an estimate of the relative sharpness of different images of the same scene/scanned object is to save the images as JPG.

Since JPG is a lossy format, image will compress better if they have less details (less high frequency information), therefore, the largest file will be the sharpest, all else being equal.

Quickly flipping through the images in a viewer at 100% will also reveal any subtle differences, our eyes are really sensitive to changes. (a technique astronomers used to use to find moving objects in the sky)


Not the answer you're looking for? Browse other questions tagged or ask your own question.