Abstract
Four clarity evaluation functions are introduced. Their merits and deficits in sensitivity and speed were tested by using four photos with different clarity. Based on the test, a new evaluation function was proposed, which is adopted by Fourier spectrum evaluation function. Test results show that the new function has the better sensitivity on clarity evaluation compared to the Fourier spectrum evaluation function. This new function was applied to the vision measuring machine for clarity evaluation. Gauss curve fitting method is used to get the exact focusing position after acquiring the evaluation value of each position. It’s shown that the new evaluation function has good performance on machine’s auto-focusing action. It’s suitable to be used for the precise focusing situation.
Introduction
Vision measuring system based on microscope has been widely applied to PCB and precise components checking. Vision machine and AOI testing equipment are the typical products in the Chinese domestic market. The calibration template is used to get the correspondence between world coordinates and image coordinates. The calibration coefficient is saved and called out for measurement. Before the workpiece is measured, it should be focused to obtain a clear image. A blurred image has bad influence on image features detection and boundary elements extraction. It would also reduce the measuring accuracy because of the inaccurate calibration.
In order to obtain a clear image, it’s necessary to accurately adjust the distance between the lens and the measuring object for an Image acquisition system. The key point is to determine which image is clear. That the image is clear or blurred represents the energy concentration and diffusion by the energy point of view. While by the frequency domain point of view, it is the increase and decrease of high frequency components. All of these have become the important basis for the design of focus evaluation functions. How to design or select an appropriate evaluation function has become one of the key technologies for image focusing.
Introduction of the clarity evaluation function
With the rapid development of electronics and information technology, the computer’s computing power is increased and the related focus evaluation algorithms are invented. The common focus evaluation algorithms are Brenner function, Robert operator, Tenengrad function, variance evaluation function, vollathF4, vollathF5 and so on, which are based on spatial domain. Chung-Feng and Jeffrey found that the Brenner gradient and threshold pixel counting methods were the optimal methods for acquiring high quality metaphase chromosome images from the bone marrow and blood specimen [1]. It’s also found that VollathF4 is suitable for medical image focusing situation. All of these tradition methods have its’ special applicable environment. The evaluation algorithms based on frequency domain include fast Fourier spectrum analysis, wavelet multi-scale decomposition analysis. Spatial domain algorithms are generally simple and have small calculation [2, 3, 4, 5]. But they are often not sensitive enough especially near the focus position. It is easy to take the near focus position as the exact one. Frequency domain algorithms are relatively complex and have large amount of calculation, but they are more sensitive at the near focus position than spatial domain algorithms [6, 7]. So the frequency domain algorithms are more suitable for the precise focusing situation if not considering time consumption. That the acceleration algorithms and enhanced computer’s computing power shorten the computing time makes it’s possible to be used on real-time industry situations.
A good focus evaluation function should have the following characteristics: (1) unbiased; (2) single peak; (3) high sensitivity; (4) high signal to noise ratio; (5) small calculation. The following parts will describe several evaluation functions applied in the image measuring instrument.
Brenner function
The Brenner gradient function is a simple gradient evaluation function, which simply sums the squares of the difference between two adjacent pixels. The evaluation value could reflect gray-level value changes of the adjacent pixels. The higher value it gets, the better contrast the image has. So a clear image has high value of the Brenner gradient function. So we can use the Brenner gradient function to evaluate the image clarity. The Brenner gradient function of an
The variance evaluation function represents the degree to which the signal deviates from the mean. A clear image has more gray-level difference and signal deviation than a blurred image. So this function can be used as a clarity evaluation function. The variance evaluation function is shown in
Coin surface image with 640 
Eqs (2) and (3), where
Vollath proposed two kinds of functions, VollathF6 and VollathF4, which have a good suppression effect on the image noise. VollathF4 is based on the auto-correlative function. A clear image has weak correlation between each pixel. This method is considered to be a preferred method in the medical image focusing, and its evaluation function is shown in Eq. (4).
Fourier spectrum evaluation function is based on the theory of Fourier transform and its theory. It’s theoretical basis is that a clear image contains more high-frequency components than a blurred one. Frequency domain analysis can be done if an image is transformed by the two-dimensional Fourier transform. The discrete Fourier transform of an image with
That a clear image has more sharp edge means it have more high frequency components than a blurred one. It also means more energy. So energy spectrum can be used to construct a focus evaluation function. It can be defined as follows:
The sum of the energy of an image is used to evaluate an image’s clarity. It is defined as Eq. (8).
Figure 1 includes four 24-bit colour BMP images of coin metal surface with 640
Since the DFT (direct Fourier transform) take up long calculation time, It’s not suitable for engineering applications that require real-time processing. FFT (fast Fourier transform) replaces it in actual application for less time cost. There should be point number
Four images in Fig. 1 were evaluated by the above four methods. Fourier spectrum analysis uses the window with 256
Evaluation results
Clarity evaluations of the focusing an defocusing images with four different methods.
As can be seen from Table 1, evaluation functions based on spatial domain have less time-consuming. The time cost of Brenner function, Power function, VollathF4 function and Fourier spectrum function increases in turn. Obviously, the evaluation value of the clear image is larger than the blurred one.
In order to test the sensitivity of these four functions, more images are acquired in our experiments. We fix the distance between the CCD lens and the coin surface first, and then adjust the focusing distance with a fixed step to capture two sets of images from low clarity to high clarity and from high to low clarity again. Totally the number of the images is 13. All these images are saved in order and evaluated by these four functions. The evaluation values are normalized after the evaluation. Figure 2 shows the curves of these image evaluation values from low clarity to high clarity and from high clarity to low clarity.
From this figure, we can see that the curve of Fourier spectrum function has maximum slope near the focus position without local extreme point. It means that it has high sensitivity and single peak on the near focus evaluation. The curve of variance evaluation function has minimum slope and the small value changes near the focus position. Although the curve of Brenner and variance are sharp, but it’s slope is smaller than the Fourier spectrum function near the focus position.
Spectrum maps (a)–(d) which are gotten by FFT to image (a)–(d).
In a word, the Fourier spectrum function has large time consuming, but it has good sensitivity and single peak especially near the focus position. The time consumption of Fourier spectrum analysis to an image with 640
The spectral information could be obtained by the fast Fourier transform to the image gray-level information. However, the transformed
Filter’s 3-D model.
Spectrum maps (a)–(d), gotten by using improved evaluation function to transform image (a)–(d).
High-pass filter could suppress the low frequency content in an image. It’s suitable to apply a high pass filter to deduce the low frequency influence at near focus position. There is a problem to find the cut-off frequency for the high pass filter function because of the different image content. It’s hard to say which frequency is high. The improved spectral evaluation function is shown as follows:
where
The spectrum radius is used as a high pass filter. The three-dimensional surface shape of it is shown in Fig. 4. It can be seen from the figure, the farther it is away from the centre region, the greater the weight gain. High frequency components get higher gain and low frequency components are opposite. It greatly suppresses the interference caused by the low frequency component and overcomes the shortcomings of other high filters that need to determine the filter radius in advance. When the actual application is processed, the coefficient
Clarity evaluations of the focusing an defocusing images with five different methods.
All images in Fig. 1 are processed by the improved evaluation function and the spectrum images are then obtained. These spectrum images are shown in Fig. 5. It can be seen from the figure that the number of points with large brightness from left to right is increased obviously. More points in Fig. 3 near the image centre are with low brightness compared with Fig. 2. This means the energy of low frequency components is suppressed. Compared with Fig. 5, it can be seen that more high frequency components are strengthened and the contrast are significantly enhanced. So it’s easier to evaluate the image clarity.
We apply the improved clarity evaluation method to compute the clarity values of these images captured before. For comparison, we draw the curve in the Fig. 2 together after the evaluation value is normalized. Figure 6 shows the curves of these image evaluation values. From this figure, we can see that the curve of improved function is sharper than the curve of Fourier function at the near focus position, which would result in the accurate detection of the best focus in the auto focusing steps.
Compared to the traditional methods, the improved clarity evaluation method has the best sensitivity and single peak, which could reduce the negative effect of background noise and increase the focusing accuracy. Compared to the wavelet-based method, which is computation expensive in decomposing the image into different frequency bands and computation of transform [10], the improved method has less time consuming and more simple and applicable in the engineering practice. Different from the LSF method, based on line detection, which is effective only for image with lines and sensitive to noise in edge line detection [11], the improved function can be used in various types of image with enough information of background and target.
In order to further test the effectiveness of the improved evaluation function, it is applied to the automatic vision measuring machine to do the focus evaluation test. The test scenario is shown in Fig. 7. The test equipment is VMC250 of 3D-Family, which is an auto vision measuring machine. It has the optical lens with 0.7–4.5 magnification and color CCD vision system. The lighting system chooses led ring lamp. One Yuan coin is chosen to be the focus target. Image focus window is the 256
Auto focusing test environment.
The machine drives Z axis motor to move at a fixed step. At each position, it stops and does the image acquirement and evaluation. It records position value
Equation (11) is the expression of the Gaussian curve, where the parameters
If both sides of Eq. (11) take natural logarithm, it’ll get Eq. (12) as follows:
If all record points (
The matrix can be expressed as:
If the coefficient matrix
Gauss curve fitting to the acquired point group.
Using a various test samples and different fixed steps to repeat the test, it is found that the focus success rate could arrive 99.96% if having appropriate fixed step. There is a greater focusing failure probability in the choice of a large fixed step, Which is mainly due to the sampling points in the entire collection procedure are too few. So the improved evaluation function has good sensitivity, unbiased and single peak. But if choosing small fixed steps, such as 0.2 mm, the focus time is relatively long. If start focusing at a position with 5 mm distance from the focus point, it took an average of 8.5 seconds to get the right focus position. Considering its focusing performance, in an vision measuring instrument, its practical application is divided into the following two cases: one is to align the lens to the location where contains rich feature information of the workpiece and narrow the focus evaluation window to reduce the computing time; another method is to combine the improved clarity evaluation function with other small computational evaluation function and use rough and precise two-step focusing method [16, 17, 18].
There is a huge demand to high focus precision and high focus speed in modern AOI instruments. It depends on both the design of a good evaluation function and the design of good focus motion control algorithms. How to design a faster, more efficient and accurate evaluation function is one of the key. It is a practical way to improve traditional focus functions or introduce other excellent algorithms according to the focusing characteristics. In this paper, the improved Fourier spectrum evaluation function is very excellent in focusing sensitivity, unbiased and single peak performance. It has been successfully applied in the vision measuring machine. After the practical application test, it’s shown that the evaluation function is suitable for high precision focusing. It could also be applied to other occasions where precise focusing is required.
