Automatic focusing method based on variable step distance traversal

文档序号:405106 发布日期:2021-12-17 浏览:30次 中文

阅读说明:本技术 基于变步距遍历的自动聚焦方法 (Automatic focusing method based on variable step distance traversal ) 是由 左超 张晓磊 孙佳嵩 胡岩 沈德同 尹维 于 2021-07-26 设计创作,主要内容包括:发明提出了一种基于变步距遍历的自动聚焦方法,先以大步距在给定的搜索区间中执行迭代搜索并计算聚焦评价函数,找到该轮聚焦中聚焦评估函数的极值点并以该点位置确定下轮遍历搜索区间;再以较小步距进行下一轮遍历,直到步距小于阈值聚焦结束。这种方法兼具大步距遍历的快速和小步距遍历的精确,且有效避免了各自的弊端。(The invention provides an automatic focusing method based on variable step-pitch traversal, which comprises the steps of executing iterative search in a given search interval by large step pitch, calculating a focusing evaluation function, finding an extreme point of the focusing evaluation function in the round of focusing, and determining a next round of traversal search interval according to the point position; and performing the next round of traversal by a smaller step pitch until the step pitch is smaller than the threshold value and focusing is finished. The method has the advantages of high speed of large-step traversal and high accuracy of small-step traversal, and effectively avoids respective defects.)

1. An automatic focusing method based on variable step distance traversal is characterized by comprising the following steps:

step 1, determining an initial traversal step distance;

step 2, taking the movement range of the electric control displacement table of the microscope objective as an initial search domain, performing equal-distance traversal by using a larger initially determined step pitch in a first round of traversal, and calculating a focusing evaluation function of each point;

step 3, comparing the focus evaluation functions of all the traversal positions to obtain the position of the focus evaluation function with the maximum value;

step 4, taking the interval of the positive and negative intervals of the point as a next round of search domain, performing next round of traversal by small step pitch, and calculating the focus evaluation function of each point;

and 5, repeating the steps 3-4 until the step distance is smaller than the threshold value of the step distance when the focusing is stopped, and finishing the focusing.

2. The variable-step traversal-based auto-focusing method according to claim 1, wherein the principle of determining the initial traversal step in step 1 is as follows: the initial traversal step distance is adopted to avoid skipping a focus face, and the initial traversal step distance is smaller than the width of the maximum value peak of the focus evaluation function curve.

3. The variable-step-distance traversal-based autofocus method of claim 1 or 2, wherein step 1 is specifically:

(1) firstly, traversing the whole motor motion range by a minimum step pitch to obtain an accurate focusing evaluation function curve graph;

(2) the width of the portion of the maximum peak above the curve mean is chosen as the initial traversal step, which must be smaller than the width of the maximum peak.

4. The variable-step-distance traversal-based automatic focusing method according to claim 1, wherein the method for calculating the focusing evaluation function in the step 2 is as follows:

the average gray value of the image processed by the Sobel gradient operator is used as a focusing evaluation function, and the calculation formula is as follows: v mean (Sobel (f (x, y))).

5. The variable-step traversal-based auto-focusing method according to claim 1, wherein the method for determining the next smaller traversal step in step 4 is as follows:

and taking 1/N of the previous round of traversal step distance from the next round of smaller traversal step distance, wherein N is a positive integer between 5 and 10.

6. The variable-step-pitch traversal-based auto-focusing method as claimed in claim 1, wherein the threshold in step 5 is determined based on motor accuracy, and the threshold is set to a distance on the same order of magnitude as the motor accuracy.

Technical Field

The invention belongs to the technical field of computational optical microscopy imaging, and particularly relates to an automatic focusing method based on variable step distance traversal.

Background

The optical microscope has high precision and good stability and is widely applied to the field of biomedicine. When a sample is observed and detected, if the focusing of the optical microscope is carried out only by hand, errors are easy to bring, and the automation degree of the optical microscope is low, so that the optical microscope does not meet the requirements of modern development. Therefore, through the automatic control of the optical microscope, the full automation of the focusing process can not only improve the speed of the experiment and the analysis, but also reduce the influence of human errors on the microscopic imaging quality, and the use is more convenient.

Manual focusing often requires observing whether an image is clear or not and whether an edge is sharp or not through human eyes, and this subjective determination method cannot be used for objective focusing determination, and an imaging system cannot determine whether an image is focused or not. In order to realize the automatic focusing of the imaging system, it becomes a primary task to enable the imaging system or the image processing terminal to have the capability of judging whether the image is focused or not. Effective information extracted from images at different focusing and defocusing positions has great difference, and the image focusing can be judged according to the difference. The judgment of the focusing evaluation function on the focusing directly influences the speed and the accuracy of an automatic focusing algorithm, so that the focusing evaluation function plays a crucial role in the focusing process. For decades, focusing criteria obtained by processing and calculating the acquired images have been proposed by researchers and scholars, and the focusing criteria for different aspects have been developed. Using the sharpness of the image as a criterion, an autofocus function of performing a search according to the sharpness can be realized.

As can be seen from the manual focusing process of the microscope, the image can be blurred due to defocusing, and the detailed part of the image becomes more and more obvious along with the focusing process. Therefore, the function of the automatic focusing search algorithm is to control the motor to move in the stroke of the microscope objective lens, and the automatic focusing search algorithm is combined with an image definition evaluation algorithm to find the optimal focusing plane. The microscope focusing process requires extremely high precision, so that the focusing step distance needs to be optimally selected, if the moving step distance is too large, the focusing surface of an image is directly skipped, so that how to make focusing impossible is caused, and although the probability of searching the focusing surface is increased, the reduction of the step distance causes more total steps to be searched, and the time is consumed. The automatic focusing search mode mainly comprises a distance measurement method, an image processing method and a focusing detection method, wherein the distance measurement method can be subdivided into three methods, namely a triangular distance measurement method, an ultrasonic distance measurement method and an infrared distance measurement method. The phase difference detection method and the contrast detection method in the contrast distance measurement method and the focus detection method do not need additional measuring equipment, and the automatic focusing based on image processing is more adaptive, so that the method becomes a research hotspot in the focusing field.

In an automatic focusing algorithm based on image processing, a traversal search method is simple and easy to understand and high in anti-interference capability, but the method has a large calculation amount because image focusing evaluation is carried out on images layer by layer, and the moving interval distance can be obtained only by a large amount of experiments. Therefore, this method is not necessarily practical in practical use, and needs to be improved to be practical.

Disclosure of Invention

The invention aims to provide an automatic focusing method based on variable-step-pitch traversal, which has the advantages of rapidness in large-step-pitch traversal and accuracy in small-step-pitch traversal and effectively avoids respective defects.

The technical scheme of the invention is as follows: an automatic focusing method based on variable step distance traversal comprises the following steps:

step 1, determining an initial traversal step distance;

step 2, taking the movement range of the electric control displacement table of the microscope objective as an initial search domain, performing equal-distance traversal by using a larger initially determined step pitch in a first round of traversal, and calculating a focusing evaluation function of each point;

step 3, comparing the focus evaluation functions of all the traversal positions to obtain the position of the focus evaluation function with the maximum value;

step 4, taking the interval of the positive and negative intervals of the point as a next round of search domain, performing next round of traversal by small step pitch, and calculating the focus evaluation function of each point;

and 5, repeating the steps 3-4 until the step distance is smaller than the threshold value of the step distance when the focusing is stopped, and finishing the focusing.

Preferably, the principle of determining the initial traversal step distance in step 1 is as follows: the initial traversal step distance is adopted to avoid skipping a focus face, and the initial traversal step distance is smaller than the width of the maximum value peak of the focus evaluation function curve.

Preferably, step 1 specifically comprises:

(1) firstly, traversing the whole motor motion range by a minimum step pitch to obtain an accurate focusing evaluation function curve graph;

(2) the width of the portion of the maximum peak above the curve mean is chosen as the initial traversal step, which must be smaller than the width of the maximum peak.

Preferably, the method for calculating the focus evaluation function in step 2 is as follows:

the average gray value of the image processed by the Sobel gradient operator is used as a focusing evaluation function, and the calculation formula is as follows: v mean (Sobel (f (x, y))).

Preferably, the method for determining the next smaller traversal step in step 4 is as follows:

and taking 1/N of the previous round of traversal step distance from the next round of smaller traversal step distance, wherein N is a positive integer between 5 and 10.

Preferably, the threshold in step 5 is determined based on the motor accuracy, and the threshold is set to a distance on the same order of magnitude as the motor accuracy.

Compared with the prior art, the invention has the following remarkable advantages: (1) the variable-step traversal has the advantages that the large-step traversal is rapid, the small-step traversal is accurate, and the defects that the large-step skipping of an extreme point and the small-step calculation are time-consuming are effectively overcome; (2) the automatic focusing algorithm based on image processing does not depend on additional measuring equipment, has a simple structure, and is concise and clear in principle and calculation, and rapid and accurate automatic focusing can be realized.

Drawings

FIG. 1 is a schematic flow chart of the present invention.

Fig. 2 is a diagram illustrating an ideal focus merit function.

Fig. 3 is a schematic diagram of determining an initial traversal stride.

FIG. 4 is a schematic diagram of a variable step-pitch traversal algorithm flow of the present invention.

FIG. 5 is a diagram illustrating the focusing effect of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

The overall flow of the present embodiment is shown in fig. 1, wherein the flow of the variable-pitch traversal algorithm is shown in fig. 4. The specific method is as follows.

Step 1, determining an initial traversal step distance, as shown in fig. 2 and fig. 3. The principle of determining the initial traversal step of the first round is that the focus plane should not be skipped with this step. Therefore, the traversal step distance should be smaller than the width of the maximum peak of the focus evaluation function curve, so as to ensure that the traversal process includes the area near the maximum value.

The specific method is as follows:

(1) firstly, traversing the whole motor motion range by a minimum step pitch to obtain an accurate focusing evaluation function curve graph;

(2) at this time, the width of the part of the maximum peak higher than the curve mean value is selected as the initial traversal step pitch, the step pitch is certainly smaller than the width of the maximum peak, the equidistant traversal is carried out by the larger step pitch, and the focusing evaluation function of each point is calculated, namely the average gray value of the image processed by the Sobel gradient operator:

V=mean(Sobel(f(x,y)))。

the ideal focusing evaluation function curve has good unimodal performance, sensitivity and robustness, and can better meet the requirements of high universality and small calculated amount.

It is noted that although the process of determining the initial traversal step has already performed a fine, time-consuming traversal, only this initial step needs to be determined. In the case of a small difference in sample thickness, the subsequent auto-focusing process can follow the initial step in this step.

And 2, taking the motion range of the electric control displacement table of the microscope objective as an initial search domain, performing equal-distance traversal by using a larger initially determined step pitch in the first round of traversal, and calculating a focusing evaluation function of each point.

And 3, comparing the focus evaluation functions of all the traversal positions to obtain the position of the focus evaluation function with the maximum value.

And 4, taking the interval of the positive and negative intervals of the point as a next round of search domain, and determining the step pitch of the next round of traversal. For simplicity of calculation, 1/N (N is a positive integer) of the step distance of the previous round of traversal is usually taken as the step distance of the current round of traversal. The larger N is, the smaller the traversal step distance of the wheel is, the more accurate the focusing position is determined, but the calculation amount is increased; the smaller N is, the larger the traversal step distance of the round is, the faster the traversal is, but the larger the step distance is, the result of the subsequent round is wrong because the focus plane is skipped. Therefore, the result accuracy is taken as the principle, and a larger N value is adopted, and generally 5-10 can be selected. That is to say that the first and second electrodes,

and performing next round of traversal by the small step pitch, and calculating a focusing evaluation function of each point.

And 5, repeating the steps 3-4 until the step distance is smaller than the threshold value, and finishing focusing. The main basis for determining the threshold is the motor accuracy, and the threshold can be strictly set to a distance on the same order of magnitude as the motor accuracy. But may be increased as appropriate.

The above embodiment is an automatic focusing method based on variable-pitch traversal, which includes a focus evaluation method based on image processing and a search algorithm of variable-pitch traversal.

The focusing evaluation method based on image processing does not depend on additional measuring equipment, and is simple in structure, and concise and clear in principle and calculation; the variable-step-pitch traversal search algorithm has the advantages of high speed of large-step-pitch traversal and accuracy of small-step-pitch traversal, and effectively avoids the defects that the large-step-pitch skips over an extreme point and the small-step-pitch calculation is time-consuming. The invention is an effective improvement of the automatic focusing algorithm based on traversal search, greatly improves the focusing speed, ensures the focusing precision and leads the focusing process to be more automatic and efficient.

The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:产生周期连续可调激光阵列线源的光学系统及其调节方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!