Automatic focusing method and system for microscopic system in microbial population analyzer
Through image clarity evaluation and gradient method combined with multi-wavelength light source module, dynamically adjusting the objective lens magnitude and light source light source, the problems of unstable focus accuracy and rigid light source adaptation in traditional microscopic imaging systems are solved, and efficient and high-precision microbial analysis is achieved.
Patent Information
- Application Number
- CN202510692057.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-05-27
AI Technical Summary
Traditional microscopic imaging systems have significant bottlenecks in autofocus, light source adaptation and complex sample analysis, including unstable focus accuracy, inability to dynamically match sample characteristics of light sources, and unreasonable allocation of computing resources, making it difficult to achieve efficient and high-precision microbial analysis.
Through the image clarity evaluation method and gradient method, dynamically adjust the objective lens magnitude and light source, combined with the multi-wavelength light source module, self-positioning of the focus area and intelligent adaptation of the light source, an adaptive closed-loop imaging system is built, and the focal plane is dynamically adjusted to adapt to environmental interference.
Dynamic and accurate focus of microbial targets is achieved, the work efficiency and imaging quality of microscopic analysis are improved, the limitations of passive focus is overcome, and the needs of multimodal imaging are adapted to the needs of multimodal imaging.
Smart Images

Figure CN120215101B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of microscopic system focusing, and in particular relates to an automatic focusing method and system for a microscopic system in a microbial population analyzer. Background Art
[0002] Currently, the activated sludge process is the mainstream technology for urban wastewater treatment, effectively removing organic matter from wastewater through the presence of various microorganisms. The diversity and abundance of microbial species are key indicators of wastewater treatment efficiency, and the growth status of different microbial populations directly determines the ultimate outcome of wastewater purification. Accurate detection of microorganisms in activated sludge is a key component in ensuring the effectiveness of activated sludge wastewater treatment methods. It is also of immeasurable importance for real-time monitoring of the operational status of wastewater treatment systems, promoting the sustainable development of the wastewater treatment industry, and strengthening environmental protection efforts.
[0003] Traditional microbial microscopic examination methods for activated sludge are highly dependent on manual identification of the types and quantities of microorganisms. This process not only requires operators to have profound professional knowledge, but also has significant disadvantages such as time-consuming and inefficient detection. Secondly, as the core equipment for microbial microscopy, the imaging quality of the microscope system has a decisive influence on the accuracy of microbial morphological observation, structural analysis, and dynamic behavior research. Since the first application of autofocus technology in the camera field in 1963, its development has undergone iterative upgrades from mechanical, optical to image analysis-based passive focusing methods (such as DFF and DFD), and with the integration of deep learning technology, it has gradually achieved an intelligent leap from feature extraction to end-to-end focusing.
[0004] However, passive focusing methods rely on image analysis, resulting in high computational complexity and slow focusing speeds. This is especially true when dealing with complex samples (such as multi-layer structures and low-contrast samples), as the evaluation function is susceptible to interference, which in turn affects focusing accuracy. Furthermore, traditional focal plane modeling assumes that the sample is in a single plane, making it difficult to adapt to the three-dimensional deformation and thickness differences of actual samples, resulting in blurred imaging when the depth of field is insufficient. Furthermore, environmental interference (such as vibration and temperature changes) and compatibility issues with multimodal imaging modes further restrict the stability and applicability of the system.
[0005] In summary, traditional microscopy systems have significant bottlenecks in autofocus, light source adaptation, and complex sample analysis:
[0006] ① The autofocus mechanism has inherent flaws and relies on a single metric for focus: the traditional contrast method is easily interfered by low-texture samples, the gradient method is sensitive to noise, and the frequency domain analysis has poor real-time performance, resulting in unstable focus accuracy;
[0007] ② Rigid light source adaptation: Fixed wavelength and intensity light sources make it difficult to balance resolution and chromatic aberration. It is also impossible to dynamically match objective lens parameters with sample characteristics, making it difficult to strike a balance between resolution and chromatic aberration control.
[0008] ③ The global image processing method is inefficient: the allocation of computing resources is unreasonable, the global image processing calculation is redundant, it is difficult to focus on high-value areas, and it seriously restricts the application expansion of high-throughput scenarios. Summary of the Invention
[0009] The purpose of the present invention is to provide an automatic focusing method and system for a microscope system in a microbial population analyzer, which achieves precise focusing through image clarity and performs separate focusing processing on each level of objective lens magnification, thereby improving image acquisition accuracy. Secondly, based on the change of objective lens magnification, self-positioning of the focusing area is achieved, dynamic and precise focusing of microbial targets is achieved, and the work efficiency of microscopic analysis is improved.
[0010] The present invention is mainly achieved through the following technical solutions:
[0011] An automatic focusing method for a microscopic system in a microbial population analyzer comprises the following steps:
[0012] Step S1: Initialization operation: Control the X-axis stepper motor and the Y-axis stepper motor to move the stage to move the sample on the slide into the field of view of the microscope system; initialize the position of the stage and the magnification of the objective lens, and initialize the light source settings;
[0013] Step S2: Coarse focus adjustment: Coarsely adjust the height of the objective lens, and collect an image of the target object during the continuous movement of the objective lens from top to bottom. Determine the optimal coarse focus position based on the clarity of the image, and move the objective lens to the optimal coarse focus position;
[0014] Step S3: Fine focus adjustment: adapt the light source, then finely adjust the height of the objective lens, and collect an image of the target object during the continuous movement of the objective lens from top to bottom. Based on the clarity of the image, determine the optimal fine focus position, and move the objective lens to the optimal fine focus position;
[0015] Step S4: Scan and capture an image of the target object, locate the focus area, and move the center of the focus area to the center of the field of view of the microscope system;
[0016] Step S5: Change the magnification of the objective lens and repeat steps S2 to S4 until the set threshold of the objective lens magnification is reached, and focusing is completed.
[0017] In order to better implement the present invention, further, in step S2 and step S3, the clarity of the image is evaluated by a contrast method or a gradient method; the contrast method evaluates the clarity of the image by analyzing the local contrast of the image, and the gradient method evaluates the clarity of the image by analyzing the gradient change of the image.
[0018] In order to better implement the present invention, further, the contrast method includes the following steps:
[0019] Step A1: Collect images and obtain the image sequence {img1, img2, ..., img z}, where img z is the image of the target object taken when the objective lens moves to the height Z;
[0020] Step A2: grayscale the image: divide the image into M×N sub-blocks and convert the color image of the sub-block into a grayscale image;
[0021] Step A3: Calculate the grayscale variance or standard deviation of all sub-blocks and use it as the local contrast value; calculate the variance of the image grayscale value as the contrast evaluation function;
[0022] Step A4: The contrast evaluation value is distributed in a single-peak curve as the height position of the objective lens changes. If the first-order derivative of the contrast evaluation function is equal to zero and the second-order derivative is less than zero, it is determined that the optimal coarse focus position or the optimal fine focus position is obtained.
[0023] In order to better implement the present invention, further, the gradient method includes the following steps:
[0024] Step B1: Collect images and obtain an image sequence {img1, img2, ..., img z}, where img z is the image of the target object taken when the objective lens moves to the height Z;
[0025] Step B2: grayscale processing is performed on a single pixel of the image;
[0026] Step B3: Perform Gaussian filtering on the image to smooth and remove noise;
[0027] Step B4: Calculate the gradient value and the square of the gradient amplitude of the image, and use the square sum of the gradient amplitude of the image as the gradient evaluation function;
[0028] Step B5: The larger the sum of squares of the gradient amplitudes of the image, the clearer the image. The gradient evaluation function presents a single-peak curve distribution as the height position of the objective lens changes. If the first-order derivative of the gradient evaluation function is equal to zero and the second-order derivative is less than zero, it is determined that the optimal position for coarse focus or the optimal position for fine focus is obtained.
[0029] In order to better implement the present invention, further, step S4 includes the following steps:
[0030] Step S41: Scan and capture along the X-axis and Y-axis to obtain X×Y images;
[0031] Step S42: Determine the position of the image with the best focus area as (x p ,y p );
[0032] Step S43: Divide the image with the best focus area into M×N sub-blocks, and determine the position of the sub-block with the best focus area as (m p , n p ); where the pixel size of each sub-block is a×a;
[0033] Step S44: Obtain the focus position (x M ,y M ):
[0034]
[0035] Among them: x The distance of the X-axis stepper motor corresponding to a single image;
[0036] l y The distance of the Y-axis stepper motor corresponding to a single image;
[0037] a is a single-dimensional pixel of the image;
[0038] Step S45: moving the center of the focus area to the center of the field of view of the microscope system based on the focus position.
[0039] In order to better implement the present invention, further, in step S42 and step S43, determining the optimal focus area includes the following steps:
[0040] Step C1: Mark the image or sub-block and perform grayscale processing;
[0041] Step C2: Construct a comprehensive information evaluation function:
[0042]
[0043] Where: C max , G max , E max They are the maximum contrast, maximum gradient, and maximum entropy of the full image sub-block, respectively, used for normalization;
[0044] α, β, γ are weight coefficients respectively, and α+β+γ=1;
[0045] C(x, y) is the contrast value of the image or sub-block at position (x, y);
[0046] G(x, y) is the gradient strength value of the image or sub-block at position (x, y);
[0047] E(x, y) is the entropy value of the image or sub-block at position (x, y);
[0048] Step C3: Based on the information comprehensive evaluation function, calculate the maximum information comprehensive evaluation value S max (x, y), the corresponding coordinates are (x max ,y max ), determined as the best focus area.
[0049] In order to better implement the present invention, further, in step S3, adapting the light source includes the following steps:
[0050] Step S301: construct the objective function:
[0051] f(I c )=α1d eff +α2Δt;
[0052] Where: α1, α2 are weight coefficients, where α1+α2=1;
[0053] d eff Equivalent Abbe resolution for the synthesis of multi-wavelength light sources;
[0054] Δt is the color difference;
[0055] Maximize the equivalent Abbe resolution and minimize chromatic aberration;
[0056] Step S302: Construct the constraint conditions as follows:
[0057]
[0058] Where: I c is the wavelength λ c Light intensity weight of the light source;
[0059] c is the type of light source;
[0060] Step S303: Based on the Lagrange multiplier method, the constraints are integrated into the objective function by introducing multipliers, and the candidate points are solved using the gradient collinearity and extreme value necessary conditions to obtain the optimal parameters of the light source.
[0061] To better implement the present invention, the light source further includes a plurality of micro light source modules arranged in an array, wherein the micro light source modules include a purple light source, a red light source, a blue light source, and a green light source, and the corresponding wavelength ranges are 380-450nm, 620-780nm, 450-495nm, and 495-570nm, respectively; the light intensity of each color light source in the micro light source module is adjusted:
[0062] I c-out =k1Ic ;
[0063] Where: I c-out is the wavelength λ c The output light intensity weight of the light source;
[0064] k1 is the light intensity expansion coefficient,
[0065] max(I c ) is the wavelength λ c The maximum light intensity weight of the light source.
[0066] To better implement the present invention, the micro light source module can further provide ultraviolet light (UVA wavelength range is 315-380nm, UVB wavelength range is 280-315nm, UVC wavelength range is 190-280nm). Preferably, the micro light source module also includes a yellow light source, an orange light source, and a near-infrared light source, and the corresponding wavelength ranges are 570-590nm, 590-620nm, and 780nm-1100nm, respectively.
[0067] In order to better implement the present invention, further, the wavelengths of the purple light source, red light source, blue light source and green light source are 415nm, 685nm, 475nm and 530nm respectively.
[0068] The present invention is mainly achieved through the following technical solutions:
[0069] An automatic focusing system for a microscopic system in a microbial population analyzer, used to implement the above-mentioned automatic focusing method for a microscopic system in a microbial population analyzer, comprising:
[0070] Industrial cameras, used to scan and capture images of targets;
[0071] The stage motion module, including the X-axis stepper motor and the Y-axis stepper motor, is used to adjust the position of the stage to move the sample on the slide into the field of view of the microscope system;
[0072] Focus adjustment module, including Z-axis coarse focusing stepper motor and Z-axis fine focusing stepper motor, used for coarse and fine adjustment of the height of the objective lens;
[0073] A light source module, used to provide a multi-band light source;
[0074] Initialization module, used to initialize the parameters of the microscope system;
[0075] A focusing module, configured to determine an optimal coarse focus position and an optimal fine focus position based on image clarity;
[0076] A focus positioning module is used to analyze the scanned image of the target object and locate the focus area;
[0077] Image acquisition module, used to receive images taken by industrial cameras;
[0078] Image processing module, used to pre-process images and analyze image clarity;
[0079] Light source adaptation module, used to adapt light source parameters.
[0080] The beneficial effects of the present invention are as follows:
[0081] During use, the present invention can dynamically adapt the light source, focus on each level of objective lens magnification, progressively determine the focus area, and dynamically adjust the position of the stage to move the center of the focus area to the center of the field of view of the microscope system, ultimately achieving high-precision focus. Specifically, the present invention collects clear images under each level of objective lens magnification and performs self-positioning of the focus area respectively, achieving dynamic and precise focus on microbial targets and improving the work efficiency of microscopic analysis. Specifically, the present invention combines the spatial distribution characteristics of microorganisms with automated microscopic focusing technology, and when determining the optimal focus area, accurately locks the focus position based on the comprehensive information evaluation function.
[0082] This invention analyzes and processes microscopic images in real time, establishing a precise image clarity evaluation function. It also combines active ranging technology with image analysis to achieve precise focusing of the objective lens, overcoming the limitations of passive focusing. It constructs a three-dimensional focal plane model and dynamically adjusts the focal plane, supplemented by environmental compensation technology to suppress interference and achieve multimodal imaging.
[0083] The present invention proposes a multimodal fusion architecture of light source, focusing and focusing, and constructs an adaptive closed-loop imaging system. The light source of the present invention achieves full visible spectrum coverage, monochromatic purity improvement and three-dimensional vector illumination through a programmable photonic chip array; when adapting the light source, the overall light source characteristics and the output light intensity weight of the monochromatic light source are optimized, realizing intelligent light source adaptation and having good practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] Figure 1 This is a flow chart of the automatic focusing method of the microscope system in the microbial population analyzer of the present invention;
[0085] Figure 2 This is an image of the target object captured during the coarse focus adjustment process;
[0086] Figure 3 This is an image of the target object captured during the fine focus adjustment process;
[0087] Figure 4 Schematic diagram of the structure of the light source module;
[0088] Figure 5 Flowchart of the contrast method;
[0089] Figure 6 This is the flow chart of the gradient method;
[0090] Figure 7 A flow chart for determining the focus area of the next magnification of the objective lens;
[0091] Figure 8 This is a structural diagram of the autofocus system of the microscope system in the microbial population analyzer of the present invention. DETAILED DESCRIPTION
[0092] Example 1:
[0093] An automatic focusing method for a microscopic system in a microbial population analyzer, such as Figure 1 As shown, the following steps are included:
[0094] Step S1: Initialization operation, the specific steps are as follows:
[0095] Step S11: pre-mounting the slide on the stage and making it; then, controlling the X-axis stepper motor and the Y-axis stepper motor to adjust the stage so that it is within the field of view of the microscope system;
[0096] Step S12: Initializing the position of the stage and adjusting the distance between the stage and the objective lens to the limit position;
[0097] Step S13: Initialize the magnification of the objective lens to 4X;
[0098] Step S13: Initialize the light source settings; preferably, turn on the light and adjust it to uniform mode, with the setting ratio of each color light source being 25%, specifically a purple light source, a red light source, a blue light source and a green light source, and the light source wavelengths are 415nm, 685nm, 475nm and 530nm respectively.
[0099] Step S2: Coarse focus adjustment. The specific steps are as follows:
[0100] Step S21: adapting the light source, and then initializing the position of the Z-axis coarse focusing stepper motor;
[0101] Step S22: Control the Z-axis coarse focusing stepper motor to move from top to bottom, and acquire images of the target object at different objective lens movement heights;
[0102] Step S23: Filter the clearest image and confirm the optimal position of coarse focus; specifically, Figure 2As shown, (a)-(d) and (f) are the images of the target object captured when the Z-axis coarse focusing stepper motor moves from top to bottom to heights h1-h5, respectively. The image of the target object captured when the objective lens moves to height h3 has the best clarity, and height h3 is the optimal coarse focusing position;
[0103] Step S24: Move the objective lens to the optimal coarse focusing position via the Z-axis coarse focusing stepper motor.
[0104] Step S3: Fine focus adjustment. The specific steps are as follows:
[0105] Step S31: Initializing the position of the Z-axis fine focusing stepper motor;
[0106] Step S32: Control the Z-axis fine focusing stepper motor to move from top to bottom, and acquire images of the target object at different objective lens movement heights;
[0107] Step S33: Filter the clearest image and confirm the best position for fine focus; specifically, Figure 3 As shown, (a)-(d) and (f) are images taken when the Z-axis fine focus stepper motor moves from top to bottom to the heights Z1-Z5, respectively. The image clarity at the height Z3 is the best, and the height Z3 is the best fine focus position;
[0108] Step S34: moving the objective lens to the optimal fine focus position via the Z-axis coarse focus stepping motor;
[0109] Step S4: Scan and capture an image of the target object, locate the focus area, and move the center of the focus area to the center of the field of view of the microscope system;
[0110] Step S5: Change the magnification of the objective lens and repeat steps S2 to S4 until the set threshold of the objective lens magnification is reached, and focusing is completed.
[0111] Preferably, in step S2 and step S3, the method for screening the clearest image includes a contrast method and a gradient method, which mainly evaluates the clarity of the image by analyzing the local contrast and gradient changes of the image.
[0112] Among them, such as Figure 5 As shown, the contrast method includes the following steps:
[0113] Step A1: Image acquisition: Use the microscope system camera to acquire image sequences at different movement heights of the objective lens:
[0114] {img1, img2, ..., img z};
[0115] Where: z: the number of steps that the Z-axis coarse focus stepper motor or the Z-axis fine focus stepper motor moves on the Z axis;
[0116] img z : The image of the target object captured when the objective lens moves to the height Z is specifically expressed as:
[0117]
[0118] n, m: the number of rows and columns of single-dimensional pixels, with a total of n×m pixels;
[0119] Pi nm :Single pixel, and Pi nm =[R GB];
[0120] R, G, and B: Red, Green, and Blue color values.
[0121] Step 2: Grayscale the image:
[0122] 1. Block processing: Divide the image into M×N sub-blocks (such as 32×32 pixels) to avoid global noise interference;
[0123] 2. Grayscale: Convert the color image of the sub-block into a grayscale image;
[0124]
[0125] Where: I: grayscale value of the sub-block image;
[0126] k R : R color grayscale conversion coefficient, default k R =0.299, adjusted by engineers;
[0127] k G : G color grayscale conversion coefficient, default k G =0.587, adjusted by engineers;
[0128] k B : B color grayscale conversion coefficient, default k B =0.114, adjusted by engineers;
[0129] a: single-dimensional pixel of the image, for example, a=32 for 32×32 pixels;
[0130] R ij : R color value of the ijth pixel in the sub-block image;
[0131] G ij : G color value of the ijth pixel in the sub-block image;
[0132] B ij: B color value of the ijth pixel in the sub-block image;
[0133] i, j: process variables.
[0134] 3. The grayscale value after single layer segmentation is:
[0135]
[0136] Where: I(Z): the grayscale value set of pixels in layer Z.
[0137] Step A3: Contrast calculation:
[0138] The grayscale variance (or standard deviation) of each sub-block is calculated as the local contrast value; the global contrast is the weighted average of the contrasts of all sub-blocks.
[0139] The variance of the image grayscale value is used as the contrast evaluation function:
[0140]
[0141] Where: C(Z): variance of the grayscale value of the Z layer image;
[0142] I(i, j, Z): grayscale value of the Z-layer sub-block;
[0143] M, N: number of single-dimensional image segmentations;
[0144] i, j: process variables;
[0145] μ(Z): average grayscale of the image.
[0146] Step A4: Find the optimal focal length based on the contrast evaluation function:
[0147] The contrast evaluation value is distributed as a single peak curve (parabola) along the Z axis position. Therefore, let the function y = f(Z) = C(Z);
[0148] If there exists a first-order derivative f′(x)=0 and a second-order derivative f”(x)<0, x∈Z, then the optimal coarse focus position or the optimal fine focus position is x.
[0149] The first-order derivative of the discrete quantity is:
[0150]
[0151] Discrete second-order derivative:
[0152]
[0153] Where: Δx: single step length of the Z-axis coarse focusing stepper motor or the Z-axis fine focusing stepper motor.
[0154] Among them, such as Figure 6 As shown, the gradient method includes the following steps:
[0155] Step B1: image acquisition, which is the same as the above step A1 and will not be described in detail.
[0156] Step B2: Grayscale the single pixel of the image:
[0157] I=k R R inm +k G G inm +k B B inm ;
[0158] Where: I: gray value of a single pixel;
[0159] R inm , G inm , B inm They are the R color value, G color value, and B color value of a single pixel respectively;
[0160] k R : R color grayscale conversion coefficient, default k R =0.299, adjusted by engineers;
[0161] k G : G color grayscale conversion coefficient, default k G =0.587, adjusted by engineers;
[0162] k B : B color grayscale conversion coefficient, default = k B 0.114, adjusted by engineers;
[0163]
[0164] n, m: the number of rows and columns of pixels in a single dimension, with a total of n×m pixels;
[0165] I(Z): The grayscale value set of pixels in the Z layer.
[0166] Step B3: Perform Gaussian filtering on the image: smooth and remove noise on the image (Gaussian kernel σ=1.0).
[0167] 1. The two-dimensional Gaussian function model is:
[0168]
[0169] Where: G(x, y): weight of Gaussian kernel;
[0170] σ: standard deviation of the Gaussian kernel, controls the smoothing strength, σ=1;
[0171] x, y: Coordinates with the kernel center as the origin, ranging from -k, k. The kernel size is (2k+1)×(2k+1), where k=3σ. When σ=1, the kernel size is 7×7; when σ=2, the kernel size is 13×13.
[0172] 2. Traverse each position (u, v) in the kernel, where u and v are both integers, and calculate the value of the continuous high-speed function:
[0173]
[0174] Among them: G continuous (u, v): value of the continuous Gaussian function;
[0175] u: X-axis coordinate offset in the Gaussian kernel matrix. u is an integer step size in the range [-k, k], with the kernel center as the origin. When σ = 1 and k = 3σ, u∈{-3, -2, -1, 0, 1, 2, 3};
[0176] v: Y-axis coordinate offset in the Gaussian kernel matrix, v is an integer step size belonging to [-k, k], with the kernel center as the origin. When σ = 1 and k = 3σ, v∈{-3, -2, -1, 0, 1, 2, 3};
[0177] k: Kernel boundary expansion coefficient, determined by the Gaussian kernel standard deviation σ, with the default k = 3σ.
[0178] 3. Discrete normalization of continuous high-speed function values:
[0179]
[0180] Where: S: the sum of Gaussian values at all (u, v) positions:
[0181] Ensure that the total weight of the discrete kernel is 1 to avoid image brightness offset and perform discrete normalization on the Gaussian kernel value:
[0182]
[0183] G discrete (u, v): Discrete and normalized Gaussian kernel value.
[0184] 4. Gaussian filter operation, convolution of image grayscale value:
[0185]
[0186] Where: I smooth (i, j): grayscale value of the smoothed image.
[0187] I(i+u, j+v): Grayscale value of a single pixel at position (i+u, j+v) in the element image, I(i+u, j+v)∈I(Z); i, j: process variables.
[0188] Step B4: Gradient calculation:
[0189] 1. Image gradient value calculation. The gradient value of the two-dimensional image I(x, y) is:
[0190] in:
[0191] The gradient value of the image;
[0192] x: the position of the far point of the pixel in the X-axis direction;
[0193] y: the position of the far point of the pixel in the Y-axis direction;
[0194] Partial differential symbol.
[0195] 2. Sobel operator:
[0196] (1) Sobel operator in x direction:
[0197] The x-direction difference is The weight vector corresponding to the formula is [-1, 0, 1].
[0198] Where: I(x+1, y): the grayscale value of a single pixel at position (x+1, y) in the element image;
[0199] I(x-1, y): the grayscale value of a single pixel at position (x-1, y) in the element image;
[0200] In the y direction, a Gaussian smoothing kernel [1, 2, 1] is used to perform weighted averaging of neighboring pixels to suppress noise;
[0201] Perform the outer product of the difference and the smoothing kernel to obtain the horizontal gradient kernel:
[0202]
[0203] Where: S x : Sobel operator in x direction;
[0204] T: matrix transpose symbol;
[0205] : Matrix dot product notation.
[0206] (2) Sobel operator in the y direction:
[0207] S y =S x T;
[0208] Where: S y : Sobel operator in y direction.
[0209] 3. The gradient calculation formula is as follows:
[0210] (1) Use the Sobel operator to calculate the x gradient:
[0211]
[0212] Where: i, j: process variables;
[0213] S x (u+2, v+2): the element in the u+2th row and v+2th column of the kernel matrix.
[0214] (2) Use the Sobel operator to calculate the y gradient:
[0215]
[0216] Where: i, j: process variables;
[0217] S y (u+2, v+2): the element in the u+2th row and v+2th column of the kernel matrix;
[0218] Compute the squared gradient magnitude:
[0219]
[0220] in: gradient amplitude;
[0221] || ||: Two-dimensional norm symbol.
[0222] Step 5: Construct the gradient evaluation function:
[0223]
[0224] Where: G(Z): the sum of the squared gradient amplitudes of the image at the Z-axis position of the objective lens.
[0225] Step 6: The larger the sum of squares of the gradient amplitudes, the clearer the image, and the gradient evaluation function presents a single-peak curve (parabolic distribution) as the Z-axis position changes.
[0226] Let function y=f(Z)=C(Z); if there exists a first-order derivative f'(x)=0 and a second-order derivative f"(x)<0, x∈Z, then the optimal focal position is x.
[0227] Discrete first-order derivative:
[0228]
[0229] Discrete second-order derivative:
[0230]
[0231] Where: Δx: single step length of the Z-axis coarse focusing stepper motor or the Z-axis fine focusing stepper motor.
[0232] Preferably, in step S4, the focused area is represented by the following main forms: a larger image information entropy value indicates more information, a larger gradient intensity value indicates more information, and a larger contrast value indicates more information. After the microscope system is focused, a clear scan image of the entire slide is obtained, and then the focused area image is searched; the obtained clear image is divided into a plurality of sub-blocks to search for the focused area sub-block, and the position of each sub-block is calculated.
[0233] like Figure 7 As shown, step S4 includes the following steps:
[0234] Step S41: Scan and capture along the X-axis and Y-axis to obtain X×Y images;
[0235] Step S42: Based on the method for obtaining the focus area, determine the position of the image with the best focus area as (x p ,y p );
[0236] Step S43: Divide the image with the best focus area into M×N sub-blocks, and the number of pixels of each sub-block is a×a;
[0237] Based on the method of obtaining the focus area, the position of the sub-block with the best focus area is determined as (m p , n p );
[0238] Step S44: Determine the focus position (x M ,λ M ):
[0239]
[0240] Among them: x : The distance of the X-axis stepper motor corresponding to a single image;
[0241] l y : The distance of the Y-axis stepper motor corresponding to a single image;
[0242] a: A single-dimensional pixel of an image.
[0243] Step S45: moving the center of the focus area to the center of the field of view of the microscope system based on the focus position.
[0244] Preferably, the method for obtaining the focus area comprises the following steps:
[0245] Step C1: grayscale processing is performed on the scanned image or the segmented sub-blocks. Specifically, the scanned image or the segmented image sub-blocks are marked; then, single-pixel grayscale processing is performed.
[0246] Step C2: Construct a comprehensive information evaluation model:
[0247] The objective function is set as follows: the image contrast is clear and the edge contour is obvious; the amount of information is large, wherein the greater the contrast value of the image or sub-block, the more information; the greater the gradient intensity value of the image or sub-block, the more information; the greater the entropy value of the image or sub-block, the more information.
[0248] Specifically, the comprehensive information evaluation function is:
[0249]
[0250] Where: C max , G max , E max They are the maximum contrast, maximum gradient, and maximum entropy of the full image sub-block, respectively, used for normalization;
[0251] α, β, γ: weight coefficient, and α+β+γ=1;
[0252] C(x, y): contrast value of the image or sub-block at position (x, y);
[0253] G(x, y): Gradient intensity value of the image or sub-block at position (x, y);
[0254] E(x, y): entropy value of the image or sub-block at position (x, y).
[0255] Step C3: Use an algorithm (such as the bubble method) to obtain the maximum information comprehensive evaluation value S max (x, y), the corresponding coordinates are (x max ,y max ), determined as the best focus area.
[0256] Among them, the contrast value of the image or sub-block at the position (x, y) is:
[0257]
[0258] Where: I xy (i, j): grayscale value of the image or sub-block at position (x, y);
[0259] n, m: the number of rows and columns of single-dimensional pixels, with a total of n×m pixels;
[0260] i, j: process variables;
[0261] μ(x, y): The average grayscale of the image at position (x, y).
[0262] Among them, the gradient strength value of the image or sub-block at position (x, y) is:
[0263]
[0264] Where: S x : Sobel operator in x direction;
[0265] S y : Sobel operator in y direction.
[0266] The entropy value of the image or sub-block at position (x, y) is calculated as follows:
[0267] Entropy is a metric used in information theory to measure the uncertainty of random variables. In image processing, texture complexity can be quantified using entropy. High entropy indicates a dispersed distribution of pixel grayscale values and rich textures, while low entropy indicates a concentrated distribution of pixel grayscale values and smooth textures. Entropy, based on the grayscale histogram, reflects the randomness of the pixel value distribution.
[0268]
[0269] Where: P(v) represents the probability of occurrence of gray value v in the scanned image or sub-block.
[0270] Calculate the probability of occurrence P(v):
[0271] Statistical sub-block grayscale histogram:
[0272] For m×n scanned images or sub-blocks, count the frequency of occurrence of grayscale value v in the scanned images or sub-blocks:
[0273]
[0274] Where: δ(x): Dirac function, when x = 0, δ(x) is 1, otherwise it is 0.
[0275] Then the probability P(v) is:
[0276]
[0277] Example 2:
[0278] This embodiment is optimized based on the embodiment 1. In step S3, the content of adapting the light source is as follows:
[0279] The resolution model of the microscope system based on Abbe's formula is:
[0280]
[0281] Where: d a : Abbe resolution limit at monochromatic light wavelength λ;
[0282] NA: Numerical aperture.
[0283] For a polychromatic light source, the resolution is determined by the shortest wavelength λmin, but the intensity contribution of each wavelength must be considered. Therefore, the equivalent Abbe resolution of the multi-wavelength light source is:
[0284]
[0285] Where: c: light source type;
[0286] I c : wavelength λ c The light intensity weight of the light source.
[0287] Construct a light source adaptation model. The specific contents are as follows:
[0288] Step S301: Determine the optimization goal as maximizing the effective resolution of the imaging system and minimizing chromatic aberration; construct the objective function as follows:
[0289] f(I c )=α1d eff +α2Δt;
[0290] Where: α1, α2: weight coefficients used to balance the equivalent Abbe resolution and color difference, where α1+α2=1, α1=0.7, α2=0.3 by default, which can be adjusted by engineers;
[0291] Δt: chromatic aberration, the standard deviation of optical path length differences at different wavelengths;
[0292] Optimize the objective function f(I c ) value to the minimum;
[0293] Step S302: Construct the constraint conditions as follows:
[0294] Chromatic aberration is mainly caused by the difference in refractive index at different wavelengths. The calculation formula for chromatic aberration is as follows:
[0295]
[0296] in: Mean optical path difference,
[0297] OPC c : Optical path difference at different wavelengths, OPCc =n(λ c )*tn(λ ref )*t;
[0298] t: material thickness;
[0299] n(λ c ): wavelength λ c The refractive index of the light source in the material;
[0300] n(λ ref ): reference wavelength λ ref The refractive index in the material;
[0301] The Sellmeier equation is used to describe how the refractive index of different transparent media changes with wavelength:
[0302]
[0303] Where: n(λ): refractive index of wavelength λ light source in the material;
[0304] g: fitting length;
[0305] B i , C i : Fitting empirical constants related to the material; taking BK7 glass as an example, when g = 3, B1 = 1.03961212, B2 = 0.231792344, B3 = 1.01046945; C1 = 0.0060006986, C2 = 0.0200179144, C3 = 103.560653.
[0306] Optimize the model and substitute the objective function to obtain:
[0307]
[0308] Simplified to:
[0309]
[0310] Step S303: The Lagrange multiplier method integrates constraints into the objective function by introducing multipliers. It then uses gradient collinearity and extremum requirements to find candidate points. This method is a fundamental tool for optimization problems. Its core is to balance the economics between the objective function and the constraints, and it has broad application value in mathematics, physics, and engineering.
[0311] (1) Introduce the Lagrangian multiplier μ and construct the Lagrangian function:
[0312]
[0313] (2) For each I cFind the partial derivative and set it equal to zero:
[0314]
[0315] Solving for the constant:
[0316]
[0317] (3) Introducing objective lens weighted priority allocation strategy:
[0318] 415nm purple light source → 100× objective lens with ultra-high magnification field of view, used for analyzing microbial ultrastructure and physiological status;
[0319] 530nm green light source → 40× objective lens with high magnification field of view, used for analyzing sludge structure and floc activity;
[0320] 475nm blue light source → 10× objective lens with medium field of view, suitable for analyzing protozoa and small flocs to determine sludge load and effluent quality;
[0321] 685nm red light source → 4× objective lens with a large field of view for overall assessment of sludge status and metazoan distribution.
[0322] The wavelength weight strategy of the priority allocation strategy is:
[0323] The wavelength weight strategy for non-priority allocation is:
[0324] Where: ∝: positive correlation symbol.
[0325] Normalized constraint solving:
[0326]
[0327] Where: c : light source weight coefficient;
[0328]
[0329] Preferably, the light source includes a plurality of micro light source modules arranged in an array, wherein the micro light source modules include a violet light source, a red light source, a blue light source, and a green light source, and the corresponding wavelength ranges are 380-450nm, 620-780nm, 450-495nm, and 495-570nm, respectively; the light intensity of each color light source in the micro light source module is adjusted:
[0330] I c-out =k1I c ;
[0331] Where: I c-out is the wavelength λc The output light intensity weight of the light source;
[0332] k1 is the light intensity expansion coefficient,
[0333] max(I c ) is the wavelength λ c The maximum light intensity weight of the light source.
[0334] The rest of this embodiment is the same as that of embodiment 1, so it will not be described again.
[0335] Example 3:
[0336] An automatic focusing system for a microscope system in a microbial population analyzer, such as Figure 8 As shown, it includes a control module and a light source module connected to the control module, an industrial camera, a stage motion module, and a focus adjustment module. The control module includes:
[0337] Initialization module, used to initialize the parameters of the microscope system;
[0338] A focusing module, configured to determine an optimal coarse focus position and an optimal fine focus position based on image clarity;
[0339] A focus positioning module is used to analyze the scanned image of the target object and locate the focus area;
[0340] Image acquisition module, used to receive images taken by industrial cameras;
[0341] Image processing module, used to pre-process images and analyze image clarity;
[0342] Light source adaptation module, used to adapt light source parameters.
[0343] The industrial camera is used to scan and capture images of a target object; and the light source module is used to provide a multi-band light source.
[0344] The stage motion module includes an X-axis stepper motor and a Y-axis stepper motor, which are used to adjust the position of the stage to move the sample on the glass slide into the field of view of the microscope system; the focus adjustment module includes a Z-axis coarse focusing stepper motor and a Z-axis fine focusing stepper motor, which are used to coarsely and finely adjust the height of the objective lens.
[0345] Preferably, it also includes a communication unit, a clock unit, a data storage unit and a power supply unit connected to the control module.
[0346] Preferably, if Figure 4As shown, the light source module has an overall circular structure and is composed of a ring array of several micro light source modules. Each micro light source module integrates four color light sources—purple, red, blue, and green. Each light source achieves 0-100% light intensity adjustment via analog signals. Specifically, the wavelength ranges of the four color light sources are: 380-450nm, 620-780nm, 450-495nm, and 495-570nm, respectively, used to produce a wide color gamut output covering the visible spectrum.
[0347] Preferably, the parameters of the light source module are as follows:
[0348] (1) The radius R (unit: mm) of the light source module matches the working distance (WD) of the objective lens.
[0349] (2) The number of light sources N;
[0350] (3) Each micro light source module contains four-color light sources, and the wavelengths of the four-color light sources are λ V ,λ R ,λ B and λ G , the corresponding central wavelengths are: 415nm, 685nm, 475nm and 530nm, and the light intensity can be independently adjusted to I V , I R , I B , I G ∈[0,1].
[0351] Preferably, the incident angle θ of the light of each color light source is determined by the radius R and the working distance WD of the objective lens, and the calculation formula is:
[0352]
[0353] Preferably, the numerical aperture (NA) is:
[0354] NA=n*sinθ max ;
[0355] Where: n: refractive index of the medium between the objective lens and the sample;
[0356] θ max : The maximum incident angle of each color light source is determined by the outermost light source in the light source array.
[0357] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the scope of protection of the present invention.
Claims
1. An automatic focusing method for a microscopic system in a microbial population analyzer, characterized in that: The following steps are involved: Step S1: Initialization operation: Control the X-axis stepper motor and the Y-axis stepper motor to move the stage to move the sample on the slide into the field of view of the microscope system; initialize the position of the stage and the magnification of the objective lens, and initialize the light source settings; Step S2: Coarse focus adjustment: Coarsely adjust the height of the objective lens, and collect an image of the target object during the continuous movement of the objective lens from top to bottom. Determine the optimal coarse focus position based on the clarity of the image, and move the objective lens to the optimal coarse focus position; Step S3: Fine focus adjustment: adapt the light source, then finely adjust the height of the objective lens, and collect an image of the target object during the continuous movement of the objective lens from top to bottom. Based on the clarity of the image, determine the optimal fine focus position, and move the objective lens to the optimal fine focus position; In step S3, adapting the light source includes the following steps: Step S301: construct the objective function: ; Among them: α1, α2 are weight coefficients, where α1+α2=1; d eff Equivalent Abbe resolution for the synthesis of multi-wavelength light sources; Δt is the color difference; Maximize the equivalent Abbe resolution and minimize chromatic aberration; Step S302: Construct the constraint conditions as follows: ; Among them: I c is the wavelength λ c Light intensity weight of the light source; c is the type of light source; Step S303: Based on the Lagrange multiplier method, the constraints are integrated into the objective function by introducing multipliers, and the candidate points are solved by using the gradient collinearity and extreme value necessary conditions to obtain the optimal parameters of the light source; Step S4: Scan and capture an image of the target object, locate the focus area, and move the center of the focus area to the center of the field of view of the microscope system; Step S5: Change the magnification of the objective lens and repeat steps S2 to S4 until the set threshold of the objective lens magnification is reached, and focusing is completed.
2. The automatic focusing method of a microscopic system in a microbial population analyzer according to claim 1, characterized in that: In step S2 and step S3, the clarity of the image is evaluated by a contrast method or a gradient method; the contrast method evaluates the clarity of the image by analyzing the local contrast of the image, and the gradient method evaluates the clarity of the image by analyzing the gradient change of the image.
3. The automatic focusing method of a microscopic system in a microbial population analyzer according to claim 2, characterized in that: The contrast method comprises the following steps: Step A1: Collect images and obtain image sequences , where img z is the image of the target object taken when the objective lens moves to the height Z; Step A2: grayscale the image: divide the image into M×N sub-blocks and convert the color image of the sub-block into a grayscale image; Step A3: Calculate the grayscale variance or standard deviation of all sub-blocks and use it as the local contrast value; calculate the variance of the image grayscale value as the contrast evaluation function; Step A4: The contrast evaluation value is distributed in a single-peak curve as the height position of the objective lens changes. If the first-order derivative of the contrast evaluation function is equal to zero and the second-order derivative is less than zero, it is determined that the optimal coarse focus position or the optimal fine focus position is obtained.
4. The automatic focusing method of a microscopic system in a microbial population analyzer according to claim 2, characterized in that: The gradient method comprises the following steps: Step B1: Collect images and obtain image sequences , where img z is the image of the target object taken when the objective lens moves to the height Z; Step B2: grayscale processing is performed on a single pixel of the image; Step B3: Perform Gaussian filtering on the image to smooth and remove noise; Step B4: Calculate the gradient value and the square of the gradient amplitude of the image, and use the square sum of the gradient amplitude of the image as the gradient evaluation function; Step B5: The larger the sum of squares of the gradient amplitudes of the image, the clearer the image. The gradient evaluation function presents a single-peak curve distribution as the height position of the objective lens changes. If the first-order derivative of the gradient evaluation function is equal to zero and the second-order derivative is less than zero, it is determined that the optimal position for coarse focus or the optimal position for fine focus is obtained.
5. The automatic focusing method of a microscopic system in a microbial population analyzer according to claim 1, characterized in that: The step S4 comprises the following steps: Step S41: Scan and capture along the X-axis and Y-axis to obtain X×Y images; Step S42: Determine the position of the image with the best focus area as (x p ,y p ); Step S43: Divide the image with the best focus area into M×N sub-blocks, and determine the position of the sub-block with the best focus area as (m p , n p ); where the pixel size of each sub-block is a×a; Step S44: Obtain the focus position of the objective lens at the next magnification ( , ): , ; Among them: x The distance of the X-axis stepper motor corresponding to a single image; l y The distance of the Y-axis stepper motor corresponding to a single image; a is a single-dimensional pixel of the image; Step S45: moving the center of the focus area to the center of the field of view of the microscope system based on the focus position.
6. The method for automatically focusing a microscopic system in a microbial population analyzer according to claim 5, characterized in that: In step S42 and step S43, determining the optimal focus area includes the following steps: Step C1: Mark the image or sub-block and perform grayscale processing; Step C2: Construct a comprehensive information evaluation function: ; Where: C max , G max , E max They are the maximum contrast, maximum gradient, and maximum entropy of the full image sub-block, respectively, used for normalization; α, β, γ are weight coefficients, and α+β+γ=1; C(x, y) is the contrast value of the image or sub-block at position (x, y); G(x, y) is the gradient intensity value of the image or sub-block at position (x, y); E(x, y) is the entropy value of the image or sub-block at position (x, y); Step C3: Based on the information comprehensive evaluation function, calculate the maximum information comprehensive evaluation value S max (x, y), the corresponding coordinates are (x max ,y max ), determined as the best focus area.
7. The automatic focusing method of a microscopic system in a microbial population analyzer according to claim 1, characterized in that: The light source includes a plurality of micro light source modules arranged in an array, wherein the micro light source modules include a violet light source, a red light source, a blue light source, and a green light source, and the corresponding wavelength ranges are 380-450nm, 620-780nm, 450-495nm, and 495-570nm, respectively; the light intensity of each color light source in the micro light source module is adjusted: ; Among them: I c-out is the wavelength λ c The output light intensity weight of the light source; k1 is the light intensity expansion coefficient, ; max(I c ) is the wavelength λ c The maximum light intensity weight of the light source.
8. The method for automatically focusing a microscopic system in a microbial population analyzer according to claim 7, characterized in that: The wavelengths of the purple light source, red light source, blue light source and green light source are 415 nm, 685 nm, 475 nm and 530 nm respectively.
9. An automatic focusing system for a microscopic system in a microbial population analyzer, used to implement the automatic focusing method for a microscopic system in a microbial population analyzer according to any one of claims 1 to 8, characterized in that: include: Industrial cameras, used to scan and capture images of targets; The stage motion module, including the X-axis stepper motor and the Y-axis stepper motor, is used to adjust the position of the stage to move the sample on the slide into the field of view of the microscope system; Focus adjustment module, including Z-axis coarse focusing stepper motor and Z-axis fine focusing stepper motor, used for coarse and fine adjustment of the height of the objective lens; A light source module, used to provide a multi-band light source; Initialization module, used to initialize the parameters of the microscope system; A focusing module, configured to determine an optimal coarse focus position and an optimal fine focus position based on image clarity; A focus positioning module is used to analyze the scanned image of the target object and locate the focus area; Image acquisition module, used to receive images taken by industrial cameras; Image processing module, used to pre-process images and analyze image clarity; Light source adaptation module, used to adapt light source parameters.
Citation Information
Patent Citations
Microscope focusing method and apparatus, computer apparatus, and storage medium
CN109116541A