Microscopic visual threshold segmentation algorithm based on OTSU improvement for micro-nano object image
By improving the OTSU algorithm, combining image gradient information to optimize bilateral filtering and modifying the inter-class variance formula, the noise interference and stability problems of the threshold segmentation algorithm at the micro-nanoscale are solved, and a more accurate and stable image segmentation effect is achieved.
Patent Information
- Application Number
- CN202411956182.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-28
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2044-12-28
AI Technical Summary
The threshold segmentation algorithm at the micro-nanoscale is greatly disturbed by noise and has poor stability. The OTSU segmentation algorithm has the problem of pixel quantity bias, making it difficult to obtain accurate segmentation results in images with complex content or significant illumination changes.
Improve the OTSU algorithm, combine image gradient information to optimize the gray value weight factor of the bilateral filtering algorithm, modify the inter-class variance formula to weaken the impact of pixel proportion imbalance, and enhance local analysis capabilities through iterative algorithms.
Improves the stability and accuracy of threshold segmentation, enhances the anti-interference ability to noise and the adaptability of images, especially in micro-nano microscopy images.
Smart Images

Figure CN119991697A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of microscopic vision image processing, and in particular relates to a microscopic vision threshold segmentation algorithm for micro-nano object images based on an improved OTSU (Otsu algorithm). Background Art
[0002] With the rapid development of nanotechnology and micro-processing technology, micro-nano vision technology, as an important bridge connecting the macro and nano worlds, is rapidly becoming a key tool in scientific research and industrial applications. Micro-nano vision technology mainly uses high-precision imaging and analysis methods to reveal the structural and functional characteristics of materials, devices and biological systems at the micro and nano scales. For example, in the biomedical field, through high-resolution imaging, researchers can observe biological processes at the level of single cells, subcellular structures and molecules; in the field of materials science, micro-nano vision technology can assist in the design of new functional materials; at the same time, in the field of microelectronics and nano devices, high-resolution imaging can accurately detect tiny defects on the chip to ensure the performance and reliability of the device.
[0003] In the field of microscopic vision technology, the main focus is on the identification and analysis of micro-nano objects in images. Therefore, image processing technology is needed to extract information about the target objects in the image. Threshold segmentation technology is an image segmentation method based on pixel grayscale value or color. By setting a threshold, the pixels in the image are divided into two categories according to the grayscale value. This can simplify the image data, highlight the target area, and facilitate subsequent image analysis and processing. Threshold segmentation technology provides a basic framework and preliminary results, and the algorithm is simple and the calculation speed is fast. It is suitable for real-time image processing and large-scale data processing scenarios, and is of great significance to target extraction, data compression, feature extraction, and image enhancement.
[0004] Images under microscopic vision are usually affected by factors such as sensor noise, signal transmission interference, and ambient light, resulting in irregular brightness fluctuations, a phenomenon usually referred to as noise. The presence of noise will change the grayscale value of image pixels, thereby affecting the result of threshold segmentation. The book "Digital Image Processing" mentions that the traditional linear noise reduction algorithm is equivalent to a low-pass filter, which mainly performs weighted calculations on the grayscale values of surrounding pixels to weaken the impact of noise, but at the same time affects the high-frequency characteristics of the image. Therefore, in order to protect the high-frequency information of the image, the bilateral filtering algorithm is widely used.
[0005] The paper "Guided Image Filtering" mentions that bilateral filtering is an adaptive image denoising algorithm that achieves edge preservation by dynamically adjusting the weight of the convolution kernel according to the local characteristics of the pixels. The core of the algorithm consists of two weights: the first part is based on the spatial distance between pixels, similar to Gaussian filtering, which is used to smooth the image; the second part determines the weight by the grayscale value difference. When the grayscale difference is large, the weight is reduced accordingly. This design enables bilateral filtering to reduce the blurring effect when processing edge information. However, the current bilateral filtering algorithm has some limitations. First, the filtering effect is highly dependent on parameters, which usually need to be manually adjusted and lack versatility. Second, the edge protection ability in complex scenes is weak, especially in high-noise images, where the weight of the grayscale difference may be interfered by noise, resulting in blurred edges or over-smoothing. In addition, the 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 the bilateral filtering algorithm to enhance its stability and edge protection effect is an important direction of current research.
[0006] At present, threshold segmentation methods are mainly divided into two categories: global threshold segmentation and adaptive threshold segmentation. The paper "Image Segmentation Using Multilevel Thresholding: A Research Review" points out that global threshold segmentation segments the entire image through a single threshold that is given or automatically calculated; while adaptive threshold segmentation technology dynamically determines the local area threshold according to the grayscale characteristics of the local area of the image, so that different areas of the image are segmented using different thresholds. However, due to inevitable interference such as uneven lighting, image noise and impurities, the performance of threshold segmentation may be significantly affected. In practical applications, higher requirements are placed on the anti-interference and efficiency of threshold segmentation algorithms.
[0007] The OTSU algorithm, also known as the maximum inter-class variance method, is widely used in the field of image processing because of its high stability and low computational complexity. In the OTSU algorithm, the image pixels are divided into two categories by traversing the entire grayscale value range, and the inter-class variance when each grayscale value is used as the threshold is calculated. The inter-class variance is an indicator of the degree of separation between the foreground and the background, reflecting the discrimination between the two types of data. The OTSU algorithm completes the global threshold segmentation by selecting the grayscale value corresponding to the maximum inter-class variance as the optimal threshold. From the formula of the OTSU algorithm, it can be seen that it mainly considers two factors: one is the ratio of the number of foreground and background pixels. When the number of pixels in the two categories is equal, the inter-class variance reaches the maximum value; the other is the average grayscale difference between the foreground and the background. The greater the grayscale difference, the greater the inter-class variance value. Therefore, the maximum inter-class variance method can balance the number of pixels and the grayscale difference at the same time. However, the OTSU algorithm also has certain limitations. For images with a large difference in the number of foreground and background pixels, the selected threshold often tends to be biased towards one category, making it difficult to obtain accurate segmentation results. In addition, as a global threshold segmentation method, the OTSU algorithm lacks the ability to adapt to local information and is not suitable for images with complex content or significant lighting changes.
[0008] Therefore, the present invention aims to solve the problems that the threshold segmentation algorithm at the micro-nano scale is greatly interfered by noise and has poor stability, and the OTSU segmentation algorithm has pixel quantity bias. The maximum inter-class variance formula is improved and a local judgment mechanism is introduced into the OTSU algorithm, as well as the influence of pixel ratio imbalance on the result is weakened. At the same time, the filtering algorithm is combined to enhance its robustness and adaptability, thereby improving the stability and accuracy of the OTSU algorithm in the segmentation of micro-nano microscopic images. Summary of the invention
[0009] The main purpose of the present invention is to provide a microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images, which overcomes the problem of inaccurate calculation results caused by unbalanced pixel number ratio during threshold segmentation and improves the limitation of poor local analysis ability of the global threshold segmentation algorithm.
[0010] Another object of the present invention is to provide an improved microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images, which can solve the problem of inaccurate threshold segmentation in micro-nano microscopic vision caused by the large difference in the ratio of foreground and background data in the traditional OTSU algorithm, and has a certain local analysis ability. At the same time, the improved bilateral filtering algorithm can better retain the high-frequency information in the image while ensuring the denoising effect, thereby greatly improving the stability of threshold segmentation.
[0011] To achieve the above objectives, a microscopic visual threshold segmentation algorithm based on OTSU improvement for micro-nano object images is proposed, which includes the following steps:
[0012] Step S1: Combine image gradient information to calculate a new grayscale weight factor based on exponential and logarithmic functions, and perform bilateral filtering on the image;
[0013] Step S2: using the traditional inter-class variance formula to calculate the traditional grayscale threshold of the filtered image, and using the improved inter-class variance formula based on the natural constant function to calculate the improved grayscale threshold;
[0014] Step S3: using the traditional gray threshold and the improved gray threshold, adaptively iterate the pixels of the image to complete the three-region threshold segmentation.
[0015] As a further preferred technical solution of the above technical solution, for step S1, the bilateral filtering algorithm is shown in formula (1):
[0016]
[0017] Among them, f Bilateral (x0, y0) represents the gray value of the point (x0, y0) in the filtered image, M(x0, y0) represents the convolution kernel weight set centered at (x0, y0), ω(x, y) is the weight function of bilateral filtering, and the value of the weight function ω(x, y) is the product of the weight coefficient in the spatial distance domain and the weight coefficient in the gray domain. The corresponding formula is shown in formula (2):
[0018] ω(x,y)=ω d (x,y)·ω s (x,y) (2);
[0019] Among them, ω(x,y) consists of two parts, namely the spatial distance domain weighting coefficient ω d (x,y) and grayscale domain weighting coefficient ω s (x, y); the former uses the physical distance between two pixels to calculate the Gaussian weight, and the latter uses the grayscale difference between two pixels to calculate the Gaussian weight, ω d (x,y),ω s The formula corresponding to (x, y) is shown in equations (3) and (4):
[0020]
[0021] Among them, σ d is the spatial domain standard deviation, σ s is the grayscale domain standard deviation;
[0022] Change the grayscale weighted formula shown in formula (4) to formula (5):
[0023]
[0024] Among them, Δf(x,y) represents the gray value difference between pixels, and the explanations of the remaining parts are as follows:
[0025] Replace ω in formula (4) s The squared grayscale difference parameter in (x,y) [f(x,y)-f(x0,y0)] 2 Change to grayscale difference exponent parameter exp(|f(x,y)-f(x0,y0)|);
[0026] To ensure that the filtering effect is the grayscale difference index after modification, an adaptive weight value k is added in front s , as shown in formula (6):
[0027] k s =log k [|f(x,y)-f(x0,y0)|+1] (6);
[0028] Where k represents the filtering critical value, which is calculated as follows: The gradient image of the original image is constructed using the Robert operator, and the Robert operator is shown in formula (7):
[0029]
[0030] After that, the average gray value Mean_Val is calculated for the gradient image, and the average gray value Mean_Val is substituted into the weight value k as the parameter k s in the formula.
[0031] Using formula (5) to calculate ω zs (x,y) replaces ω in formula (4) s (x, y) is substituted into formula (1), and the image is 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 the pixel points segmented when each gray value is used as the threshold, and then takes the gray value corresponding to the maximum inter-class variance as the threshold of the threshold segmentation;
[0033] In the calculation method of 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. Assume that L(x,y) is a grayscale image with a pixel value range of 0 to 255, N is the total number of pixels in the image, and n i represents the number of pixels with gray value i, then the total number of pixels is expressed as shown in formula (8):
[0034]
[0035] After counting the total number of pixels, we need to find the proportion of pixels corresponding to each gray value to the total number. Assume that p i It represents the proportion of pixels with gray value i, so p i It is defined as shown in formula (9):
[0036]
[0037] Assume that the binarization threshold of the image is T, then the pixels of the image are divided into two parts according to the grayscale value, foreground and background, and the corresponding grayscale value intervals correspond to [0, T], [T + 1, 255] respectively. Assume that μ0, μ1 are the expected grayscale values of the foreground and background, ω0, ω1 are the sum of the grayscale value probabilities of the background and foreground, and μ is the average grayscale value of all pixels in the image. The definitions of each symbol are shown in equations (10), (11), and (12):
[0038]
[0039]
[0040] Based on the above formula, let the between-class variance be σ, and the between-class variance function is shown in formula (13):
[0041] σ 2 =ω0ω1(μ0-μ1) 2 (13);
[0042] Based on the above formula, after counting all the gray values as the inter-class variance of the threshold, the gray value corresponding to the largest inter-class variance is taken as the segmentation threshold T1. Suppose the gray value T is used as the threshold to calculate the inter-class variance. The calculation formula is T:ω0ω1(μ0-μ1) 2 , then the traditional grayscale threshold T1 is as shown in formula (14):
[0043] T1=Max[T:ω0ω1(μ0-μ1) 2 ]T∈[0,255] (14);
[0044] The natural constant function logarithmic formula ln(ω0ω1+1) is used to replace ω0ω1 in formula (13), and the weight of the pixel ratio product is weakened;
[0045] We also use the natural constant function exponential function to convert the average grayscale difference square (μ0-μ1) in formula (13) 2 Replace it with exp(|μ0-μ1|)·|μ0-μ1|, thereby amplifying the average grayscale difference feature in the variance formula. The modified between-class variance formula is shown in formula (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, denoted as T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|. Then, let the threshold T2 corresponding to the maximum inter-class variance obtained be the improved gray threshold, which is 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. Assume T1 < T2, and the segmentation process is as 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 as 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 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 value K, the threshold values T1 and T2 are updated and compared with the improved inter-class variance algorithm formula (13) before and after improvement for this part of pixels, and then the formula (17) is continued to be used in combination with the updated threshold values T1 and T2 to segment this part of pixels. The remaining part after segmentation, that is, the pixels between the updated threshold values T1 and T2, continues to use the formula (18) to calculate the corresponding entropy value and judge whether it exceeds the threshold value. Repeat this process until the entropy value is less than the threshold value K, and the final T is obtained. m The split is complete.
[0058] The beneficial effects of the present invention are:
[0059] (1) The present invention combines the gray value weight factor formula of the gradient image optimization bilateral filtering algorithm to protect the filtering weight of the small gradient value, and uses the natural constant exponential formula to further reduce the weight of the position with a large gradient value, so that the 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, the present invention can solve the problem of inaccurate threshold segmentation caused by the large difference in the ratio of the foreground and background data in the traditional OTSU algorithm, so that it can adapt to various image types and maintain efficient segmentation performance. This versatility makes the improved OTSU algorithm perform well in a wide range of application fields;
[0061] (3) The present invention combines the iterative algorithm with the traditional threshold segmentation algorithm, and classifies and discusses the pixels in the image in an iterative manner, so that the algorithm has a certain local analysis capability and can more accurately separate the foreground and background in the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 It is a flow chart of the present invention.
[0063] Figure 2 It is a schematic diagram of the improved bilateral filtering algorithm of the present invention.
[0064] Figure 3 It is a schematic diagram of the improved OTSU threshold segmentation algorithm flow of the present invention.
[0065] Figure 4 This is a comparison chart between the implementation effect of the algorithm proposed by the present invention and the traditional method. DETAILED DESCRIPTION
[0066] The following description is used to disclose the present invention so that those skilled in the art can implement the present invention. The preferred embodiments described below are only examples, and those skilled in the art can think of other obvious variations. The basic principles of the present invention defined in the following description can be applied to other embodiments, variations, improvements, equivalents, and other technical solutions that do not deviate from the spirit and scope of the present 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 may be regarded as prior art.
[0068] Preferred embodiments.
[0069] like Figure 1-4 As shown, the present invention discloses a microscopic vision threshold segmentation algorithm based on OTSU improvement for micro-nano object images, comprising the following steps:
[0070] Step S1: Combine image gradient information to calculate a new grayscale weight factor based on an exponential and logarithmic function (replacing the weight factor based on the traditional grayscale difference formula), and perform bilateral filtering on the image;
[0071] Step S2: using the traditional inter-class variance formula to calculate the traditional grayscale threshold of the filtered image, and using the improved inter-class variance formula based on the natural constant function to calculate the improved grayscale threshold;
[0072] Step S3: using the traditional gray threshold and the improved gray threshold, adaptively iterate the pixels of the image to complete the three-region threshold segmentation.
[0073] Specifically, for step S1, (in order to prevent the high-frequency features in the image from being affected, the bilateral filtering algorithm is selected to perform noise reduction on 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 value according to the similarity between pixels and their distance in space, so as to obtain the convolution kernel weight value of the pixel) The bilateral filtering algorithm is shown in formula (1):
[0074]
[0075] Among them, f Bilateral (x0, y0) represents the gray value of the point (x0, y0) in the filtered image, M(x0, y0) represents the convolution kernel weight set centered at (x0, y0), ω(x, y) is the weight function of bilateral filtering, and the value of the weight function ω(x, y) is the product of the weight coefficient in the spatial distance domain and the weight coefficient in the gray domain. The corresponding formula is shown in formula (2):
[0076] ω(x,y)=ω d (x,y)·ωs (x,y) (20);
[0077] Among them, ω(x,y) consists of two parts, namely the spatial distance domain weighting coefficient ω d (x,y) and grayscale domain weighting coefficient ω s (x, y); the former uses the physical distance between two pixels to calculate the Gaussian weight, and the latter uses the grayscale difference between two pixels to calculate the Gaussian weight, ω d (x,y),ω s The formula corresponding to (x, y) is shown in equations (3) and (4):
[0078]
[0079] Among them, σ d is the spatial domain standard deviation, σ s is the grayscale domain standard deviation;
[0080] (It can be obtained from the formula that this algorithm is an adaptive algorithm that continuously adjusts the weight of the convolution kernel according to different pixel states; the formula consists of two parts, ω 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 formula (4) s (x,y) is the grayscale difference square value |f(x,y)-f(x0,y0)| 2 As a Gaussian parameter to calculate the weight, the larger the grayscale difference, the greater the weight ω s The smaller (x,y) is, the more the weight ratio can be reduced when the edge information in the image is encountered after multiplying the two parts, thereby preventing blurred edges.
[0081] However, since the traditional bilateral filtering algorithm uses the square of the grayscale difference |f(x,y)-f(x0,y0)| 2 As a parameter, the difference size is limited. When the gradient value is not high, its ability to reduce the weight is not so strong, so the ability to protect edge information is limited. Therefore, preferably, in order to further protect the high-frequency characteristics of the image, some improvements are made to the algorithm flow of the gray domain weighted coefficient of the bilateral filter. The improved process steps are as follows Figure 2 (shown)
[0082] Change the grayscale weighted formula shown in formula (3) to formula (5):
[0083]
[0084] Among them, Δf(x,y) represents the gray value difference between pixels, and the explanations of the remaining parts are as follows:
[0085] (In order to enhance the protection of edge information, it is necessary to further increase the proportion of grayscale difference) s The squared grayscale difference parameter in (x,y) [f(x,y)-f(x0,y0)] 2 Change to grayscale difference exponent parameter exp(|f(x,y)-f(x0,y0)|);
[0086] To ensure that the filtering effect is the grayscale difference index after modification, an adaptive weight value k is added in front s , as shown in formula (6):
[0087] k s =log k [|f(x,y)-f(x0,y0)|+1] (24);
[0088] Where k represents the filtering critical value, which is calculated as follows: The gradient image of the original image is constructed using the Robert operator, and the Robert operator is shown in formula (7):
[0089]
[0090] After that, the average gray value Mean_Val is calculated for the gradient image, and the average gray value Mean_Val is substituted into the weight value k as the parameter k s in the formula.
[0091] Using formula (5) to calculate ω zs (x,y) replaces ω in formula (4) s (x, y) is substituted into formula (1), and the image is 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 the pixel points segmented when each gray value is used as the threshold, and then takes the gray value corresponding to the maximum inter-class variance as the threshold for threshold segmentation;
[0093] In the calculation method of 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. Assume that L(x,y) is a grayscale image with a pixel value range of 0 to 255, N is the total number of pixels in the image, and n i represents the number of pixels with gray value i, then the total number of pixels is expressed as shown in formula (8):
[0094]
[0095] After counting the total number of pixels, we need to find the proportion of pixels corresponding to each gray value to the total number. Assume that P i It represents the proportion of pixels with gray value i, so pi It is defined as shown in formula (9):
[0096]
[0097] Assume that the binarization threshold of the image is T, then the pixels of the image are divided into two parts according to the grayscale value, foreground and background, and the corresponding grayscale value intervals correspond to [0, T], [T + 1, 255] respectively. Assume that μ0, μ1 are the expected grayscale values of the foreground and background, ω0, ω1 are the sum of the grayscale value probabilities of the background and foreground, and μ is the average grayscale value of all pixels in the image. The definitions of each symbol are shown in equations (10), (11), and (12):
[0098]
[0099] Based on the above formula, let the between-class variance be σ, and the between-class variance function is shown in formula (13):
[0100] σ 2 =ω0ω1(μ0-μ1) 2 (31);
[0101] Based on the above formula, after counting all the gray values as the inter-class variance of the threshold, the gray value corresponding to the largest inter-class variance is taken as the segmentation threshold T1. Suppose the gray value T is used as the threshold to calculate the inter-class variance. The calculation formula is T:ω0ω1(μ0-μ1) 2 , then the traditional grayscale threshold T1 is as shown in formula (14):
[0102] T1=Max[T:ω0ω1(μ0-μ1) 2 ]T∈[0,255] (32);
[0103] (From the OTSU algorithm formula, we can know that the OTSU threshold segmentation method mainly focuses on two parts. One is the product of the proportion of the number of pixels in the two parts. This part is simply understood as the focus on the difference in the number of data between classes. For, since ω1=1-ω0, ω0ω1 is written as ω0(1-ω0)=ω0-ω0 2 , this formula reaches its maximum value when the amount of data of the foreground and background is equal; and the second part (μ0-μ1) 2 It represents the average grayscale difference between the foreground and the background. Naturally, the larger the grayscale difference, the larger the value of this formula. It can be seen that the maximum inter-class variance takes into account the difference in quantity and grayscale at the same time. When the data volume difference between the foreground and background in the image is large, the threshold value obtained by the maximum inter-class variance method is always biased towards the larger data volume, which will mistake part of the background for the foreground or the foreground for the background. The pixel ratios of the foreground and background in the real image vary. Therefore, it is one-sided to think that the difference between the foreground and background is the largest when the pixel volume ratio is 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 using the improved between-class variance formula with the gray value T as the threshold to calculate the between-class variance is expressed 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 processing on the gray values outside the two thresholds. Assume 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 to measure the complexity and uncertainty of image information and is affected by the size of noise. When the calculated entropy value is small, it may indicate that the image is simple in content and has a concentrated distribution of grayscale values, such as a pure color image or a single-color graphic. When the entropy value is large, it means that the image information is rich, the grayscale distribution is uniform, and it contains a lot of details and textures, such as complex natural scenes, images with more noise, etc. Therefore, by calculating the entropy of the grayscale value in the middle part, the corresponding degree of confusion is obtained (if the entropy value is not high, it may be part of the background or foreground. If the entropy value is large, it may indicate that there is both background and foreground, and it needs to be discussed again). The specific method is as follows:
[0116] Take the gray value of the middle part of the two thresholds to calculate the image entropy. If the entropy value is less than the set threshold K (then it is considered that the pixels in this part are relatively flat and may belong to the foreground or background), calculate the gray average value T of this part of the threshold mean , determine whether the average value is closer to T1 or T2. If it is close to T1, then let Otherwise, Then according to the threshold T m Segment this part of the gray value.
[0117] Furthermore, if the calculated entropy value is greater than the set threshold K (it means that this part of the pixels contains both foreground and background information), the improved inter-class variance algorithm formula (13) and the improved inter-class variance algorithm formula (15) are used to update the thresholds T1 and T2 for this part of the pixels and compare them. Then, the formula (17) is used to combine the updated thresholds T1 and T2 to segment this part of the pixels. The remaining part after segmentation is the pixels 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. The process is repeated until the entropy value is less than the threshold K, and the final T is obtained. m To verify the innovativeness of the proposed method, the proposed method and the traditional OTSU threshold segmentation method were used to perform threshold segmentation on the cell nucleus target on the same image of the cell micro-nano microscope image, and the segmentation effect was compared. Figure 4 As shown, it can be seen that the proposed method is more accurate in cell nucleus segmentation than the OTSU algorithm before the improvement, and basically all cell nucleus targets can be accurately segmented. The traditional OTSU often segments the cell body, and the segmentation accuracy is poor. Therefore, the method in this paper has certain advantages. In addition, the cell microscopic images are only used here to verify the innovation of this method. This method is also applicable to other microscopic images of micro-nano objects.
[0118] It is worth mentioning that the technical features such as the OTSU algorithm involved in the patent application of this invention should be regarded as the prior art. The specific structure, working principle and possible control method and spatial layout method of these technical features can be selected by conventional methods in the field, and should not be regarded as the inventive point of the patent of this invention. The patent of this invention will not be further elaborated.
[0119] For those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A microscopic vision threshold segmentation algorithm based on OTSU improvement for micro-nano object images, characterized in that: It includes the following steps: Step S1: Combining the image gradient information, calculate a new gray weight factor based on exponential and logarithmic functions, and perform bilateral filtering on the image; Step S2: Calculate the traditional gray threshold for the filtered image using the traditional between-class variance formula, and calculate the improved gray threshold using the between-class variance formula improved based on the natural constant function; Step S3: Using the traditional gray threshold and the improved gray threshold, perform adaptive iterative operations on the pixels of the image to complete the three-region threshold segmentation.
2. According to claim 1, the improved microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images is characterized in that: For step S1, the bilateral filtering algorithm is shown in Equation (1): Among them, f Bilateral (x0, y0) represents the gray value of the point (x0, y0) in the filtered image, M(x0, y0) represents the convolution kernel weight set centered at (x0, y0), ω(x, y) is the weight function of bilateral filtering, and the value of the weight function ω(x, y) is the product of the weight coefficient in the spatial distance domain and the weight coefficient in the gray domain. The corresponding formula is shown in formula (2): ω(x,y)=ω d (x,y)·ω s (x,y) (2); Among them, ω(x,y) consists of two parts, namely the spatial distance domain weighting coefficient ω d (x,y) and grayscale domain weighting coefficient ω s (x, y); the former uses the physical distance between two pixels to calculate the Gaussian weight, and the latter uses the grayscale difference between two pixels to calculate the Gaussian weight, ω d (x,y),ω s The formula corresponding to (x, y) is shown in equations (3) and (4): Among them, σ d is the spatial domain standard deviation, σ s is the grayscale domain standard deviation; Change the gray-weighted formula shown in Equation (4) to Equation (5): Among them, Δf(x,y) represents the gray value difference between pixels, and the explanations of the other parts are as follows: Replace ω in formula (4) s The squared grayscale difference parameter in (x,y) [f(x,y)-f(x0,y0)] 2 Change to grayscale difference exponent parameter exp(|f(x,y)-f(x0,y0)|); To ensure that the filtering effect is the grayscale difference index after modification, an adaptive weight value k is added in front s , as shown in formula (6): k s =log k [|f(x,y)-f(x0,y0)|+1] (6); Among them, k represents the filtering critical value, and its calculation method is: use the Robert operator to construct the gradient image of the original image, and the Robert operator is shown in Equation (7): After that, the average gray value Mean_Val is calculated for the gradient image, and the average gray value Mean_Val is substituted into the weight value k as the parameter k s In the formula; Using formula (5) to calculate ω zs (x,y) replaces ω in formula (4) s (x, y) is substituted into formula (1), and the image is subjected to convolution filtering using the replaced formula (1).
3. According to claim 2, the improved microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images is characterized in that: For step S2, the Otsu method first calculates the between-class variance between the pixel points segmented when each gray value is used as the threshold, and then takes the gray value corresponding to the maximum between-class variance as the threshold for threshold segmentation; In the calculation method of 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. Assume that L(x,y) is a grayscale image with a pixel value range of 0 to 255, N is the total number of pixels in the image, and n i represents the number of pixels with gray value i, then the total number of pixels is expressed as shown in formula (8): After counting the total number of pixels, we need to find the proportion of pixels corresponding to each gray value to the total number. Assume that P i It represents the proportion of pixels with gray value i, so p i It is defined as shown in formula (9): Let the binarization threshold of the image be T. Then, the pixels of the image are divided into two parts, foreground and background, according to the gray value size, and the corresponding gray value intervals are [0,T] and [T + 1,255] respectively. Let μ0, μ1 be the gray value expectations of the foreground and background, ω0, ω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): Based on the above formulas, let the between-class variance be σ, and the between-class variance function is shown in Equation (13): s 2 =ω0ω1(μ0-μ1) 2 (13); Based on the above formula, after counting all the gray values as the inter-class variance of the threshold, the gray value corresponding to the largest inter-class variance is taken as the segmentation threshold T1. Suppose the gray value T is used as the threshold to calculate the inter-class variance. The calculation formula is T:ω0ω1(μ0-μ1) 2 , then the traditional grayscale threshold T1 is as shown in formula (14): T1=Max[T:ω0ω1(μ0-μ1) 2 ]T∈[0,255] (14); Use the natural constant function logarithm formula ln(ω0ω1 + 1) to replace ω0ω1 in formula (13) to weaken the weight of the pixel ratio product part; We also use the natural constant function exponential function to convert the average grayscale difference square (μ0-μ1) in formula (13) 2 Replace it with exp(|μ0-μ1|)·|μ0-μ1|, thereby amplifying the average grayscale difference feature in the variance formula. The modified between-class variance formula is shown in formula (15): Assume that the between-class variance calculated using the improved between-class variance formula with the gray value T as the threshold is expressed as T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|. Then, the maximum between-class variance corresponds to the threshold T2, that is, the improved gray threshold is expressed as: T2 = Max[T: ln(ω0ω1 + 1)·exp(|μ0 - μ1|)·|μ0 - μ1|] T ∈ [0,255] (16).
4. According to claim 3, the improved microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images is characterized in that: For step S3, compare the obtained thresholds T1 and T2, and perform threshold segmentation processing on the gray values outside the two thresholds. Assume T1 < T2, and the segmentation process is shown in Equation (17): 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 Equation (18): 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: Take the gray value of the middle part of the two thresholds to calculate the image entropy. If the entropy value is less than the set threshold K, calculate the average gray value T of this part of pixels. mean , determine whether the average value is closer to T1 or T2. If it is close to T1, then let Otherwise, Then according to the threshold T m Segment this part of the gray value.
5. According to claim 4, the improved microscopic vision threshold segmentation algorithm based on OTSU for micro-nano object images is characterized in that: For step S3, if the calculated entropy value is greater than the set threshold value K, the improved inter-class variance algorithm formula (13) and the improved inter-class variance algorithm formula (15) are used to update the threshold values T1 and T2 for this part of pixels and compare them. Then, the formula (17) is used to segment this part of pixels in combination with the updated threshold values T1 and T2. The remaining part after segmentation, that is, the pixels between the updated threshold values T1 and T2, is used to calculate the corresponding entropy value using formula (18) and determine whether it exceeds the threshold value. The process is repeated until the entropy value is less than the threshold value K, and the final T is obtained. m The split is complete.
Citation Information
Patent Citations
Power transmission line aerial image adaptive enhancement method
CN111161196A
SAR image speckle noise suppression method based on Gamma-Lee filtering
CN111861905A
Pressure vessel laser welding control method based on machine vision
CN115908410A
Bone target recognition and segmentation method based on X-ray data
CN116152505A
Image segmentation method, apparatus and device, and a medium
WO2021212913A1
Cited By
Filling opening anti-leakage monitoring system and method based on machine vision
CN121746366A