The Importance of Focus in Hyperspectral Imaging
Hyperspectral imaging (HSI) is a powerful technology that captures information across hundreds of narrow spectral bands, far beyond what is visible to the human eye. From precision agriculture to mineral exploration, environmental monitoring, and industrial inspection, hyperspectral cameras provide critical data that drives insights and decision-making.
But one important factor that is often overlooked is Focus, and it can make or break your results.
What is Focus?
In imaging, focus refers to the sharpness and clarity of the image. The focal point is the specific point where light originating from an object converges after passing through a lens. Focus is achieved when this convergence occurs exactly on the image sensor plane. If the light converges in front of or behind the sensor, the image will appear out of focus.
- If the image is in focus, it will appear sharp and clear with dramatic contrast between the dark and white areas.
- If the image is out of focus, it appears blurry with less contrast and more gradual transitions between light and dark areas.
Why Focus Matters in Hyperspectral Imaging
In hyperspectral imaging, proper focus is especially important to ensure both spatial accuracy and spectral accuracy. If the system is not properly focused, the quality of the spectral data and the reliability of the analysis can be significantly impacted.
Preserves Spatial Detail: When a hyperspectral camera is properly focused, the edges and features of the target appear sharper with more contrast. This is important so that you can more easily and accurately detect and analyze specific features in your image, such as small defects, contaminants or material differences. If the system is out of focus, these critical features can appear blurred and are less likely to be accurately detected.
Maintains Spectral Integrity: In hyperspectral imaging, each pixel of the sensor collects the full spectral information across the wavelength range of the camera. When the camera is out of focus, the light can spread across neighboring pixels on the sensor. This can lead to mixed spectral signatures, reduced measurement reliability and lower confidence in detection and classification models. It can also reduce the signal to noise ratio due to reduced peak signal intensity per pixel, making it harder to detect weaker spectral absorption features in material identification.
As an example, consider this bluebird, imaged with a 25 pixel x 25 pixel sensor. When the image is sharply focused, you can clearly differentiate small features such as the eye, beak, and whites of the feathers. However, when the image is out of focus, those same details become less defined at the pixel level.
The same is true for hyperspectral data. If you are looking to detect or evaluate small features on your target, such as a foreign objects in food production, delicate structures of a plant, or small mineral fragments in a core sample, an out-of-focus camera will result in essential spatial and spectral data being blended together and can make detection and analysis more difficult.
How to Focus Your Hyperspectral Camera
A hyperspectral camera can be focused in one of two ways:
- Adjusting the focus position of the lens.
- Changing the working distance of the camera.
Adjusting the focus ring is typically the easiest way to adjust the focus, as it doesn't require movement of the camera or change to the imaging setup. Rotating the focus ring will move the internal optics of the lens, changing the position of where the light converges relative to the sensor. This can be achieved by manually adjusting the focus on the lens itself or through an internal motorized focus feature.
Adjusting the working distance, or the distance between the target and the object, requires physically moving the camera closer to or farther away from the target which in turn, changes where light converges relative to the sensor.
Focus targets are specialized tools that can be used to test and optimize focus of your hyperspectral camera. A target with clearly defined black and white edges is ideal to ensure sharp focus.
When focusing a spectrograph-based pushbroom hyperspectral camera, such as those built by Specim, a Ronchi Rulings focus target is recommended. It consists of a series of equally spaced black and white lines and provides the high contrast the camera needs to achieve sharp focus. It can be placed directly under the camera, with lines oriented perpendicular to the spatial axis, to cover the entire field of view. Imaging it's high frequency pattern typically reveals even very small focus errors immediately.
When using a focusing target, the primary goal is to observe clear definition between the black and white bars. When the camera is positioned directly above the focus target, observe the spatial plot from the camera using your data acquisition and camera control software.
The camera has achieved maximum focus when the spatial plot resembles a square wave pattern rather than a sine wave pattern. In addition, when the camera is properly focused, the contrast observed between the white and black pixels will be near 100%, and when the camera is out of focus it will be lower.
Other Variables That Impact Focus
- Minimum Focus Distance: The minimum focus distance is the smallest possible distance between the camera lens and the target in which the system (with current objective lens) can sharply focus on an object. The minimum focus distance is dependent on the lens and is a specification provided by the lens manufacturer. If the target is closer than the lens's minimum focus distance, the lens cannot achieve sharp focus and the final image will be blurred.
- Depth of Field (DoF): Depth of field is the range of distances from the camera over which objects appear in focus. It is defined as the distance between the nearest and farthest points in the scene that appear sharp, and is primarily determined by the aperture (f-number) and focal length of the lens.
A shallow depth of field (lower f-number, longer focal length) results in only a small portion of the scene around the focus position appearing sharp, while objects outside this region appear blurred. In contrast, a deep depth of field (higher f-number, shorter focal length) allows a larger portion of the scene in front of and behind the focus point to remain in focus.
Achieving proper focus is relatively straightforward when imaging a flat target, since there is a single, consistent distance at which the entire surface can be brought into optimal focus. When imaging a target with variations in height or depth across the field of view, it can become more difficult to achieve focus across the scene, particularly if those variations extend beyond the system’s depth of field.
Depth of field must be considered carefully when selecting an objective lens to prevent spectral mixing due to spatial blur. In hyperspectral imaging, the acceptable range is often much narrower for depth of field than for RGB imaging, because subtle spectral differences must be preserved.
For Specim cameras, the easiest way to determine the depth of field for your camera system is to use their Field of View calculator.
When is Focus NOT Critical in Hyperspectral Imaging?
Properly focusing a hyperspectral camera is always recommended when collecting data. However, there are situations where perfect focus is less critical to the final results.
Sharp focus becomes less important when imaging homogeneous materials where the goal is simply to identify or classify the material rather than analyze fine spatial features. In these cases, the spectral information from most of the sample remains relatively consistent even if the image is slightly out of focus. One good example of this is using hyperspectral imaging to classify different types of plastics in recycling applications.
This figure illustrates the effect of focus on the reflectance spectra collected from a plastic sample. The top images show the regions where the spectra were extracted. The orange curve represents the spectrum from the in-focus image, while the green, violet and blue curves represent spectra collected from the out-of-focus image.
As you can see, the orange and green spectra appear nearly identical indicating that the spectral signal within the interior of the sample remains largely unaffected by the focus. However, the violet and blue spectra, which were taken closer to the edges of the plastic sample, show a deviation. This is due to the spatial blur occurring, which leads to spectral mixing between the sample and background.
This effect becomes more apparent when the spectra are used for material classification. The figure to the left compares the results of a classification model applied to the same plastic sample under both in-focus and out-of-focus conditions.
In these classification maps, colours represent the different materials identified by the model:
- Violet: HDPE (the actual material being imaged)
- Green: LDPE
- Orange: PP
Both images show some misclassification near the edges of the plastic sample, with the errors more significantly pronounced in the out-of-focus image. This occurs because spectral blending at the sample boundaries is causing the model to incorrectly interpret the mixed spectra as a different materials.
Importantly, this misclassification primarily affects only the edge regions. The majority of the sample remains correctly classified, demonstrating that focus is less critical when analyzing large, homogeneous materials where edge accuracy is not essential.
Hyperspectral Remote Sensing: Outdoor and airborne imaging applications are more complex than controlled lab-based or industrial setups. While the same fundamental principles of focus apply, these applications typically prioritize spectral resolution and material identification over fine spatial detail. Since the sensors are operating at much larger working distances and capturing broad scenes, resolving very small features at the pixel level is often not the primary objective.
Conclusion
In hyperspectral imaging, focus is not just a technical detail, it’s an important factor that can affect the accuracy and reliability of both spatial and spectral data.
Properly focused images preserve fine details, maintain spectral integrity, and ensure accurate detection and classification, especially when analyzing complex or heterogeneous targets. While focus may be less critical for homogeneous materials, taking the time to achieve sharp focus can dramatically improve the quality of your results and the confidence in your analyses.
To maximize the performance of your hyperspectral system, invest in proper focusing techniques, use high-contrast targets like Ronchi Rulings for pushbroom cameras, and select the proper lens for your application.
Looking for more ways to optimize your hyperspectral imaging results? Find valuable tools, guides and resources in our Support section!