Find Sharpest Files

Find the sharpest files in a batch

Thanks for Andrea Nivini (info at andreanivini d0t it) for suggesting this module.

There are a number of situations where a photographer or engineer may want to capture a sequence of similar images, then compare them to see which is sharpest— or to rank the sharpness.

  • You might have a sequence of images taken at different apertures, ISO speed settings, (software) noise reduction settings, etc., and you want quickly rank them from sharpest and softest, without performing a detailed MTF analysis.
  • You may want to check autofocus performance and/or consistency by comparing a batch of images acquired with autofocus with each other or with manually-focused images (made at small focus increments around the autofocus setting).
  • You may have taken a sequence of images under slightly different conditions, e.g., images of a flower taken when there is a slight breeze— and you want to quickly determine which is sharpest.

The Imatest Find Sharp Files module lets you do this quickly and conveniently on any image— it doesn’t have to be a test chart. Here is an example showing three images of the SFRplus test chart from a sequence of six.

Results from an SFRplus image.
Canon EOS-40D, 17-85mm lens @ 26mm f/4.5-f/22
Sharpest image: f/8 Sharpest
Fifth sharpest: f/5.6 Fifth sharpest
Fuzziest image: f/22:
Evidently shaken during the
long (4 second) exposure.
Vertical edges are OK, but Horizontal
edges will give misleading results.
Worst image (shaken)

Sharpness ranking:
The result of running
Find Sharp Files


Algorithm: Find Sharpest Files ranks sharpness based the standard deviation of the absolute value of the gradient of the selected region, normalized to the mean pixel level of the region.


Start by acquiring a sequence of images. As described above, it could be a set of test chart images taken with different settings or a set of natural scenes where you wish to find the one least blurred by the wind. If needs be, run the sequence through View/Rename Files to give them a sensible name, instead of the IMG_7201.jpg,
IMG_7202.jpg, IMG_7203.jpg etc. The images should be of the same subject with the same framing and similar lighting.

Find Sharp Files shoud never be used for comparing different images. Results will be misleading!

Open Find Sharp Files by clicking on the button in the right of the Imatest main window.

Find Sharp Files opening window
Find Sharp Files opening window

Click on 1. Select files to select a group of files using standard Windows techniques. The folder below contains both CR2 and JPEG images. *.jpg was entered in the File name window at the bottom, then Enter was pressed. This displays only the JPEG (.jpg) files, which makes batch selection easier. You can click on a file and then either control-click on another file (to add that file) or shift-click (to add a range of files). The yellow tooltip that appears when you hover the cursor above an image thumbnail shows the full file name, date, and size.

file selection
File selection

After files have been selected, the upper box will be populated and the lower (results) box will be empty. Now update the settings if needed (they’re not critical).

  • Gamma is used to linearize the (crops of) files before the Sharpness ranking is calculated. It has little effect on the results when images are exposed the same, but it may improve the accuracy when there are different exposures. Gamma is measured by several Imatest modules. 0.5 is the default, typical of many digital cameras.
  • Channel: Choose Y (luminance), R, G, and B. Individual channels tend to have better Sharpness numbers than the Y (0.3*R + 0.59*G + 0.11*B) channel because of chromatic aberration.
  • Ranking: Determines which gradient is used for ranking. Choose Whole gradient for all directions (this is the default), Horizontal (Vertical edges), or Vertical (Horizontal edges). All three are selected and displayed.

Click on 2. Scan for Sharpness, then crop the image. If the pixel size is the same as the previous run, you’ll be asked if you want to repeat the same regions. Otherwise you’ll be asked to select a crop, using the same dialog boxes as other Imatest modules.

Crop selection criteria In most instances (if you’re measuring image sharpness) the crop should include lines and edges: features that reveal image sharpness. The rare exception is when you’re measuring the effects of (software) noise reduction, where smooth or finely textured crops may be appropriate. Crop size strongly affects speed. We recommend crop sizes under 1MB.After the crop has been selected, the analysis is performed, and the large box below 2. Scan for Sharpness is populated. Small crops of these images were shown in the Introduction, above. The Sharpness numbers are different because the crop is slightly different.

Find Sharp Files results
Find Sharp Files results (sorted by Rank)

The sharpness gradient numbers are NOT standard measurements; they are for comparing relative sharpness only. They are strongly dependent on image features and region selection, and should not be saved or used for any purpose beyond simple sharpness comparisons within a single batch of images.

Viewing image details

Once the Sharpness scan is complete you can view the entire image, the selected crop, or the EXIF data by clicking on a file name in either of the large boxes, then clicking on the View image, View image crop, or View all EXIF data buttons at the bottom. (Phil Harvey’s EXIF tools must be installed to view all EXIF data.)

View image results

View image

View image crop results

View image crop

These images are shown here reduced. They can be enlarged and zoomed in.

Example from MTF Curves and Image appearance

The images in MTF curves and Image appearance provide an ideal example of how Find Sharp Files can be used— for general images as well as images of test charts. This page contains ten images each of a portion of the SFRplus test chart and an art gallery. Starting from a reference image (typical of a good quality image from a DSLR cameras), the chart and gallery images were subjected to identical processing: sharpening, blurring (similar to what a poor lens or misfocus would do), and combinations of the two (blurring + the sort of sharpening you might apply to compensate for the blurring). The results for the gallery image are shown below. More details can be found in MTF curves and Image appearance.

gallery image results
Gallery image results, showing ranking

gallery image, showing crop
Gallery image, showing crop (in red)