CN110324536B - Image change automatic sensing focusing method for microscope camera - Google Patents

Image change automatic sensing focusing method for microscope camera Download PDF

Info

Publication number
CN110324536B
CN110324536B CN201910764039.3A CN201910764039A CN110324536B CN 110324536 B CN110324536 B CN 110324536B CN 201910764039 A CN201910764039 A CN 201910764039A CN 110324536 B CN110324536 B CN 110324536B
Authority
CN
China
Prior art keywords
focusing
value
scene
image
evaluation function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910764039.3A
Other languages
Chinese (zh)
Other versions
CN110324536A (en
Inventor
余飞鸿
夏浩盛
周海洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Touptek Photoelectric Technology Co ltd
Original Assignee
Hangzhou Touptek Photoelectric Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Touptek Photoelectric Technology Co ltd filed Critical Hangzhou Touptek Photoelectric Technology Co ltd
Priority to CN201910764039.3A priority Critical patent/CN110324536B/en
Publication of CN110324536A publication Critical patent/CN110324536A/en
Application granted granted Critical
Publication of CN110324536B publication Critical patent/CN110324536B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/673Focus control based on electronic image sensor signals based on contrast or high frequency components of image signals, e.g. hill climbing method

Abstract

The invention discloses an image change automatic perception focusing method for a microscope camera, which comprises the following steps: defining a plurality of scene states according to the change states of the image brightness and the image evaluation function value; monitoring the real-time change condition of the image brightness and the image evaluation function value of the current scene, determining the scene state of the current scene according to the real-time change condition of the image brightness and the image evaluation function value, and adopting a focusing monitoring strategy corresponding to the scene state according to the scene state, wherein the focusing monitoring strategy comprises the following steps: entering a single focusing process when the image brightness and/or the image evaluation function value is stable; and executing a single focusing process based on the hill climbing searching method to determine the optimal focusing position. The image change automatic perception focusing method can automatically adopt different focusing strategies according to different focusing scenes so as to improve the focusing accuracy.

Description

Image change automatic sensing focusing method for microscope camera
Technical Field
The invention belongs to the technical field of automatic focusing of a microscope camera, and particularly relates to an automatic image change perception focusing method for the microscope camera.
Background
The automatic focusing technology is a technology for evaluating the definition of a target scene by a digital method by means of a modern microelectronic technology, a digital image processing technology and a mechanical control method, replacing manual focusing with automatic focusing and finally enabling a system to image clearly. The auto-focusing technology is widely applied to the fields of machine vision, military, security monitoring, smart phones and the like, and is gradually developed into a complex technology integrating light, machine, electricity and computer.
Early autofocus methods include distance measurement and focus detection. The distance measurement method comprises an ultrasonic distance measurement method, an infrared distance measurement method, a laser distance measurement method, a triangular distance measurement method and the like. The focus detection method mainly includes a contrast detection method, a phase difference detection method, and the like. The contrast detection method and the phase detection method are commonly used in the single lens reflex camera, and other methods are not necessarily suitable for the industrial field due to the complex system implementation and low accuracy.
The automatic focusing method based on digital image processing is most widely applied at present, and comprises two main categories of an out-of-focus depth method and a depth-of-focus method. The out-of-focus depth method is a method for obtaining depth information from out-of-focus images to complete automatic focusing, the required images and calculated amount are small, the focusing speed is high, but the out-of-focus depth method requires that an approximate pre-estimated imaging system mathematical model is established in advance, so the focusing precision is not high enough. The focusing depth method needs a series of images at different focusing positions, and adopts a proper focusing evaluation function to describe the definition of the images, wherein the maximum value of the evaluation function corresponds to the optimal focusing position.
The focusing search algorithm is one of the key technologies of automatic focusing by a focusing depth method, and commonly used algorithms include an exhaustion method, a hill climbing method, a golden section method and a function approximation method. The hill climbing search method is widely applied due to good effect and simplicity and feasibility. The principle of the hill-climbing search method is as follows: searching is carried out from one point, and each time the searching is carried out, the system acquires the image at the corresponding position and calculates the image evaluation function value. And if the image evaluation function value begins to decrease, changing the search direction to decrease the step length and continuing searching, and repeating the searching until the step length is decreased to a preset minimum value, and finishing focusing. The hill-climbing search method has certain limitations: noise interference causes local peaks to appear on the evaluation function curve, resulting in mis-focusing.
The patent application with application publication number CN 107509023a discloses an automatic focusing search algorithm, which combines a hill-climbing search method and a function approximation method, wherein the hill-climbing search method in the algorithm adopts a rough-fine combined two-stage algorithm: during rough focusing, the large step distance considers the rapidity of the algorithm, and a gray variance function is selected to quickly approach a focusing position; when fine focusing is carried out, the sensitivity of the small step distance consideration algorithm adopts a Laplacian function to accurately focus the position. The focusing interval is narrowed by comparing 3 pictures and the best focusing position is fitted in the small interval by adopting a function approximation method. The automatic focusing search algorithm changes the search direction and adjusts the search step length according to the size of the image evaluation function value so as to shorten the automatic focusing time.
The above-mentioned methods are all single-time focusing methods, and have the disadvantage that manual operation is required to realize focusing after the scene is changed.
Disclosure of Invention
In view of the existing problems, the invention provides an image change automatic sensing focusing method for a microscope camera, which is based on a hill climbing search method, increases a focusing scene monitoring function, and can automatically adopt different focusing strategies according to different focusing scenes so as to improve the focusing accuracy.
The technical scheme of the invention is as follows:
an image change auto-perception focusing method for a microscope camera, comprising the steps of:
defining a plurality of scene states according to the change states of the image brightness and the image evaluation function value;
monitoring the real-time change condition of the image brightness and the image evaluation function value of the current scene, determining the scene state of the current scene according to the real-time change condition of the image brightness and the image evaluation function value, and adopting a focusing monitoring strategy corresponding to the scene state according to the scene state, wherein the focusing monitoring strategy comprises the following steps: entering a single focusing process when the image brightness and/or the image evaluation function value is stable;
and executing a single focusing process based on the hill climbing searching method to determine the optimal focusing position.
According to the image change automatic perception focusing method for the microscope camera, a single focusing process is achieved based on a hill climbing searching method, after single focusing is finished, image brightness and an image evaluation function value are monitored for a scene image, the scene state of the monitored scene image is determined according to the change situation of the image brightness and the image evaluation function value, a corresponding focusing monitoring strategy is adopted according to different scene states, focusing is automatically started again after a monitored scene tends to be stable, and focusing accuracy is improved.
In the invention, 4 scene states are defined according to the change conditions of the image brightness and the image evaluation function value. Specifically, the scene state includes:
scene state I: the image brightness and the image evaluation function value are kept unchanged in the single focusing process, which indicates that the current scene is not changed;
scene state II: the brightness of the image changes in the single focusing process, which indicates that the current scene changes;
scene state III: searching the maximum value of the image evaluation function value in the single focusing process, wherein the image evaluation function value is changed to show that the current scene is changed;
scene state IV: after the single focusing is finished, the image evaluation function value is changed, which indicates that the current scene is changed.
The 4 scene states are obtained through a large number of experimental summaries, and when the scenes are in the scene state II, the scene state III and the scene state IV, the scenes are changed, and a focusing process needs to be carried out again.
In the invention, the brightness change of the image is taken as the judgment standard of a scene state II, and specifically, the difference value between the brightness of the image when the last focusing is finished and the brightness of the image calculated in the current focusing process is taken as the change value of the brightness of the image;
in the scene monitoring process, when the change value of the image brightness is greater than a threshold ThrDifZL2, the image brightness is considered to be changed; if the change value of the image brightness is less than or equal to the threshold value thrdiffl 2, the image brightness is considered to be kept unchanged.
On the basis of defining the scene state, in practical application, the scene may be preliminarily classified according to the image brightness of the scene and the real-time change condition of the image evaluation function value, and specifically, determining the scene state of the current scene according to the real-time change condition of the image brightness and the image evaluation function value includes:
if the image brightness changes, marking that the current scene is in a scene state II;
on the basis of searching the maximum value of the image evaluation function value, when the change value of the maximum value of the image evaluation function value is greater than a threshold ThrDifFV1, marking that the current scene is in a scene state III;
when the image brightness keeps unchanged and the maximum value of the image evaluation function value or the change value of the maximum value of the image evaluation function value is not searched for and is less than or equal to a threshold value ThrDifFV1, marking that the current scene is in a scene state I;
on the basis of searching the maximum value of the image evaluation function value, when the change value of the image evaluation function value is greater than a threshold ThrDifFV2, marking that the current scene is in a scene state IV;
and taking the difference value between the image evaluation function value when the current focusing is finished and the maximum value of the image evaluation function value searched in the current focusing process as the change value of the maximum value of the image evaluation function value.
After the single focusing is finished, whether scene change exists in the single focusing process is judged, specifically, the scene change is judged by comparing the change value of the maximum value of the image evaluation function value with a threshold value ThrDifFV1, and when the change value of the maximum value of the image evaluation function value is larger than the threshold value ThrDifFV1, the scene change in the focusing process is considered, and the current focusing is quit.
After the single focusing exits, whether the scene changes or not needs to be monitored, and the scene change situation is reflected by the change situation of the image brightness and the image evaluation function value. A scene change is considered to have occurred when the value of the change in image brightness is greater than the threshold thrdiffl 2 and the value of the change in image merit function is greater than the threshold ThrDifFV 2. Since the image brightness and the image evaluation function value are statistical information and fluctuation is inevitable, the set threshold value must be larger than the maximum value of the fluctuation.
To prevent the following from occurring: if in a low-illumination scene, the statistical information fluctuates relatively greatly, the scene is not changed, but the judgment condition is met, and focusing is started by mistake. Therefore, additional constraints are added in the present invention: the scene is determined to be really changed only when the scene is determined to be changed twice continuously, that is, the current scene is determined to be really the scene state II, the scene state III or the scene state IV when the current scene is determined to be the scene state II, the scene state III or the scene state IV for 2 times continuously.
The scene state classification is a stable basis for realizing focusing monitoring, and after the scene state is determined, the time for restarting focusing can be determined according to the change of the image brightness or the image evaluation function value corresponding to the specific scene state monitoring, so that the focusing time can be shortened, and the focusing accuracy can be improved.
When the scene is monitored to be changed, namely the scene states are judged to be the scene state II, the scene state III and the scene state IV, the single focusing is restarted after the scene is static, otherwise the focusing is frequently restarted, and whether the scene is static or not is judged according to the change degree of the image brightness and the image evaluation function value.
In the present invention, when the scene state is the scene state II, the adopted focusing monitoring strategy includes:
in the scene monitoring process, when the difference value of the image brightness of the scenes at two adjacent moments is smaller than the threshold ThrDifZL3, the image brightness of the scenes is restored to be stable, and the single-focusing process is restarted.
When the scene state is the scene state II, the image brightness of the scene is changed, for example, the image brightness of the scene is changed due to the movement of the sample, at the moment, the focusing monitoring strategy is adopted, the change amplitude of the image brightness is detected, when the change amplitude of the image brightness is small and is smaller than a set threshold ThrDifZL3, the image brightness tends to be stable, the focusing is automatically restarted at the moment, the manual restarting for starting the focusing is avoided, the focusing time is shortened, and the focusing accuracy can also be ensured when the image brightness tends to be stable and then the focusing is restarted.
In the present invention, when the scene state is the scene state III, the adopted focusing monitoring strategy includes:
in the scene monitoring process, when the difference value of the image evaluation function values of the scenes at two adjacent moments is smaller than a threshold value ThrDifFV3, the image evaluation function values of the scenes are restored to be stable, and the single-focusing process is restarted.
In the present invention, when the scene state is a scene state IV, the adopted focusing monitoring strategy includes:
in the scene monitoring process, when the difference value of the image evaluation function values of the scenes at two adjacent moments is smaller than a threshold value ThrDifFV3, namely the image evaluation function values of the scenes are restored to be stable, the change of the image evaluation function values is continuously judged, and when the current image evaluation function value is larger than the threshold value ThrDifFV2 compared with the change value at the end of the last focusing, the single-focusing process is restarted;
when the scene states are the scene state III and the scene state IV, it indicates that the image evaluation function value of the scene has changed. At the moment, the adopted focusing monitoring strategy is that the change amplitude of the image evaluation function value is detected, for a scene state III, only the change amplitude of the image evaluation function value at two adjacent moments is judged and sampled, when the change amplitude is small and is smaller than a set threshold ThrDifFV3, the image evaluation function value area is stable, and at the moment, the focusing is automatically restarted; for the scene state IV, because the definition of the scene state IV is that the image evaluation function value changes after the single focusing is finished, on the basis that the change range of the image evaluation function value at two adjacent moments is smaller than the set threshold ThrDifFV3, the change condition of the maximum value of the image evaluation function value needs to be judged, and when the change value of the maximum value of the image evaluation function value is larger than the threshold ThrDifFV2, the focusing is automatically restarted, thereby avoiding the manual restart of focusing, shortening the focusing time, and when the image brightness tends to be stable and then the focusing is restarted, the focusing accuracy can also be ensured.
And when the scene state is the scene state I, continuously monitoring the real-time change conditions of the image brightness and the image evaluation function value of the current scene.
Preferably, the threshold value ThrDifZL2 is 150-200, the threshold value ThrDifZL3 is 100-120, and further, the threshold value ThrDifZL2 is 200, and the threshold value ThrDifZL3 is 100.
Preferably, the threshold ThrDifFV1 and the threshold ThrDifFV2 are selected in relation to the magnitude of the image evaluation function value obtained at the previous moment, and the approximate rule is that the magnitude of the threshold ThrDifFV2 increases with the increase of the image evaluation function value obtained at the previous moment.
In order to improve focusing efficiency, in the process of executing single focusing based on the hill climbing searching method, the maximum value of an image evaluation function value representing the optimal focusing position is searched by adopting a variable step searching mode, and the specific process is as follows:
dividing a scene into an out-of-focus area and a focus area according to the magnitude of an image evaluation function value, and adopting a larger search step length in the out-of-focus area; in the focus area, a smaller search step is used.
In order to improve focusing accuracy, the method also corrects the searching direction in the process of executing single focusing based on the hill-climbing searching method, and comprises the following specific steps:
and calculating the average value of the evaluation function values of the adjacent four steps of images for two times continuously, and if the average value of the evaluation function values of the former four steps of images is larger than the average value of the evaluation function values of the latter four steps of images, which indicates that the searching is carried out towards the defocusing direction, changing the searching direction to continuously search for the maximum value of the evaluation function values of the images, which indicates the best focusing position.
In the invention, the image evaluation function value is calculated by utilizing the high-frequency component, and the specific process comprises the following steps:
filtering the scene image by adopting an IIR filter H1 and an IIR filter H2 in the horizontal direction and an FIR filter V1 and an FIR filter V2 in the vertical direction, and outputting high-frequency components;
after an absolute value of the output high-frequency component is taken, the high-frequency flux exceeding a threshold value is counted through threshold value judgment, and a statistical value of the high-frequency component is obtained;
assuming that the statistical values of the high-frequency components output by the four filters corresponding to the region n are H1_ n, H2_ n, V1_ n, and V2_ n, respectively, the two sets of image evaluation function values FV1_ n and FV2_ n of the region n are:
FV1_n=α×H1_n+(1-α)×V1_n
FV2_n=β×H2_n+(1-β)×V2_n
wherein α and β are weight coefficients, respectively.
The invention has the beneficial effects that:
the invention can automatically sense the searching direction in focusing search and quickly return after searching wrong direction, thereby reducing the focusing time;
the method can change the step length in a self-adaptive manner, a long step length is selected when the defocusing area moves, a small step length is selected when the focusing area moves, the focusing speed is accelerated, and the focusing precision can be improved by searching in the focusing area by adopting the small step length; the function of focusing can be completed under the condition of low image quality by expanding the image evaluation function;
the invention also adds a focusing monitoring function, and can more accurately judge the change of the scene by monitoring the image brightness and the image evaluation parameter value, thereby realizing the automatic focusing function; after the focusing is quitted, the scene change is monitored twice, and the scene is judged to be really changed, so that the influence of slight shaking on the algorithm is avoided, and a more stable scene monitoring function is realized; after the scene is judged to be changed, the scene change is continuously monitored, and the focusing is restarted until the scene is judged to be static, so that the condition that the scene is always in a frequent focusing state in the scene change process is avoided, and the focusing stability and accuracy are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of a single focusing provided by an embodiment;
FIG. 2 is a flowchart illustrating a method for determining different scene states according to a single focusing result;
FIG. 3 is a flow chart of scene state monitoring after a single focus exit;
fig. 4 is a logic block diagram of the calculation of the evaluation function value of the image.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the detailed description and specific examples, while indicating the scope of the invention, are intended for purposes of illustration only and are not intended to limit the scope of the invention.
The embodiment provides an image change automatic sensing focusing method for a microscope camera, which monitors image change through a focusing monitoring strategy, restarts a single focusing process and realizes an automatic focusing function under the condition of image change.
The image change automatic sensing focusing method for the microscope camera can be realized in the microscope camera with a stepping motor. The whole process of the motor has 854 steps, the stepping motor can move to a designated position according to an image change automatic sensing focusing method, images at different positions are captured, and the optimal focusing position is found according to criteria in the image change automatic sensing focusing method, namely the maximum value of an image evaluation function value is found.
The image change automatic perception focusing method for the microscope camera comprises the following specific implementation processes: the method comprises the steps of starting single focusing based on a hill climbing search method, judging a scene state after a motor successfully finds an optimal focusing position, entering a focusing monitoring strategy, monitoring the change of image brightness and an image evaluation function value, and restarting a focusing function after the image change is monitored and the image change is stable.
In this embodiment, the image brightness is referred to as parameter 1 for short, and the image evaluation function value is referred to as parameter 2 for short. As shown in fig. 1, the single focusing process is performed based on the hill-climbing search method, and the process of determining the best focus position is as follows:
s101, determining an initial searching direction.
Setting the step length of the first step of motor search to 7, respectively capturing two images, calculating the parameter 2 values of the two images and comparing the two images, wherein the initial search direction is the direction of increasing the parameter 2.
And S102, searching the motor variable step length.
In order to improve focusing efficiency, searching is carried out according to a variable step length searching mode, and the specific searching process is as follows:
firstly, dividing an out-of-focus area and a focus area according to a parameter 2; a larger search step length is selected in the out-of-focus area, so that the motor can leave the out-of-focus area and enter the focus area in a shorter time, and unnecessary search time in the out-of-focus area is shortened; selecting a smaller search step length in a focusing area, so that the motor can more accurately search the optimal focusing point; meanwhile, considering the condition that the initial position of focusing search is near the optimal focus point, the search step length of the focus area can be further subdivided, when the initial position of focusing search is in the focus area, small step length search is firstly adopted, after 10 times of continuous search, if the optimal focus point is not found, the search step length is increased.
In this embodiment, the next search step length is determined according to the parameter 2 threshold value ThrFV and the current value of the parameter 2:
Figure BDA0002171332940000101
wherein stepn+1For the next motor movement step, FVnAnd (4) as the function value of the nth image evaluation, namely a parameter 2, ThrFV is a parameter 2 threshold, the threshold divides the motor motion area into an out-of-focus area and a focus area, the area of the parameter 2, which is larger than the threshold ThrFV, is the focus area, otherwise, is the out-of-focus area. According to the experimental determination, the threshold ThrFV is 30.
In the searching process, parameters 2 of four continuous images are calculated and respectively recorded as FV1、FV2、FV3、FV4When FV1<FV2>FV3>FV4And FV2>ThrMaxFV, then judge that the best focus position, FV, is found2The corresponding image position is the best focus position and returns to the best focus position. The threshold thrmaxvv is used to determine the best focus position, and should be set according to the evaluation function value of the actual image, and the range of the threshold that can be selected is larger than the local peak value and smaller than the best focus peak value, and is measured through experiments, where thrmaxvv is 400.
S103, judging whether the optimal focusing position is searched in the previous step 15, returning to the optimal focusing position if the optimal focusing position is searched in the previous step 15, and executing S104 if the optimal focusing position is not searched in the previous step 15;
s104, recording and judging whether the maximum value of the parameter 2 of the image captured in the previous 15 steps is larger than a set threshold value ThrStartFV or not, if the maximum value of the parameter 2 is smaller than ThrStartFV, enlarging the parameter 2 value of the image captured in a subsequent search area by 10 times, and continuing searching by changing the step length of the motor, namely, jumping to execute S102; if the maximum value of the parameter 2 is greater than ThrStartFV, the parameter 2 of the captured image of the subsequent search area is kept unchanged, and the motor continues the search step by step, i.e., the jump is performed S102.
The threshold ThrStartFV, which is used to approximately predict the size of the image search full range parameter 2, may be set equal to the threshold ThrMaxFV. When the image optimal peak evaluation function is too small and smaller than the threshold ThrMaxFV, the optimal focusing position cannot be identified by the criterion of S102, so that it is necessary to identify the situation by setting the threshold ThrStartFV, so as to enlarge the parameter 2, and then perform the determination of S102.
And S105, if the optimal focusing position is not searched all the time, judging that the focusing result is out-of-focus, finishing focusing, and exiting the focusing process.
In order to improve focusing accuracy, the motion direction of the motor, namely the searching direction, is corrected in the searching process, so that the motor can turn to the defocused area immediately when searching, and the specific method comprises the following steps:
and calculating the average value of the parameters 2 in the four adjacent steps twice continuously, and if the average value of the parameters 2 in the first four steps is larger than the average value of the parameters 2 in the last four steps, indicating that the searching is going to the defocusing direction, changing the searching direction to continuously search for the optimal focusing position.
The experiment adopts an ROI (Region of Interest) focusing window, and the Region of Interest can be selected by self for automatic focusing. The image is divided into 7-by-7 equal areas for selection, so that the focusing of samples with different heights can be realized, the interference of different object distances to the focusing is avoided, and the accurate focusing is realized.
In this embodiment, the parameter 2 is calculated using a high-frequency component. As shown in fig. 4, TH1, TH2, TH3 and TH4 are threshold values respectively. Firstly, an original image passes through a filter to obtain a high-frequency component, then an absolute value of the output of the filter is taken, then the absolute value is judged through a threshold value, statistics exceeding the threshold value is carried out, finally, the statistic value of the high-frequency component of the image is output, and a four-way high-pass filter is adopted and respectively comprises an IIR filter H1 and an IIR filter H2 in the horizontal direction, and an FIR filter V1 and an FIR filter V2 in the vertical direction. Assuming that the statistical values of the four filter outputs corresponding to the region n are H1_ n, H2_ n, V1_ n, and V2_ n, respectively, two sets of evaluation function values FV1_ n and FV2_ n of the region can be calculated by the following expressions:
FV1_n=α×H1_n+(1-α)×V1_n
FV2_n=β×H2_n+(1-β)×V2_n
wherein, alpha is 0.45, beta is 0.85.
And after the single focusing is finished, judging the scene state, entering a focusing monitoring strategy, monitoring the change of the image brightness and the image evaluation function value, and restarting the focusing function after the image change is monitored and the image change is stable.
In this embodiment, the scene states are divided into 4 types, which are respectively: scene state I: the image brightness and the image evaluation function value are kept unchanged in the single focusing process, which indicates that the current scene is not changed; scene state II: the brightness of the image changes in the single focusing process, which indicates that the current scene changes; scene state III: searching the maximum value of the image evaluation function value in the single focusing process, wherein the image evaluation function value is changed to show that the current scene is changed; scene state IV: after the single focusing is finished, the image evaluation function value is changed, which indicates that the current scene is changed. When the scene is monitored to be in the scene state II, the scene state III and the scene state IV, the scene is changed, and the focusing function needs to be automatically restarted.
According to the flowchart shown in fig. 2, after a single focusing is finished, the scene states are preliminarily classified according to the changes of the parameters 1 and 2, the change of the parameter 1 is recorded every step by the motor, whether the change of the parameter 1 is larger than a set threshold value or not is judged, and if the change of the parameter 1 is larger than the set threshold value, which indicates that the scene is changed in the focusing process, the scene states are preliminarily classified into the scene states II. The purpose of setting the scene state II is to determine whether the sample moves during focusing, and if the sample moves, the change of the parameter 1 is greater than a threshold thrdiffl 1, and through experiments, the threshold is set to thrdiffl 1-2000.
After the parameter 1 is monitored to realize the classification of the scene state II, the parameter 2 is monitored after the scene brightness is stable, and when the optimal focusing position is not found, the scene state is preliminarily judged to be the scene state I.
If the best focusing position is found in the focusing process, the peak value of the image evaluation function curve is found and then returns to the peak value in the improved hill climbing searching method, under the condition that the scene is not changed, the image evaluation function value at the returned peak value point is approximately equal to the maximum value recorded in the focusing process, if the difference between the two values is too large, the scene is changed in the focusing process, and the current position is not the true focusing position. Therefore, the difference between the parameter 2 value FV1 returned from the end of the previous focusing and the maximum value FV2 of the parameter 2 during the focusing process should be less than a certain threshold thrdiff 1, and if the difference exceeds the threshold, the following steps are performed:
|FV1-FV2|>ThrDifFV1
and marking the scene state as a scene state III, otherwise marking the scene state as a scene state I.
According to experimental tests, the threshold thrdiff 1 was set according to FV1 size as follows:
Figure BDA0002171332940000141
according to the flowchart shown in fig. 3, after a single focusing operation is finished, different focusing monitoring strategies are entered according to different scene states. If the scene state is preliminarily marked as the scene state I, continuing to monitor the parameter 1 and the parameter 2, calculating the value ZL2 of the current scene parameter 1 and the value FV2 of the parameter 2 once every 0.2s, comparing the values with the value ZL1 of the parameter 1 and the maximum value FV1 of the parameter 2 at the end of the last focusing, and if the change exceeds a certain threshold, determining that the scene is changed. The change of the parameter 1 exceeds a threshold ThrDifZL2, and the scene state is recorded as a scene state II; the parameter 2 changes beyond the threshold thrdiff 2, noting the scene state as scene state IV. As shown in the following formula:
|ZL1-ZL2|>ThrDifZL2
|FV1-FV2|>ThrDifFV2
the parameters 1 and 2 are statistical information, and there is a fluctuation, so the set threshold value must be larger than the maximum value of the fluctuation. According to experimental tests, the threshold thrdiffl 2 is 200, and ThrDifFV2 is set as:
Figure BDA0002171332940000142
if the scene state is recorded as scene state II, waitingAnd restarting the single focusing function after the scene brightness is stable. I.e. the value ZL of the current scene parameter 1 is calculated every moment (e.g. every 0.2s time)TAnd the ZL of the previous momentT-tComparing, when the variation is less than the threshold value, namely:
|ZLT-ZLT-t|<ThrDifZL3
the scene is considered to be stationary and focusing is restarted. According to experimental tests, the parameter 1 change threshold thrdiffl 3 is 100.
And if the scene state is recorded as a scene state III, restarting the single focusing function after the scene evaluation function value is stable. That is, the value FV of the current scene parameter 2 is calculated once every instant (for example, every time t equal to 0.2s)TAnd with the value FV of the parameter 2 at the previous momentT-tComparing, when the variation is less than the threshold value, namely:
|FVT-FVT-t|<ThrDifFV3
the scene is considered to be stationary and focusing is restarted. According to experimental tests, the parameter 2 variation threshold thrdiff 3 is 20.
If the scene state is recorded as a scene state IV, waiting for the scene evaluation function value to be stable, namely the parameter 2 changes less than a certain threshold ThrDifFV3, in order to prevent frequent restart of focusing caused by slight shaking, judging the change of the parameter 2 value of the current image relative to the parameter 2 value at the end of the last focusing again, if the scene change condition is still met (the change is less than the threshold ThrDifFV2), considering that the scene actually changes, restarting focusing, otherwise, considering that the scene does not change, namely the scene state is 1, and continuing to enter into focusing monitoring.
In the image change automatic perception focusing method, the search direction can be automatically perceived in focusing search, and the image change automatic perception focusing method can return quickly after searching for the wrong direction, so that the focusing time is reduced; the step length can be adaptively changed, a long step length is selected when the defocused area moves, a small step length is selected when the focused area moves, the focusing speed is accelerated, and the focusing precision can be improved by searching in the focused area with the small step length; by expanding the image evaluation function, the function of focusing can be realized under the condition of low image quality,
meanwhile, a focusing monitoring method is added, the change of the scene can be more accurately judged by monitoring the image parameters 1 and 2, and the automatic focusing function is realized; after the focusing is quitted, the scene change is monitored twice, and the scene is judged to be really changed, so that the influence of slight shaking on the algorithm is avoided, and a more stable scene monitoring function is realized; after the scene is judged to be changed, the scene change is continuously monitored, and the focusing is restarted until the scene is judged to be static, so that the condition that the scene is always in a frequent focusing state in the scene change process is avoided, and the focusing stability and accuracy are improved.
The above-mentioned embodiments are intended to illustrate the technical solutions and advantages of the present invention, and it should be understood that the above-mentioned embodiments are only the most preferred embodiments of the present invention, and are not intended to limit the present invention, and any modifications, additions, equivalents, etc. made within the scope of the principles of the present invention should be included in the scope of the present invention.

Claims (4)

1. An image change auto-perception focusing method for a microscope camera, comprising the steps of:
defining a plurality of scene states according to the change states of the image brightness and the image evaluation function value;
monitoring the real-time change condition of the image brightness and the image evaluation function value of the current scene, determining the scene state of the current scene according to the real-time change condition of the image brightness and the image evaluation function value, and adopting a focusing monitoring strategy corresponding to the scene state according to the scene state, wherein the focusing monitoring strategy comprises the following steps: entering a single focusing process when the image brightness and/or the image evaluation function value is stable;
executing a single focusing process based on a hill climbing searching method, and determining an optimal focusing position;
wherein the scene state comprises:
scene state I: the image brightness and the image evaluation function value are kept unchanged in the single focusing process, which indicates that the current scene is not changed;
scene state II: the brightness of the image changes in the single focusing process, which indicates that the current scene changes;
scene state III: searching the maximum value of the image evaluation function value in the single focusing process, wherein the image evaluation function value is changed to show that the current scene is changed;
scene state IV: after the single focusing is finished, the image evaluation function value is changed, which indicates that the current scene is changed;
taking the difference value between the image brightness at the end of the last focusing and the image brightness calculated in the current focusing process as the change value of the image brightness;
in the scene monitoring process, when the change value of the image brightness is greater than a threshold ThrDifZL2, the image brightness is considered to be changed; if the change value of the image brightness is less than or equal to the threshold value thrdiffl 2, the image brightness is considered to be kept unchanged. (ii) a
The determining the scene state of the current scene according to the real-time change condition of the image brightness and the image evaluation function value comprises the following steps:
if the image brightness changes, marking that the current scene is in a scene state II;
on the basis of searching the maximum value of the image evaluation function value, when the change value of the maximum value of the image evaluation function value is greater than a threshold ThrDifFV1, marking that the current scene is in a scene state III;
when the image brightness keeps unchanged and the maximum value of the image evaluation function value or the change value of the maximum value of the image evaluation function value is not searched for and is less than or equal to a threshold value ThrDifFV1, marking that the current scene is in a scene state I;
on the basis of searching the maximum value of the image evaluation function value, when the change value of the image evaluation function value is greater than a threshold ThrDifFV2, marking that the current scene is in a scene state IV;
taking the difference value between the image evaluation function value when the current focusing is finished and the maximum value of the image evaluation function value searched in the current focusing process as the change value of the maximum value of the image evaluation function value;
when the scene state is a scene state II, the adopted focusing monitoring strategy comprises the following steps:
in the scene monitoring process, when the image brightness difference value of the scenes at two adjacent moments is smaller than a threshold ThrDifZL3, indicating that the image brightness of the scenes is recovered to be stable, and restarting to enter a single focusing process;
when the scene state is the scene state III, the adopted focusing monitoring strategy includes:
in the scene monitoring process, when the difference value of the image evaluation function values of the scenes at two adjacent moments is smaller than a threshold value ThrDifFV3, indicating that the image evaluation function values of the scenes are stable, restarting and entering a single-time focusing process;
when the scene state is a scene state IV, the adopted focusing monitoring strategy includes:
in the scene monitoring process, when the difference value of the image evaluation function values of the scenes at two adjacent moments is smaller than a threshold value ThrDifFV3, namely the image evaluation function values of the scenes are restored to be stable, the change of the image evaluation function values is continuously judged, and when the current image evaluation function value is larger than the threshold value ThrDifFV2 compared with the change value at the end of the last focusing, the single-focusing process is restarted;
and when the scene state is the scene state I, continuously monitoring the real-time change conditions of the image brightness and the image evaluation function value of the current scene.
2. The image change auto-perception focusing method for the microscope camera according to claim 1, wherein in the process of performing single focusing based on the hill-climbing search method, the maximum value of the image evaluation function value representing the best focusing position is searched in a variable step size search mode, and the specific process is as follows:
dividing a scene into an out-of-focus area and a focus area according to the magnitude of an image evaluation function value, and adopting a larger search step length in the out-of-focus area; in the focus area, a smaller search step is used.
3. The image change auto-perception focusing method for the microscope camera according to claim 1, wherein in the process of performing single focusing based on the hill-climbing search method, the search direction is also corrected, and the specific process is as follows:
and calculating the average value of the evaluation function values of the adjacent four steps of images for two times continuously, and if the average value of the evaluation function values of the former four steps of images is larger than the average value of the evaluation function values of the latter four steps of images, which indicates that the searching is carried out towards the defocusing direction, changing the searching direction to continuously search for the maximum value of the evaluation function values of the images, which indicates the best focusing position.
4. The image change auto-perception focusing method for the microscope camera according to claim 1, wherein the image evaluation function value is calculated by using the high frequency component by the specific process:
filtering the scene image by adopting an IIR filter H1 and an IIR filter H2 in the horizontal direction and an FIR filter V1 and an FIR filter V2 in the vertical direction, and outputting high-frequency components;
after an absolute value of the output high-frequency component is taken, the high-frequency flux exceeding a threshold value is counted through threshold value judgment, and a statistical value of the high-frequency component is obtained;
assuming that the statistical values of the high-frequency components output by the four filters corresponding to the region n are H1_ n, H2_ n, V1_ n, and V2_ n, respectively, the two sets of image evaluation function values FV1_ n and FV2_ n of the region n are:
FV1_n=α×H1_n+(1-α)×V1_n
FV2_n=β×H2_n+(1-β)×V2_n
wherein α and β are weight coefficients, respectively.
CN201910764039.3A 2019-08-19 2019-08-19 Image change automatic sensing focusing method for microscope camera Active CN110324536B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910764039.3A CN110324536B (en) 2019-08-19 2019-08-19 Image change automatic sensing focusing method for microscope camera

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910764039.3A CN110324536B (en) 2019-08-19 2019-08-19 Image change automatic sensing focusing method for microscope camera

Publications (2)

Publication Number Publication Date
CN110324536A CN110324536A (en) 2019-10-11
CN110324536B true CN110324536B (en) 2021-09-07

Family

ID=68126270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910764039.3A Active CN110324536B (en) 2019-08-19 2019-08-19 Image change automatic sensing focusing method for microscope camera

Country Status (1)

Country Link
CN (1) CN110324536B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111432129B (en) * 2020-04-14 2021-08-24 广东欧谱曼迪科技有限公司 Automatic focusing hill climbing searching method based on threshold value method and local maximum value
CN111654637B (en) * 2020-07-14 2021-10-22 RealMe重庆移动通信有限公司 Focusing method, focusing device and terminal equipment
CN112969027B (en) * 2021-04-02 2022-08-16 浙江大华技术股份有限公司 Focusing method and device of electric lens, storage medium and electronic equipment
CN113766213A (en) * 2021-09-02 2021-12-07 信利光电股份有限公司 Method for improving AF burning parameter detection efficiency of camera module

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494737A (en) * 2009-03-09 2009-07-29 杭州海康威视数字技术股份有限公司 Integrated camera device and self-adapting automatic focus method
CN102053339A (en) * 2010-11-23 2011-05-11 天津市亚安科技电子有限公司 Automatic focusing method
CN105391945A (en) * 2015-12-23 2016-03-09 北京奇虎科技有限公司 Automatic focusing control method and device of camera
US10250794B2 (en) * 2017-01-04 2019-04-02 Motorola Mobility Llc Capturing an image using multi-camera automatic focus

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105611158A (en) * 2015-12-23 2016-05-25 北京奇虎科技有限公司 Automatic focus following method and device and user equipment
CN106131406A (en) * 2016-07-05 2016-11-16 上海理工大学 A kind of method of self adaptation focusing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494737A (en) * 2009-03-09 2009-07-29 杭州海康威视数字技术股份有限公司 Integrated camera device and self-adapting automatic focus method
CN102053339A (en) * 2010-11-23 2011-05-11 天津市亚安科技电子有限公司 Automatic focusing method
CN105391945A (en) * 2015-12-23 2016-03-09 北京奇虎科技有限公司 Automatic focusing control method and device of camera
US10250794B2 (en) * 2017-01-04 2019-04-02 Motorola Mobility Llc Capturing an image using multi-camera automatic focus

Also Published As

Publication number Publication date
CN110324536A (en) 2019-10-11

Similar Documents

Publication Publication Date Title
CN110324536B (en) Image change automatic sensing focusing method for microscope camera
CN107395993B (en) Full-automatic focusing method and system
CN105430279B (en) Camera fast automatic focusing method and device
US8970770B2 (en) Continuous autofocus based on face detection and tracking
CN107888819B (en) Automatic focusing method and device
CN108259753B (en) Camera automatic focusing method and device based on defocus estimation and improved hill climbing method
US8233078B2 (en) Auto focus speed enhancement using object recognition and resolution
CN105578048B (en) A kind of quick focusing method and device, mobile terminal
US20220124252A1 (en) Methods and apparatus for defocus reduction using laser autofocus
JP5546646B2 (en) Imaging apparatus and main subject recognition method
CN105430277B (en) Autofocus control method and device
CN106534676A (en) Automatic focus adjustment method for zoom camera systems
KR100897768B1 (en) An automatic focusing method and apparatus for using the same
CN108769533B (en) Automatic focusing method
CN105391945A (en) Automatic focusing control method and device of camera
CN114460791A (en) Focusing method and device, electronic equipment and storage medium
US20200228719A1 (en) Focus control apparatus, imaging apparatus, focus control method, and storage medium
CN114061921A (en) Return trip difference detection method and device, monitoring equipment and readable storage medium
CN111491105B (en) Focusing method of mobile terminal, mobile terminal and computer storage medium
CN112689853A (en) Image processing method, image processing apparatus, photographing device, movable platform and storage medium
US20190094656A1 (en) Imaging apparatus and control method of the same
JP4574559B2 (en) Imaging device, focus position detection device, and focus position detection method
CN110839126B (en) Zoom tracking method and device and zoom camera
JP3134446B2 (en) Focus detection device
CN112640425A (en) Focusing control method, device, equipment, movable platform and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant