Microscope camera automatic focusing method based on hill climbing algorithm and CNN model
Through the microscope camera autofocus method combining mountain climbing algorithm and CNN model, the shortcomings of bone marrow smear detection equipment in scanning efficiency, recognition accuracy and focus positioning are solved, and fast and high-precision autofocus and image clarity evaluation are achieved, which improves detection efficiency and accuracy.
Patent Information
- Application Number
- CN202510340456.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-05-23
AI Technical Summary
The existing bone marrow smear detection equipment has shortcomings in scanning efficiency, identification accuracy and focus positioning, which is difficult to meet the needs of large-scale testing and is easily affected by subjective factors of the inspector.
The microscope camera autofocus method based on mountain climbing algorithm and convolutional neural network (CNN) model is adopted to achieve fast and high-precision autofocus and image sharpness evaluation through image acquisition, data preprocessing and CNN model training.
It improves the scanning efficiency and identification accuracy of bone marrow smears, realizes automatic focus and positioning, reduces manpower investment and subjective deviations, and improves the stability and reliability of the equipment.
Smart Images

Figure CN120034737A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical testing equipment and medical image processing, and in particular to an automatic focusing method for a microscope camera based on a hill climbing algorithm and a CNN model. Background Art
[0002] Bone marrow examination is an important means of diagnosing blood system diseases, and bone marrow smear is the most common morphological observation method. Traditional bone marrow smear examination mostly relies on manual microscopy, where inspectors manually operate microscopes to observe, take pictures, count and interpret. This process is not only time-consuming and laborious, but also easily affected by the subjective factors of the inspectors, making it difficult to ensure the accuracy and consistency of the results.
[0003] With the rapid development of medical image processing technology and automated detection technology, the application of digital scanning and automatic recognition technology in bone marrow smear detection has increased, and various automated scanning and image recognition equipment have emerged. However, the existing equipment still has shortcomings in the following aspects: 1. Scanning efficiency: Due to the limitations of microscope focusing, mechanical movement, image acquisition and storage, the scanning speed is relatively slow, which makes it difficult to meet the needs of rapid detection of large quantities of bone marrow smears.
[0004] 2. Recognition accuracy: There are many types of cells in bone marrow smears, with great differences in morphology, which requires high accuracy of the algorithm. Some traditional algorithms or single models are difficult to meet the clinical demand for high accuracy.
[0005] 3. Focusing and positioning: Bone marrow smears are prone to complex backgrounds and difficulty in accurately focusing on the target due to factors such as specimen preparation technology and staining quality, making it difficult to achieve stable autofocus and precise positioning.
[0006] The hill climbing algorithm is a local search method. In the microscope autofocus, the sharpness evaluation function (such as gradient and variance) is calculated by adjusting the focal length to gradually find the clearest image. However, the algorithm is prone to fall into the local optimum and is difficult to adapt to complex samples.
[0007] The goal of the CNN (Convolutional Neural Network) focus model is to predict the optimal focus position in the image by learning from a large number of sample images. This model is particularly suitable for images with low contrast or noise interference, which can improve the accuracy of focus and avoid the limitations of traditional focus methods, such as relying on simple features such as gradient, texture or contrast. Summary of the invention
[0008] To solve the above problems, the present invention provides an automatic focusing method for a microscope camera based on the combination of the hill-climbing algorithm and the convolutional neural network, aiming to achieve a fast and high-precision focusing effect, enabling automatic scanning of bone marrow smears with fast high-precision scanning, multi-level focusing, and intelligent analysis, so as to improve the inspection efficiency and accuracy, reduce the burden on medical workers, and provide high-quality data support for subsequent scientific research and clinical diagnosis.
[0009] The technical solution adopted by the present invention to solve its technical problems is as follows: An automatic focusing method for a microscope camera based on the hill-climbing algorithm and the CNN model, comprising the following steps: Step S1. Image acquisition: Using a high-resolution camera, the acquisition range covers 500 groups of images. Each group of images is continuously adjusted in focal length at a fixed step of 1 μm to collect at least 15 frames, obtaining an initial data set.
[0010] Further, the acquisition range covers the entire focal length interval from "completely out of focus" to "over focus" to ensure data diversity. At least 15 frames of images are collected at each focal length to reduce the influence of single-frame noise or jitter, obtaining an initial data set.
[0011] Step S2. Data preprocessing: Preprocess the initial data set obtained in step S1, specifically including data cleaning, normalization, data augmentation, data set division, and feature engineering, obtaining a preprocessed data set.
[0012] Further, the data cleaning is to delete or fill the missing values in the data, detect and process the outliers in the data, and remove the duplicate samples.
[0013] Step S3. Convolutional neural network model training: By constructing a CNN binary classification model, learn the image features in the data set preprocessed in step S2 to distinguish clear and blurred images. Adopt dynamic adjustment of the learning rate and early stopping mechanism to optimize the stability of the training process, prevent overfitting, and automatically select the best model parameters, thereby obtaining an optimal model.
[0014] Further, the dynamic adjustment of the learning rate is to adopt a custom learning rate scheduler, dynamically adjust the learning rate through a linear warm-up and decay strategy, and provide real-time monitoring and update functions.
[0015] Step S4. Automatic focusing model evaluation: Use the hill-climbing algorithm and the CNN binary classification model trained in step 3 to evaluate the images collected by the microscope in real-time processing step S1. Accurately quantify the image sharpness through deep feature extraction and binary classification scoring mechanism, and obtain the best focal length according to the sharpness evaluation mechanism, adaptive step control, and termination and convergence conditions respectively.
[0016] Furthermore, the hill climbing algorithm performs an efficient search on the Z-axis focal plane through a gradient ascent strategy in the autofocus system, quickly determines the optimal focal length, and achieves rapid coarse focusing.
[0017] This method uses image contrast as an evaluation function and moves to higher definition areas in an iterative manner until the definition peak is reached.
[0018] Furthermore, the images collected by the microscope are sparsely sampled using a large step size strategy of 3-5 μm in the initial sampling stage to cover the entire possible focal plane area and establish a preliminary focus-clarity relationship mapping.
[0019] Furthermore, the clarity evaluation mechanism is to apply the Laplacian operator to perform edge detection, calculate the image contrast function value as a clarity metric, and construct a functional relationship curve between focal length and clarity.
[0020] Furthermore, the adaptive step size control is achieved by dynamically adjusting the search step size. When the definition gradient changes significantly, the step size is automatically reduced to perform finer sampling in high gradient areas.
[0021] Furthermore, the termination and convergence conditions are to control the convergence time within 500ms, and the final positioning accuracy reaches the range of ±15μm, providing a good initial value for subsequent fine focusing.
[0022] Furthermore, the CNN binary classification model uses a pre-trained VGG19 convolutional neural network architecture to achieve high-precision evaluation of microscope image clarity. The model receives the initial position provided by the coarse focus stage and performs precise positioning within a limited focal plane to achieve micron-level focusing accuracy.
[0023] The beneficial effects of the present invention are as follows The present invention automatically determines the image clarity through deep learning, solving the problem of inaccurate focusing in low-contrast and noisy environments caused by traditional methods. The convolutional neural network is used to extract high-level hierarchical feature information of the image, which has strong adaptability and robustness and can cope with complex microscope imaging environments. Combined with the hardware control system, a fast and accurate autofocus process is achieved.
[0024] The present invention can improve the scanning efficiency of bone marrow smears and shorten the diagnosis cycle; improve the recognition accuracy of bone marrow cells and reduce manpower input and subjective bias; achieve automatic focusing and automatic positioning, and improve the stability and reliability of equipment use; and build a complete data management and traceability system to facilitate clinical and scientific research applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is an overall flow chart of focusing implementation of the present invention.
[0026] Figure 2 It is a schematic diagram of microscope camera image acquisition and focus adjustment.
[0027] Figure 3 It is a schematic diagram of the convolutional neural network (CNN) model structure.
[0028] Figure 4 This is a flow chart of the autofocus process of a microscope camera based on a convolutional neural network.
[0029] Figure 5 This is a comparison chart of autofocus time and image clarity.
[0030] Figure 6 This is the focus effect picture. DETAILED DESCRIPTION
[0031] The present invention provides a high-precision microscope camera autofocus method based on hill climbing algorithm and CNN. First, the hill climbing algorithm is used for preliminary focusing, and then the precise focus is further obtained through the deep learning focus model. The system can automatically evaluate the image clarity and achieve the best focusing effect in combination with the focus adjustment mechanism. The method can be applied to batch automated scanning of bone marrow smears to achieve high-precision cell morphology information collection and analysis, providing strong support for the diagnosis of blood system diseases.
[0032] The following is combined with Figure 1-6 And specific implementation methods are further described in detail: like Figure 1 As shown in the figure, the flowchart describes the complete process of training a CNN focus model based on a classification dataset, which includes four main steps (S1-S4): S1. Image acquisition S1.1 Collection Target S1.1.1 Collect 500 sets of microscopic image sequences in total; S1.1.2 Each set of images is continuously shot at different focal lengths to form a focal length sequence; S1.2 Acquisition parameter settings; S1.2.1 Focus adjustment step: fixed at 1μm; S1.2.2 Focus range: from completely out of focus (underfocus) to overfocus (focus passes over the sample); S1.2.3 Each focus sequence must cover the complete clarity change process S1.3 Collection process S1.3.1 Sample preparation and loading 1) Place the sample to be observed on the microscope stage; 2) Ensure that the sample is fixed and stable to avoid displacement S1.3.2 Initial Setup 1) Set the microscope focus to the lowest position (completely out of focus) 2) Record the initial position parameters S1.3.3 Automated collection procedures 1) Start the automatic acquisition process; 2) Take the first image from the initial underfocus position; 3) Adjust the focus precisely in 1μm steps; 4) Take and save images at each focus position; 5) Continue adjusting until the overfocus position is reached S1.3.4 Image storage and organization 1) Each set of images is saved in sequence; 2) The file naming format is: group number_focal length position.format; 3) The relevant metadata (focal length value, timestamp, etc.) is also recorded This approach acquires a comprehensive dataset with different resolution levels.
[0033] S2. Data Preprocessing S2.1 Image quality assessment and screening of the dataset obtained in S1 S2.1.1 Automatic evaluation stage: 1) Apply clarity evaluation algorithms (such as Laplacian, Sobel gradient, variance, etc.) to calculate the clarity score for each image; 2) Draw a clarity curve for each set of sequences and identify the clarity peak; 3) Mark outliers or low-quality sequences (such as unstable lighting, sample movement, etc.) S2.1.2 Manual review stage: 1) Expert review of automated evaluation results; 2) Confirmation of the best focus position in each sequence; 3) Identification and rejection of images or entire sequences that do not meet the criteria S2.2 Binary classification of the dataset obtained in S1 S2.2.1 Establish labeling standards: 1) Clear (label 1): The sample edges in the image are sharp, details are discernible, and the cell texture is clearly visible; 2) Unclear (label 0): Obviously out of focus or overfocus, the edges are blurred, and details are lost S2.2.2 Marking method: 1) Strict standard method: only the 1-3 images with the highest clarity scores in each sequence are marked as "clear" (1), and the rest are marked as "unclear" (0) S2.3 Balancing and splitting the dataset obtained in S1 S2.3.1 Category balancing treatment: 1) Count the ratio of "clear" to "unclear" samples; 2) If there is a serious imbalance (usually "unclear" samples will be far more than "clear" samples): Undersample the majority class or perform data augmentation on the minority class (such as rotation, flipping, slight displacement, etc.) S2.3.2 Dataset Split: 1) Training set: 80% (for model learning), 2) Validation set: 10% (for hyperparameter tuning), 3) Test set: 10% (for final evaluation), 4) Ensure that the class distribution in each subset is similar S2.4 Standardization of the images in the dataset obtained in S1 S2.4.1 Resize: resize all images to a uniform resolution (e.g. 512×512 pixels); S2.4.2 Intensity normalization: normalize pixel values to the range [0,1]; S2.4.3 Data enhancement: expand the dataset by rotation, scaling, brightness adjustment, etc. After the above steps of data preprocessing, the processed data set is obtained.
[0034] S3. Convolutional neural network model training S3.1 Data preparation S3.1.1 Dataset obtained after preprocessing in S2; S3.2 Model construction; S3.2.1 Model architecture selection 1) Infrastructure: Select the VGG19 pre-trained model as the backbone network; 2) Adaptation layer: Add a global average pooling layer to reduce the number of parameters; 3) Output layer: Add a fully connected layer and a sigmoid activation function to output a probability value between 0 and 1 S3.3 Model training strategy S3.3.1 Training parameter configuration 1) Loss function: weighted binary cross-entropy; 2) Optimizer: Adam optimizer (initial learning rate: 0.0001); 3) Learning rate strategy: learning rate decay; 4) Batch size: 32 or 64 (adjusted according to GPU memory); 5) Training cycle (Epochs): 50-100 (with early stopping mechanism) S3.3.2 Regularization techniques 1) Dropout (0.3-0.5) to prevent overfitting; 2) L2 weight regularization (weight decay); 3) Batch Normalization S3.3.3 Training monitoring indicators 1) Loss curves of training set and validation set; 2) Accuracy; 3) Precision and recall; 4) AUC-ROC curve S3.4 Model optimization and tuning S3.4.1 Hyperparameter Optimization 1) Grid search or Bayesian optimization to find the best parameter combination 2) Tuning parameters include: learning rate, batch size, network depth, dropout ratio S3.4.2 Addressing Class Imbalance 1) Use weighted loss function; 2) Oversample minority class or undersample majority class; 3) Use special loss function such as focal loss After the above steps, the best CNN binary classification model is obtained.
[0035] S4. Autofocus Model Evaluation S4.1 Coarse adjustment stage: Use the hill climbing algorithm to quickly locate the approximate focus position: S4.1.1 Initialization process: 1) Set the initial Z-axis position; 2) Define the search step size and termination condition; 3) Select the Laplace operator image clarity evaluation function S4.1.2 Search process: 1) Collect an image at the current position and calculate the clarity score; 2) Move one step in the upward and downward directions and calculate the clarity score respectively; 3) Select the position with the highest score as the new current position; 4) If the score of the new position is lower than the current position, reduce the step size and continue searching; 5) Stop searching when the step size is less than the preset threshold or the number of iterations reaches the upper limit S4.2 Fine-tuning stage: Using the CNN binary classification model to accurately determine the optimal focus position: S4.2.1 Search process: 1) Move the Z axis with a smaller step size within the area located by the hill climbing algorithm; 2) Predict the focus probability of the image at each position through the CNN model; 3) Select the position with the highest probability as the final focus position.
[0036] like Figure 2 As shown in the figure, the hardware device used in this autofocus method is a microscope system equipped with autofocus function, which includes the following key components: Camera (1): Installed on top of the microscope, used to capture images in the microscope field of view and transmit them to a computer or other processing device for analysis.
[0037] Objective lens (2): Installed on the objective lens turret, responsible for magnifying the sample. Usually contains multiple objective lenses with adjustable magnification, and users can switch between different magnifications according to their needs.
[0038] Motorized stage (3): used to place slides and capable of high-precision XY axis movement to achieve automatic scanning and alignment of samples.
[0039] High-power microscope light source (4): Provides strong illumination to ensure sufficient image brightness during focusing, reduce noise, and improve autofocus accuracy and stability.
[0040] Automatic Z-axis (5): Controls the vertical movement of the objective lens or stage to precisely adjust the focal length and achieve autofocus function.
[0041] The system combines camera image acquisition, automatic Z-axis focal length adjustment, and deep learning models (such as CNN) for focus optimization to achieve high-precision autofocus function, which is suitable for application scenarios such as microscope scanning and pathological analysis.
[0042] like Figure 3 The figure shows a convolutional neural network (CNN) model structure for a binary classification focus task. The model is designed to determine whether an image is in focus.
[0043] Input layer: The input layer receives an image, which shows an image of a tissue slice, which may be an image of cells or other structures. Different colors (purple and pink) may represent different cell types or tissues. The image will be converted into a two-dimensional matrix of pixel values.
[0044] Convolutional layer (feature map): The input image passes through the convolutional layer, which is used to extract features from the image. The convolutional layer slides over the image through multiple convolution kernels (filters) and performs mathematical operations (convolution) to detect features such as edges, corners, textures, etc. in the image.
[0045] Each convolution kernel extracts different features, and after convolution, multiple feature maps are generated. These feature maps represent the performance of the image in different feature dimensions.
[0046] Pooling layer: After the convolutional layer, the model applies a pooling layer, usually a max pooling operation. The purpose of pooling is to reduce the spatial dimension of the feature map, reduce computational complexity, and mitigate the risk of overfitting. Max pooling selects the maximum value in each region it slides over, retaining the most important features. Pooling helps reduce the complexity of the model while retaining key features in the image.
[0047] Flattening layer: After the pooling layer, the feature map is flattened into a one-dimensional vector. This is to convert the data into a form that can be processed by the fully connected layer, because the fully connected layer requires one-dimensional input data.
[0048] Fully connected layer: The fully connected layer connects the flattened output to a layer of neurons. Each neuron is connected to all neurons in the previous layer. The role of the fully connected layer is to learn the complex relationship between the features extracted by the convolutional layer and further understand the pattern of the image.
[0049] Output layer: The last layer is the output layer, where the model makes the final prediction. The output is binary, and there are two output nodes in the figure (labeled 0 and 1). The weighted binary cross entropy loss (BinaryCross-EntropyLoss) is used as the loss function during training, and the model parameters are optimized through back propagation and gradient descent algorithms.
[0050] Figure 4 The complete workflow of a microscope autofocus system that combines traditional focusing algorithms with convolutional neural networks (CNNs) is demonstrated. This method achieves efficient and accurate autofocus in two stages: first, coarse focusing is performed using a traditional focus evaluation function, and then fine focusing is performed using a CNN model.
[0051] 1. Traditional focus evaluation stage (coarse focus) This stage mainly achieves coarse focus by calculating the evaluation function of image clarity. The process is as follows: Define the clarity evaluation function:
[0052] Set the clarity evaluation function F(z) to measure the clarity of the image. The input is the image at the current focal length position, and the output is the clarity score of the image.
[0053] At this stage, the step size Δz and the maximum number of iterations Nmax are selected, and the focal position is initialized to z0.
[0054] Capture an image at the current focal length: Capture an image for evaluation using the current focal length zt.
[0055] Calculate the clarity evaluation value of the current image: The clarity evaluation function F(zt) is used to calculate the image clarity at the current focal length zt.
[0056] Evaluate in the neighborhood of the current focal length: The focal lengths of the left and right sides are evaluated over the focal length range [zt−Δz,zt+Δz].
[0057] Calculate the clarity evaluation values Fleft=F(zt−Δz) and Fright=F(zt+Δz) of the left focal length and the right focal length respectively.
[0058] Choose the best focal length: If the sharpness is better on the left side (i.e., Fleft>F(zt)), then move the focus to the left; if the sharpness is better on the right side (i.e., Fright>F(zt)), then move the focus to the right.
[0059]
[0060] Determine whether the maximum number of iterations has been reached: If the number of iterations reaches the maximum value Nmax, the coarse focus phase ends. If the maximum number has not been reached, the focus adjustment continues.
[0061] The purpose of this stage is to quickly find a position close to the optimal focal length through a rough clarity evaluation. This stage mainly relies on simple clarity calculation of the image and does not require a deep learning model.
[0062] 2. CNN model fine focus stage After the traditional coarse focus stage, the CNN model fine focus stage is entered, and the CNN model is used to fine-tune the focal length. The steps are as follows: CNN model initialization: At this stage, a CNN model is used to further calculate the clarity score of the image.
[0063] Set a new step size Δx and the maximum number of iterations Nmax, and select the initial focal position x0=zt+Δz or x0=zt−Δz to start fine focusing.
[0064] Capture an image at the current focal length: Capture an image using the updated focal position xt.
[0065] Calculate the clarity evaluation value of the current image: Use the CNN model to calculate the clarity score F(xt) of the current image.
[0066] Determine whether the current image clarity meets the standard: If the image clarity F(xt)=1, it means that the clearest image has been found, fine focusing is completed, and the process ends.
[0067] If the current image clarity does not meet the standard, continue to adjust the focus.
[0068] Focus adjustment: At this stage, the focus adjustment is more precise, and fine-tuning is made based on the clarity calculated by the CNN model. This process is more precise than traditional focusing methods and can find the optimal focus in a local area.
[0069] During the focus adjustment process, a control strategy (such as a PID controller) is used to achieve smooth focus adjustment to avoid over-adjustment or oscillation.
[0070] Determine whether the maximum number of iterations has been reached: If the maximum number of iterations Mmax has been reached, the fine focus stage is terminated. Otherwise, the focus is adjusted and the clarity is recalculated.
[0071] Figure 5 The comparison between focusing time and image clarity is shown, and the focusing time and image clarity of the traditional hill climbing focusing method and the hill climbing focusing method combined with the CNN model are compared at different focusing points. Focus time: The average focusing time of the traditional hill-climbing focusing method is approximately between 6 and 8 seconds, and some focus points can even take more than 8 seconds (such as points 1, 4, 13, 15, etc.).
[0072] The hill climbing focusing method using the CNN model has a focusing time of 1.7 seconds to 2.1 seconds for most focus points, showing that the CNN model significantly improves the focusing efficiency.
[0073] Image clarity: The image clarity of the traditional hill-climbing focusing method varies at different focus points, with some focus points having a clarity of 1 (clear) and some having a clarity of 0 (blurred). For example, the image clarity of the 5th, 6th, 13th, 14th, 16th, etc. focus points is low.
[0074] The image clarity of almost all focus points of the hill climbing focus method combined with the CNN model reached 1 (clear), indicating that the CNN model greatly improved the image clarity.
[0075] Figure 6 The image shows the process from out-of-focus to over-focus using the new focus algorithm. The images show the effects of different focus stages in turn. Each image is marked with a label (0 or 1) below, indicating the clarity of the image.
[0076] The leftmost images (labeled 0) show that the focus is not optimal and the images are out of focus or blurry.
[0077] As the image moves to the right, the focus is gradually adjusted to the optimal state and the clarity gradually improves.
[0078] The rightmost image (labeled 1) shows the sharpest focus, with a clear image.
Claims
1. A microscope camera autofocus method based on hill climbing algorithm and CNN model, characterized in that: The steps include: Step S1. Image acquisition: A high-resolution camera is used to acquire 500 sets of images. Each set of images is continuously focused with a fixed step length of 1 μm to acquire at least 15 frames to obtain an initial data set. Step S2. Data preprocessing: preprocessing the initial data set obtained in step S1, specifically including data cleaning, normalization, data enhancement, data set partitioning and feature engineering, to obtain a preprocessed data set; Step S3. Convolutional neural network model training: By building a CNN binary classification model, the image features in the data set preprocessed in step S2 are learned to distinguish between clear and blurred images. Dynamic adjustment of learning rate and early stopping mechanism are adopted to optimize the stability of the training process, prevent overfitting, and automatically select the best model parameters to obtain the optimal model; Step S4. Autofocus model evaluation: Use the hill climbing algorithm and the CNN binary classification model trained in step 3 to evaluate the images collected by the microscope in real-time processing step S1. The image clarity is accurately quantified through deep feature extraction and binary classification scoring mechanism. The optimal focal length is obtained according to the clarity evaluation mechanism, adaptive step size control, and termination and convergence conditions.
2. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S1, the acquisition range covers the entire focal length interval from "completely out of focus" to "overfocus", and at least 15 frames of images are acquired at each focus length.
3. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S2, the data cleaning is performed by deleting or filling missing values in the data, detecting and processing outliers in the data, and removing duplicate samples.
4. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S3, the dynamic adjustment of the learning rate is to use a custom learning rate scheduler to dynamically adjust the learning rate through a linear warm-up and decay strategy, and provide real-time monitoring and updating functions.
5. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the hill climbing algorithm performs an efficient search on the Z-axis focal plane through a gradient ascent strategy in the autofocus system, quickly determines the optimal focal length, and achieves fast coarse focusing; uses image contrast as an evaluation function, and iteratively moves to a higher definition area until a definition peak is reached.
6. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the images collected by the microscope are sparsely sampled using a large step size strategy of 3-5 μm in the initial sampling stage to cover the entire possible focal plane area and establish a preliminary focus-sharpness relationship mapping.
7. The microscope camera auto-focusing method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the clarity evaluation mechanism is to apply the Laplacian operator to perform edge detection, calculate the image contrast function value as a clarity metric, and construct a functional relationship curve between focal length and clarity.
8. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the adaptive step size control is to dynamically adjust the search step size, automatically reduce the step size when the clarity gradient changes significantly, and perform more precise sampling in the high gradient area.
9. The microscope camera autofocus method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the termination and convergence conditions are to control the convergence time within 500 ms, and the final positioning accuracy reaches the range of ±15 μm, providing a good initial value for subsequent fine focusing.
10. The microscope camera auto-focusing method based on hill climbing algorithm and CNN model according to claim 1, characterized in that: In step S4, the CNN binary classification model adopts a pre-trained VGG19 convolutional neural network architecture to achieve high-precision evaluation of microscope image clarity; the CNN binary classification model receives the initial position provided by the coarse focusing stage, and performs precise positioning within a limited focal plane to achieve micron-level focusing accuracy.