A detection method for the illumination uniformity of a wide-field microscope based on multi-scale kernels

Through the detection method based on multi-scale cores, the problem of calculating errors of stain illuminance uniformity in wide-field microscopes is solved, efficient and accurate illuminance uniformity detection is achieved, and the need to disassemble and clean the light path is reduced.

CN115187508BActive Publication Date: 2025-08-01NINGBO YONGXIN OPTICS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210597431.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-30
Publication Date
2025-08-01
Estimated Expiration
2042-05-30

AI Technical Summary

Technical Problem

The prior art fails to effectively consider the impact of stain illumination uniformity calculation in wide field microscopy, resulting in large detection errors, and cumbersome and high cost of disassembly and cleaning the light path.

Method used

The detection method based on multi-scale kernels is adopted, and the image preprocessing and masking operation is performed using the OpenCV function. The minimum and maximum grayscale values of the microscope image are calculated in combination with the multi-scale kernels, stain interference is eliminated, and the weighted average values of the minimum grayscale set and the maximum grayscale set of the microscope image are calculated through the multi-scale kernels to obtain the global minimum and maximum grayscale averages, and then the illuminance uniformity is calculated.

Benefits of technology

It effectively suppresses the error influence of stain regulating uniformity, improves the accuracy and stability of detection, and the detection time is completed within 1 second, which is close to the results of manual calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115187508B_ABST
    Figure CN115187508B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for detecting the illumination uniformity of a wide-field microscope based on multi-scale kernels. Using various functions in the open-source computer vision library as auxiliary methods, the original image is first thresholded to obtain a preliminary mask image of the stain. Then, multi-scale kernels are used to traverse and calculate the minimum gray-scale set and the maximum gray-scale set corresponding to the microscopic image under different-scale mean filters. Next, the minimum and maximum values in the two sets are removed, and after weighted averaging of the remaining data respectively, the global minimum gray-scale mean and the global maximum gray-scale mean are obtained. Finally, the illumination uniformity is calculated, which can not only better remove the stain but also reduce the influence of the unremoved stain on the minimum and maximum gray-scale values, thereby improving the detection accuracy of the illumination uniformity and providing a more objective detection method for evaluating the illumination uniformity under the microscope.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for detecting the illumination uniformity of an optical microscope, and particularly to a method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel. Background Art

[0002] Illumination uniformity is an evaluation index of image quality, which reflects the degree of illumination uniformity of an image. In microscope applications, illumination uniformity provides an objective evaluation index for evaluating the illumination uniformity of an image, and this index involves the minimum gray value, maximum gray value, and average gray value of the image. Usually, the automatic detection method of illumination uniformity does not consider the influence of interference objects in the picture on the calculation. Especially in a wide-field microscope, because the cleaning process cannot completely remove the stains in the optical path and on the sample slide, calculation errors usually occur when detecting the illumination uniformity.

[0003] The stains in the microscope optical path may exist on optical devices such as the objective lens, observation head, relay lens, and camera. The stains on the sample slide may exist at any surface position of the glass slide and coverslip. If a fully assembled microscope is disassembled for the purpose of cleaning stains, then after cleaning the optical path components, the restoration work will be extremely cumbersome and time-consuming; and when there are foreign objects in the optical lens material, it will further increase the operation difficulty of removing stains and increase the hardware maintenance cost.

[0004] The conventional threshold segmentation method can remove the influence of major stains, but the remaining stains will still affect the minimum gray value and maximum gray value, and thus cannot effectively suppress the calculation error when calculating the illumination uniformity, affecting the accuracy and stability of the detection. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel, which can reduce the calculation error, avoid disassembling the microscope, and thus automatically reduce the influence of stain error on the evaluation of the illumination uniformity of the microscope.

[0006] The technical solution adopted by the present invention to solve the above technical problem is: A method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel, comprising the following steps:

[0007] Step (1): Read the microscopic image collected by an industrial camera, denoted as Figure A;

[0008] Step (2): Calculate the corresponding mask image of Figure A, denoted as Figure M;

[0009] Step (3): Call the bitwise_and function of OpenCV (Open Source Computer Vision Library, official website "https: / / docs.opencv.org / 3.4.17 / d1 / dfb / intro.html") to perform an "and" operation on Figure A and Figure M to obtain the grayscale image after masking, which is recorded as Figure A. mask ;

[0010] Step (4): Compute graph A mask The minimum grayscale value and maximum grayscale value are respectively denoted as V min 、V max ;

[0011] Step (5): Call OpenCV's mean function to calculate graph A mask The grayscale mean is denoted as G avg ;

[0012] Step (6): Calculate graph A using the following formula mask The illumination uniformity U is the illumination uniformity U of Figure A under the wide-field microscope:

[0013]

[0014] The specific steps of step (2) are as follows:

[0015] Step (2-1): Call OpenCV's GaussianBlur function to process Figure A and obtain the filtered image after Gaussian filtering, which is recorded as Figure A Gaussian ;

[0016] Step (2-2): Call OpenCV's threshold function to process Figure A Gaussian , the obtained mask image is recorded as mask image M1;

[0017] Step (2-3): remove the too small area and potential background area in the mask image M1, and record the obtained mask image as mask image M2;

[0018] Steps (2-4): Use mask map M2 to traverse statistical map A Gaussian The grayscale mean is first counted to calculate the number of non-zero pixels in the mask image M2, recorded as n; then the image A corresponding to the non-zero pixel position in the mask image M2 is accumulated and summed. Gaussian The grayscale value of the pixel is recorded as V sum ; Finally, calculate the mask image M2 under the action of Figure A Gaussian The grayscale mean is denoted as th avg , computational graph A Gaussian The formula for grayscale mean is as follows:

[0019]

[0020] Step (2-5): First, create a grayscale image with the same size as the mask image M2, denoted as image M3, and all its pixel values are 0. Then use th avg to perform thresholding on the mask image M2, and assign the judgment result to image M3, that is: if the grayscale value of the pixel point in the mask image M2 is greater than th avg , then assign the corresponding pixel point in image M3 to 255, otherwise assign it to 0;

[0021] Step (2-6): Call the MORPH_OPEN method in the morphologyEx function of OpenCV to perform an opening operation on image M3 to obtain a grayscale image with reduced pixel cluster adhesion, denoted as image M4;

[0022] Step (2-7): Remove the too-small regions and potential background regions in image M4, denoted as image M5;

[0023] Step (2-8): Call the bitwise_or function of OpenCV to perform an OR operation on image M2 and image M5 to obtain a grayscale image after the OR operation, which is the mask image M.

[0024] The specific steps of (2-3) are as follows:

[0025] Step (2-3-1): Call the findContours function of OpenCV to process image M1 to obtain the contour set of all pixel cluster contours in image M1, denoted as T1, where T1 has a total of N1 pixel cluster contours;

[0026] Step (2-3-2): Call the contourArea function of OpenCV to process the contour set T1 to obtain the corresponding contour area set of the contour set T1, denoted as S1, where S1 has a total of N1 contour areas;

[0027] Step (2-3-3): Retain the sub-contour pixel clusters T that simultaneously satisfy the following two conditions 1-i to form a new contour set, denoted as T 1-keep ;

[0028] The first condition is that the sub-contour area S of the area set S1 1-i (i = 1, 2, 3,..., N1) is greater than the preset area threshold th area , th area = 30 pixels;

[0029] The second condition is to traverse the single-pixel edges around the perimeter of image M1 and count the number of single-pixel edges that are adjacent to the sub-contour T 1-iThe number of overlapping pixel points (i = 1, 2, 3, …, N1), and this number of pixel points is less than the preset pixel number threshold th num , th num = 20 pixels;

[0030] Step (2-3-4): Call the drawContours function of OpenCV to traverse T 1-keep , and draw T 1-keep onto a new grayscale mask image, denoted as mask image M2. Among them, in drawContours, set thickness = -1, use the filled contour method, and the grayscale value of the filled pixels is 255, while the grayscale value of the unfilled pixels is 0.

[0031] Step (2-7) is specifically as follows:

[0032] Step (2-7-1): Call the findContours function of OpenCV to process image M4, and obtain the contour set of all pixel cluster contours in image M4, denoted as T2, where T2 has a total of N2 pixel cluster contours;

[0033] Step (2-7-2): Call the contourArea function of OpenCV to process the contour set T2, and obtain the corresponding contour area set of the contour set T2, denoted as S2, where S2 has a total of N2 contour areas;

[0034] Step (2-7-3): Retain the sub-contour pixel clusters T 2-i that simultaneously meet the following two conditions, and form a new contour set, denoted as T 2-keep ;

[0035] The first condition is that the sub-contour area S of the area set S2 2-i (i = 1, 2, 3, …, N2) is greater than the preset area threshold th area , th area = 30 pixels;

[0036] The second condition is that traverse and count the number of pixel points where the sub-contour T 2-i (i = 1, 2, 3, …, N2) coincides with the single-pixel edge around image M4, and this number of pixel points is less than the preset pixel number threshold th num , th num = 20 pixels;

[0037] Step (2-7-4): Call the drawContours function of OpenCV to traverse T 2-keep , and draw T 2-keepDraw it onto a new grayscale mask image, denoted as Image M5. Among them, in drawContours, set thickness = -1 and use the method of filling contours. The grayscale value of the filled pixels is 255, and the grayscale value of the unfilled pixels is 0.

[0038] The specific steps of step (4) are as follows:

[0039] Step (4-1): First, define mean filters of different scales, denoted as filter F k (k = 1, 2, 3, …, K), where K represents the total number of filter F k Then, preset the scale of each filter, denoted as S k pixels × S k pixels (k = 1, 2, 3, …, K), where S k represents the width and height of the k-th filter in pixels, and it is a positive integer in the range of 75 to 200;

[0040] Step (4-2): Define k as an accumulative variable and initialize it to k = 1;

[0041] Step (4-3): Judge the size relationship between k and K. If k ≤ K, then execute step (4-4); otherwise, execute step (4-7);

[0042] Step (4-4): Divide Image A mask into M k equally sized square grid regions using the k-th scale. Use H k and W k to represent the number of horizontal grid squares and the number of vertical grid squares of Image A mask at the k-th scale respectively. The calculation formulas for M k , H k and W k are as follows:

[0043]

[0044] In the above formula, M k represents the total number of square grid regions divided by the medium scale of Image A mask at the k-th scale. H k and W k represent the number of horizontal grid squares and the number of vertical grid squares of Image A mask at the k-th scale respectively. H and W represent the number of vertical pixels and the number of horizontal pixels of Image A mask respectively. floor(·) represents the floor operation;

[0045] Step (4-5): Calculate the grayscale mean value of each square grid region in Image A mask and denote it as Vavg-k,m (where k = 1, 2, 3, …, K; m = 1, 2, 3, …, M k ), V avg-k,m is calculated as follows:

[0046]

[0047] In the above formula, t represents the total number of pixel points in each sub-region at the k-th scale, a k,m,t represents the t-th coefficient in the m-th sub-region at the k-th scale, A mask-k,m,t represents the gray value of the t-th pixel point taken from Figure A at the k-th scale mask in the m-th sub-region, represents the sum of the effective pixel gray values taken from Figure A mask in the m-th sub-region at the k-th scale, n k,m represents the number of effective pixel points taken from Figure A mask in the m-th sub-region at the k-th scale, V avg-k,m represents the gray mean value corresponding to Figure A mask in the m-th sub-region at the k-th scale; if the pixel gray value of A mask-k,m,t is 0, let a k,m,t = 0; if the pixel gray value of A mask-k,m,t is not 0, let a k,m,t = 1;

[0048] Step (4 - 6): Increment the variable k by 1, and return to Step (4 - 3);

[0049] Step (4 - 7): Re-initialize the accumulative variable k, and initialize it to k = 1;

[0050] Step (4 - 8): Judge the size relationship between k and K. If k ≤ K, then execute Step (4 - 9), otherwise, execute Step (4 - 13);

[0051] Step (4 - 9): At the k-th scale, statistically find the minimum value and the maximum value in the m gray mean values V avg-k,m , and denote them as V min-k , V max-k respectively;

[0052] Step (4 - 10): Remove the minimum value and the maximum value in V min-k , and statistically find the average value of the remaining V min-k values, and denote it as V min , and the formula is as follows:

[0053]

[0054] In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, Vmin-k Denote the minimum value among m gray-scale means V at the k-th scale as V avg-k,m in, and V min denotes the minimum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object;

[0055] Step (4-11): Remove the minimum and maximum values in V max-k , and calculate the average value of the remaining V max-k values, denoted as V max , and the formula is as follows:

[0056]

[0057] In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, and V max-k denotes the maximum value among m gray-scale means V avg-k,m at the k-th scale, and V max denotes the maximum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object;

[0058] Step (4-12): Increment the variable k by 1, and return to Step (4-8);

[0059] Step (4-13): Obtain the maximum gray-scale value V mask and the minimum gray-scale value V min of Figure A max .

[0060] Compared with the prior art, the advantages of the present invention are as follows: taking various functions in the open-source computer vision library as auxiliary methods, first performing thresholding on the original image to obtain a preliminary mask image of the stain, then using a multi-scale kernel to traverse and calculate the minimum gray value set and the maximum gray value set corresponding to the microscopic image under different-scale mean filters, then removing the minimum and maximum values in the two sets, and performing weighted averaging on the remaining data respectively to obtain the global minimum gray value mean and the global maximum gray value mean, and finally calculating the illumination uniformity. Compared with the conventional stain interference removal technology based on threshold segmentation, the method of the present invention can not only better remove stains, but also reduce the influence of the remaining stains on the minimum and maximum gray values, thereby improving the detection accuracy of the illumination uniformity and providing a more objective detection method for evaluating the illumination uniformity under a microscope. The method of the present invention is applicable to the detection requirements of the illumination uniformity of a wide-field microscope under different cleanliness levels, can effectively suppress the error influence of stains on the illumination uniformity, and improve the detection accuracy and stability. In addition, in terms of the accuracy of detecting the illumination uniformity, the method of the present invention is similar to the "manual calculation" method, and the comprehensive running time is better than 1 second, featuring accuracy, stability, and speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 It is a schematic structural diagram of the hardware platform of the microscope acquisition device used in the method of the present invention;

[0062] Figure 2 It is a flow chart of the method for detecting the illumination uniformity of a microscope based on a multi-scale kernel of the present invention;

[0063] Figure 3 It is a flow chart of calculating the mask image of microscopic image A of the present invention;

[0064] Figure 4 It is a schematic diagram of the mask effect of the present invention;

[0065] Figure 5 It is a flow chart of calculating the minimum gray value and the maximum gray value in microscopic image A based on a multi-scale kernel of the present invention;

[0066] Figure 6 They are three sample diagrams of the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0067] The present invention will be further described in detail below with reference to the embodiments of the drawings.

[0068] Embodiment: The hardware platform of the microscope acquisition device used in the embodiment of the present invention is as Figure 1 shown. It includes an industrial camera 1, a relay lens 2, an objective lens 3, a blank sample 4, an electric platform 5, a light source 6, an industrial camera data cable 7, and a microscope bracket 8.

[0069] A method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel, the flowchart is as shown in Figure 2 and includes the following steps:

[0070] Step (1): Read the microscopic image collected by the industrial camera 1, denoted as Figure A;

[0071] Step (2): Calculate the corresponding mask image for Figure A, denoted as Figure M. The specific steps are as follows:

[0072] Step (2-1): Call the GaussianBlur function of OpenCV to process Figure A to obtain the filtered image after Gaussian filtering, denoted as Figure A Gaussian ;

[0073] Step (2-2): Call the threshold function of OpenCV to process Figure A Gaussian , and denote the obtained mask image as mask image M1;

[0074] Step (2-3): Remove the too small regions and potential background regions in the mask image M1, and denote the obtained mask image as mask image M2. The specific steps are as follows:

[0075] Step (2-3-1): Call the findContours function of OpenCV to process Figure M1 to obtain the contour set of all pixel cluster contours in Figure M1, denoted as T1, where there are N1 pixel cluster contours in T1;

[0076] Step (2-3-2): Call the contourArea function of OpenCV to process the contour set T1 to obtain the corresponding contour area set of the contour set T1, denoted as S1, where there are N1 contour areas in S1;

[0077] Step (2-3-3): Retain the sub-contour pixel clusters T that satisfy both of the following two conditions 1-i , and form a new contour set, denoted as T 1-keep ;

[0078] The first condition is that the sub-contour area S of the area set S1 1-i (i = 1, 2, 3,..., N1) is greater than the preset area threshold th area . In this embodiment, the value of th area = 30 pixels;

[0079] The second condition is that by traversing the single-pixel edges around Figure M1, count the number of pixel points that coincide with the sub-contour T 1-i (i = 1, 2, 3,..., N1), and this pixel point number is less than the preset pixel number threshold th num . In this embodiment, the value of th num = 20 pixels;

[0080] Step (2-3-4): Call the drawContours function of OpenCV to traverse T 1-keep , and draw T 1-keep onto a new grayscale mask image, denoted as mask image M2. Among them, in drawContours, set thickness = -1, and use the filled contour method. The grayscale value of the filled pixels is 255, and the grayscale value of the unfilled pixels is 0;

[0081] Step (2-4): Use mask image M2 to traverse and calculate the grayscale mean of statistical chart A Gaussian . First, count the number of non-zero pixel points in mask image M2, denoted as n; then accumulate and sum the grayscale values of the pixel points in chart A Gaussian corresponding to the positions of the non-zero pixel points in mask image M2, denoted as V sum ; finally, calculate the grayscale mean of chart A under the action of mask image M2 Gaussian , denoted as th avg . The formula for calculating the grayscale mean of chart A Gaussian is as follows:

[0082]

[0083] Step (2-5): First, create a grayscale image with the same size as mask image M2, denoted as image M3, and all its pixel values are 0. Then use th avg to perform thresholding on mask image M2, and assign the judgment result to image M3, that is: if the grayscale value of the pixel point in mask image M2 is greater than th avg , then assign the corresponding pixel point in image M3 to 255, otherwise assign it to 0;

[0084] Step (2-6): Call the MORPH_OPEN method in the morphologyEx function of OpenCV to perform an opening operation on image M3 to obtain a grayscale image that reduces pixel cluster adhesion, denoted as image M4;

[0085] Step (2-7): Remove the too-small regions and potential background regions in image M4, denoted as image M5, specifically as follows:

[0086] Step (2-7-1): Call the findContours function of OpenCV to process image M4 to obtain the contour set of all pixel cluster contours in image M4, denoted as T2, where T2 has a total of N2 pixel cluster contours;

[0087] Step (2-7-2): Call the contourArea function of OpenCV to process the contour set T2 to obtain the corresponding contour area set of the contour set T2, denoted as S2, where S2 has a total of N2 contour areas;

[0088] Step (2-7-3): Retain the sub-contour pixel clusters T that satisfy both of the following two conditions 2-i , and form a new contour set, denoted as T 2-keep ;

[0089] The first condition is that the sub-contour area S of the area set S2 2-i (i = 1, 2, 3, …, N2) is greater than a preset area threshold th area . In this embodiment, the value of th area = 30 pixels;

[0090] The second condition is to traverse and count the number of pixel points where the sub-contour T 2-i (i = 1, 2, 3, …, N2) coincides with the single-pixel edge around in Figure M4. This number of pixel points is less than a preset pixel number threshold th num . In this embodiment, the value of th num = 20 pixels. The filled pixel gray value is 255, and the unfilled pixel gray value is 0;

[0091] Step (2-7-4): Call the drawContours function of OpenCV to traverse T 2-keep , and draw T 2-keep onto a new grayscale mask image, denoted as Figure M5. Among them, in drawContours, set thickness = -1 and use the filled contour method. The filled pixel gray value is 255, and the unfilled pixel gray value is 0;

[0092] Step (2-8): Call the bitwise_or function of OpenCV to perform an OR operation on Figure M2 and Figure M5 to obtain an OR-operation grayscale image, which is the mask image M;

[0093] Step (3): Call the bitwise_and function of OpenCV to perform an AND operation on Figure A and Figure M to obtain a masked grayscale image, denoted as Figure A mask ;

[0094] Step (4): Calculate the minimum gray value and the maximum gray value of Figure A mask , denoted as V min , V max The specific steps are as follows:

[0095] Step (4-1): First, define mean filters of different scales, denoted as filter F k (k = 1, 2, 3, …, K), where K represents the total number of filters F k . Then, preset the scale of each filter, denoted as S k pixels × Sk pixels (k=1,2,3,…,K), where S k represents the width and height of the k-th filter in pixels, and is a positive integer ranging from 75 to 200. In this embodiment, six mean filters of different scales are selected, that is, K = 6, and the sizes of each scale kernel are 75 pixels × 75 pixels, 100 pixels × 100 pixels, 125 pixels × 125 pixels, 150 pixels × 150 pixels, 175 pixels × 175 pixels, and 200 pixels × 200 pixels, respectively.

[0096] Step (4-2): define k as an accumulation variable and initialize it to k=1;

[0097] Step (4-3): Determine the relationship between k and K. If k≤K, then execute step (4-4); otherwise, execute step (4-7);

[0098] Step (4-4): Use the kth scale to map A mask Divided into M k square grid areas of equal size, using H k and W k Represents the k-th scale A mask The number of horizontal and vertical squares, M k 、H k and W k The calculation formula is as follows:

[0099]

[0100] In the above formula, M k Represents the k-th scale A mask The total number of grid areas divided at the medium scale, H k and W k Represents the k-th scale A mask The number of horizontal and vertical squares in Figure A, H and W represent mask The number of vertical pixels and horizontal pixels of the image are shown in Figure A. Floor(·) represents a rounding operation. For example, the result of floor(20.12) is an integer 20. In this embodiment, for example, when k=1, the first scale kernel of 75 pixels × 75 pixels is selected. mask The size of is the same as that of Figure A, both are 2056 pixels × 1504 pixels, so after the current scale kernel processing, in Figure A mask The image is divided into H1 = 27 horizontal squares and W1 = 20 vertical squares, and the size of each square is 75 pixels × 75 pixels;

[0101] Steps (4-5): Calculate Graph A maskThe grayscale mean of each square grid area is denoted as V avg-k,m (where k = 1, 2, 3, …, K; m = 1, 2, 3, …, M k ),V avg-k,m The calculation formula of is as follows:

[0102]

[0103] In the above formula, t represents the total number of pixel points in each sub-region at the k-th scale, a k,m,t represents the t-th coefficient in the m-th sub-region at the k-th scale, A mask-k,m,t represents the grayscale value of the t-th pixel point taken from the m-th sub-region of Figure A at the k-th scale mask at the k-th scale; represents the sum of the effective pixel grayscale values taken from the m-th sub-region of Figure A mask at the k-th scale, n k,m represents the number of effective pixel points taken from the m-th sub-region of Figure A mask at the k-th scale, V avg-k,m represents the grayscale mean of the m-th sub-region corresponding to Figure A mask at the k-th scale; if the pixel grayscale value of A mask-k,m,t is 0, let a k,m,t = 0; if the pixel grayscale value of A mask-k,m,t is not 0, let a k,m,t = 1; in this embodiment, when k = 1, the size of each sub-region is 75 pixels × 75 pixels, then t = 5625 pixels;

[0104] Step (4 - 6): Increment the variable k by 1 and return to Step (4 - 3);

[0105] Step (4 - 7): Re-initialize the cumulative variable k, initialized to k = 1;

[0106] Step (4 - 8): Judge the size relationship between k and K. If k ≤ K, then execute Step (4 - 9), otherwise, execute Step (4 - 13);

[0107] Step (4 - 9): At the k-th scale, count the minimum value and the maximum value in the m grayscale means V avg-k,m and denote them as V min-k , V max-k respectively;

[0108] Step (4 - 10): Remove the minimum value and the maximum value from V min-k and count the average value of the remaining V min-k values, denoted as V min , and the formula is as follows:

[0109]

[0110] In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, and V min-k represents the minimum value among the m gray-scale means V under the k-th scale, and V avg-k,m ; V min represents the minimum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object;

[0111] Step (4-11): Remove the minimum and maximum values in V max-k , and count the average value of the remaining V max-k values, denoted as V max , and the formula is as follows:

[0112]

[0113] In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, and V max-k represents the maximum value among the m gray-scale means V under the k-th scale, and V avg-k,m ; V max represents the maximum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object;

[0114] Step (4-12): Increment the variable k by 1, and return to Step (4-8);

[0115] Step (4-13): Obtain the maximum gray-scale value V mask and the minimum gray-scale value V max of Figure A min ;

[0116] Step (5): Call the mean function of OpenCV to calculate the gray-scale mean value of Figure A mask , denoted as G avg ;

[0117] Step (6): Use the following formula to calculate the illumination uniformity U of Figure A mask . The illumination uniformity U is the illumination uniformity U of Figure A under the wide-field microscope:

[0118]

[0119] In the above formula, V min is the minimum gray-scale value of Figure A mask , and V max is the maximum gray-scale value of Figure A maskThe maximum gray value, G avg is Figure A mask The gray mean value, U is for Figure A mask The detection result of the illumination uniformity is a percentage value.

[0120] The correctness of the method of the present invention is verified as follows:

[0121] 1. Precision experiment

[0122] The method of the present invention is applied to detect the illumination uniformity of a microscope. The 3 sample images selected in this embodiment are as Figure 6 shown. The names of the relevant parallel test methods and the test data are shown in Table 1. Among them, |ΔU| represents the absolute value of the difference in illumination uniformity between each method and the "manual calculation" method. In addition, due to the randomness of the "manual calculation" method, the corresponding data of this method in Table 1 are the results of statistical averaging of 15 samplings.

[0123] Table 1 Illumination uniformity test data table of different parallel methods

[0124]

[0125] As shown in Table Ⅰ, this embodiment sets up a total of 3 groups of experiments. Each group of experiments is for 1 sample image, and the illumination uniformity test data of 4 different parallel methods under each sample are recorded. The meanings of each parallel method are shown in Table 2:

[0126] Table 2 Functional descriptions of 5 parallel methods in the test

[0127]

[0128] The test data in Table 1 show that:

[0129] (1) By comparing the results of |ΔU| in Table 1, it is found that the deviation result of Method 3 (the method of the present invention) is the smallest, indicating that the method of the present invention is closer to the result of analyzing the illumination uniformity by "manual calculation";

[0130] (2) The |ΔU| of Method 1 and Method 2 is much greater than 10%, while the |ΔU| of Method 3 (the method of the present invention) is always less than 1%, indicating that the method of the present invention can effectively suppress the influence of stains on the calculation of illumination uniformity and is relatively stable;

[0131] (3) For Method 4 (manual calculation), 15 groups of data are collected first and then statistically averaged in order to reduce the randomness in the manual sampling process. This randomness includes random noise and random point selection. The method of the present invention has the characteristic of statistical averaging, which can effectively suppress randomness and improve the detection stability;

[0132] 2. Running speed experiment

[0133] Table 3 records the running time of the embodiments of the present invention.

[0134] Table 3 Running time of the embodiments of the present invention

[0135]

[0136] The results in Table 3 show that:

[0137] (1) The running time is related to the stain cleaning degree of the sample legend. The more stains, the longer the running time.

[0138] (2) The comprehensive running time is better than 1 second.

[0139] 3. Conclusion

[0140] In summary, the present invention is applicable to detecting the illuminance uniformity of a wide-field microscope. Its results are similar to those of "manual calculation", with the characteristics of accuracy, stability, and rapidity, and it can well suppress the error influence of the optical path and sample stains on the analysis of illuminance uniformity.

Claims

1. A method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel, characterized in that It includes the following steps: Step (1): Read the collected microscopic image, denoted as Figure A; Step (2): Calculate the corresponding mask image for Figure A, denoted as Figure M; Step (3): Call the bitwise_and function of OpenCV to perform an "AND" operation on Figure A and Figure M to obtain the masked grayscale image, denoted as Figure A mask ; Step (4): Calculate Figure A mask 's minimum gray value and maximum gray value, denoted as V min and V max respectively, including: traversing and calculating the minimum gray set and maximum gray set corresponding to the microscopic image under different scale mean filters using a multi-scale kernel, then removing the minimum value and maximum value from the two sets, and performing weighted averaging on the remaining data respectively to obtain the minimum gray value and maximum gray value of Figure A mask ; Step (5): Call the mean function of OpenCV to calculate the grayscale mean of Figure A mask and denote it as G avg ; Step (6): Calculate the illumination uniformity U of Figure A using the following formula. The illumination uniformity U is the illumination uniformity of Figure A under the wide-field microscope: mask where the illumination uniformity U is the illumination uniformity of Figure A under the wide-field microscope: .

2. The method for detecting the illumination uniformity of a wide-field microscope based on a multi-scale kernel according to claim 1, wherein The specific steps of Step (2) are as follows: Step (2-1): Call the GaussianBlur function of OpenCV to process Figure A, and obtain the filtered image after Gaussian filtering, denoted as Figure A Gaussian ; Step (2-2): Call the threshold function of OpenCV to process Figure A Gaussian , and denote the obtained mask image as mask image M1; Step (2-3): Remove the too-small regions and potential background regions in mask image M1, and denote the obtained mask image as mask image M2; Step (2-4): Using the mask image M2, traverse the statistical graph A Gaussian For the grayscale mean value, first count the number of non-zero pixel points in the mask image M2, denoted as n; then accumulate and sum the grayscale values of the pixel points in graph A corresponding to the positions of the non-zero pixel points in the mask image M2 Gaussian , denoted as V sum ; Finally, calculate the grayscale mean value of graph A under the action of the mask image M2 Gaussian , denoted as th avg , and the formula for calculating the grayscale mean value of graph A Gaussian is as follows: Step (2-5): First, create a grayscale image with the same size as the mask image M2, denoted as image M3, and all its pixel values are 0. Then use th avg Perform thresholding on the mask image M2 and assign the judgment result to image M3, that is: if the grayscale value of the pixel point in the mask image M2 is greater than th avg , then assign the corresponding pixel point in image M3 to 255, otherwise assign it to 0; Step (2-6): Call the MORPH_OPEN method in the morphologyEx function of OpenCV to perform an opening operation on Figure M3, and obtain a grayscale image with reduced pixel cluster adhesion, denoted as Figure M4; Step (2-7): Remove the too-small regions and potential background regions in Figure M4, denoted as Figure M5; Step (2-8): Call the bitwise_or function of OpenCV to perform an OR operation on Figure M2 and Figure M5, and obtain an OR-operation grayscale image, which is the mask image M.

3. The detection method for illumination uniformity of a wide-field microscope based on a multi-scale kernel according to claim 2, wherein The specific steps of Step (2-3) are as follows: Step (2-3-1): Call the findContours function of OpenCV to process Figure M1, and obtain the contour set of all pixel cluster contours in Figure M1, denoted as T1, where T1 has a total of N1 pixel cluster contours; Step (2-3-2): Call the contourArea function of OpenCV to process the contour set T1, and obtain the corresponding contour area set of the contour set T1, denoted as S1, where S1 has a total of N1 contour areas; Step (2-3-3): Retain the sub-contour pixel clusters T that simultaneously satisfy the following two conditions 1-i , to form a new contour set, denoted as T 1-keep ; The first condition is that the sub - contour area S of the area set S1 1-i is greater than a preset area threshold th area , th area = 30 pixels, where i = 1, 2, 3, …, N1; The second condition is to traverse the single-pixel edges around the graph M1 and count the number of pixel points that coincide with the sub-contour T 1-i where i = 1, 2, 3, …, N1, and the number of such pixel points is less than a preset pixel number threshold th num , th num = 20 pixels; Step (2-3-4): Call the drawContours function of OpenCV to traverse T 1-keep and draw T 1-keep onto a new grayscale mask image, denoted as mask image M2. Among them, in drawContours, set thickness = -1 and use the method of filling contours. The grayscale value of the filled pixels is 255, and the grayscale value of the unfilled pixels is 0.

4. The detection method for the illumination uniformity of a wide-field microscope based on a multi-scale kernel according to claim 2, wherein The specific steps of Step (2-7) are as follows: Step (2-7-1): Call the findContours function of OpenCV to process Figure M4, and obtain the contour set of all pixel cluster contours in Figure M4, denoted as T2, where T2 has a total of N2 pixel cluster contours; Step (2-7-2): Call the contourArea function of OpenCV to process the contour set T2, and obtain the corresponding contour area set of the contour set T2, denoted as S2, where S2 has a total of N2 contour areas; Step (2-7-3): Retain the sub-contour pixel clusters T that simultaneously satisfy the following two conditions 2-i , to form a new contour set, denoted as T 2-keep ; The first condition is that the sub-contour area S of the area set S2 2-i is greater than a preset area threshold th area , where th area = 30 pixels, where i = 1, 2, 3, …, N2; The second condition is to traverse and count the sub - contour T 2-i The number of pixel points that coincide with the single - pixel edges around in Figure M4, where i = 1, 2, 3, …, N2, and this number of pixel points is less than the preset pixel number threshold th num , th num = 20 pixels; Step (2-7-4): Call the drawContours function of OpenCV to traverse T 2-keep , and draw T 2-keep onto a new grayscale mask image, denoted as Figure M5. Among them, in drawContours, set thickness = -1 and use the method of filling the contour. The grayscale value of the filled pixels is 255, and the grayscale value of the unfilled pixels is 0.

5. The detection method for the illumination uniformity of a wide-field microscope based on a multi-scale kernel according to claim 1, characterized in that The specific steps of Step (4) are as follows: Step (4-1): First, define mean filters of different scales, denoted as filter F k , and then preset the scale of each filter, denoted as S k pixels × S k pixels, where k = 1, 2, 3, …, K, and K represents the total number of filters F k , S k represents the width and height of the k-th filter in pixels, which is a positive integer ranging from 75 to 200; Step (4-2): Define k as an accumulative variable and initialize it to k = 1; Step (4-3): Judge the size relationship between k and K. If k ≤ K, then execute Step (4-4); otherwise, execute Step (4-7); Step (4-4): Divide Figure A using the k-th scale mask into M k equally sized square grid regions. Use H k and W k to represent the number of horizontal grids and the number of vertical grids of Figure A at the k-th scale respectively. The calculation formulas for M mask , H k , and W k , and W k are as follows: In the above formula, M k represents the total number of square grid regions divided by the medium scale in Figure A at the k-th scale, H mask and W k respectively represent the number of horizontal grids and the number of vertical grids in Figure A at the k-th scale. H and W respectively represent the number of vertical pixels and the number of horizontal pixels in Figure A k , and floor(·) represents the floor operation; mask ; mask ​ Step (4-5): Calculate the grayscale mean of each square grid area in Figure A mask and denote it as V avg-k,m , where k = 1, 2, 3, …, K; m = 1, 2, 3, …, M, and the calculation formula of V avg-k,m is as follows: In the above formula, t represents the total number of pixel points in each sub-region at the k-th scale, a k,m,t represents the t-th coefficient in the m-th sub-region at the k-th scale, A mask-k,m,t represents the gray value of the t-th pixel point taken from Figure A at the k-th scale mask in the m-th sub-region; represents the sum of the gray values of the effective pixels taken from Figure A at the k-th scale mask in the m-th sub-region, n k,m represents the number of effective pixel points taken from Figure A at the k-th scale mask in the m-th sub-region, V avg-k,m represents the gray mean value corresponding to Figure A at the k-th scale mask in the m-th sub-region; if the pixel gray value of A mask-k,m,t is 0, let a k,m,t = 0; if the pixel gray value of A mask-k,m,t is not 0, let a k,m,t = 1; Step (4-6): Cumulatively add 1 to the variable k and return to Step (4-3); Step (4-7): Re-initialize the accumulative variable k and initialize it to k = 1; Step (4-8): Judge the size relationship between k and K. If k ≤ K, then execute Step (4-9), otherwise, execute Step (4-13); Step (4-9): At the k-th scale, count the minimum and maximum values of the m grayscale means V avg-k,m and denote them as V min-k , V max-k ; Step (4-10): Remove the minimum and maximum values in V min-k and calculate the average value of the remaining V min-k values, denoted as V min , and the formula is as follows: In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, and V min-k represents the minimum value among the m gray-scale means V avg-k,m under the k-th scale, and V min represents the minimum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object; Step (4-11): Remove the minimum and maximum values in V max-k and calculate the average value of the remaining V max-k values, denoted as V max , and the formula is as follows: In the above formula, k represents the serial number of the selected scale, K represents the total number of scales, and V max-k represents the maximum value among the m gray-scale means V avg-k,m under the k-th scale, and V max represents the maximum gray-scale value corresponding to Figure A mask ; min(·) represents the operation of selecting the minimum value of all elements in the target object, and max(·) represents the operation of selecting the maximum value of all elements in the target object; Step (4-12): Cumulatively add 1 to the variable k and return to Step (4-8); Step (4-13): Obtain Figure A mask The maximum gray value V max and the minimum gray value V min .

Citation Information

Patent Citations

  • Rubber sealing ring surface defect detection method based on machine vision

    CN111145165A

  • Visual inspection system LED light source illumination optimization method and used experimental equipment

    CN113916906A