Microscopic vision threshold segmentation algorithm for micro-nano object image based on OTSU improvement

By improving the gray-level weighting factor and inter-class variance formula of the OTSU algorithm and combining iterative algorithms, the inaccuracy of threshold segmentation and the problem of local information adaptability at the micro- and nano-scale were solved, and more stable and accurate image segmentation was achieved.

CN119991697BActive Publication Date: 2025-12-30SHAOXING RES INST OF ZHEJIANG UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411956182.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-28
Publication Date
2025-12-30
Estimated Expiration
2044-12-28

AI Technical Summary

Technical Problem

Threshold segmentation algorithms at the micro- and nanoscale are highly susceptible to noise interference and have poor stability. The OTSU segmentation algorithm has a pixel bias, which leads to inaccurate segmentation. Furthermore, global threshold segmentation algorithms lack the ability to adapt to local information.

Method used

By combining image gradient information, the gray-level weight factor of the bilateral filtering algorithm is improved, and the inter-class variance formula is improved by using a natural constant function. A local judgment mechanism is introduced, and adaptive threshold segmentation is performed by combining iterative algorithms.

Benefits of technology

It improves the stability and accuracy of threshold segmentation, can adapt to various image types, maintains high-efficiency segmentation performance, and preserves edge information and high-frequency features in micro and nano microscopic images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991697B_ABST
    Figure CN119991697B_ABST
Patent Text Reader

Abstract

The application discloses a micro-vision threshold segmentation algorithm based on OTSU improvement for micro-nano object images, and comprises the following steps: S1, combining image gradient information, calculating a new gray weight factor based on an exponential function and a logarithmic function, and performing bilateral filtering processing on the image; S2, calculating a traditional gray threshold of the filtered image by using a traditional inter-class variance formula, and calculating an improved gray threshold by using an improved inter-class variance formula based on a natural constant function; and S3, performing adaptive iterative operation on pixels of the image by using the traditional gray threshold and the improved gray threshold, so that three-region threshold segmentation is completed. The micro-vision threshold segmentation algorithm based on OTSU improvement disclosed by the application overcomes the problem that the calculation result is inaccurate due to the imbalance of the pixel quantity ratio during threshold segmentation, and improves the limitation of poor local analysis capability of the global threshold segmentation algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of microscopic visual image processing technology, specifically relating to a microscopic visual threshold segmentation algorithm based on OTSU (Otsu algorithm) for micro-nano object images. Background Technology

[0002] With the rapid development of nanotechnology and microfabrication techniques, micro-nano vision technology, as an important bridge connecting the macroscopic and nanoscale worlds, is rapidly becoming a key tool in scientific research and industrial applications. Micro-nano vision technology primarily uses high-precision imaging and analysis to reveal the structural and functional characteristics of materials, devices, and biological systems at the micro and nanoscale. For example, in the biomedical field, high-resolution imaging allows researchers to observe biological processes at the single-cell, subcellular, and molecular levels; in materials science, micro-nano vision technology can assist in the design of novel functional materials; and in the fields of microelectronics and nanodevices, high-resolution imaging enables the precise detection of minute defects on chips, ensuring device performance and reliability.

[0003] In the field of microscopic vision technology, the main focus is on the identification and analysis of micro- and nano-sized objects in images. Therefore, image processing techniques are needed to extract information about these objects. Thresholding segmentation is an image segmentation method based on pixel grayscale values ​​or colors. By setting a threshold, pixels in an image are divided into two classes according to their grayscale values. This simplifies image data, highlights target areas, and facilitates subsequent image analysis and processing. Thresholding segmentation provides a basic framework and preliminary results. Its algorithm is simple, computationally fast, and suitable for real-time image processing and large-scale data processing scenarios. It is of great significance for target extraction, data compression, feature extraction, and image enhancement.

[0004] Images under microscopic vision are often affected by factors such as sensor noise, signal transmission interference, and ambient light, resulting in irregular brightness fluctuations, a phenomenon commonly referred to as noise. The presence of noise alters the grayscale values ​​of image pixels, thus affecting the results of thresholding. The book *Digital Image Processing* mentions that traditional linear noise reduction algorithms are essentially low-pass filters, primarily using weighted calculations of surrounding pixel grayscale values ​​to reduce the impact of noise, but this also affects the high-frequency characteristics of the image. Therefore, bilateral filtering algorithms are widely used to preserve the high-frequency information of the image.

[0005] The paper "Guided Image Filtering" describes bilateral filtering as an adaptive image denoising algorithm that achieves edge preservation by dynamically adjusting the weights of the convolution kernel based on the local characteristics of pixels. The core of this algorithm consists of two weights: the first is based on the spatial distance between pixels, similar to Gaussian filtering, used to smooth the image; the second determines the weight based on the difference in grayscale values, decreasing the weight as the difference in grayscale values ​​increases. This design allows bilateral filtering to reduce blurring effects when processing edge information. However, current bilateral filtering algorithms have some limitations. First, the filtering effect is highly dependent on parameters, which usually need to be manually adjusted, lacking universality. Second, its edge protection capability is weak in complex scenes, especially in high-noise images, where the weights for grayscale differences may be affected by noise, leading to blurred or over-smoothed edges. Furthermore, this algorithm shows insufficient adaptability when processing images with rich textures or multiple edge characteristics. Therefore, as shown in the papers "Bilateral filtering for gray and color images", "Cuckoo Search Optimization-Based Bilateral Filter for Multiplicative Noise Reduction in Satellite Images" and "An improved bilateral filtering based on curvature feature for point cloud denoising in road surface detection", improving bilateral filtering algorithms to enhance their stability and edge protection effect is an important direction of current research.

[0006] Currently, thresholding methods are mainly divided into two categories: global thresholding and adaptive thresholding. The paper "Image Segmentation Using Multilevel Thresholding: A Research Review" points out that global thresholding segments the entire image using a given or automatically calculated single threshold; while adaptive thresholding dynamically determines the threshold for local regions based on their grayscale characteristics, allowing different regions of the image to be segmented using different thresholds. However, due to unavoidable interference such as uneven illumination, image noise, and impurities, the performance of thresholding can be significantly affected. In practical applications, higher demands are placed on the robustness and efficiency of thresholding algorithms.

[0007] The OTSU algorithm, also known as the maximum inter-class variance method, is widely used in image processing due to its high stability and low computational complexity, as mentioned in the paper "Characteristic analysis of Otsuthreshold and its applications." In the OTSU algorithm, image pixels are divided into two classes by traversing the entire grayscale range, and the inter-class variance is calculated for each grayscale value used as a threshold. Inter-class variance is an indicator of the separation between foreground and background, reflecting the discriminative power of the two classes. The OTSU algorithm completes global thresholding by selecting the grayscale value corresponding to the maximum inter-class variance as the optimal threshold. As can be seen from the OTSU algorithm formula, it mainly considers two factors: first, the ratio of the number of foreground and background pixels; the inter-class variance reaches its maximum when the number of pixels in both classes is equal; second, the average grayscale difference between the foreground and background; the greater the grayscale difference, the greater the inter-class variance. Therefore, the maximum inter-class variance method can simultaneously balance the number of pixels and the grayscale difference. However, the OTSU algorithm also has certain limitations. For images where the number of pixels in the foreground and background differs significantly, the selected threshold often favors one category, making it difficult to obtain accurate segmentation results. Furthermore, as a global thresholding segmentation method, the OTSU algorithm lacks adaptability to local information and is unsuitable for images with complex content or significant lighting variations.

[0008] Therefore, this invention aims to solve the problems of threshold segmentation algorithms at the micro-nano scale being greatly affected by noise and having poor stability, as well as the pixel quantity bias of the OTSU segmentation algorithm. It improves the maximum inter-class variance formula, introduces a local judgment mechanism into the OTSU algorithm, and reduces the impact of pixel ratio imbalance on the results. At the same time, it combines filtering algorithms to enhance its robustness and adaptability, thereby improving the stability and accuracy of the OTSU algorithm in micro-nano microscopic images. Summary of the Invention

[0009] The main objective of this invention is to provide a microscopic vision thresholding algorithm based on OTSU improvement for micro-nano object images, which overcomes the problem of inaccurate calculation results caused by the imbalance of pixel number ratio during thresholding and improves the limitation of poor local analysis capability of global thresholding algorithm.

[0010] Another objective of this invention is to provide a microscopic vision thresholding algorithm based on OTSU for micro-nano object images. This algorithm can solve the problem of inaccurate thresholding under micro-nano vision caused by the bias in the calculated threshold due to the large difference in the ratio of foreground and background data in the traditional OTSU algorithm. It also has a certain local analysis capability. At the same time, the improved bilateral filtering algorithm can better preserve the high-frequency information in the image while ensuring the denoising effect, thereby greatly improving the stability of thresholding.

[0011] To achieve the above objectives, a microscopic visual thresholding algorithm based on OTSU improvement for micro / nano object images is proposed, comprising the following steps:

[0012] Step S1: Combine image gradient information to calculate a new gray-level weight factor based on exponential and logarithmic functions, and perform bilateral filtering on the image;

[0013] Step S2: Calculate the traditional grayscale threshold for the filtered image using the traditional inter-class variance formula, and calculate the improved grayscale threshold using the inter-class variance formula based on the natural constant function.

[0014] Step S3: Using traditional grayscale thresholds and improved grayscale thresholds, perform adaptive iterative calculations on the pixels of the image to complete the three-zone threshold segmentation.

[0015] As a further preferred technical solution to the above technical solution, for step S1, the bilateral filtering algorithm is as shown in equation (1):

[0016]

[0017] Among them, f Bilateral (x0,y0) represents the gray value of point (x0,y0) in the filtered image, M(x0,y0) represents the set of convolution kernel weights centered at (x0,y0), and ω(x,y) is the weight function of the bilateral filter. The value of the weight function ω(x,y) is the product of the spatial distance domain weighting coefficient and the gray domain weighting coefficient, and the corresponding formula is shown in equation (2):

[0018] ω(x,y)=ω d (x,y)·ω s (x,y) (2);

[0019] Here, ω(x,y) consists of two parts, namely the spatial distance domain weighting coefficient ω d (x,y) and grayscale weighting coefficient ω s (x,y); the former calculates the Gaussian weight using the physical distance between two pixels, while the latter calculates the Gaussian weight using the grayscale difference between two pixels, ω. d (x,y), ω s The formulas corresponding to (x,y) are shown in equations (3) and (4):

[0020]

[0021] Where, σ d Let σ be the standard deviation of the spatial domain. s The standard deviation of the grayscale range;

[0022] The gray-scale weighting formula shown in equation (4) is changed to equation (5):

[0023]

[0024] Where Δf(x,y) represents the grayscale difference between pixels, and the explanations of the remaining parts are as follows:

[0025] In formula (4), ω s The squared gray-level difference parameter [f(x,y)-f(x0,y0)] in (x,y) 2 Change it to the grayscale difference exponent parameter exp(|f(x,y)-f(x0,y0)|);

[0026] To ensure the filtering effect is the modified grayscale difference index, an adaptive weight value k is added before it. s As shown in equation (6):

[0027] k s =log k [|f(x,y)-f(x0,y0)|+1] (6);

[0028] Where k represents the filtering threshold, which is calculated as follows: The gradient image of the original image is constructed using the Robert operator, as shown in equation (7):

[0029]

[0030] Next, the average gray value Mean_Val is calculated for the gradient image, and this average gray value Mean_Val is substituted into the weight value k as the parameter k. s In the formula.

[0031] ω calculated using formula (5) zs (x,y) replace ω in formula (4) s (x,y) are substituted into formula (1), and the image is then subjected to convolution filtering using the replaced formula (1).

[0032] As a further preferred technical solution of the above technical solution, for step S2, the maximum inter-class variance method first calculates the inter-class variance between pixels when each gray value is used as the threshold, and then takes the gray value corresponding to the largest inter-class variance as the threshold for threshold segmentation.

[0033] In methods for calculating inter-class variance, it is necessary to first count the total amount of data, which corresponds to the total number of pixels in the image. Assuming L(x,y) is a grayscale image with pixel values ​​ranging from 0 to 255, and N is the total number of pixels in the image, n... i Let i represent the number of pixels with a grayscale value of i. Then the total number of pixels is expressed as shown in equation (8):

[0034]

[0035] After counting the total number of pixels, we need to find the proportion of the total number of pixels corresponding to each grayscale value. Let p be an example. i p represents the proportion of pixels with grayscale value i, therefore p i Defined as shown in equation (9):

[0036]

[0037] Let the binarization threshold of the image be T. Then, the pixels of the image are divided into two parts according to the gray value: the foreground and the background. The corresponding gray value ranges are [0,T] and [T+1,255], respectively. Let μ0 and μ1 be the expected gray values ​​of the foreground and background, ω0 and ω1 be the sum of the gray value probabilities of the background and foreground, and μ be the average gray value of all pixels in the image. Then, the definitions of each symbol are shown in equations (10), (11), and (12):

[0038]

[0039]

[0040] Based on the above formula, let the inter-class variance be σ, and the inter-class variance function is shown in equation (13):

[0041] σ 2 =ω0ω1(μ0-μ1) 2 (13);

[0042] Based on the above formula, after calculating the inter-class variance of all gray values ​​as thresholds, the gray value corresponding to the largest inter-class variance is taken as the segmentation threshold T1. Let the calculation formula for calculating the inter-class variance with gray value T as threshold be T: ω0ω1(μ0-μ1). 2 Then the traditional grayscale threshold T1 is as shown in equation (14):

[0043] T1 = Max[T:ω0ω1(μ0-μ1)] 2 T∈[0,255] (14);

[0044] By replacing ω0ω1 in formula (13) with the natural constant function logarithm formula ln(ω0ω1+1), the weight of the pixel ratio product is weakened.

[0045] Furthermore, the exponential function of the natural constant function is used to square the average gray difference (μ0-μ1) in formula (13). 2 Replace it with exp(|μ0-μ1|)·|μ0-μ1|, thereby amplifying the average gray difference feature in the variance formula. The modified inter-class variance formula is shown in equation (15):

[0046]

[0047] Assume that the inter-class variance is calculated using the improved inter-class variance formula with the gray value T as the threshold, which is expressed as T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|. Then, let the threshold T2 corresponding to the obtained maximum inter-class variance, that is, the improved gray threshold, be expressed as:

[0048] T2 = Max[T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|] T ∈ [0, 255] (16).

[0049] As a further preferred technical solution of the above technical solution, for step S3, compare the obtained thresholds T1 and T2, and perform threshold segmentation on the gray values outside the two thresholds. Let T1 < T2, and the segmentation process is shown in Equation (17):

[0050]

[0051] where f thre (i, j) represents the gray value of the pixel at the (i, j) position in the image after threshold segmentation, and f(i, j) represents the gray value of the pixel at the (i, j) position in the original image.

[0052] Calculate the corresponding entropy value using the pixel values in the middle part between the two thresholds. The calculation formula of the image entropy is shown in Equation (18):

[0053]

[0054] where H is the entropy value of the pixels between the two thresholds, P represents the sum of the probabilities occupied by these pixels, and p i is the same as Equation (9) and represents the proportion of pixels with the gray value i

[0055] By calculating the entropy of the gray values in the middle part, the corresponding degree of chaos is obtained, and the specific method is as follows:

[0056] Take the gray values in the middle part between the two thresholds to calculate the image entropy. If the entropy value is less than the set threshold K, calculate the average value T of the gray values of these pixels mean , and judge whether the average value is closer to T1 or T2. If it is closer to T1, then let Otherwise, let After that, segment these gray values according to the threshold T m

[0057] ​As a further preferred technical solution of the above technical solution, for step S3, if the calculated entropy value is greater than the set threshold K, the thresholds T1 and T2 are updated and compared using the original inter-class variance algorithm formula (13) and the improved inter-class variance algorithm formula (15) for this part of the pixels. Then, the pixels are segmented using formula (17) in combination with the updated thresholds T1 and T2. The remaining part after segmentation is the pixel between the updated thresholds T1 and T2. The corresponding entropy value is calculated using formula (18) and it is determined whether it exceeds the threshold. This process is repeated until the entropy value is less than the threshold K, and the final T is obtained. m Segmentation complete.

[0058] The beneficial effects of this invention are as follows:

[0059] (1) This invention combines the gray value weight factor formula of the gradient image optimization bilateral filtering algorithm to protect the filtering weight with small gradient value, and uses the natural constant exponent formula to further reduce the weight of the position with large gradient value, so that edge information can be more effectively protected during the filtering process.

[0060] (2) By modifying the proportion of each component of the inter-class variance, this invention can solve the problem of inaccurate threshold segmentation caused by the bias in the threshold calculation due to the large difference in the ratio of foreground and background data in the traditional OTSU algorithm. This allows the improved OTSU algorithm to adapt to various image types and maintain efficient segmentation performance. This versatility makes the improved OTSU algorithm perform well in a wide range of applications.

[0061] (3) This invention combines the iterative algorithm with the traditional threshold segmentation algorithm. By iteratively classifying and discussing the pixels in the image, the algorithm has a certain local analysis capability and can more accurately separate the foreground and background in the image. Attached Figure Description

[0062] Figure 1 This is a flowchart of the present invention.

[0063] Figure 2 This is a schematic diagram of the improved bilateral filtering algorithm of the present invention.

[0064] Figure 3 This is a schematic diagram of the improved OTSU threshold segmentation algorithm of the present invention.

[0065] Figure 4 This is a comparison chart of the implementation effect of the algorithm proposed in this invention and the traditional method. Detailed Implementation

[0066] The following description is intended to disclose the present invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art. The basic principles of the invention defined in the following description can be applied to other embodiments, modifications, improvements, equivalents, and other technical solutions that do not depart from the spirit and scope of the invention.

[0067] In the preferred embodiments of the present invention, those skilled in the art should note that the OTSU algorithm and the like involved in the present invention can be considered as prior art.

[0068] Preferred embodiment.

[0069] like Figure 1-4 As shown, this invention discloses a microscopic visual thresholding algorithm based on OTSU improvement for micro / nano object images, comprising the following steps:

[0070] Step S1: Combine image gradient information and calculate new gray-level weight factors based on exponential and logarithmic functions (replacing the weight factors based on the traditional gray-level difference formula) to perform bilateral filtering on the image;

[0071] Step S2: Calculate the traditional grayscale threshold for the filtered image using the traditional inter-class variance formula, and calculate the improved grayscale threshold using the inter-class variance formula based on the natural constant function.

[0072] Step S3: Using traditional grayscale thresholds and improved grayscale thresholds, perform adaptive iterative calculations on the pixels of the image to complete the three-zone threshold segmentation.

[0073] Specifically, for step S1, (to prevent high-frequency features in the image from being affected, a bilateral filtering algorithm is used to denoise the image. The core idea of ​​the bilateral filtering algorithm is to take all pixels near a pixel as a spatial window, and calculate a weighted average based on the similarity between pixels and their spatial distance, so as to obtain the convolution kernel weight value of the pixel) the bilateral filtering algorithm is shown in equation (1):

[0074]

[0075] Among them, f Bilateral (x0,y0) represents the gray value of point (x0,y0) in the filtered image, M(x0,y0) represents the set of convolution kernel weights centered at (x0,y0), and ω(x,y) is the weight function of the bilateral filter. The value of the weight function ω(x,y) is the product of the spatial distance domain weighting coefficient and the gray domain weighting coefficient, and the corresponding formula is shown in equation (2):

[0076] ω(x,y)=ω d (x,y)·ωs (x,y) (20);

[0077] Here, ω(x,y) consists of two parts, namely the spatial distance domain weighting coefficient ω d (x,y) and grayscale weighting coefficient ω s (x,y); the former calculates the Gaussian weight using the physical distance between two pixels, while the latter calculates the Gaussian weight using the grayscale difference between two pixels, ω. d (x,y), ω s The formulas corresponding to (x,y) are shown in equations (3) and (4):

[0078]

[0079] Where, σ d Let σ be the standard deviation of the spatial domain. s The standard deviation of the grayscale range;

[0080] (As can be seen from the formula, this algorithm is an adaptive algorithm that continuously adjusts the weights of the convolution kernel according to different pixel states; the formula contains two parts, ω is calculated by formula (3).) d (x,y) can actually be understood as calculating Gaussian weights, and then performing Gaussian filtering on the image; ω calculated by equation (4) s For (x,y), the squared value of the gray level difference |f(x,y)-f(x0,y0)| is used. 2 The weights are calculated using Gaussian parameters; the larger the grayscale difference, the higher the weight ω. s The smaller (x,y) is, the more the weight ratio can be reduced when encountering edge information in the image after the two parts are multiplied, thus preventing blurred edges.

[0081] However, traditional bilateral filtering algorithms utilize the square of the gray-level difference |f(x,y)-f(x0,y0)| 2 As a parameter, but with a limited difference, its ability to reduce weights is not strong when the gradient value is low, thus limiting its ability to protect edge information. Therefore, preferably, to further protect the high-frequency features of the image, some improvements have been made to the algorithm flow of the gray-level domain weighting coefficients of the bilateral filter. The improved flow steps are as follows: Figure 2 (As shown)

[0082] The gray-scale weighting formula shown in equation (3) is changed to equation (5):

[0083]

[0084] Where Δf(x,y) represents the grayscale difference between pixels, and the explanations of the remaining parts are as follows:

[0085] (To enhance the protection of edge information, it is necessary to further increase the proportion of grayscale difference) ω in formula (4) s The squared gray-level difference parameter [f(x,y)-f(x0,y0)] in (x,y) 2 Change it to the grayscale difference exponent parameter exp(|f(x,y)-f(x0,y0)|);

[0086] To ensure the filtering effect is the modified grayscale difference index, an adaptive weight value k is added before it. s As shown in equation (6):

[0087] k s =log k [|f(x,y)-f(x0,y0)|+1] (24);

[0088] Where k represents the filtering threshold, which is calculated as follows: The gradient image of the original image is constructed using the Robert operator, as shown in equation (7):

[0089]

[0090] Next, the average gray value Mean_Val is calculated for the gradient image, and this average gray value Mean_Val is substituted into the weight value k as the parameter k. s In the formula.

[0091] ω calculated using formula (5) zs (x,y) replace ω in formula (4) s (x,y) are substituted into formula (1), and the image is then subjected to convolution filtering using the replaced formula (1).

[0092] More specifically, for step S2, the maximum inter-class variance method first calculates the inter-class variance between pixels when each gray value is used as the threshold, and then takes the gray value corresponding to the largest inter-class variance as the threshold for threshold segmentation.

[0093] In methods for calculating inter-class variance, it is necessary to first count the total amount of data, which corresponds to the total number of pixels in the image. Assuming L(x,y) is a grayscale image with pixel values ​​ranging from 0 to 255, and N is the total number of pixels in the image, n... i Let i represent the number of pixels with a grayscale value of i. Then the total number of pixels is expressed as shown in equation (8):

[0094]

[0095] After counting the total number of pixels, we need to find the proportion of the total number of pixels corresponding to each grayscale value. Let P be an example. i p represents the proportion of pixels with grayscale value i, therefore pi Defined as shown in equation (9):

[0096]

[0097] Let the binarization threshold of the image be T. Then, the pixels of the image are divided into two parts according to the gray value: the foreground and the background. The corresponding gray value ranges are [0,T] and [T+1,255], respectively. Let μ0 and μ1 be the expected gray values ​​of the foreground and background, ω0 and ω1 be the sum of the gray value probabilities of the background and foreground, and μ be the average gray value of all pixels in the image. Then, the definitions of each symbol are shown in equations (10), (11), and (12):

[0098]

[0099] Based on the above formula, let the inter-class variance be σ, and the inter-class variance function is shown in equation (13):

[0100] σ 2 =ω0ω1(μ0-μ1) 2 (31);

[0101] Based on the above formula, after calculating the inter-class variance of all gray values ​​as thresholds, the gray value corresponding to the largest inter-class variance is taken as the segmentation threshold T1. Let the calculation formula for calculating the inter-class variance with gray value T as threshold be T: ω0ω1(μ0-μ1). 2 Then the traditional grayscale threshold T1 is as shown in equation (14):

[0102] T1 = Max[T:ω0ω1(μ0-μ1)] 2 T∈[0,255] (32);

[0103] (As can be seen from the OTSU algorithm formula, the OTSU threshold segmentation method mainly focuses on two parts. One is the product of the proportions of the number of pixels in the two parts. This part can be simply understood as focusing on the difference in the number of data between classes. For example, since ω1=1-ω0, ω0ω1 can be written as ω0(1-ω0)=ω0-ω0) 2 This formula reaches its maximum value when the amount of data in the foreground and background is equal; while the second part (μ0-μ1) 2 This represents the average grayscale difference between the foreground and background. Naturally, the larger the grayscale difference, the larger the value of this formula. It can be seen that the maximum inter-class variance (MOV) considers both the difference in quantity and grayscale. When the difference in the amount of data between the foreground and background in an image is large, the threshold obtained by the MOV method will always be biased towards the one with more data. This may lead to some background being mistakenly identified as foreground or vice versa. In reality, the pixel ratio of the foreground and background in an image varies greatly. Therefore, it is one-sided to assume that the difference between the foreground and background is greatest when their pixel ratios are equal.

[0104] Use the natural constant function logarithmic formula ln(ω0ω1 + 1) to replace ω0ω1 in formula (13), and weaken the weight of the pixel ratio product part;

[0105] Also use the natural constant function exponential function to square the average gray difference (μ0 - μ1) in formula (13) 2 Replace it with exp(|μ0 - μ1|)·|μ0 - μ1|, so as to amplify the average gray difference feature in the variance formula. The modified between-class variance formula is shown in formula (15):

[0106]

[0107] Assume that the between-class variance is calculated using the improved between-class variance formula with the gray value T as the threshold, denoted as T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|. Then the maximum between-class variance obtained corresponds to the threshold T2, that is, the improved gray threshold is expressed as:

[0108] T2 = Max[T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|] T ∈ [0, 255] (34);

[0109] Furthermore, for step S3, (the iterative algorithm flowchart is as Figure 3 shown) Compare the obtained thresholds T1 and T2, and perform threshold segmentation on the gray values outside the two thresholds. Let T1 < T2, and the segmentation process is as shown in formula (17):

[0110]

[0111] where f thre (i, j) represents the gray value of the pixel at the (i, j) position in the image after threshold segmentation, and f(i, j) represents the gray value of the pixel at the (i, j) position in the original image.

[0112] Calculate the corresponding entropy value using the pixel values in the middle part of the two thresholds. The calculation formula of the image entropy is shown in formula (18):

[0113]

[0114] where H is the entropy value of the pixels between the two thresholds, P represents the sum of the probabilities of these pixels, and p i is the same as formula (9) and represents the proportion of pixels with gray value i.

[0115] Image entropy is an important indicator of the complexity and uncertainty of image information and is affected by noise levels. A small entropy value may indicate a simple image with a concentrated grayscale distribution, such as a solid color image or a single-color graphic. A large entropy value indicates a rich image with a uniform grayscale distribution, containing a lot of detail and texture, such as complex natural scenes or images with a lot of noise. Therefore, by calculating the entropy of the grayscale values ​​in the middle part, the corresponding degree of disorder can be obtained (if the entropy value is low, it may be part of the background or foreground; if the entropy value is large, it may indicate both background and foreground, requiring further discussion). The specific method is as follows:

[0116] The image entropy is calculated by taking the gray values ​​in the middle of the two thresholds. If the entropy value is less than the set threshold K (then the pixels in this part are considered relatively flat and may belong to the foreground or background), the average gray value T of this threshold part is calculated. mean Determine whether the average value is closer to T1 or T2. If it is closer to T1, then let... Otherwise, let Then based on the threshold T m Segment this portion of grayscale values.

[0117] Furthermore, if the calculated entropy value is greater than the set threshold K (which indicates that this part of the pixels contains both foreground and background information), the thresholds T1 and T2 are updated and compared using the original inter-class variance algorithm formula (13) and the improved inter-class variance algorithm formula (15) for this part of the pixels. Then, the updated thresholds T1 and T2 are used to segment this part of the pixels using formula (17). The remaining part after segmentation is the pixel between the updated thresholds T1 and T2. The corresponding entropy value is calculated using formula (18) and it is determined whether it exceeds the threshold. This process is repeated until the entropy value is less than the threshold K, and the final T is obtained. m Segmentation was completed. To verify the innovation of the proposed method, threshold segmentation of cell nuclei was performed on the same image using both the proposed method and the traditional OTSU threshold segmentation method, based on micro / nano-microscopic images of cells. The segmentation results were compared. Figure 4 As shown, the proposed method is more accurate in segmenting cell nuclei than the previous OTSU algorithm, and can basically accurately segment all cell nuclei. The traditional OTSU often segments the cell body as well, resulting in poor segmentation accuracy. Therefore, the proposed method has certain advantages. In addition, cell microscopic images are only used here to verify the innovation of the proposed method. The proposed method is also applicable to microscopic images of other micro and nano objects.

[0118] It is worth mentioning that the technical features such as the OTSU algorithm involved in this patent application should be regarded as prior art. The specific structure, working principle and possible control methods and spatial arrangement methods of these technical features can be adopted by conventional choices in the field, and should not be regarded as the inventive point of this patent. This patent will not be further elaborated in detail.

[0119] For those skilled in the art, modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this invention should be included within the protection scope of this invention.

Claims

1. A microscopic vision threshold segmentation algorithm based on OTSU improved for micro-nano object images, characterized in that, The method comprises the following steps: Step S1: combining image gradient information to calculate a new gray weight factor based on exponential and logarithmic functions to perform bilateral filtering processing on the image; Step S2: calculating a traditional gray threshold value for the filtered image by using a traditional inter-class variance formula and calculating an improved gray threshold value by using an improved inter-class variance formula based on a natural constant function; Step S3: performing adaptive iterative operation on the pixels of the image by using the traditional gray threshold value and the improved gray threshold value, so as to complete three-region threshold segmentation; For step S1, the bilateral filtering algorithm is shown in formula (1): (1); wherein, represents a filtered image a gray value of a point, represents a convolution kernel weight set centered at is a weight function of bilateral filtering, the weight function The value of the weight function is the product of the spatial distance domain weighting coefficient and the gray domain weighting coefficient, and the corresponding formula is shown as formula (2):​ (2); wherein, consists of two parts, respectively, spatial distance domain weighting coefficient and gray domain weighting coefficient ; the former uses the physical distance between two pixels to calculate the Gaussian weight, and the latter uses the gray difference of two pixels to calculate the Gaussian weight, , The corresponding formulas are shown in formulas (3) and (4): (3); (4); wherein, is the spatial domain standard deviation, is the gray scale domain standard deviation; The gray weighting formula shown in formula (4) is changed to formula (5): (5); wherein represents a formula for the difference in the gray value between pixels in formula (4) The explanations for the remaining parts are shown as follows: The gray difference square parameter in formula (4) is changed to a gray difference exponential parameter ;​​ To ensure the filtering effect is the gray difference index after modification, an adaptive weight value is added in front As shown in equation (6): (6); wherein represents a filter threshold, which is calculated by constructing a gradient image of the original image using a Robert operator as shown in equation (7): (7); After that, the average gray value of the gradient image is calculated The average gray value is substituted into the formula of the weight value as a parameter of the weight value The formula (5) is used to calculate Instead of the formula (4) in the formula (1), the formula (5) is used to calculate The formula (5) is used to calculate The formula (5) is used to calculate 2. The threshold segmentation algorithm for microscopic vision based on OTSU improvement for micro-nano object image according to claim 1, characterized in that, For step S2, the maximum inter-class variance method first calculates the inter-class variance between the pixels segmented when each gray value is taken as a threshold value, and then takes the gray value corresponding to the maximum inter-class variance as the threshold value of the threshold segmentation; In the calculation method of inter-class variance, the total amount of data needs to be counted first, which corresponds to the total number of pixels in the image in the image, For a gray image, the pixel value range is 0 to 255, The total number of pixels in the image, The number of pixel points with a gray value of is represented, and the total number of pixels is represented as shown in equation (8): (8); After counting the total number of pixels, the proportion of the total number of pixels corresponding to each gray value is required, The proportion of pixels with a gray value of is represented, so is defined as shown in equation (9): (9); Let the binarization threshold of the image be Then the pixels of the image are divided into two parts according to the size of the gray value, foreground and background, and the corresponding gray value intervals are Let be the expected value of the gray value of the foreground and the background, be the sum of the gray value probability of the background and the foreground, be the average gray value of all pixels of the image, and the definition of each symbol is shown in the formula (10), (11), (12): (10); (11); (12); Based on the above formula, let the inter-class variance be The inter-class variance function is shown in equation (13): (13); Based on the above formula, after all the gray value is counted as the threshold of the inter-class variance, the maximum inter-class variance corresponding to the gray value is taken as the segmentation threshold , and the gray value is taken as the threshold to calculate the inter-class variance. The calculation formula is , then the traditional gray threshold is shown as formula (14): (14); Using natural constant function logarithm formula Instead of the formula (13) in The pixel proportion product part is occupied by weakening the weight; The average gray difference square in formula (13) is replaced by the natural constant function exponential function so as to amplify the average gray difference feature in the variance formula. The modified between-class variance formula is shown in formula (15):​ (15); The gray value is taken as a threshold value The inter-class variance is calculated by using the improved inter-class variance formula, and is represented as The maximum inter-class variance corresponds to the threshold value The improved gray threshold value is represented as: (16)。 3. The threshold segmentation algorithm for microscopic vision based on OTSU improvement for micro-nano object image according to claim 2, characterized in that, For step S3, the threshold value thus obtained and is compared, and the gray scale values outside the two thresholds are subjected to thresholding processing, and the segmentation process is as shown in equation (17): (17); The pixel values in the middle part of the two threshold values are used to calculate the corresponding entropy values, and the calculation formula of the image entropy is shown in formula (18): (18); The corresponding confusion degree is obtained by calculating the entropy of the middle part gray value, and the specific mode is as follows: The entropy of the image is calculated by taking the gray value of the middle part of the two thresholds , the average value of the gray value of the pixels in this part is calculated , it is determined whether the average value is closer to or , if it is closer to , then , otherwise , then the part of the gray value is segmented according to the threshold .

4. The threshold segmentation algorithm for microscopic vision based on OTSU improvement for micro-nano object image according to claim 3, characterized in that, For step S3, if the calculated entropy value is greater than the set threshold , the threshold is updated using the original Otsu's algorithm formula (13) and the improved Otsu's algorithm formula (15) for this part of pixels , and are compared, and then the formula (17) is used to update the threshold , and segment the pixels between the updated threshold , and , the corresponding entropy value is calculated using the formula (18) and it is judged whether it exceeds the threshold, and the process is repeated until the entropy value is less than the threshold , and the final segmentation is completed.

Citation Information

Patent Citations

  • Pressure vessel laser welding control method based on machine vision

    CN115908410A