Sharpness measurement in thermal spectrum


Ing. Jiří Mekyska, prof. Ing. Zdeněk Smékal, CSc.


It is possible to download software here.

Publication to be cited

FAÚNDEZ ZANUY, M.; MEKYSKA, J.; ESPINOSA-DURÓ, V. On the focusing of thermal images. PATTERN RECOGNITION LETTERS, 2011, vol. 32, no. 11, pp. 1548-1557. ISSN: 0167-8655.


This toolbox contains functions that can be used for the measurement of sharpness coefficient which is calculated from the image in thermal spectrum. According to these coefficients it is possible to get the sharpness curve which is useful for the evaluation of the amount of blur contained in the image.

Focus measure based on these functions should satisfy these requirements:

  1. It should be independent of image content. However, if the image contains a large amount of thin details, it is easier to focus.
  2. Monotonic with respect to blur. If we move away from the optimal focus position, the focus measure should decrease monotonically. Typically this will happen when moving the focus in both directions (left and right).
  3. The focus measure must be unimodal, that is, it must have one and only one maximum value. While this is simple for “flat” scenes, this cannot be true for scenes with objects at different focal distances. For instance, if the nearer object if focused, the most distant will be blurred and vice versa. However, computational photography methods let to combine multi-focus images.
  4. Large variation in value with respect to the degree of blurring. This will permit a sharp peak (maximum focus value).
  5. Minimal computation complexity. For real time image acquisition the feedback about the focus measure should be obtained as quickly as possible.
  6. Robust to noise: In presence of noise the maximum focus value should be stable and unique. In this aspect is important to emphasize that near infrared and visible images are sensible to illumination conditions. If illumination is not good enough, the image would be noisy. However, thermal cameras are not affected by illumination because they acquire the heat emission, not the illumination reflection.

According to these requirements we have implemented in toolbox these functions:


This is a very simple measure. Blurred images have smaller variance than focused one.

Energy of image gradient

The energy of image gradient is based on the vertical and horizontal gradients of the image.


This measure is based on the gradient magnitude from the Sobel operator.

Energy of Laplacian

Sum-modified Laplaciens

It has been noted that in the case of the Laplacian the second derivatives in the x- and y-directions can have opposite signs and tend to cancel each other. Therefore, there was proposed the sum modified Laplacian.

Spatial Frequency

The spatial frequency is a modified version of the energy of image gradient.

All functions in this toolbox are written in MATLAB. To see how to use them please type “help function_name”. Toolbox contains also an example script demonstrating the use of functions.