Automatic focusing method and device and computer equipment
By acquiring and analyzing reference images at different objective lens positions in a microscope, and combining blur and sharpness features with a machine learning model, the focal plane can be quickly locked, solving the problems of low efficiency and high computational load in microscope autofocus technology, and achieving a highly efficient focusing process.
Patent Information
- Application Number
- CN202511937785.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2045-12-22
AI Technical Summary
Existing microscope autofocus technology suffers from low focusing efficiency and high computational load, making it difficult to meet the needs of high-speed scanning and real-time detection.
By controlling the movement of the microscope objective lens, reference images are acquired at different objective lens positions. The position of the target focal plane is determined by using blur and sharpness features. Combined with a machine learning model, the focal plane is quickly locked, reducing the amount of image acquisition and computational burden.
While maintaining focusing accuracy, it significantly improves focusing efficiency and reduces computational load, making it suitable for high-speed scanning and real-time detection scenarios.
Smart Images

Figure CN121364556A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of microscope technology, in particular to an automatic focusing method and device and computer equipment. BACKGROUND
[0002] In the field of microscopic observation, automatic focusing technology is the key to guarantee imaging quality and observation efficiency. With the improvement of image sensor performance, people have higher requirements for the speed and accuracy of automatic focusing technology.
[0003] In the traditional technology, the focusing depth method is used for automatic focusing, which requires collecting a large amount of image data in different focusing states, resulting in a large number of image collections. Although it can ensure accuracy to some extent, the data processing amount is large and the focusing time is long, which is difficult to meet the needs of high-speed scanning, real-time detection and other scenes.
[0004] It can be seen that in the field of microscope automatic focusing in the prior art, there are still problems of low focusing efficiency and large amount of calculation. SUMMARY
[0005] Therefore, it is necessary to provide an automatic focusing method, device and computer equipment which can improve the focusing efficiency and reduce the calculation amount under the premise of ensuring the focusing accuracy.
[0006] In a first aspect, the present application provides an automatic focusing method applied to a microscope, the automatic focusing method comprising:
[0007] In response to an automatic focusing instruction, controlling a moving of an objective lens according to a first step value corresponding to an imaging parameter of the microscope, and collecting at least two first reference images in different objective lens positions;
[0008] According to the objective lens position and the blur feature corresponding to the first reference image, determining a first objective lens position;
[0009] According to the first objective lens position and a preset second step value, controlling the moving of the objective lens, and collecting at least two second reference images in different objective lens positions;
[0010] According to the objective lens position and the sharpness feature corresponding to the second reference image, determining a target focal plane position and completing focusing.
[0011] In one embodiment, the imaging parameter includes a depth of field parameter; the first reference image includes a first current reference image and a first step reference image; and the step of controlling the moving of the objective lens according to the first step value corresponding to the imaging parameter of the microscope in response to the automatic focusing instruction and collecting at least two first reference images in different objective lens positions includes:
[0012] collecting a first current reference image under a current objective lens position;
[0013] controlling the objective lens to move at least once according to a first step value corresponding to the depth of field parameter, and collecting at least one first step reference image.
[0014] In one of the embodiments, the determining the first objective lens position according to the objective lens position and the blur characteristic corresponding to the first reference image comprises:
[0015] calculating the blur characteristic of each of the first reference images according to a preset blur algorithm;
[0016] calculating the ratio of the blur characteristics and the difference of the objective lens positions of each two of the first reference images in sequence to obtain the relative blur change characteristic of the first reference images;
[0017] determining the first objective lens position according to the relative blur change characteristic.
[0018] In one of the embodiments, the determining the first objective lens position according to the relative blur change characteristic comprises:
[0019] inputting the relative blur change characteristic into a pre-trained objective lens position prediction model to obtain the first objective lens position.
[0020] In one of the embodiments, the training process of the objective lens position prediction model comprises:
[0021] controlling the objective lens to move according to a preset step interval within the movable range of the objective lens of the microscope to obtain sample images of the target sample under each objective lens position;
[0022] calculating the blur characteristic of each of the sample images according to a preset blur algorithm;
[0023] calculating the ratio of the blur characteristics and the difference of the objective lens positions of each two of the sample images in sequence to obtain the relative blur change characteristic, and taking the difference or the subtracted number corresponding to the difference of the objective lens positions as the real objective lens position of the relative blur change characteristic.
[0024] training a preset machine learning model according to the relative blur change characteristics and the real objective lens positions to obtain the objective lens position prediction model.
[0025] In one of the embodiments, the calculating the blur characteristic of each of the images according to a preset blur algorithm comprises:
[0026] performing image feature extraction on the image according to a preset gradient operator to obtain gradient information; the gradient information comprises horizontal gradient and vertical gradient.
[0027] The sum of the horizontal gradient and the absolute value of the vertical gradient is taken as the blur degree feature of the image.
[0028] In one embodiment, the acquiring of the second reference images at different objective lens positions according to the first objective lens position and the preset second step value comprises:
[0029] The objective lens is controlled to move to a target position according to the first objective lens position and the second step value, and images at different objective lens positions are acquired; the target position comprises at least two of the first objective lens position, the difference between the first objective lens position and the second step value, and the sum of the first objective lens position and the second step value.
[0030] In one embodiment, the determining of the target focal plane position and the completion of focusing according to the objective lens position corresponding to the second reference image and the sharpness feature comprises:
[0031] The sharpness feature of each of the second reference images is calculated according to a preset sharpness algorithm.
[0032] The target reference image is selected according to the sharpness feature of each of the second reference images, and the objective lens position corresponding to the target reference image is taken as the target focal plane position.
[0033] The objective lens is controlled to move to the target focal plane position.
[0034] In a second aspect, the present application provides an automatic focusing device applied to a microscope, the automatic focusing device comprising:
[0035] A first moving module is configured to acquire first reference images at different objective lens positions by controlling the objective lens to move according to a first step value corresponding to the imaging parameter of the microscope in response to an automatic focusing instruction.
[0036] A position analysis module is configured to determine a first objective lens position according to the objective lens position corresponding to the first reference image and a blur degree feature.
[0037] A second moving module is configured to acquire second reference images at different objective lens positions by controlling the objective lens to move according to a preset second step value and the first objective lens position.
[0038] A focal plane analysis module is configured to determine a target focal plane position and complete focusing according to the objective lens position corresponding to the second reference image and a sharpness feature.
[0039] In a third aspect, the present application provides a computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the method described above when executing the computer program.
[0040] The automatic focusing method, device and computer equipment can determine the first objective lens position according to the blur degree feature corresponding to the first reference image and the objective lens position of the first reference image, control the movement of the objective lens according to the first objective lens position and the preset second step value, collect at least two second reference images at different objective lens positions, determine the target focal plane position according to the sharpness feature corresponding to the second reference image and the objective lens position of the second reference image, and complete focusing. The first step value is determined according to the imaging parameter, the first reference image is collected, the coarse adjustment process can be more adapted to the microscope, the rapid determination of the first objective lens position is driven by the blur degree feature, the second step value is used for collection and the sharpness feature is obtained, and finally the target focal plane position is locked. Therefore, the image collection amount and the calculation burden can be significantly reduced while the focusing accuracy is maintained, the technical effects of improving the focusing efficiency and reducing the calculation amount under the premise of ensuring the focusing accuracy are achieved. BRIEF DESCRIPTION OF DRAWINGS
[0041] Figure 1 An application environment diagram of the automatic focusing method in an embodiment is shown;
[0042] Figure 2 A flowchart of the automatic focusing method in an embodiment is shown;
[0043] Figure 3 A flowchart of the automatic focusing method in another embodiment is shown;
[0044] Figure 4 A flowchart of the automatic focusing method in another embodiment is shown;
[0045] Figure 5 A structural block diagram of the automatic focusing device in an embodiment is shown;
[0046] Figure 6 An internal structure diagram of the computer equipment in an embodiment is shown. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application.
[0048] The automatic focusing method provided by the embodiments of the present application can be applied to, for example, Figure 1The application environment shown. Among them, the terminal 102 communicates with the image acquisition device 106 arranged on the microscope 104 through the wired network. The terminal 102 controls the objective lens to move according to the first step value corresponding to the imaging parameter of the microscope in response to the automatic focusing instruction, acquires at least two first reference images of different objective lens positions, and acquires at least two first reference images of different objective lens positions through the image acquisition device 106; according to the objective lens position and the blur characteristic corresponding to the first reference image, the first objective lens position is determined; according to the first objective lens position and the preset second step value, the objective lens is controlled to move, and at least two second reference images of different objective lens positions are acquired; according to the objective lens position and the definition characteristic corresponding to the second reference image, the target focal plane position is determined and the focusing is completed. Wherein, the terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones and tablet computers and other terminal devices.
[0049] In one embodiment, as shown in Figure 2 , an automatic focusing method is provided, and the method is applied to the terminal 102 in Figure 1 for example, which includes the following steps:
[0050] Step S100, in response to an automatic focusing instruction, the objective lens is controlled to move according to the first step value corresponding to the imaging parameter of the microscope, and at least two first reference images of different objective lens positions are acquired.
[0051] Wherein, the automatic focusing instruction can be a control signal for triggering the automatic focusing process, and further, the automatic focusing instruction can be used to start the microscope automatic focusing process, so that the system is switched from standby state to focusing calculation and execution mode.
[0052] The imaging parameter can be a set of optical and electronic parameters that affect the quality of microscope image acquisition, which can be used to determine the resolution and contrast characteristics of image acquisition. Exemplarily, the imaging parameter can include but is not limited to one or more of depth of field, magnification, light source wavelength, sensor resolution, etc.
[0053] The first step value can be the step unit of the objective lens moving along the optical axis direction in the coarse focusing stage. The first step value can be used to realize the rapid scanning of a large range of focal plane area and reduce the number of image acquisition. The first step value can include but is not limited to step ratio based on magnification, step interval based on depth of field estimation, compensation step length based on system response delay, etc. Correspondingly, the first reference image can be a set of images collected at different objective lens positions in the coarse focusing stage. Exemplarily, the first reference image can be used to provide low-density sampling data of a large range of focal plane area for preliminary judgment of blur trend.
[0054] Further, the first step value corresponding to the imaging parameter of the microscope is used to control the movement of the objective lens. After receiving the auto-focusing instruction, the first step value is calculated or called according to the imaging parameter, and the step motor is driven to adjust the position of the objective lens along the optical axis. In an exemplary embodiment, the first step value can be obtained by looking up a table according to the mapping relationship between the depth of field, the numerical aperture of the objective lens, and the first step value, and the actuator is driven to execute, so that the initial motion reference of the rough search can be established, and the movement of the objective lens at a predetermined interval can be ensured.
[0055] In step S200, the first objective lens position is determined according to the objective lens position corresponding to the first reference image and the blur characteristic.
[0056] The blur characteristic can be a quantitative index reflecting the degree of loss of image details, and can be used to quickly evaluate the image blur trend under the condition of large step, so as to realize rough positioning with low computational overhead. For example, the blur characteristic can include any one or more of the gradient amplitude sum, the frequency domain low frequency energy ratio, the local variance mean, etc. according to different calculation methods.
[0057] The first objective lens position can be a rough focal plane coordinate calculated based on the first reference image and the blur characteristic. Accordingly, the first objective lens position can be determined according to the objective lens position corresponding to the first reference image and the blur characteristic, which can be to calculate the blur characteristic for each first reference image, to construct a curve of the blur characteristic changing with the objective lens position, and to determine the position of the extreme point through fitting. In an exemplary embodiment, the first objective lens position can be determined according to the objective lens position corresponding to the first reference image and the blur characteristic, which can use cubic spline interpolation to fit the blur characteristic curve, and find the maximum point as the first objective lens position, so that the rough positioning of the large range focal plane can be realized, the search space can be significantly reduced, and the consumption of computing resources can be reduced.
[0058] In step S300, the movement of the objective lens is controlled according to the first objective lens position and the preset second step value, and at least two second reference images at different objective lens positions are acquired.
[0059] The second step value can be a step unit of the movement of the objective lens along the optical axis in the fine focusing stage.
[0060] The second reference image can be a set of images collected at different objective lens positions in the fine focusing stage, which is used to provide high-density sampling data near the target focal plane, so as to realize accurate definition distribution evaluation.
[0061] In the embodiment, the first objective lens position can be taken as a reference, and the objective lens can be driven forward or backward by a preset second step value to form a local search interval. Further, the first objective lens position and the preset second step value can be used to control the movement of the objective lens, and one or more step points can be taken on one side or both sides of the first objective lens position, so as to limit the fine search range to the vicinity of the coarse focus plane and avoid repeated sampling of invalid areas.
[0062] In step S400, the target focus plane position is determined according to the objective lens position corresponding to the second reference image and the definition feature, and the focusing is completed.
[0063] The definition feature can be a quantitative index reflecting the richness of image details, so as to accurately evaluate the image quality under the condition of small step and support high-precision focus plane positioning. For example, the definition feature can include but is not limited to Laplacian variance, Tenengrad gradient energy, Brenner gradient, etc.
[0064] The target focus plane position can be the optimal imaging focus plane coordinate determined after fine search. The target focus plane position can be used as the final focusing output to control the objective lens to stop at the best imaging position. The target focus plane position can include but is not limited to the position corresponding to the maximum definition, the position of the gradient zero point, the position corresponding to the variance peak, etc.
[0065] According to the objective lens position corresponding to the second reference image and the definition feature, the definition feature of each second reference image can be calculated, a curve of the definition changing with the objective lens position can be constructed, the peak point can be located, and the objective lens can be moved to the position. Alternatively, the objective lens position with the highest definition can be found from the plurality of definition features as the target focus plane.
[0066] The automatic focusing method provided in the embodiment can control the movement of the objective lens according to the first step value corresponding to the imaging parameter of the microscope in response to the automatic focusing instruction, acquire at least two first reference images at different objective lens positions, determine the first objective lens position according to the objective lens position corresponding to the first reference image and the blur degree feature, control the movement of the objective lens according to the first objective lens position and the preset second step value, acquire at least two second reference images at different objective lens positions, determine the target focus plane position according to the objective lens position corresponding to the second reference image and the definition feature, and complete the focusing. The first step value is determined by the imaging parameter, the first reference image acquisition is guided, the coarse adjustment process can be more adapted to the microscope, the blur degree feature is calculated to drive the rapid determination of the first objective lens position, the second step value is used for acquisition and the definition feature is obtained, and finally the target focus plane position is locked. Therefore, the image acquisition amount and the calculation burden can be significantly reduced while the focusing accuracy is maintained, and the technical effects of improving the focusing efficiency and reducing the calculation amount under the premise of ensuring the focusing accuracy are achieved.
[0067] In one embodiment, the imaging parameter comprises a depth of field parameter; the first reference image comprises a first current reference image and a first step reference image; in response to the auto-focusing instruction, the objective lens is controlled to move according to a first step value corresponding to the imaging parameter of the microscope, and the first reference image is obtained by capturing at least two images at different positions of the objective lens, comprising:
[0068] capturing the first current reference image at the current position of the objective lens;
[0069] controlling the objective lens to move at least once according to a first step value corresponding to the depth of field parameter, and obtaining at least one first step reference image.
[0070] The depth of field parameter can be the range of axial distance allowed by the objective lens in the microscope under the premise of maintaining acceptable image clarity, which can ensure that the step distance matches the resolution characteristics of the optical system and avoid excessive sampling density.
[0071] The first current reference image can be a reference image captured when the objective lens is at the current preset position at the start of the auto-focusing process, which can be used to provide a clarity reference for the starting point of focusing. In one exemplary embodiment, the first current reference image can trigger the imaging sensor immediately after responding to the auto-focusing instruction without any displacement, capturing the image at the current position of the objective lens, thereby establishing a physical starting reference for the focusing process and avoiding starting from a random position to search, improving the reliability of trend judgment.
[0072] The first step reference image can be an auxiliary image captured after moving the objective lens according to the step value calculated based on the depth of field parameter, which can be used to provide a small number of physically meaningful comparison samples for quickly judging the trend of blur change and supporting the preliminary inference of the first objective lens position. In this embodiment, the first step reference image can be moved one or more times along the optical axis direction after capturing the first current reference image and corresponding images are obtained. Further, one or more first step reference images can be captured by moving once in the direction of expected blur decrease, or two or more first step reference images can be captured by moving once in each of the positive and negative directions to construct a blur change gradient, thereby realizing the minimum necessary sampling under physical and optical constraints and compressing the image acquisition amount in the rough search stage to one to three images, significantly reducing the data volume and computational load.
[0073] The automatic focusing method provided by the embodiment can establish a definition reference of a focusing starting point and provide a minimum necessary sampling under physical optical constraints by collecting a first current reference image under a current objective lens position and collecting at least one first step reference image by controlling the objective lens to move at least once according to a first step value corresponding to a depth of field parameter, can change blind search depending on fixed steps or statistical models in the traditional method into directional sampling based on inherent characteristics of an optical system, and thus can compress the image collection amount from five to ten images in the traditional method to two to three images in the rough focusing stage, significantly reduce the calculation burden, and achieve the technical effects of improving the focusing efficiency and reducing the calculation amount under the premise of ensuring the focusing accuracy.
[0074] In one of the embodiments, the first objective lens position is determined according to the objective lens position corresponding to the first reference image and the blur characteristic.
[0075] The blur characteristic of each first reference image is calculated according to a preset blur algorithm.
[0076] The ratio of the blur characteristics of each two first reference images and the difference of the corresponding objective lens positions are sequentially calculated to obtain the relative change characteristic of the blur of the first reference image.
[0077] The first objective lens position is determined according to the relative change characteristic of the blur.
[0078] The preset blur algorithm can be a set of mathematical calculation rules for quantifying the degree of image blur, and can provide a reproducible and comparable blur value output for the first reference image. For example, the preset blur algorithm can use any one or more of the blur algorithms including but not limited to Laplacian variance, Tenengrad gradient energy, Brenner gradient, etc. For example, the blur characteristic can be obtained by calculating the variance after performing Laplacian convolution on the local region of the image, or the blur characteristic can be obtained by summing and normalizing the square of the gradient amplitude of the image, or the blur characteristic can be obtained by other blur characteristics calculated by using existing blur algorithms to generate a blur sequence of discrete sampling points, which is not limited in the embodiment.
[0079] The ratio of the blur characteristics can be the quotient value between the blur characteristics of two adjacent first reference images, which can present the relative change of the blur characteristics. It can be understood that the relative value can effectively eliminate the influence of system gain, illumination intensity drift, etc. on the absolute blur value, thereby improving the stability of the change trend judgment.
[0080] The ratio of the blur degree features of each two first reference images can be calculated in sequence, which can be a division operation on the blur degree feature values of the adjacent two first reference images to obtain a proportion index, or can be a ratio of the blur degree features of any two first reference images calculated by permutation and combination, which can include a forward blur degree feature ratio and a backward blur degree feature ratio. Further, the relative change feature of the blur degree can also be the logarithmic result of the ratio to enhance the linear response, eliminate the interference of system gain and illumination fluctuation on the absolute value of the blur degree, and make the stability and comparability of the change trend higher.
[0081] The difference in objective lens position can be the spatial displacement of the objective lens in the optical axis direction when the two first reference images are collected, which can be used to provide the physical spatial scale corresponding to the change in blur degree, normalize the blur degree ratio, and construct the relative change feature. In some embodiments, the difference in objective lens position corresponding to each two first reference images can also be calculated by multiplying the fixed first step value by the difference in image number, and can also be achieved by reading the actual position of the step motor encoder and calculating the difference.
[0082] The relative change feature of the blur degree can be an index reflecting the relative change rate of the blur degree between adjacent first reference images, which can be used to enhance the robustness of the focus surface positioning to illumination fluctuation, sample non-uniformity and sensor noise, and avoid absolute value threshold misjudgment. In an exemplary embodiment, the relative change feature of the blur degree can be calculated by dividing the blur degree feature ratio of the image pair by the corresponding objective lens position difference to represent the local change slope of the blur degree with spatial displacement, construct a local change index robust to noise and system drift, and have higher coarse positioning reliability than the traditional absolute blur degree curve.
[0083] According to the relative change feature of the blur degree, the first objective lens position can be determined based on prior knowledge setting, or can be obtained by querying based on a fitted mapping relationship table, a mathematical model, a neural network, etc., so that the coarse focus surface can be determined based on the local derivative feature rather than the global fitting, avoiding model generalization bias and improving positioning stability and calculation efficiency.
[0084] The automatic focusing method provided in the embodiment calculates the blur degree features of each first reference image according to a preset blur degree algorithm, sequentially calculates the ratio of the blur degree features of each two first reference images and the difference of the corresponding objective lens positions to obtain blur degree relative change features, determines the first objective lens position according to the blur degree relative change features, and determines the blur degree relative change features by calculating the blur degree features of each first reference image, which can eliminate the interference of system gain and illumination fluctuation on the absolute value of blur degree, make the change trend more stable and comparable, thereby change the coarse positioning mechanism from the single model prediction depending on the absolute blur degree value to the differential detection based on the relative change rate between image pairs, accurately position the first objective lens position, and thus avoid the calculation mode depending on the absolute threshold value in the traditional method, and still output consistent coarse positioning results when the sample reflectivity, background brightness, imaging noise and other conditions change, thereby improve the focusing efficiency and reduce the amount of calculation under the premise of ensuring the focusing accuracy.
[0085] In one of the embodiments, determining the first objective lens position according to the blur degree relative change features comprises:
[0086] Inputting the blur degree relative change features into a pre-trained objective lens position prediction model to obtain the first objective lens position.
[0087] The pre-trained objective lens position prediction model can be a mapping function trained by supervised learning or unsupervised learning, which is used to map the blur degree relative change features to the predicted value of the first objective lens position. In an exemplary embodiment, the pre-trained objective lens position prediction model can be trained using a large number of labeled data sets, the input is a plurality of blur degree relative change feature vectors, and the output is the corresponding real objective lens position label. Exemplarily, the model structure can adopt linear regression, support vector machine, lightweight neural network, multilayer perception, etc.
[0088] By inputting the blur degree relative change features into the pre-trained objective lens position prediction model to obtain the first objective lens position, the blur degree relative change features are used as robust inputs, a data-driven prediction model is combined to realize nonlinear mapping, the coarse positioning accuracy is effectively improved and the subsequent search range is reduced, thereby reducing the image acquisition amount and the calculation burden on the basis of retaining the feature anti-interference ability, and achieving the technical effects of improving the focusing efficiency and the calculation efficiency.
[0089] In one of the embodiments, the training process of the objective lens position prediction model comprises:
[0090] Within the movable range of the objective lens of the microscope, the objective lens is controlled to move according to a preset step interval to obtain sample images of the target sample at each objective lens position;
[0091] According to a preset blur degree algorithm, the blur degree features of each sample image are calculated.
[0092] The ratio of the blur degree features of each two sample images and the difference of the objective lens positions are sequentially calculated to obtain a blur degree relative change feature, and the minuend or the subtrahend corresponding to the difference of the objective lens positions is taken as a true objective lens position of the blur degree relative change feature.
[0093] According to the plurality of blur degree relative change features and the true objective lens positions, a preset machine learning model is trained to obtain an objective lens position prediction model.
[0094] The target sample can be a representative biological or industrial sample used for training the objective lens position prediction model. For example, the target sample can be a single or multiple sample of a fluorescently labeled tissue section, an unstained cell suspension, a metal-coated microstructure, etc.
[0095] The sample image can be imaging data collected at each preset position within the movable range of the objective lens for training, used for calculating the blur degree feature and constructing a supervised label. The preset step interval can be a fixed step unit of the objective lens moving along the optical axis during the model training stage, which can be used to ensure that the training data covers dense sampling of the focal plane region, and provides spatial resolution support for establishing an accurate mapping relationship. For example, the preset step interval can be a minimum step determined according to the optical diffraction limit, or an equivalent step determined based on the sensor pixel size, or a uniform step determined based on the depth of field, which is not limited in the present embodiment.
[0096] Within the movable range of the objective lens of the microscope, the objective lens is controlled to move according to the preset step interval to obtain a sample image of the target sample at each objective lens position. The objective lens can be moved point by point according to the preset step interval within the full movable range of the objective lens, and the imaging sensor is triggered to collect an image at each position.
[0097] The blur degree feature of each sample image, the ratio of the blur degree features, and the difference of the objective lens positions can be calculated according to the calculation method in any of the above embodiments, which is not repeated here.
[0098] The true objective lens position can be used to label the true focal plane coordinates corresponding to the blur degree relative change feature, and can be used to provide an accurate training target for the machine learning model to establish a mapping relationship between the blur degree relative change feature and the focal plane position.
[0099] The preset machine learning model can be an algorithm framework for learning the mapping relationship between the blur relative change feature and the real objective lens position. Exemplarily, the preset machine learning model can include one or more of a support vector regression model, a random forest regression model, a multilayer perception model, and the like, but is not limited thereto. The objective lens position prediction model can be a deployable model instance trained for online prediction of the first objective lens position, and can be used to receive a small amount of blur relative change features in an actual focusing process, quickly output a coarse positioning result, and replace a traditional fitting method.
[0100] The automatic focusing method provided by the embodiment can obtain sample images of a target sample at each objective lens position by controlling the movement of the objective lens according to a preset step interval within the movable range of the objective lens of the microscope, calculate the blur feature of each sample image according to a preset blur algorithm, sequentially calculate the ratio of the blur features of each two sample images and the difference of the objective lens positions, obtain the blur relative change feature, and take the difference or the minuend corresponding to the difference of the objective lens positions as the real objective lens position of the blur relative change feature. The preset machine learning model is trained according to the plurality of blur relative change features and the real objective lens positions, and an objective lens position prediction model is obtained. The blur feature sequence of the discrete sampling points is generated by constructing a high-density sample image set covering the complete focal plane area, high-quality input features are provided for machine learning, and the input-output pairing data required for end-to-end supervised training is constructed by assigning an accurate physical position label to each blur relative change feature, so as to generate a deployable prediction model. The efficient nonlinear mapping from the low-dimensional relative change feature to the focal plane position can be realized, the modeling process with high computational cost is transferred to the offline stage compared with the traditional fitting method, the real-time image acquisition amount and processing burden are significantly reduced, and the dual technical effects of improving the focusing efficiency and reducing the computational amount are simultaneously achieved under the premise of ensuring the focusing accuracy.
[0101] In one of the embodiments, calculating the blur feature of each image according to the preset blur algorithm includes:
[0102] performing image feature extraction on the image according to a preset gradient operator to obtain gradient information; the gradient information includes a horizontal gradient and a vertical gradient;
[0103] taking the sum of the absolute values of the horizontal gradient and the vertical gradient as the blur feature of the image.
[0104] The preset gradient operator can be a fixed convolution kernel template for extracting local gradient responses of an image, and can be used to efficiently extract horizontal and vertical direction change information of edge and texture structure in the image as a calculation basis of the blur degree feature. For example, the preset gradient operator can be preset by the system as a standard difference operator, such as a Sobel operator, a Prewitt operator or a Scharr operator, and is convoluted with a local area of the image through a sliding window.
[0105] The horizontal gradient can be a pixel intensity change rate of the image in the horizontal direction, and can be used to reflect the intensity distribution of the horizontal edge in the image. Further, the horizontal gradient can be a gradient response matrix obtained by convoluting the image with a convolution kernel of the preset gradient operator in the horizontal direction. Correspondingly, the vertical gradient can be a pixel intensity change rate of the image in the vertical direction, and can be used to reflect the intensity distribution of the vertical edge in the image. Further, the vertical gradient can be a gradient response matrix obtained by convoluting the image with a convolution kernel of the preset gradient operator in the vertical direction.
[0106] The sum of the absolute values of the horizontal gradient and the vertical gradient can be used as a lightweight blur degree indicator. For example, the value can decrease as the image blur degree increases, thereby quickly evaluating the focal plane state.
[0107] The automatic focusing method provided in this embodiment extracts gradient information from an image according to a preset gradient operator, and uses the sum of the absolute values of the horizontal gradient and the vertical gradient as the blur degree feature of the image. The gradient operator extracts horizontal and vertical gradient components and uses the sum of the absolute values of the two as the blur degree feature, which can construct a low-complexity and high-efficiency image sharpness evaluation mechanism, greatly reducing the processing time and algorithmic demand of a single image. The gradient operator is sensitive to edge structure and has strong correlation with focal plane sharpness. The sum of the absolute values retains directional information and is more robust than single-channel gradient, thereby effectively reducing the computational burden of each image while maintaining the positioning accuracy comparable to traditional methods.
[0108] In one embodiment, the movement of the objective lens is controlled according to the first objective lens position and a preset second step value, and at least two second reference images of different objective lens positions are obtained by capturing, including:
[0109] The movement of the objective lens is controlled according to the first objective lens position and the second step value to obtain at least two images of different objective lens positions; the target position includes at least two of the first objective lens position, the difference between the first objective lens position and the second step value, and the sum of the first objective lens position and the second step value.
[0110] The first objective position can be a coarse focal plane coordinate calculated based on the first reference image and the blur feature, and can be used as a starting reference point for fine search to limit the spatial range of subsequent high-precision search. Further, the first objective position is determined by fitting the curve of the blur feature of the first reference image with respect to the objective position to determine the position corresponding to the blur extreme point.
[0111] According to the first objective position and the second step value, the objective is controlled to move to the target position and at least two images at different objective positions are obtained. The image acquisition can be triggered after the objective is moved to the specified target position based on the first objective position and the second step value. Further, the image acquisition can be realized by collecting images at two or three discrete points, such as the first objective position, the first objective position minus the second step value, and the first objective position plus the second step value. Thus, the number of images collected can be compressed to a minimum under the premise of ensuring the probability of capturing the focal plane, and the data generation and processing load can be significantly reduced.
[0112] The automatic focusing method provided by the embodiment controls the objective to move to the target position according to the first objective position and the second step value, and collects at least two images at different objective positions. The first objective position is used as an anchor point to collect a minimum number of images in a neighborhood that is most likely to contain the real focal plane. The first objective position is used as a sampling center to ensure that the real focal plane is within the sampling interval, and the second step value is used as an interval unit to ensure the sampling point resolution. The change trend of the sharpness can be fully captured, so that the number of images collected is compressed from multiple images in the traditional method to two to three images. The effect of optimizing the number of images collected and the amount of calculation is realized without sacrificing the focusing accuracy.
[0113] In one of the embodiments, determining the target focal plane position and completing focusing according to the objective position corresponding to the second reference image and the sharpness feature includes:
[0114] According to a preset sharpness algorithm, the sharpness feature of each second reference image is calculated respectively;
[0115] According to the sharpness feature of each second reference image, a target reference image is selected, and the objective position corresponding to the target reference image is used as the target focal plane position;
[0116] The objective is controlled to move to the target focal plane position.
[0117] The sharpness feature can be a quantitative index reflecting the richness of image details, and is used for selecting the optimal image and determining the target focal plane position.
[0118] According to the preset sharpness algorithm, the sharpness features of each second reference image are calculated, which can be applying the preset sharpness algorithm to each second reference image, calculating the sharpness value pixel by pixel or in a local area, and generating a corresponding sharpness feature vector, so as to realize high-resolution quantitative evaluation of the image quality of the local area and provide comparable numerical basis for subsequent screening.
[0119] According to the sharpness features of each second reference image, the target reference image is screened, and the objective lens position corresponding to the target reference image is taken as the target focal plane position, which can be comparing the sharpness feature values of all second reference images, selecting the image corresponding to the maximum value as the target reference image, and extracting the objective lens position thereof as the target focal plane position. By directly selecting the image with the highest sharpness feature value as the target, the accurate determination of the target focal plane can be realized, the misjudgment caused by local noise interference can be avoided, and the positioning reliability and stability are improved.
[0120] The automatic focusing method provided in this embodiment calculates the sharpness features of each second reference image, screens the target reference image and takes the corresponding objective lens position as the target focal plane position, and controls the objective lens to move to the target focal plane position, realizes high-resolution quantitative evaluation through the preset sharpness algorithm, realizes accurate target determination through sharpness feature comparison, and can improve the positioning robustness in dynamic or low signal-to-noise ratio scenes, thereby achieving the technical effects of reducing the calculation complexity and avoiding the risk of curve fitting.
[0121] In order to more clearly set forth the technical solutions of the present application, a detailed embodiment is further provided.
[0122] In the field of microscopic observation, the automatic focusing technology is the key to guarantee the imaging quality and observation efficiency. The traditional focusing depth method needs to collect a large amount of image data in different focusing states, and the data processing amount is large and the focusing time is long, which is difficult to meet the needs of high-speed scanning, real-time detection and other scenes. With the improvement of the performance of image sensors and the development of machine learning technology, higher requirements are put forward for the speed and accuracy of automatic focusing technology. Although some existing automatic focusing methods try to reduce the number of image collection, there are deficiencies in the mapping accuracy of the blur degree and the depth, which leads to poor focusing accuracy or the need for multiple adjustments, affecting the observation experience and detection efficiency. In one embodiment, in order to solve the problems of large data amount, slow focusing and insufficient accuracy of the traditional method, an automatic focusing method based on defocus depth estimation is provided, which can realize fast and accurate focusing with only a small amount of images, including a mathematical modeling stage and a focusing execution stage.
[0123] I. Mathematical modeling stage.
[0124] Mathematical modeling is used to establish a mapping relationship model between blur degree and relative depth, which provides a calculation basis for subsequent focusing, such as Figure 3As shown, including focusing on the object, from the lower defocus position to the upper defocus position, interval one depth of field acquisition one image; using machine learning method to extract the characteristics of the image; according to the image characteristics and relative position relationship, establish mathematical model, the specific steps are as follows:
[0125] 1. Image acquisition: for different samples or different regions of the same sample, collect multiple groups of images at different height positions, ensure that the images cover different defocus degrees and sample characteristics.
[0126] 2. Feature extraction: using image feature extraction algorithm to process the collected images, calculate and extract the ratio of image features, which represents the blur degree of the image.
[0127] 3. Model construction: the extracted image feature ratio (blur index) and the corresponding Z axis height (relative depth) are used as a data set, the data set is fitted and trained, and a mathematical model of the mapping relationship between blur and relative depth is established.
[0128] II. Focusing execution phase.
[0129] Based on the established mathematical model, the focus position is calculated by collecting a small amount of real-time images and driving the lens focusing, such as Figure 4 As shown, it can include: obtaining the image and coordinates of the current position (for example, figure A and position A corresponding to figure A); move up 5 depth of field; obtain the current image and coordinates (for example, figure B and position B corresponding to figure B); continue to move up 5 depth of field; obtain the image and coordinates of the current position (for example, figure C and position C corresponding to figure C); according to the image, calculate the multi-modal feature information, according to the feature and coordinate information, predict the focal plane coordinates; move to the position of focal plane minus one depth of field; start moving up two depth of field; calculate the sharpness value of the image; move to the position with the best sharpness. The specific process is as follows:
[0130] 1. Initial image acquisition: control the Z axis of the microscope to move slightly, collect two images in different focusing states during the movement, and record the Z axis position coordinates corresponding to the two images.
[0131] 2. Real-time feature extraction: using the same image feature extraction algorithm as in the mathematical modeling stage, the two real-time images collected are processed for features, and the corresponding image feature ratio is calculated.
[0132] 3. Focal plane position prediction: the extracted real-time image feature ratio and the corresponding Z axis position are substituted into the established mathematical model, and the Z axis position corresponding to the focal plane is calculated and predicted by the model.
[0133] 4. Focal plane precision verification: control the Z-axis to move to the predicted focal plane position, then move up and down by N depth of field distances at this position, respectively collect images in this range, calculate the sharpness values of the three images, and select the Z-axis position corresponding to the highest sharpness image as the final focal plane position.
[0134] 5. Final focusing: drive the microscope Z-axis to move to the determined final focal plane position, complete the auto-focusing process.
[0135] In one specific embodiment, the microscope uses a numerical aperture of 0.33 microscope objective, and the observation scene applied to the semiconductor glue sample is taken as an example, and the specific implementation steps are as follows:
[0136] I. Mathematical modeling phase.
[0137] 1. Image acquisition: select three different types of semiconductor glue samples, collect images at intervals of 100 um within the range of 10-20 mm of the microscope Z-axis height, collect 100 images for each sample, and obtain a total of 300 images and corresponding Z-axis position data.
[0138] 2. Feature extraction: the preset blur algorithm used in this embodiment is to use the Sobel gradient operator as the image feature extraction algorithm, calculate the horizontal gradient and vertical gradient of each image, and take the ratio of the sum of the gradient absolute values as the image feature ratio (blur index).
[0139] 3. Model construction: use a nonlinear regression algorithm to fit the "blur- relative depth" data, and establish a nonlinear mapping model: y=f(x), where y is the relative depth (Z-axis height, unit: mm), and x is the blur index.
[0140] II. Focusing execution phase.
[0141] 1. Initial image acquisition: control the Z-axis to move slightly upward by 500 um from the current position (assuming 12 mm), collect two images (i.e. the first reference image) at positions 12.5 mm and 13 mm, respectively, and record the corresponding Z-axis coordinates.
[0142] 2. Real-time feature extraction: use the Sobel gradient operator to calculate the blur features (i.e. the absolute values of the horizontal gradient and the vertical gradient) of the two images, and then calculate the ratio of the blur features of the two images to obtain the blur index (i.e. the relative change feature of the blur), which is 28.5 and 30.2, respectively.
[0143] 3. Focal plane position prediction: substitute the blur index and the corresponding Z-axis position into the linear model to calculate the predicted focal plane Z-axis position as 64.2 mm, i.e. the first objective position.
[0144] 4. Focal plane precision verification: The microscope depth of field is known to be 0.5 mm, the Z-axis is controlled to move to 64.2 mm, and then images are collected at three positions of 64.0 mm, 64.2 mm, and 64.4 mm. The clarity values calculated by the gray variance method are 125, 189, and 132, respectively. The position of 64.2 mm with the highest clarity is selected as the final focal plane position.
[0145] 5. Final focusing: The Z-axis is driven to move to 64.2 mm, and the focusing is completed. The entire process takes about 0.8 seconds.
[0146] In another specific embodiment, a microscope objective with a numerical aperture of 0.9 is used in the microscope, and the observation scene applied to a biological section sample is taken as an example. The specific implementation steps are as follows:
[0147] I. Mathematical modeling stage.
[0148] 1. Image acquisition: Four different types of biological section samples are selected. At a Z-axis height of 2 mm, images are collected at intervals of 0.01 mm. For each sample, 100 images are collected, and a total of 400 images and corresponding Z-axis position data are obtained.
[0149] 2. Feature extraction: The preset blur algorithm used in this embodiment is to use the Laplacian operator as the image feature extraction algorithm to calculate the second derivative absolute value of each image, and select the clearest image among multiple images as the standard clear image.
[0150] 3. Model construction: 400 groups of data are trained using the support vector machine algorithm to establish a non-linear mapping model. The model fitting goodness R 2 is 0.96.
[0151] II. Focusing execution stage.
[0152] 1. Initial image acquisition: The Z-axis is controlled to move downward by 0.16 mm from 49 mm, and two images are collected at positions of 48.84 mm and 49.16 mm, respectively.
[0153] 2. Real-time feature extraction: The blur features of the two images are calculated by the Laplacian operator, and the blur indexes are 42.1 and 45.3, respectively.
[0154] 3. Focal plane position prediction: The support vector machine model is substituted to predict the focal plane Z-axis position as 48.8 mm.
[0155] 4. Focal plane precision verification: Images are collected at positions of 48.7 mm, 48.8 mm, and 48.9 mm, and the clarity values are 98, 176, and 105, respectively. It is determined that 48.8 mm is the final focal plane.
[0156] 5. Final focusing: drive Z-axis to move to 48.8mm, complete focusing, time consumption is about 1.0s.
[0157] As can be seen from the above embodiment results, the automatic focusing method of the embodiment can realize fast focusing with time consumption maintained within 1s, and has higher focusing progress, so that the final focal plane image clarity reaches the optimum, thereby effectively adapting to different microscopic observation scenes.
[0158] The automatic focusing method provided in the embodiment can realize the following technical effects: (1) fast focusing speed: only 2 to 3 images of different focusing conditions need to be processed to complete the core calculation, which greatly reduces the data acquisition and processing amount compared with the traditional focusing depth method, and significantly improves the focusing efficiency; (2) high focusing accuracy: a precise mapping model of the blur and the relative depth is established through the machine learning algorithm, and the clarity verification in the depth of field range is combined to ensure the accuracy of the focusing position; (3) strong adaptability: the model can be established by collecting images of different samples and different heights, and can adapt to various microscopic observation scenes and sample types; (4) simple operation: the focusing process has high automation degree, and the whole process from image acquisition to lens positioning can be completed without manual intervention.
[0159] It should be understood that, although each step in the flowchart involved in each embodiment described above is displayed in sequence according to the direction of the arrow, these steps are not necessarily executed in sequence according to the direction of the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0160] Based on the same inventive concept, the embodiments of the present application also provide a device for implementing the above-mentioned method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more device embodiments provided below can refer to the limitations of the method described above, which will not be repeated here.
[0161] In one embodiment, as shown in Figure 5 The present application provides an automatic focusing device applied to a microscope, the automatic focusing device comprising:
[0162] The first moving module 100 is configured to control the objective lens to move according to a first step value corresponding to an imaging parameter of the microscope in response to an autofocus instruction, and acquire at least two first reference images at different objective lens positions.
[0163] The position analysis module 200 is configured to determine the first objective lens position according to the objective lens position corresponding to the first reference image and the blur feature.
[0164] The second moving module 300 is configured to control the objective lens to move according to the first objective lens position and a preset second step value, and acquire at least two second reference images at different objective lens positions.
[0165] The focal plane analysis module 400 is configured to determine the target focal plane position and complete focusing according to the objective lens position corresponding to the second reference image and the sharpness feature.
[0166] In one of the embodiments, the imaging parameter comprises a depth of field parameter; the first reference image comprises a first current reference image and a first step reference image; and the first moving module 100 is further configured to:
[0167] acquire the first current reference image at the current objective lens position;
[0168] control the objective lens to move at least once according to a first step value corresponding to the depth of field parameter, and acquire at least one first step reference image.
[0169] In one of the embodiments, the position analysis module 200 is further configured to:
[0170] calculate the blur feature of each of the first reference images according to a preset blur algorithm;
[0171] calculate the ratio of the blur features of each two of the first reference images and the difference of the corresponding objective lens positions in sequence, and obtain the relative change feature of the blur of the first reference images;
[0172] determine the first objective lens position according to the relative change feature of the blur.
[0173] In one of the embodiments, the position analysis module 200 is further configured to:
[0174] input the relative change feature of the blur into a pre-trained objective lens position prediction model to obtain the first objective lens position.
[0175] In one of the embodiments, the training process of the objective lens position prediction model comprises:
[0176] control the objective lens to move according to a preset step interval within the movable range of the objective lens of the microscope to obtain sample images of the target sample at each objective lens position.
[0177] According to a preset blur algorithm, a blur feature of each of the sample images is calculated;
[0178] A ratio of the blur features of each two of the sample images and a difference in objective lens positions are sequentially calculated to obtain a blur relative change feature, and a subtrahend or a minuend corresponding to the difference in objective lens positions is taken as a true objective lens position of the blur relative change feature.
[0179] According to the blur relative change features and the true objective lens positions, a preset machine learning model is trained to obtain the objective lens position prediction model.
[0180] In one of the embodiments, according to the preset blur algorithm, the calculation of the blur feature of each image includes:
[0181] According to a preset gradient operator, image feature extraction is performed on the image to obtain gradient information; the gradient information includes a horizontal gradient and a vertical gradient;
[0182] A sum of absolute values of the horizontal gradient and the vertical gradient is taken as the blur feature of the image.
[0183] In one of the embodiments, the second moving module 300 is further configured to:
[0184] According to the first objective lens position and the second step value, the objective lens is controlled to move to a target position to obtain at least two images at different objective lens positions; the target position includes at least two of the first objective lens position, a difference between the first objective lens position and the second step value, and a sum of the first objective lens position and the second step value.
[0185] In one of the embodiments, the focal plane analysis module 400 is further configured to:
[0186] According to a preset sharpness algorithm, a sharpness feature of each of the second reference images is calculated;
[0187] According to the sharpness feature of each of the second reference images, a target reference image is screened, and an objective lens position corresponding to the target reference image is taken as a target focal plane position.
[0188] The objective lens is controlled to move to the target focal plane position.
[0189] The above automatic focusing device can be realized by software, hardware, and a combination thereof. The above modules can be embedded in or independent of a processor in a computer device in a hardware form, or can be stored in a memory in a computer device in a software form, so as to be called and executed by a processor to perform operations corresponding to the above modules.
[0190] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements an autofocus method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0191] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0192] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the autofocus method of any of the above embodiments:
[0193] In response to the autofocus command, the objective lens is moved according to the first step value corresponding to the imaging parameters of the microscope, and at least two first reference images with different objective lens positions are acquired.
[0194] The position of the first objective lens is determined based on the objective lens position and blur characteristics corresponding to the first reference image;
[0195] The objective lens is moved according to the first objective lens position and a preset second step value, and at least two second reference images with different objective lens positions are acquired.
[0196] Based on the objective lens position and sharpness characteristics corresponding to the second reference image, the target focal plane position is determined and focusing is completed.
[0197] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the autofocus method of any one of the above embodiments:
[0198] In response to the autofocus instruction, the objective lens is controlled to move according to a first step value corresponding to the imaging parameter of the microscope, and at least two first reference images at different objective lens positions are acquired;
[0199] According to the objective lens position and the blur feature corresponding to the first reference image, a first objective lens position is determined;
[0200] According to the first objective lens position and a preset second step value, the objective lens is controlled to move, and at least two second reference images at different objective lens positions are acquired;
[0201] According to the objective lens position and the sharpness feature corresponding to the second reference image, a target focal plane position is determined, and focusing is completed.
[0202] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0203] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database according to the blockchain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device according to quantum computing, etc., without being limited thereto.
[0204] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0205] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. An auto-focusing method characterized by, The automatic focusing method applied to a microscope comprises: in response to an automatic focusing instruction, controlling movement of an objective lens according to a first step value corresponding to an imaging parameter of the microscope, and collecting at least two first reference images at different objective lens positions; determining a first objective lens position according to an objective lens position corresponding to the first reference images and a blur degree feature; controlling movement of the objective lens according to the first objective lens position and a preset second step value, and collecting at least two second reference images at different objective lens positions; determining a target focal plane position and completing focusing according to an objective lens position corresponding to the second reference images and a definition degree feature.
2. The autofocusing method of claim 1, wherein, The imaging parameter comprises a depth of field parameter; the first reference images comprise a first current reference image and a first step reference image; the step of controlling movement of the objective lens according to a first step value corresponding to an imaging parameter of the microscope in response to an automatic focusing instruction and collecting at least two first reference images at different objective lens positions comprises: collecting a first current reference image at a current objective lens position; controlling movement of the objective lens at least once according to a first step value corresponding to the depth of field parameter, and collecting at least one first step reference image.
3. The autofocusing method of claim 1, wherein, The step of determining a first objective lens position according to an objective lens position corresponding to the first reference images and a blur degree feature comprises: calculating a blur degree feature of each of the first reference images according to a preset blur degree algorithm; sequentially calculating a ratio of blur degree features of each two of the first reference images and a difference of the corresponding objective lens positions, to obtain a blur degree relative change feature of the first reference images; determining a first objective lens position according to the blur degree relative change feature.
4. The autofocusing method according to claim 3, wherein The step of determining a first objective lens position according to the blur degree relative change feature comprises: inputting the blur degree relative change feature into a pre-trained objective lens position prediction model to obtain the first objective lens position.
5. The autofocusing method according to claim 4, wherein The training process of the objective lens position prediction model comprises: controlling movement of the objective lens according to a preset step interval within a movable range of the objective lens of the microscope, to obtain sample images of a target sample at each objective lens position; calculating a blur degree feature of each of the sample images according to a preset blur degree algorithm; sequentially calculating a ratio of blur degree features of each two of the sample images and a difference of the objective lens positions, to obtain a blur degree relative change feature, and taking a subtrahend or a minuend corresponding to the difference of the objective lens positions as a real objective lens position of the blur degree relative change feature; training a preset machine learning model according to a plurality of the blur degree relative change features and the real objective lens positions, to obtain the objective lens position prediction model.
6. The autofocusing method according to any one of claims 3 to 5, wherein The step of calculating a blur degree feature of each image according to a preset blur degree algorithm comprises: performing image feature extraction on the image according to a preset gradient operator, to obtain gradient information; the gradient information comprises a horizontal gradient and a vertical gradient; taking a sum of absolute values of the horizontal gradient and the vertical gradient as the blur degree feature of the image.
7. The auto-focusing method according to claim 1, wherein The step of controlling movement of the objective lens according to the first objective lens position and a preset second step value, and collecting at least two second reference images at different objective lens positions comprises: According to the first objective position and the second step value, the objective is controlled to move to a target position, and at least two images of different objective positions are obtained; the target position at least includes two of the first objective position, the difference between the first objective position and the second step value, and the sum of the first objective position and the second step value.
8. The auto-focusing method according to claim 1, wherein According to the objective position corresponding to the second reference image and the definition feature, the target focal plane position is determined and focusing is completed, which includes: According to a preset definition algorithm, the definition feature of each of the second reference images is calculated respectively; According to the definition feature of each of the second reference images, a target reference image is screened, and the objective position corresponding to the target reference image is taken as the target focal plane position; The objective is controlled to move to the target focal plane position.
9. An auto-focusing device characterized by comprising: The automatic focusing device is applied to a microscope, and the automatic focusing device includes: A first moving module is configured to, in response to an automatic focusing instruction, control an objective to move according to a first step value corresponding to an imaging parameter of the microscope, and obtain at least two first reference images of different objective positions; A position analysis module is configured to determine a first objective position according to an objective position corresponding to the first reference image and a blur feature; A second moving module is configured to control the objective to move according to the first objective position and a preset second step value, and obtain at least two second reference images of different objective positions; A focal plane analysis module is configured to determine a target focal plane position and complete focusing according to an objective position corresponding to the second reference image and a definition feature. 10.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-9. The processor implements the method in any one of claims 1 to 8 when executing the computer program.
Citation Information
Patent Citations
Microscope focusing method and apparatus, computer apparatus, and storage medium
CN109116541A
Microscope fine focusing method based on random forest
CN112433339A
Focusing control method and device for microscopic imaging
CN117310962A
Multi-stage automatic focusing method according to time-frequency domain catched by iris picture
CN1892401A
Automatic focusing method and apparatus, storage medium and electronic device
WO2018228479A1
Cited By
Remote video monitoring method, system and device capable of intelligently zooming
CN121751009A