Figures
Abstract
The use of inexpensive black and white cameras in conjunction with multi-band lighting offers the highest accuracy and cost benefits among the several techniques for accomplishing multispectral images. The focus point shifts with varied wavelength illumination, since the lens optical glass has varying refractive indices for different wavelength light sources. Thus, quick and precise focusing is essential for enhancing system efficiency as a whole. To solve this problem, this study proposes a multispectral quick focusing method. First, analyzes the current methods for evaluating image sharpness and proposes an improved Tenengrad function for the focused scene that could extract gradient information from the image in several directions and improve sharpness evaluation. The improved gradient extraction method combines the Scale Invariant Feature Transformation (SIFT) algorithm to form a new multi-scale image sharpness evaluation function, SIFT Quad-Tenen. To improve the focusing efficiency and optimize the focusing process, a search strategy combining a climbing search algorithm and a traversal method was proposed. Finally, considering the similarity of images between different wavelength bands under multi-light source conditions, the Pearson correlation coefficient is introduced to improve the focusing speed and accuracy. The experimental results demonstrate the superiority of the SIFT Quad-Tenen evaluation function in terms of stability and sensitivity, as well as the significant improvement of the focusing speed and accuracy of the Pearson-Hill climbing algorithm.
Citation: Ma C, Zhang M, Dai Z, Zhang Q, Ma J, Niu X, et al. (2025) Optimizing autofocus under multispectral lighting via enhanced SIFT and Pearson correlation coefficient. PLoS One 20(11): e0336810. https://doi.org/10.1371/journal.pone.0336810
Editor: Muhammad Shahid Farid, University of the Punjab, PAKISTAN
Received: July 3, 2025; Accepted: October 30, 2025; Published: November 17, 2025
Copyright: © 2025 Ma et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Data Availability: All experimental data files are available from the OSF database (accession link: https://osf.io/6a7ft/?view_only=5f07a3f0183a42be90c843a73337bb80).
Funding: National Natural Science Foundation of China (62073124) and Aeronautical Science Foundation of China (Grant No. 20200051042003). This work was supported by the National Natural Science Foundation of China (Grant 62073124; PI: Yongyi Yan) and the Aeronautical Science Foundation of China (Grant 20200051042003; PI: Chao Ma).
Competing interests: The authors have declared that no competing interests exist.
1 Introduction
Spectrum is the collection of monochromatic light arranged in an orderly manner according to the wavelength after being decomposed by a dispersive system (such as a prism or grating). It includes the invisible infrared and ultraviolet rays in addition to the visible light spectrum, which is discernible to the human eye. The measurement of a substance’s spectral reflectance, or its reflection to a particular band of light, provides information about its physicochemical characteristics and has grown in importance as an optical detection method [1–4]. With the advent of multispectral imaging technology in the field of satellite remote sensing since the late sixties of the last century, this technology has steadily extended to agricultural monitoring, food safety, medical imaging, and safety monitoring from the initial remote sensing [5,6]. It has excellent analytical capabilities and is also widely used in computer vision and image processing [7,8]. Multispectral imaging technology has promoted the development of multispectral imaging equipment, which can more effectively collect and analyze spectral data and offer robust support for multispectral technology’s multi-field application [9–12].
Combining the capabilities of target imaging with spectrum acquisition, the multispectral imaging device is a commonly used detection tool [1,13]. It can combine the target’s spectral and spatial information, conduct spectral imaging of the same object in the continuous spectral band, and greatly enhance the information dimension of target observation [8,14]. Depending on how devices work, these devices fall into four major categories: computational multispectral cameras, dispersive, filter, and interferometric cameras [15–17]. To achieve spectrum separation and imaging, dispersive multispectral cameras use a prism or grating as a dispersive component [18]; Filter type multispectral cameras are equipped with a rotatable narrow-band filter wheel in front of a normal camera to selectively capture images in a specific wavelength band [19]; Interferometric multispectral cameras use the interferometric principle to obtain spectral information of targets by measuring the interference patterns at different optical path differences and performing the reverse Fourier transform [20]. Computational multispectral cameras, on the other hand, use advanced algorithms to reconstruct spectral images from the acquired data. As a result of these technological advancements, multispectral imaging devices have become commonplace in both industrial and research [15,21,22]. However, every type of multispectral imaging device has specific characteristics and limitations.
Dispersive multispectral cameras offer high spectral resolution and continuous spectral acquisition, making them suitable for applications requiring fine spectral analysis in the field of multispectral imaging technology [7,23]. However, their systems are large, complex, expensive, and slow to image; sometimes the Signal-to-Noise Ratio (SNR) is decreased due to uneven light intensity distribution [18,24,25]. In contrast, filter-based multispectral cameras are widely favored due to their simple structure, low cost, fast imaging speed, and easy miniaturization [26,27], but their spectral resolution is limited by the choice of filters, and the filter configuration is difficult to change once fixed [28,29]. Interferometric multispectral cameras can provide extremely high spectral resolution, but they are highly complex, require strict maintenance and calibration, and require complex algorithms to reconstruct spectral images [29,30]. Computational multispectral cameras can flexibly adjust spectral channels through software algorithms, and the hardware design tends to be miniaturized and integrated, and the cost-effectiveness increases with the increase of computing power [31]. Therefore, the multispectral imaging system based on Light Emitting Diodes (LED) strobe computational imaging has become an attractive solution.
LEDs are used as the light source in the multispectral imaging system based on LED strobe computational imaging. The target is illuminated by progressively regulating the emission of light from LEDs of various wavelengths. The capability of this camera to accurately regulate the sequence and timing of the LEDs’ opening at each wavelength allows it to image the target sequentially under various light wavelengths. After the images of each wavelength are captured by the camera’s sensor, these images are reconstructed into a multispectral image by a processing algorithm. The main advantages of this approach are its flexible light source control, low cost, and low energy consumption, making it suitable for portable or miniaturized multispectral imaging systems. However, since different wavelengths of light sources can cause changes in the refractive index of the imaging system, affecting the positive focus position of the imaging [32], the imaging system needs to have the ability to autofocus under different wavelength light sources.
An enhanced Tenengrad evaluation function is presented to increase the accuracy of image sharpness evaluation by incorporating multi-directional gradient information extraction, which improves the focusing speed and accuracy of cameras under various wavelength light sources. At the same time, the SIFT algorithm is introduced to improve the anti-interference ability of multi-light source scenes. In terms of search strategy, the improved hill-climbing search algorithm was selected, the focus area was determined by coarse focusing, and then the ergodic method was used to fine-tune the focus in the focus area, and the Pearson correlation coefficient was added to determine the lighting sequence, to further optimize the search strategy. Finally, a multispectral illumination autofocus experimental platform is constructed that can simulate scenes of various band light sources to evaluate and improve the autofocus algorithm’s performance under various band light sources.
2 Related work
2.1 Image sharpness evaluation
In the process of realizing autofocus, the autofocus algorithm needs to rely on the image sharpness evaluation function to determine whether to focus or not. At present, image sharpness evaluation methods are mainly divided into three categories: spatial domain, frequency domain, and deep learning [15]. Frequency domain methods evaluate the sharpness of an image by analyzing its frequency components, and commonly used techniques include the Fourier transform [18] and wavelet transform [19]. However, these methods are rarely used in practical applications due to their high computational complexity and poor real-time performance. Deep learning-based methods for evaluating image sharpness have steadily gained popularity as deep learning has advanced. The deep learning methods train a network model on a dataset and input the image to be detected into the network to obtain an image sharpness value. This method relies on a large number of datasets for training, and it performs well in image feature extraction and model training [20], but its operation is complex, and the real-time performance is poor. The spatial domain evaluation approach analyzes the relationship between image pixels and adjacent pixels to distinguish between clear and blurry images. Common spatial domain evaluation functions include the Roberts function, Brenner function, and Tenengrad function. These methods are simple to calculate and efficient, so they are widely used in practical applications. However, the traditional spatial domain method is sensitive to noise and has poor noise immunity. To improve the noise immunity of these methods, the researchers made several improvements. Zhan et al. evaluated the quality of blurred images by combining maximum gradient and gradient variability with subjective scoring [33]. Li et al. obtained image sharpness values by dividing the gradient image of the image into blocks of equal size and using an orthogonal matrix [34]. Zhang et al. used the Sobel operator to obtain the gradient information in the four directions of the image, and combined it with the Brenner function, proposed an improved autofocus algorithm with the Sobel function [35]. Xiong et al. improved the Brenner function to obtain gradient information in more directions and improve the accuracy of image sharpness evaluation [36].
2.2 Search strategy
In the autofocus algorithm, search strategies are needed to find the positive focal length, and the main search strategies include traversal search, Fibonacci search, curve fitting search, and hill climbing search. The traversal search method determines the optimal focal length by evaluating the sharpness of the image over the entire focal length range. The Fibonacci search method uses the Fibonacci sequence to efficiently narrow the search area [37]. The curve fitting search method predicts the optimal focal length point by fitting the curve of the relationship between image sharpness and focal length. The traversal search method is simple and can ensure the global optimal solution, but it is inefficient. The Fibonacci search method is efficient and predictable, but it may fall into local optima. The curve fitting search method improves the speed and accuracy through model prediction, but requires sufficient data and a suitable model. The hill climbing search method starts from the initial point and gradually moves to the direction of increasing the value of the evaluation function in the neighborhood, and The hill-climbing search method responds quickly and is simple to implement, but it is easily affected by the local optimal solution and the initial point selection. Guo et al. [38] proposed a sharpness evaluation function based on histogram eigenfunction and a hill climbing search algorithm judged by slope change. Wu et al. [39] proposed a partition search algorithm combining adaptive step size and a two-step search method to improve the anti-interference ability of the algorithm. Jia et al. [40] divided the improved hill climbing search algorithm into coarse focusing methods based on small focus areas and fine focusing methods based on function approximation to improve focusing accuracy.
3 Proposed optimization algorithm
3.1 SIFT Quad-Tenen evaluation function
The traditional Tenengrad function uses the Sobel operator to extract the horizontal and vertical gradients of an image. Although the traditional Tenengrad function is widely used in image sharpness evaluation, it mainly extracts the horizontal and vertical gradient information of the image and ignores the gradient in other directions. This limitation may result in the Tenengrad function not providing an accurate assessment of sharpness when evaluating images with complex textures or oblique features [16]. To solve this problem, as shown in Fig 1, the algorithm proposed in this study improves the Tenengrad function and adds gradient information extraction ± 45° direction. This improvement allows the algorithm to obtain gradient information from multiple directions, to more accurately evaluate the sharpness value of the image. The improved function uses the Sobel operator template in four directions, corresponding to 0°, 45°, 90°, and 135° directions, respectively, to achieve comprehensive capture of image gradient information. The improved function uses the Sobel operator template in four directions, which are expressed as Eq 1:
S1 and S2 are the Sobel operator templates in the horizontal and vertical directions, and S3 and S4 are the Sobel operator templates in the ±45° direction. Although the improved Tenengrad adopts the strategy of extracting gradient information in 4 directions, the improved function considers 8 adjacent pixels of (x,y) pixels. The improved expression for extracting the multidirectional gradient information for the Tenengrad function (Quad-Tenengrad function) is Eq 2:
where I1(x,y), I2(x,y), I3(x,y), and I4(x,y) are Eq 3:
When extracting gradient information in four directions, the Quad-Tenengrad function may introduce additional noise information. To suppress these noises, a weight allocation strategy based on image texture structure information was proposed. When calculating the image sharpness value, the algorithm will adjust the weight according to the richness of texture structure information in different areas of the image. Areas of the image that are rich in texture structure information will be given higher weight, while areas lacking texture information will be given lower weight. This method can not only suppress the extraction of noise information but also enhance the algorithm’s ability to recognize effective texture information of the image, to improve the anti-noise performance of the algorithm.
Scale-invariant feature transform (SIFT) is a feature extraction technology widely used in the field of image processing, which can extract feature points that are invariant to rotation, scale scaling and brightness changes, and has good robustness to noise. The SIFT algorithm is applied to the local area of the image to improve the performance of the Quad-Tenengrad function, and the weight of the feature points is assigned accordingly. The key steps of the SIFT algorithm are as follows:
(1) Scale-space construction: The Gaussian difference pyramid is used to generate a scale space, which involves applying Gaussian filters of different scales to the original image to obtain a series of images that are gradually blurred. The mathematical expression is Eq 4:
where L represents the scale space function, f is the input image, G is the Gaussian function, σ is the scale coordinate, and its function form is Eq 5:
Through the further processing of the Gaussian pyramid, the Difference of Gaussian is established, and the scale space is established. The function form is as Eq 6:
(2) Feature point detection: In the scale space, by comparing the target pixel with the pixel in the neighborhood, the extreme point is identified as the key point. According to the distribution characteristics of pixels in the vicinity of the key points in the gradient direction, the gradient method is used to ensure that the filtered feature points have rotation invariance when rotating. The pixel (x,y) direction and amplitude are represented by m(x,y), , Eqs 7 and 8.
where L(x,y) is the scale space where pixel (x,y) is located.
(3) Generate descriptors: After determining the orientation of the key, the gradient information of the pixels around the key is used to generate the feature descriptor. The feature description mainly includes the following steps: determining the neighborhood region of the key point, dividing the neighborhood region into several subregions, calculating the gradient direction histogram for each subregion, connecting the gradient direction histograms of all subregions to form a feature vector, and the feature descriptor obtained by the SIFT algorithm is a 128-dimensional vector. Weights are assigned according to the number of feature points in each image, and the formula for calculating weight a is as Eq 9:
where Ni is the number of feature points of the ith image, and is the number of feature points of the whole image. Then the formula for the SIFT Quad-Tenen function is Eq 10.
As shown in Fig 2, SIFT Quad-Tenen function is an image sharpness evaluation method that combines SIFT feature point detection and Quad-Tenengrad multi-directional gradient information extraction. This function has significant anti-interference characteristics during autofocus, especially in scenes where different light sources are switched.
3.2 Pearson hill climbing algorithm
The hill climbing search algorithm is widely used in the search strategy of camera focus, but it has some limitations in the focus search process, especially in terms of speed. The hill climbing algorithm may need to be iterated several times to gradually approach the optimal solution, and the focusing speed does not meet the background requirements. Therefore, the hill climbing algorithm was changed to a coarse-fine hill climbing algorithm by combining the characteristics of the traversal method.
The process of the algorithm is as shown in Fig 3.
(1) Starting from the starting position, the search was started with the large step size L, and the images of the starting position, step length L and 2L were evaluated respectively, and the sharpness values were F, Fm, and Fe.
(2) Compared with F, Fm and Fe, when Fs <Fm<Fe proves that the search direction is correct, the new Fs is assigned Fm and the new Fm Fe, and the next step L image is searched to obtain the new evaluation value and assigned to Fe.
(3) Compare the new F, Fm, and Fe, and continue to step 2 if Fs < Fm < Fe. If Fs < Fm and Fe<Fm, step 4 is performed on the interval from the focal length of Fs to the area where Fm is located Ls, Lm.
(4) For the interval Ls, Lm, the traversal method is used to obtain the maximum image sharpness value, and the focal length where the maximum value is located is the positive focal position.
(5) The remaining light source scenes are centered on the focal length of the previous scene, and the focus is completed by traversing and searching Fmax in small steps L’ on the left and right sides of the focal length position.
The improved hill climbing algorithm improves the focusing speed, but the positive focus position of different light source scenes cannot be guaranteed to be within the step size L’, and the Pearson correlation coefficient is introduced to optimize the coarse-fine hill climbing algorithm to ensure the focusing accuracy. Pearson correlation coefficient let the two sets of data be X and Y, and calculate the mean values and
of X and Y, respectively, then the covariance can be expressed as Eq 11:
where Xi and Yi are each value of X and Y, respectively, and n is the amount of data. Calculate the standard deviations and
of X and Y and the Pearson correlation coefficient (denoted as r), respectively, expressed as Eq 12:
The Pearson correlation coefficient is a statistic that measures the degree of linear correlation between two continuous variables. Its value ranges from -1 to 1, where a value close to 1 indicates a strong positive correlation. Values close to -1 indicate a strong negative correlation. Values close to 0 indicate no or weak linear correlation. Thus, the modified Pearson hill climbing algorithm of the camera focus search strategy in the multi-light scene is:
(1) The initial position and the images acquired in different lighting scenes every 5 steps were evaluated, and the order of lighting when the camera was focused was determined according to the Pearson correlation coefficient of the obtained data.
(2) Under the first light source, the search was started with a large step size L, and the starting position, step size L, and 2L images were evaluated, and the sharpness values were F, Fm, and Fe.
(3) Compare the new F, Fm, and Fe, and continue to step 2 if Fs<Fm<Fe. If Fs < Fm and Fe<Fm, step 4 is performed on the range from the focal length of Fs to the interval of Fm (Ls, Lm).
(4) The maximum image sharpness value is obtained by the traversal method for the interval Ls, Lm, and the focal length of the maximum value is F1 at the positive focal point.
(5) Under the second light source, the traversal search is carried out in small steps L’ on the left and right sides of the focal length F1, and the maximum image sharpness value is obtained after comparison, that is, the positive focus position F2.
(6) Perform step 3 to obtain the focal length of the remaining light sources in turn according to the order of the acquired lighting, and complete the camera autofocus in the multi-light source scene.
The optimization algorithm combined with the Pearson correlation coefficient is shown in Fig 4.
4 Experimental results and analysis
The experimental system is shown in Fig 5, including an industrial computer, an 8-zone controllable LED light source, a high-definition industrial camera, and a lens controller for zoom. The imaging system employed a Teledyne LT665RM industrial camera with a Sony ICX694 sensor. A Canon EF 50mm f/1.8 STM lens was used for image acquisition. Lens focusing was controlled via a motorized lens controller manufactured by Innovative Scientific Solutions, Inc. (ISSI). The image resolution used in the experiments is 1600 * 1200 pixels. The entire focusing range of the Canon EF50mm f/1.8 STM lens was discretized into a scale of 0–3000. Considering the use of the Pearson correlation coefficient, the focusing strategy for the first spectral band differed from that of the subsequent bands. For the first band, a variable step-size approach was applied across the entire focusing range (0–3000), starting with a coarse step of 100, which was progressively reduced with a decay factor of 0.5, ultimately reaching a step size of 1 to ensure optimal precision. From the second spectral band onward, due to the correlation with the preceding band and the narrower defocusing range, fine focusing with a fixed step size of 1 was directly employed. The analysis of the experimental data was performed on the computer controlling the multispectral device, and SIFT was implemented in the Python OpenCV environment with default parameters.
To provide a quantitative reference for comparison with the focusing results, the spatial resolution and the optical transfer function (OTF) of the lens under accurate focus were analyzed. The results are presented in Fig 6, where the spatial resolution and modulation transfer function (MTF) curves demonstrate the intrinsic imaging performance of the lens, thereby serving as a baseline for evaluating the proposed focusing method. To verify the advantages of the SIFT Quad-Tenen image sharpness evaluation function in terms of stability and sensitivity, this study compares several common image sharpness evaluation functions through experiments. The selected comparison objects include SMD function, Roberts function, Brenner function and EOG function. In addition, the experiment also includes the traditional Tenengrad function and the improved Quad-Tenengrad function for extracting four-directional gradient information.
In the experimental system, the lens was controlled to focus under six different light sources: purple, white, yellow, red, green, and blue, the wavelength ranges of all colors are shown in Table 1. Each set of experiments collected an image sequence from defocus to focus and then back to defocus to comprehensively evaluate the performance of each evaluation function at different focal lengths. The experimental comparisons were all performed on an industrial computer, as shown in Fig 7.
Due to the different dimensions of the image sharpness values evaluated by different definition evaluation functions, to compare the experiments, the maximum value of the image sharpness values of each function is normalized, and the expression is as Eq 13:
Among them, Fi is the sharpness value of the i-th image, and and
is the maximum and minimum sharpness value evaluated by the evaluation function for each group of images. The higher the sharpness ratio, the stronger the evaluation function’s ability to distinguish between in-focus images and out-of-focus images.
Experimental comparison requires objective indicators to evaluate different functions. This experiment selected the sharpness ratio R, sensitivity MSE, steepness S, and whether the maximum image sharpness value is correctly evaluated [12]. The formula for the sharpness ratio R is Eq 14:
The sensitivity MSE formula is Eq 15:
represents the sharpness value of the image at point
. A greater sensitivity parameter MSE indicates that the evaluation function is more sensitive in the vicinity of the optimal focus position, allowing for a clearer assessment of the sharpness values near the optimal focus position. The formula for steepness S is as Eq 16:
SR denotes the right steepness, and SL indicates the left steepness. The higher the steepness, the more it indicates that the evaluation function has good sharpness and resolution capability for defocused images near the positive focal position.
By selecting scenes with purple, white, blue, green, yellow, and red light sources to experiment with the improved evaluation function, the following are the evaluation function curves and objective assessments for the six types of light sources, where α indicates whether the maximum image sharpness value is correctly assessed.
By analyzing the performance of the image sharpness evaluation function in different light source scenes, it can be observed that the improved SIFT Quad-Tenen evaluation function is compared with the SMD, Roberts, Brenner, EOG function, Tenengrad function, and Quad-Tenengrad function. Significant performance is shown in multiple light scenes as shown in Table 2 and Fig 8. We have selected six lighting scenarios with a wavelength range of 395nm - 630nm, corresponding to lighting colors of purple, white, blue, green, yellow, and red. The specific data show that, at the purple light scenario, the sharpness ratio R shows an improvement of 149.9% compared to the Tenengrad function and 36% over Quad-Tenengrad. The sensitivity MSE is enhanced by 209.6% relative to the Tenengrad function and 85% compared to Quad-Tenengrad. Additionally, the steepness S demonstrates a 185.7% increase over the Tenengrad function and a 53.8% improvement compared to Quad-Tenengrad. And the SIFT Quad-Tenen exhibits superior performance across all metrics compared to both the Tenengrad function and Quad-Tenengrad.
At the white light scenario, the improved evaluation function outperforms the SMD, Roberts, Brenner, and EOG methods in both sharpness ratio and sensitivity. Specifically, its sharpness ratio R is 148.3% higher than the Tenengrad function and 22.5% higher than the Quad-Tenengrad variant. Its sensitivity is 161.7% higher than Tenengrad and 43.4% higher than Quad-Tenengrad. And its steepness S is 143.8% higher than Tenengrad and 40% higher than Quad-Tenengrad. Images acquired at focus and in the near-focus region at a wavelength of white contain more information in both horizontal and vertical directions, but the inclusion of noise leads the EOG function to misidentify the optimal plane. By contrast, the SIFT Quad-Tenen function not only makes correct focus decisions but also preserves outstanding performance in sharpness ratio, sensitivity, and steepness. At the yellow light scenario, the improved evaluation function outperforms the SMD, Roberts, Brenner, and EOG methods in both sharpness ratio and sensitivity. Specifically, compared to the standard Tenengrad function, it increases the sharpness ratio by 122.2%, sensitivity by 147.8%, and steepness by 192.9%; and relative to the Quad-Tenengrad variant, it raises the sharpness ratio by 16.4%, sensitivity by 147.8%, and steepness by 23.9%.
In the red light scenario, the SIFT Quad-Tenen function achieves a 101.1% improvement in sharpness ratio, a 252.8% increase in sensitivity, and a 250% gain in steepness compared to the Tenengrad function. In the green light scene, the corresponding improvements are 121.1%, 252.8%, and 250%, respectively, while in the blue light scene, the SIFT Quad-Tenen function is increased by 148.3% in the sharpness ratio, 161.7% in sensitivity, and 143.8% in steepness. These results demonstrate the superior performance of the SIFT Quad-Tenen function in image sharpness evaluation and reflect its wide applicability under different light source conditions. In addition, through the analysis of the image sharpness curve, it is found that the number of local extrema generated by the SIFT Quad-Tenen function is significantly less than that of other evaluation functions. This means that the SIFT Quad-Tenen function is less susceptible to noise interference during autofocus, reducing the likelihood of false positives. The Brenner and EOG functions mainly extract the information in the horizontal and vertical directions of the image and perform the sum of squares. Still, in the blue light source scene, the images taken by the positive focus and its nearby focal lengths contain a lot of noisy information, which makes the EOG function prone to errors in judging the maximum definition. In contrast, the SIFT Quad-Tenen function can not only maintain a high resolution ratio, sensitivity, and steepness performance while ensuring correct judgment.
The experiments under six light source scenes show that the images collected under different light sources contain different information, and the image sharpness value and focal length change. It can be seen from Table 2 that the SIFT Quad-Tenen evaluation function has good sensitivity under different light sources compared with other evaluation functions, and can accurately find the image with the maximum sharpness value in each scene. The SIFT Quad-Tenen evaluation function has better adaptability and robustness under different light source scenes.
The autofocus search strategy experiment was carried out in the camera’s multi-light scene. The SIFT Quad-Tenen image sharpness evaluation function was used to evaluate the sharpness of the acquired images. The search strategy was used to search for the optimal focal length position. In the improved hill climbing search algorithm, the Pearson correlation coefficient is obtained by evaluating the initial position and the images collected in different light scenes every 5 steps, and the Pearson correlation coefficient is shown in Fig 9.
By analyzing the Pearson correlation coefficient, it was found that the red light source had the greatest correlation with the white light source. Further observation of the correlation coefficients between red and white light sources and other light sources shows that the correlation between white and yellow light sources is the largest. Based on these findings, this study determined the order in which the camera was focused: red first, white second, and so on. Therefore, the improved search strategy is :
In the initial position and every 5 steps of the search process, the images under different lighting scenes were collected and evaluated, and the lighting sequence of the camera when focusing was determined according to the Pearson correlation coefficient. The order of determination is: red, white, yellow, green, blue, purple. Under the red light source, the improved hill-climbing algorithm is used to search for the positive focus position F-red. Under the blue light source, a traversal search of small steps is carried out with F-red as the center to obtain the maximum image sharpness value, that is, the positive focus position F-white. Focus search for other light sources: Perform step 3 to obtain F-yellow, F-green, F-blue, and F-purple according to the order of the obtained lighting, and complete the camera autofocus in a multi-light source scene.
The experiment was divided into three indicators, namely the focus search step of all light scenes, the focus time, and whether all light source scenes were correctly focused. The experiments were carried out by the traversal method, the hill climbing search algorithm, the coarse-fine hill search algorithm, and the Pearson hill search algorithm after adding the Pearson coefficient, in which the hill climbing search algorithm and the coarse-fine hill search algorithm were experimented with random light source sequences. The initial focal length of the experiment was randomly 0, 5, 8, and 11. As shown in Fig 10, the traditional traversal method leads to too long focusing time due to the comprehensiveness of its search strategy in a multi-light scene.
Although the traditional hill-climbing search algorithm has reduced the focus time, it still does not achieve the expected efficiency. In contrast, the improved coarse-fine hill search algorithm and the Pearson hill search algorithm with the Pearson coefficient significantly reduce the focus time and show better performance. Although the preliminarily improved coarse hill search algorithm is improved considerably compared with the traditional hill climbing search algorithm in terms of focus time, it still has limitations in dealing with large focal length gaps in different light source scenes. When the focal lengths of two light sources differ significantly and they are focused sequentially in the order in which they are lit, one of the light sources may fail to focus. To solve this problem, the Pearson climbing search algorithm is introduced, which uses the Pearson correlation coefficient to guide the search process by considering the correlation between different light sources. This method not only optimizes the focusing speed but also improves the accuracy of focusing, ensuring that the camera can quickly and accurately complete focusing in multi-light source scenes. The experimental results have verified the superiority of the Pearson hill climbing search algorithm in terms of focusing speed and accuracy in multi-light source scenes. By combining the image sharpness evaluation function with an improved search strategy, this study provides an effective solution for the application of autofocus technology under different light sources.
5 Conclusion
This study proposes a new image sharpness evaluation function, SIFT Quad-Tenen function, to address the problem of camera autofocus in multi-light source scenes in multispectral imaging systems, to improve the ability to accurately evaluate captured images under multi-light source conditions. This function introduces the extraction of multi-directional image information based on the traditional Tenengrad function, enhancing the accuracy of evaluation. At the same time, considering the characteristics of the SIFT algorithm in terms of illumination invariance, it integrates it into the evaluation function, which effectively overcomes the influence of different light sources. To further improve the focusing speed and accuracy, the hill climbing algorithm was improved, and the Pearson hill climbing algorithm was proposed. While maintaining the advantages of fast coarse focusing of the hill climbing algorithm, the algorithm introduces the Pearson correlation coefficient to realize the fine adjustment of the focusing process according to the characteristics of multi-light source scenes, to ensure the accuracy of camera focusing. Through experiments, we verified the cooperation between the SIFT Quad-Tenen image sharpness evaluation function and the Pearson Hill climbing algorithm, and successfully solved the problem of accurate measurement and fast focusing in the multispectral imaging system. This result not only improves the efficiency of the focus but also ensures the quality of focus in complex lighting environments. In summary, this study provides an effective solution to the problem of autofocus of a multispectral imaging system under different light sources. Through the improved image sharpness evaluation function and the optimized search algorithm, the method in this paper improves the focusing speed and ensures the accuracy of focusing while improving the autofocus under different light sources.
References
- 1. Su W-H, Sun D-W. Multispectral imaging for plant food quality analysis and visualization. Compr Rev Food Sci Food Saf. 2018;17(1):220–39. pmid:33350065
- 2. Tian X, Li K, Zhang W, Wang Z, Ma J. Interpretable model-driven deep network for hyperspectral, multispectral, and panchromatic image fusion. IEEE Trans Neural Netw Learn Syst. 2024;35(10):14382–95. pmid:37256810
- 3. Zhang M, Ma C, Ma J, Yuan Y, Huang J, Yan Y. Vis/NIR spectroscopy and machine learning model for counterfeit citri reticulatae pericarpium identification. Journal of Food Composition and Analysis. 2025;148:108240.
- 4. Hu K, Chen Z, Kang H, Tang Y. 3D vision technologies for a self-developed structural external crack damage recognition robot. Automation in Construction. 2024;159:105262.
- 5. Song H, Mehdi SR, Wan Q, Li Z, Li M, Wang M, et al. Compact staring-type underwater spectral imaging system utilizing k-Nearest neighbor-based interpolation for spectral reconstruction. Optics & Laser Technology. 2025;181:111880.
- 6. He Q, Zhan J, Liu X, Dong C, Tian D, Fu Q. Multispectral polarimetric bidirectional reflectance research of plant canopy. Optics and Lasers in Engineering. 2025;184:108688.
- 7. Blekanov I, Molin A, Zhang D, Mitrofanov E, Mitrofanova O, Li Y. Monitoring of grain crops nitrogen status from uav multispectral images coupled with deep learning approaches. Computers and Electronics in Agriculture. 2023;212:108047.
- 8. Ma F, Yuan M, Kozak I. Multispectral imaging: review of current applications. Survey of Ophthalmology. 2023;68(5):889–904.
- 9. Grbović Å1/2, Ivošević B, Budjen M, Waqar R, Pajević N, Ljubičić N, et al. Integrating UAV multispectral imaging and proximal sensing for high-precision cereal crop monitoring. PLoS One. 2025;20(5):e0322712. pmid:40402923
- 10. Lu L, Zhang X, Xu X, Shang D. Multispectral image fusion for illumination-invariant palmprint recognition. PLoS One. 2017;12(5):e0178432. pmid:28558064
- 11. Long J, Zhan Y, Pang Z, Zhou T, Li X, Lan L, et al. Joint spatial–spectral optimization for the high-magnification fusion of hyperspectral and multispectral images. IEEE Trans Geosci Remote Sensing. 2024;62:1–19.
- 12. Hu F, Zhou M, Yan P, Liang Z, Li M. A Bayesian optimal convolutional neural network approach for classification of coal and gangue with multispectral imaging. Optics and Lasers in Engineering. 2022;156:107081.
- 13. Sun Z, Hu D, Zhou T, Sun X, Xie L, Ying Y. Development of a multispectral spatial-frequency domain imaging system for property and quality assessment of fruits and vegetables. Computers and Electronics in Agriculture. 2023;214:108251.
- 14. Qin J, Chao K, Kim MS, Lu R, Burks TF. Hyperspectral and multispectral imaging for evaluating food safety and quality. Journal of Food Engineering. 2013;118(2):157–71.
- 15. Banu KS, Lerma M, Ahmed SU, Gardea-Torresdey JL. Hyperspectral microscopy- applications of hyperspectral imaging techniques in different fields of science: a review of recent advances. Applied Spectroscopy Reviews. 2023;59(7):935–58.
- 16. Yang R, Ren L, Ma F, Liang J, Wei H, Zhou Y. A super-resolution reconstruction method for pixelated multispectral images from division-of-focal-plane sensors. Optics and Lasers in Engineering. 2025;188:108926.
- 17. Xu R, Li C, Paterson AH. Multispectral imaging and unmanned aerial systems for cotton plant phenotyping. PLoS One. 2019;14(2):e0205083. pmid:30811435
- 18. Arad O, Cheplanov L, Afgin Y, Reshef L, Brikman R, Elatrash S, et al. Low-cost dispersive hyperspectral sampling scanner for agricultural imaging spectrometry. IEEE Sensors J. 2023;23(16):18292–303.
- 19. Huang F, Cao R, Lin P, Zhou B, Wu X. High-efficiency multispectral-polarization imaging system using polarization camera array with notch filters. IEEE Trans Instrum Meas. 2023;72:1–13.
- 20. Logofătu PC, Damian V. Snapshot interferometric multispectral imaging using deconvolution and colorimetric fit. Optics & Laser Technology. 2019;111:100–9.
- 21. Marbach S, Montgomery P, Flury M. Microsphere-assisted multispectral microscopy. Optics and Lasers in Engineering. 2024;180:108299.
- 22. Chen S, Zhang M, Li X, Li X, Liu W, Ji B. Precision agriculture intelligent connection network based on visual navigation. IET Networks. 2022;12(4):167–78.
- 23.
Lockwood RB, Chrisp MP, Parameswaran L, Thome KJ, Babu SR. Remote sensing using VNIR/SWIR dispersive imaging spectrometers: historical development, current state-of-the-art and future trends. In: IGARSS 2018 - 2018 IEEE International Geoscience and Remote Sensing Symposium. 2018. p. 6332–5.
- 24. Wang H, Zhang G, Cao H, Hu K, Wang Q, Deng Y, et al. Geometry-aware 3D point cloud learning for precise cutting-point detection in unstructured field environments. Journal of Field Robotics. 2025;42(7):3063–76.
- 25.
Zhao Y, Hu X, Guo H, Ma Z, Yue T, Cao X. Spectral reconstruction from dispersive blur: a novel light efficient spectral imager. In: 2019. 12194–203.
- 26. Zhang W, Suo J, Dong K, Li L, Yuan X, Pei C, et al. Handheld snapshot multi-spectral camera at tens-of-megapixel resolution. Nat Commun. 2023;14(1):5043. pmid:37598234
- 27. Logavitool G, Horanont T, Thapa A, Intarat K, Wuttiwong K-O. Field-scale detection of Bacterial Leaf Blight in rice based on UAV multispectral imaging and deep learning frameworks. PLoS One. 2025;20(1):e0314535. pmid:39823436
- 28. Xu Y, Lu L, Saragadam V, Kelly KF. A compressive hyperspectral video imaging system using a single-pixel detector. Nat Commun. 2024;15(1):1456. pmid:38368402
- 29. Li W, Wang X, Hong Y, Zeng X, Mu J, Zuo Y, et al. Single-frame measurement of the complete spatiotemporal field of ultrafast laser pulses using Carrier Frequency-Division Multiplexing Spectral Interferometry. Optics & Laser Technology. 2023;158:108786.
- 30.
Picone D, Jouni M, Mura MD. A study on combining a multi-aperture interferometric imaging spectrometer with a multispectral camera. In: IGARSS 2024 - 2024 IEEE International Geoscience and Remote Sensing Symposium; 2024. p. 7662–6.
- 31. Cao X, Yue T, Lin X, Lin S, Yuan X, Dai Q, et al. Computational snapshot multispectral cameras: toward dynamic capture of the spectral world. IEEE Signal Process Mag. 2016;33(5):95–108.
- 32. Wang Y, Kootstra G, Yang Z, Khan HA. UAV multispectral remote sensing for agriculture: a comparative study of radiometric correction methods under varying illumination conditions. Biosystems Engineering. 2024;248:240–54.
- 33. Zhan Y, Zhang R. No-reference image sharpness assessment based on maximum gradient and variability of gradients. IEEE Trans Multimedia. 2018;20(7):1796–808.
- 34. Li L, Lin W, Wang X, Yang G, Bahrami K, Kot AC. No-reference image blur assessment based on discrete orthogonal moments. IEEE Trans Cybern. 2016;46(1):39–50. pmid:25647763
- 35. Zhang F, Li S, Hu Z, Du Z, Meng X. An improved auto-focus evaluating algorithm based on sobel gradient function. Optical Technique. 2017;43(3):234–8.
- 36. Xiong R, Gu N, Xu H. An auto-focusing evaluation function adapted to multi-directional gray gradient change. Laser & Optoelectronics Progress. 2022;59(4):0418001.
- 37. Fu Y, Hao X, Jia R, Yin W, Yu X, Feng X, et al. Three-axis magnetic field compensation for SERF atomic magnetometers based on dispersion curve characteristics. IEEE Sensors J. 2025;25(11):19040–51.
- 38. Guo C, Ma Z, Guo X, Li W, Qi X, Zhao Q. Fast auto-focusing search algorithm for a high-speed and high-resolution camera based on the image histogram feature function. Appl Opt. 2018;57(34):F44–9. pmid:30645278
- 39. Wu H, Sun Y, Yu Q, Wang Q, Yu H, Lu Y. Research on fast auto-focusing strategy based on partition search algorithm. Optical Technique. 2023;49(2):245–9.
- 40. Jia D, Zhang C, Wu N, Zhou J, Guo Z. Autofocus algorithm using optimized Laplace evaluation function and enhanced mountain climbing search algorithm. Multimed Tools Appl. 2022;81(7):10299–311.