Automatic focusing method and device for microscope, operating microscope and storage medium

By acquiring image sharpness value sequences for multi-timescale analysis and fuzzy rule base reasoning, and dynamically adjusting the microscope motor step size, the problems of overshoot jitter and low efficiency in microscope autofocus are solved, achieving fast and stable autofocus effect.

CN120871416APending Publication Date: 2025-10-31ZHEJIANG HEALNOC TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511107733.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-07
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

Existing microscope autofocus methods suffer from overshoot jitter and low focusing efficiency, especially at high magnification when the depth of field is small, resulting in blurred images and low adjustment efficiency.

Method used

By acquiring image sharpness value sequences, performing multi-timescale focusing trend feature analysis, and combining fuzzy rule base for inference, the step size of the microscope motor is dynamically adjusted to quickly move out of flat areas with large fluctuations in the sharpness curve and quickly switch to small step size when approaching the peak position, thus achieving automatic focusing.

Benefits of technology

It effectively eliminates overshoot and shake, improves the efficiency and stability of autofocus, and ensures that image sharpness reaches its peak quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120871416A_ABST
    Figure CN120871416A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic focusing method and device for a microscope, an operating microscope and a storage medium, and the method comprises the steps: obtaining an image definition value sequence based on the microscope; performing focusing trend feature analysis on the image definition value sequence under multiple time scales to obtain focusing trend features and confidence; reasoning in a preset fuzzy rule base according to the focusing trend characteristic and the confidence so as to dynamically adjust a first step length of a motor in the microscope; and performing automatic focusing on the microscope based on the dynamically adjusted first step length. Through the automatic focusing method and device, the problems of overshoot jitter and low focusing efficiency in related technologies are solved, the overshoot jitter can be eliminated, and the automatic focusing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of medical image processing technology, and in particular to autofocusing methods, devices, surgical microscopes, and storage media for microscopes. Background Technology

[0002] With the development of technology, the types of microscopes have also increased. Among them, the surgical microscope, as a type of microscope, has become a core piece of equipment for delicate surgeries such as neurosurgery, ophthalmology, and otolaryngology. The image quality of a surgical microscope is a key concern. However, at high magnification, the depth of field of a microscope may be less than 1 mm, and even slight changes in object distance (such as tissue respiration fluctuations) can cause image blurring. For example, frequent changes in object distance due to tissue displacement, blood or fluid flow, or instrument manipulation can lead to image blurring. Traditional manual focusing requires users to frequently adjust knobs, severely distracting them; therefore, autofocus technology is an important and necessary technical solution in the field of surgical microscopes.

[0003] Current autofocus methods employ a hill-climbing search approach. Specifically, by gradually moving the motor, it detects changes in image sharpness (such as gradient energy and edge contrast). When sharpness decreases, the search reverses until the peak position of image sharpness is found. This type of method generally consists of two stages: a coarse search and a fine search. The coarse search uses a larger step size to determine the approximate range of sharpness, while the fine search uses a smaller step size to approximate the sharpest position. This method typically involves repeatedly crossing the peak 2-3 times, similar to a "bellows" effect. At high magnification and with a shallow depth of field, the sharpness curve is relatively steep. If the motor step size or speed is not set correctly, it is easy to overshoot the peak, causing the image to blur before reversing, which can easily lead to image blur and camera shake, and also results in low focusing efficiency.

[0004] There is currently no effective solution to the problems of overshooting and low focusing efficiency in related technologies. Summary of the Invention

[0005] This embodiment provides an autofocusing method, apparatus, surgical microscope, and storage medium for a microscope to solve the problems of overshoot jitter and low focusing efficiency in related technologies.

[0006] In a first aspect, this embodiment provides an autofocusing method for a microscope, comprising:

[0007] Based on the microscope, obtain an image sharpness value sequence;

[0008] Focus trend feature analysis was performed on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels.

[0009] Based on the focusing trend characteristics and the confidence level, inference is performed under a preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope;

[0010] The microscope is automatically focused based on the dynamically adjusted first step length.

[0011] In some embodiments, based on the microscope, an image sharpness value sequence is obtained, including:

[0012] During the operation of the motor in the microscope, images and corresponding image sharpness value sequences are acquired; an upward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is close to the sharp position; a downward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is far from the sharp position.

[0013] In some embodiments, focus trend feature analysis is performed on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels, including:

[0014] Determine the slope value of the image sharpness value sequence at multiple time scales;

[0015] Based on the slope value, the focusing trend feature is determined;

[0016] The confidence level is obtained by substituting the focus trend features and the noise intensity in the image sharpness value sequence into a preset trend confidence formula.

[0017] In some embodiments, the first step length of the motor in the microscope is obtained by reasoning based on the focusing trend characteristics and the confidence level under a preset fuzzy rule base, including:

[0018] The focusing trend features and the confidence level are input into a preset membership function for fuzzing;

[0019] Based on the fuzzy rule table in the fuzzy rule base, fuzzy inference is performed on the fuzzification result;

[0020] The fuzzy inference results are defuzzified in order to dynamically adjust the first step length of the motor in the microscope.

[0021] In some embodiments, the fuzzy inference result is defuzzified to dynamically adjust the first step length of the motor in the microscope, including:

[0022] Clustering and integration are performed based on preset step size control points and fuzzy inference results to obtain clustering and integration results;

[0023] The clustering integration is defuzzified to dynamically adjust the first step length of the motor in the microscope.

[0024] In some embodiments, the membership function includes a trend membership function, a trend confidence membership function, and an adjacent frame ratio membership function.

[0025] In some embodiments, autofocusing of the microscope based on the dynamically adjusted first-step length includes:

[0026] The first step of the dynamic adjustment moves the microscope motor and determines whether to enter the fine-tuning mode.

[0027] When it is determined that the fine-tuning mode has been entered, a trial search is performed based on a preset second step length. When the clearest position is found, the microscope is automatically focused; the second step length is less than the first step length.

[0028] Secondly, this embodiment provides an automatic focusing device for a microscope, including: an acquisition module, an analysis module, an inference module, and a focusing module;

[0029] The acquisition module is used to acquire an image sharpness value sequence based on the microscope;

[0030] The analysis module is used to perform focus trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels.

[0031] The reasoning module is used to perform reasoning based on the focusing trend characteristics and the confidence level under a preset fuzzy rule base, so as to dynamically adjust the first step length of the motor in the microscope.

[0032] The focusing module is used to automatically focus the microscope based on the dynamically adjusted first step length.

[0033] Thirdly, this embodiment provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the autofocusing method for a microscope described in the first aspect above.

[0034] Fourthly, this embodiment provides a storage medium storing a computer program that, when executed by a processor, implements the autofocusing method for a microscope described in the first aspect above.

[0035] Compared with related technologies, the autofocus method, device, surgical microscope, and storage medium for microscopes provided in this embodiment obtain an image sharpness value sequence based on the microscope; perform focusing trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focusing trend features and confidence levels; and perform inference based on the focusing trend features and confidence levels under a preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope. Based on the dynamically adjusted first step length, the microscope is automatically focused, solving the problems of overshoot and jitter and low focusing efficiency in related technologies. By using focusing trend features and confidence levels to perform inference under a fuzzy rule base, large step lengths are used to quickly move out of the flat area where the sharpness curve fluctuates greatly during autofocusing, and small step lengths are quickly and timely switched to smoothly reach the peak position where the sharpness curve fluctuates less, thereby eliminating the problem of overshoot and jitter and improving autofocusing efficiency.

[0036] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0037] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0038] Figure 1 This is a hardware structure block diagram of a terminal device for an autofocusing method for a microscope provided in one embodiment of this application;

[0039] Figure 2 This is a flowchart of an autofocusing method for a microscope provided in an embodiment of this application;

[0040] Figure 3 This is a flowchart of step S220;

[0041] Figure 4 This is a schematic diagram of a fuzzy inference engine framework provided in an embodiment of this application;

[0042] Figure 5 This is a schematic diagram of a trend membership function provided in an embodiment of this application;

[0043] Figure 6 This is a schematic diagram of a trend confidence membership function provided in an embodiment of this application;

[0044] Figure 7 This is a schematic diagram of the adjacent frame proportional membership function provided in an embodiment of this application;

[0045] Figure 8This is a schematic diagram of a step size membership function provided in an embodiment of this application;

[0046] Figure 9 This is a structural block diagram of an autofocus device for a microscope provided in one embodiment of this application.

[0047] In the diagram: 102, processor; 104, memory; 106, transmission device; 108, input / output device; 210, acquisition module; 220, analysis module; 230, inference module; 240, focusing module. Detailed Implementation

[0048] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0049] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning as understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these,” used in this application, do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to such processes, methods, products, or devices. The terms “connected,” “linked,” and “coupled,” used in this application, are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. The term “multiple” used in this application refers to two or more. The "and / or" operator describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: A alone, A and B simultaneously, and B alone. Typically, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," and "third," etc., used in this application are merely for distinguishing similar objects and do not represent a specific ordering of the objects.

[0050] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal for the autofocusing method of a microscope in this embodiment. (See diagram below.) Figure 1 As shown, a terminal may include one or more ( Figure 1Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0051] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the autofocus method for a microscope in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0052] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0053] This embodiment provides an automatic focusing method for a microscope. Figure 2 This is a flowchart of the autofocusing method for a microscope in this embodiment, as shown below. Figure 2 As shown, the process includes the following steps:

[0054] Step S210: Based on the microscope, obtain the image sharpness value sequence;

[0055] Step S220: Perform focus trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence level;

[0056] Step S230: Based on the focusing trend characteristics and confidence level, reasoning is performed under the preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope.

[0057] Step S240: Based on the dynamically adjusted first step length, the microscope is automatically focused.

[0058] Specifically, in practical applications, the methods for obtaining image sharpness value sequences in this application embodiment include, but are not limited to, obtaining image sharpness value sequences that meet the above requirements from a database that is pre-stored; downloading image sharpness value sequences that meet the requirements from a network platform (which pre-stores image sharpness value sequences of the microscope); or generating corresponding image sharpness value sequences according to needs, etc. This application embodiment does not limit the method of obtaining image sharpness value sequences.

[0059] In this context, "multi-timescale" refers to the temporal relationship between the image sharpness value sequences of each frame, such as adjacent frames and nearest neighbor frames. Focus trend features refer to the overall trend of the image sharpness value sequence. During focus trend feature analysis, the confidence level of the focus trend features can be calculated simultaneously; this confidence level accurately characterizes the accuracy of the focus trend features, thus providing strong support for subsequent calculations. Specifically, focus trend feature equations or neural network models can be used to analyze the image sharpness value sequence at multiple timescales to obtain the focus trend features and confidence levels; there are no restrictions on this approach.

[0060] The fuzzy rule base is based on the following: "In autofocus, if the historical image sharpness value sequence trend is upward, and the sharpness ratio of the current adjacent frame is also increasing, and the noise intensity is relatively low, then it can be determined that the subsequent trend will continue to rise; if the historical image sharpness value sequence trend is flat, and the current noise is relatively high, and the sharpness ratio of the adjacent frame is fluctuating, then it is determined that the current state is still in the flat region, and a large step search is needed to jump out of this region." Various pre-set fuzzy rules are used as examples. For instance, the fuzzy rules can be: Rule: IF trend = rising and C_(trend) = small and R = rising; THEN; positive small step search; Rule: IF trend = falling and C_(trend) = small and R = falling; THEN; reverse large step search; Rule: IF trend = flat and C_(trend) = small; THEN; positive large step search. Based on the focusing trend characteristics and confidence level, inference is performed under a preset fuzzy rule base to infer the image's current state during autofocus, corresponding to the image sharpness value sequence under the current motor status (large fluctuations in the sharpness curve indicate a flat region; small fluctuations indicate proximity to the peak). If in a flat region, a large step size is used to quickly move out of the flat region; if approaching the peak, a small step size is quickly and promptly switched to smoothly reach the peak, eliminating overshoot and jitter. Based on this strategy, the first step length of the motor in the microscope is dynamically adjusted. Under this dynamically adjusted first step length, the motor operation is controlled to quickly complete autofocus while eliminating overshoot and jitter, thus improving autofocus efficiency.

[0061] The autofocus methods in related technologies employ a hill-climbing search approach. Specifically, by gradually moving the motor, it detects changes in image sharpness (such as gradient energy and edge contrast). When sharpness decreases, the search reverses until the peak position of image sharpness is found. This type of method generally consists of two stages: a coarse search and a fine search. The coarse search stage uses a larger step size to determine the approximate range of sharpness, while the fine search uses a smaller step size to approximate the sharpest position. This method typically involves repeatedly crossing the peak 2-3 times, similar to a "bellows" effect. At high magnification and with a shallow depth of field, the sharpness curve is relatively steep. If the motor step size or speed is not set correctly, it is easy to overshoot the peak, causing the image to blur before reversing, which can easily lead to image blur and camera shake, and also results in low focusing efficiency. In this embodiment, an image sharpness value sequence is obtained based on a microscope; the image sharpness value sequence is analyzed for focusing trend characteristics at multiple time scales to obtain focusing trend characteristics and confidence levels; inference is performed based on the focusing trend characteristics and confidence levels under a preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope; based on the dynamically adjusted first step length, the microscope is automatically focused, solving the problems of overshoot and jitter and low focusing efficiency in related technologies. By using focusing trend characteristics and confidence levels to perform inference under a fuzzy rule base, large step lengths are used to quickly move out of the flat area where the sharpness curve fluctuates greatly during the automatic focusing process, and small step lengths are quickly and timely switched to smoothly reach the peak position where the sharpness curve fluctuates less, thereby eliminating the problem of overshoot and jitter and improving the efficiency of automatic focusing.

[0062] The steps described above are explained in detail below:

[0063] In some embodiments, step S210, which involves obtaining an image sharpness value sequence based on a microscope, includes the following steps:

[0064] Step S211: During the operation of the motor in the microscope, images and corresponding image sharpness value sequences are acquired; an upward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is close to the sharp position; a downward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is far from the sharp position.

[0065] Specifically, during the microscope's autofocus process, a motor moves in steps; each movement captures a frame of image, and each frame corresponds to a sequence of image sharpness values. After running for a certain period, this sequence of image sharpness values ​​is obtained. Each frame of the image sharpness value sequence has an image sharpness value, representing the current level of image sharpness; the sharper the image, the larger this value. An upward trend in the sharpness curve of the image sharpness value sequence can be considered as the focus approaching a sharp position; a downward trend indicates the focus moving away from a sharp position.

[0066] In this embodiment, the operation of a motor within the microscope is used to acquire an image sharpness value sequence, ensuring data accuracy and preparing for subsequent autofocus. In other embodiments, the image sharpness value sequence is a historical sequence of image sharpness values, eliminating the need for re-acquisition and further accelerating autofocus efficiency.

[0067] In some of these embodiments, such as Figure 3 As shown, step S220 involves performing focus trend feature analysis on the image sharpness value sequence across multiple time scales to obtain focus trend features and confidence levels. This includes the following steps:

[0068] Step S221: Determine the slope value of the image sharpness value sequence at multiple time scales;

[0069] Step S222: Determine the focusing trend characteristics based on the slope value;

[0070] Step S223: Substitute the noise intensity in the focus trend features and image sharpness value sequence into the preset trend confidence formula to obtain the confidence level.

[0071] Specifically, the focus trend feature refers to the overall trend of the image sharpness value sequence. Therefore, in this embodiment, it is calculated by calculating the slope value. Specifically, the slope value of the image sharpness value sequence is determined at multiple time scales; based on the slope value, the focus trend feature is determined. Generally, the image sharpness value sequence can be considered as a linear equation (Sn=K×tn+b), and the slope value K (i.e., the trend) can be obtained by least squares.

[0072] For example: The sequence of image sharpness values ​​is represented as a set [S1, S2, ..., Sn], where each element represents the image sharpness at time t, i.e., S. i For t i The image sharpness value at any given time; to improve the accuracy of trend description, a sharpness trend formula is used for calculation, the expression of which is:

[0073]

[0074] In the formula, K represents the focus trend characteristic, i.e., the overall trend of the image sharpness value sequence. If K > 0, it indicates that the image sharpness trend is increasing, and the current search direction is correct. When K < 0, it indicates that the image sharpness trend is decreasing, and a reverse search may be necessary. If K = 0, it indicates that the image sharpness trend is flat. The larger |K| is, the more significant the trend is. n is the total number of frames in the image sharpness value sequence.

[0075] To more accurately describe the above trend, a trend confidence formula is introduced to calculate the confidence level corresponding to the focus trend feature. This formula is used to further evaluate the reliability of the trend by incorporating the noise level of the image sharpness value sequence. Its expression is:

[0076]

[0077] In the formula, C trend For trend confidence; σ noise Let be the noise intensity of the image sharpness value sequence; ε be a very small constant (e.g., 0.001); where the noise fluctuation is relatively large in areas where the image sharpness is relatively flat, and relatively small in areas where there is a significant increase or decrease in noise. If the variance or standard deviation of the image sharpness value sequence is simply calculated to evaluate the noise intensity, the noise intensity will be relatively large when there is a significant increase or decrease in the image sharpness value sequence. Therefore, in this embodiment, the above formula is used to accurately describe the noise intensity.

[0078] Furthermore, to more accurately describe the noise intensity of the image sharpness value sequence, the following method is used: by fitting a trend line of the image sharpness value sequence, the residual standard deviation is calculated as a noise estimate; to achieve better fitting results, a polynomial is used to fit the trend line, as follows:

[0079] For example: The image sharpness value sequence S = [S1, S2, ..., Sn] consists of trend and noise, and is represented as:

[0080] S n =P k (n)+ε n (n = 1, 2, ..., N);

[0081] In the formula, P k (n) is a polynomial of degree k; ε n For noise, P can be solved using appropriate methods. k (n) This will not be elaborated upon further;

[0082] After the transformation, we can obtain ε. n =S n -P k If (n), then the noise intensity of the image sharpness value sequence can be expressed as:

[0083]

[0084] Therefore, when the noise intensity is low and the trend is obvious, the trend confidence level C is... trend The larger the value, the more reliable the trend. Conversely, a lower confidence level (C) indicates a more reliable trend. trend The smaller the value, the less reliable the trend is.

[0085] In some embodiments, step S230, which involves reasoning based on focusing trend features and confidence levels within a preset fuzzy rule base to obtain the first step length of the motor in the microscope, includes the following steps:

[0086] Step S231: The focus trend features and confidence scores are input into a preset membership function for fuzzing.

[0087] Step S232: Perform fuzzy inference on the fuzzification result based on the fuzzy rule table in the fuzzy rule base;

[0088] Step S233: Defuzzify the fuzzy inference result to dynamically adjust the first step length of the motor in the microscope.

[0089] In this embodiment, the reasoning can be considered to be performed within the framework of a fuzzy reasoning engine. Reasoning refers to an imprecise reasoning mechanism that transforms a given input into an output through fuzzy rules in the fuzzy rule table of the fuzzy rule base.

[0090] like Figure 4 As shown, the fuzzy inference engine framework includes fuzzification, a fuzzy rule base, fuzzy inference, and defuzzification. Fuzzification involves inputting the focusing trend features and confidence levels into a preset membership function for fuzzification. The fuzzy rule base is pre-set and contains a built-in fuzzy rule table (as shown in Table 1). The fuzzy rule table contains various fuzzy rules; in other embodiments, the fuzzy rule table can be implemented using expert debugging experience, and this is not restricted. Fuzzy inference involves performing fuzzy reasoning on the fuzzification results based on the fuzzy rule table in the fuzzy rule base. This can be considered as the process of obtaining fuzzy conclusions from the membership degrees of fuzzy rules and inputs to relevant fuzzy sets. Defuzzification involves defuzzifying the fuzzy inference results to generate a specific result, namely, outputting the first step length of the motor in the dynamically adjusted microscope. Through this process, the input focusing trend features and confidence levels are converted into a dynamic first step length output to control the motor's operation during the autofocus search process.

[0091] Table 1

[0092] <![CDATA[Rule 1: IF Trend = Rising and C trend = Small and R = Rising; THEN; Search in small positive steps]]> <![CDATA[Rule 2: IF Trend = Rising and C trend = Medium and R = Rising; THEN; Positive large-step search]]> <![CDATA[Rule 3: IF Trend = Rising and C trend = Medium and R = Falling; THEN; Reverse small step search]]> <![CDATA[Rule 4: IF Trend = Down and C]] trend = Small and R = Down; THEN; Reverse large step search]]> <![CDATA[Rule 5: IF Trend = Flat and C trend = Small; THEN; Positive large step search]]> <![CDATA[Rule 6: IF Trend = Flat and C trend = High; THEN; Positive small step search]]>

[0093] The above process is illustrated with an example below:

[0094] For blurring: Based on the image sharpness value sequence S=[S1,S2,...,Sn], calculate the trend K and noise intensity σ of the image sharpness value sequence of the window sequence between the nth frame and the ntth frame. noise (Preferred, the time scale t is 5 to 7), and the resolution ratio R between the nth frame and the (n-1)th adjacent frame.

[0095] Define the trend K and noise intensity σ respectively. noise The scope of discourse, blur marker, and membership functions for the sharpness ratio R, including trend membership function, trend confidence membership function, and adjacent frame ratio membership function. Example: Specific definitions are provided, but please understand that the following specific definitions are only examples.

[0096] Assuming the universe of discourse for trend K is [-10, 10], and the fuzzy labels are categorized as decreasing, flat, and increasing, then the trend membership function is defined as follows: Figure 5 As shown.

[0097] Based on the trend K, the trend confidence level C can be determined. trend The universe of discourse is [0, 10]. After normalization, the universe of discourse is adjusted to [0, 1]. Fuzzy labels are low, medium, and high. The trend confidence membership function is defined as follows: Figure 6 As shown.

[0098] The universe of discourse for the sharpness ratio R between adjacent frames is [0,2]. Blur is denoted as decreasing, fluctuating, or increasing. Then, the membership function for the adjacent frame ratio is as follows: Figure 7 As shown.

[0099] If the trend of the image sharpness value sequence S is 2.5, the noise intensity is 0.5, the trend confidence is 50%, and the sharpness ratio is 1.2; substitute these parameters into the above membership functions to obtain the corresponding membership tables, as shown in Table 2 (Trend Membership Table), Table 3 (Trend Confidence Membership Table), and Table 4 (Adjacent Frame Ratio Membership Table).

[0100] Table 2

[0101] Fuzzy Marking Membership degree decline 0 flat 0.04 rise 0.25

[0102] Table 3

[0103] Fuzzy Marking Membership degree Low 0.167 middle 1 high 0.167

[0104] Table 4

[0105] Fuzzy Marking Membership degree decline 0 fluctuation 0.14 rise 0.2

[0106] The fuzzy inference process involves applying the fuzzy rules in Table 1 to the fuzzified results. For example, to calculate the trigger strength of rule 1: with a trend of 0.25, a trend confidence of 0.167, and a sharpness ratio of 0.2, the trigger strength is: min{0.25, 0.167, 0.2} = 0.167. Similarly, the trigger strength of rule 2 can be calculated as 0.2; the trigger strength of rule 3 can be calculated as 0; the trigger strength of rule 4 can be calculated as 0; the trigger strength of rule 5 can be calculated as 0.04; and the trigger strength of rule 6 can be calculated as 0.04.

[0107] Among them, defuzzification: After obtaining the trigger strength of each rule based on fuzzy rule reasoning, the trigger strength of each rule can be processed to obtain the first step number after defuzzification, so as to complete the first step length of the motor in the microscope for dynamic adjustment.

[0108] This embodiment optimizes the algorithm and reduces application costs. It combines focus trend features with a fuzzy inference framework to dynamically adjust the first step length of focus, thereby solving the problems of current focus algorithms that rely too much on local information for step length search and have too simple and rigid step length strategies. This embodiment ensures that the autofocus performance and effect can meet user needs in multiple focus scenarios.

[0109] In some embodiments, the defuzzification of the fuzzy inference result in step S233 to dynamically adjust the first step length of the motor in the microscope includes the following steps:

[0110] Clustering and integration are performed based on preset step size control points and fuzzy inference results to obtain clustering and integration results;

[0111] Defuzzification of cluster integration is performed to dynamically adjust the first step length of the motor in the microscope.

[0112] Specifically, the fuzzy inference result can be considered as the trigger strength of each rule. The step size control point is set in advance based on the step size value range. For example, setting the step size value range to [-30, 30], the step size membership function is as follows: Figure 8 As shown. The step size control points are then set to [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30].

[0113] Based on this, the step size points were clustered and integrated according to the reasoning results, and the clustering and integration results are shown in Table 5.

[0114] Table 5

[0115] rule set Fuzzy reasoning results Step point set Rule 1, Rule 6 Positive small step size 5 Rule 2, Rule 5 Positive stride length 10,15,20,25,30 Rule 3 Reverse small step -5 Rule 4 Reverse large step -10,-15,-20,-25,-30

[0116] The cluster integration was defuzzified, and the defuzzification results are shown in Table 6.

[0117] Table 6

[0118] Step value Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Weight 5 0.167 / / / / 0.04 0.167 10 / 0.04 / / 0.008 / 0.04 15 / 0.08 / / 0.016 / 0.08 20 / 0.12 / / 0.024 / 0.12 25 / 0.16 / / 0.032 / 0.16 30 / 0.2 / / 0.04 / 0.2 -5 / / 0 / / / 0 -10 / / / 0 / / 0 -15 / / / 0 / / 0 -20 / / / 0 / / 0 -25 / / / 0 / / 0 -30 / / / 0 / / 0

[0119] Taking step size 5 as an example: it is derived from rules 1 and 6, belonging to the positive small step size category, so its membership degree is 1. The trigger strength of rule 1 is 0.167, and the trigger strength of rule 6 is 0.04. Therefore, the weight of step size 5 is max{1×0.167,1×0.04}=0.167. Similarly, the weights of other step size values ​​can be obtained.

[0120] Then, based on the weight values ​​of each step point, they are substituted into the preset centroid formula for calculation, as follows:

[0121] Rounding down yields a final deblurred step size of 19.

[0122] This embodiment enables accurate calculation of the first step length for each step, thereby allowing dynamic adjustment of the first step length of the motor in the microscope.

[0123] In some embodiments, step S240, which involves autofocusing the microscope based on a dynamically adjusted first step length, includes the following steps:

[0124] Step S241: Based on the motor of the first step long moving microscope dynamically adjusted, determine whether to enter the fine adjustment mode.

[0125] Step S242: When it is determined that the fine-tuning mode has been entered, a trial search is performed based on the preset second step length. When the clearest position is found, the microscope is automatically focused; the second step length is less than the first step length.

[0126] Specifically, as the image sharpness value sequence shows an upward trend in sharpness curve when focusing near the sharp position, the trend slows down. The motor is adjusted using the first step length obtained above. Each time the motor is adjusted, the previous data is used to infer the first step length for the next adjustment. When the first step length changes from positive to negative, it indicates that the sharp position has been exceeded, and the system is entered into fine-tuning mode. A trial search is then performed based on a preset second step length, which is smaller than the first step length, thus finding the sharpest focus position.

[0127] After the fuzzy inference-based search is complete, the motor has stopped near the sharpest focus position. At this point, only a few small steps (the second step) are needed for trial searching. The trial search is as follows: adjust the motor one step with the second step (which can be 1 step), sample the image sharpness once, and then continue to iterate and adjust multiple times. When it is found that the motor has passed the sharpest focus position (the maximum sharpness value), a step back is then taken to complete the focusing. In other embodiments, the second step can be appropriately increased, such as sampling every 2 steps, etc., and there is no limitation on this. The calculation of the maximum sharpness value can be obtained by quadratic curve fitting or polynomial curve fitting, and there is no limitation on this.

[0128] This embodiment can speed up the autofocus search process and improve focusing efficiency.

[0129] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0130] This embodiment also provides an autofocusing device for a microscope, which implements the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below refer to combinations of software and / or hardware that perform a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0131] Figure 9 This is a structural block diagram of the autofocus device for a microscope in this embodiment, as shown below. Figure 9 As shown, the device includes: an acquisition module 210, an analysis module 220, an inference module 230, and a focusing module 240;

[0132] The acquisition module 210 is used to acquire a sequence of image sharpness values ​​based on a microscope;

[0133] Analysis module 220 is used to perform focus trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence level;

[0134] The inference module 230 is used to perform inference based on the focusing trend characteristics and confidence level under a preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope.

[0135] The focusing module 240 is used to autofocus the microscope based on a dynamically adjusted first step length.

[0136] The aforementioned device solves the problems of overshoot and low focusing efficiency in related technologies. By using focusing trend features and confidence levels to perform inference under a fuzzy rule base, it enables the autofocus process to quickly move out of the flat area with large step sizes in the flat area where the sharpness curve fluctuates greatly, and quickly and timely switch to small step sizes to smoothly reach the peak position when the sharpness curve fluctuates less. This eliminates the problem of overshoot and improves autofocus efficiency.

[0137] In some embodiments, the acquisition module 210 is also used to acquire images and corresponding image sharpness value sequences during the operation of the motor in the microscope; an upward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is close to the sharp position; a downward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is far from the sharp position.

[0138] In some embodiments, the analysis module 220 is also configured to determine the slope value of the image sharpness value sequence at multiple time scales;

[0139] Based on the slope value, the focusing trend characteristics are determined;

[0140] The confidence level is obtained by substituting the noise intensity in the focus trend features and image sharpness value sequence into the preset trend confidence formula.

[0141] In some embodiments, the inference module 230 is also used to fuzzify the focus trend features and confidence scores into a preset membership function;

[0142] Fuzzy inference is performed on the fuzzification results based on the fuzzy rule table in the fuzzy rule base.

[0143] The fuzzy inference results are defuzzified in order to dynamically adjust the first step length of the motor in the microscope.

[0144] In some embodiments, the inference module 230 is further configured to perform clustering and integration based on preset step size control points and fuzzy inference results to obtain clustering and integration results;

[0145] Defuzzification of cluster integration is performed to dynamically adjust the first step length of the motor in the microscope.

[0146] In some of these embodiments, the membership function includes a trend membership function, a trend confidence membership function, and an adjacent frame ratio membership function.

[0147] In some embodiments, the focusing module 240 is also configured to determine whether to enter fine-tuning mode based on the motor of the first step long moving microscope that is dynamically adjusted.

[0148] When it is determined that the fine-tuning mode has been entered, a trial search is performed based on the preset second step length. When the clearest position is found, the microscope is automatically focused; the second step length is less than the first step length.

[0149] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0150] This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0151] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0152] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0153] S1, Based on the microscope, obtain the image sharpness value sequence;

[0154] S2, perform focus trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence level;

[0155] S3, based on the focusing trend characteristics and confidence level, infers under the preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope;

[0156] S4 automatically focuses the microscope based on the dynamically adjusted first step length.

[0157] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.

[0158] Furthermore, in conjunction with the autofocus method for a microscope provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the autofocus methods for a microscope described in the above embodiments.

[0159] It should be noted that all information and data involved in this application are authorized by the user or fully authorized by all parties and will be used legally.

[0160] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0161] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.

[0162] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0163] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.

Claims

1. An autofocusing method for a microscope, characterized in that, include: Based on the microscope, obtain an image sharpness value sequence; Focus trend feature analysis was performed on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels. Based on the focusing trend characteristics and the confidence level, inference is performed under a preset fuzzy rule base to dynamically adjust the first step length of the motor in the microscope; The microscope is automatically focused based on the dynamically adjusted first step length.

2. The autofocusing method for a microscope according to claim 1, characterized in that, Based on the microscope, an image sharpness value sequence is obtained, including: During the operation of the motor in the microscope, multiple frames of images and corresponding image sharpness value sequences are acquired; an upward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is close to the sharp position; a downward trend in the sharpness curve of the image sharpness value sequence indicates that the focus is far from the sharp position.

3. The autofocusing method for a microscope according to claim 1, characterized in that, Focus trend feature analysis is performed on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels, including: Determine the slope value of the image sharpness value sequence at multiple time scales; Based on the slope value, the focusing trend feature is determined; The confidence level is obtained by substituting the focus trend features and the noise intensity in the image sharpness value sequence into a preset trend confidence formula.

4. The autofocusing method for a microscope according to claim 1, characterized in that, Based on the focusing trend characteristics and the confidence level, reasoning is performed under a preset fuzzy rule base to obtain the first step length of the motor in the microscope, including: The focusing trend features and the confidence level are input into a preset membership function for fuzzing; Based on the fuzzy rule table in the fuzzy rule base, fuzzy inference is performed on the fuzzification result; The fuzzy inference results are defuzzified in order to dynamically adjust the first step length of the motor in the microscope.

5. The autofocusing method for a microscope according to claim 4, characterized in that, Defuzzifying the fuzzy inference results to dynamically adjust the first step length of the motor in the microscope includes: Clustering and integration are performed based on preset step size control points and fuzzy inference results to obtain clustering and integration results; The clustering integration is defuzzified to dynamically adjust the first step length of the motor in the microscope.

6. The autofocusing method for a microscope according to claim 4, characterized in that, The membership functions include trend membership function, trend confidence membership function, and adjacent frame ratio membership function.

7. The autofocusing method for a microscope according to claim 1, characterized in that, Based on the dynamically adjusted first step length, the microscope is automatically focused, including: The first step of the dynamic adjustment moves the microscope motor and determines whether to enter the fine-tuning mode. When it is determined that the fine-tuning mode has been entered, a trial search is performed based on a preset second step length. When the clearest position is found, the microscope is automatically focused; the second step length is less than the first step length.

8. An autofocusing device for a microscope, characterized in that, include: The module includes an acquisition module, an analysis module, an inference module, and a focusing module. The acquisition module is used to acquire an image sharpness value sequence based on the microscope; The analysis module is used to perform focus trend feature analysis on the image sharpness value sequence at multiple time scales to obtain focus trend features and confidence levels. The reasoning module is used to perform reasoning based on the focusing trend characteristics and the confidence level under a preset fuzzy rule base, so as to dynamically adjust the first step length of the motor in the microscope. The focusing module is used to automatically focus the microscope based on the dynamically adjusted first step length.

9. A surgical microscope, comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the steps of the autofocusing method for a microscope as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the autofocusing method for a microscope as described in any one of claims 1 to 7.

Citation Information

Cited By

  • An airborne optical imaging intelligent focusing system and method based on deep learning

    CN122513656B