A fast particle image segmentation method based on two-dimensional minimum intra-class variance
By combining the two-dimensional minimum intra-class variance and inter-class variance, the problem of inaccurate sediment particle image segmentation in existing methods is solved, and a faster and more accurate image segmentation effect is achieved, which is suitable for sediment particle size detection.
Patent Information
- Application Number
- CN202211443034.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-11-17
AI Technical Summary
Existing image segmentation methods have poor target extraction effects in sediment particle images, especially for single-target images. They cannot effectively distinguish the target from the background and ignore the neighborhood spatial information, resulting in inaccurate segmentation and significant noise impact.
A fast particle image segmentation method based on two-dimensional minimum intra-class variance is adopted. By constructing a two-dimensional grayscale function, combining the neighborhood average grayscale value and inter-class variance, and randomly selecting thresholds s and t, the image is divided into target domain A and background domain B. The final threshold TH is calculated by minimizing the intra-class variance and inter-class variance, and the image reprocessing algorithm is combined to remove noise and fill holes.
It achieves more accurate target and background segmentation, reduces the influence of noise, and improves the accuracy and speed of image segmentation. In particular, the segmentation effect of single target images is significantly improved, which is suitable for sediment particle size detection.
Smart Images

Figure CN116051578B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of image segmentation and water and sand detection, and in particular to an image threshold segmentation method based on probability distribution. Background Art
[0002] Image segmentation is a common method in image processing. Its purpose is to separate the image portion of interest from the background, extracting the target region for better image recognition and detection. It is a crucial step in image-based sediment particle size detection. Threshold segmentation is the most commonly used method, the simplest and most effective among many segmentation methods, and is frequently used in sediment particle image recognition. In sediment particle size detection, if the threshold is too large, the background at the edge of the particle may be mistaken for the target, resulting in the subsequent measured sediment particle size being larger than the actual particle size. If the threshold is too small, smaller particles in the image may be overlooked, resulting in a steeper particle size distribution curve and a significant deviation from the actual value. Therefore, the selection of the threshold is crucial to achieving ideal segmentation results. Threshold segmentation can be subdivided into five categories: histogram analysis, clustering, maximum entropy, high-order probability distribution and pixel similarity analysis, fuzzy shape similarity, and edge conformity analysis. Based on the size of the selected image region, these methods can be broadly divided into two categories: local threshold segmentation and global threshold segmentation.
[0003] Common local threshold segmentation methods include the Bersen algorithm, the Niblack algorithm, the Sauvola algorithm, and Gaussian weighting. Their principle is to divide the original image into multiple sub-images of fixed size and then select a threshold based on the grayscale features of each sub-image. This threshold segmentation method can handle the segmentation of multiple targets and is excellent for images with significant noise and non-uniform illumination. However, for general images, the use of local thresholds can easily result in poor connectivity and noise in the target area obtained by the final segmentation, which is inconvenient for sediment particle detection. In contrast, global thresholding has excellent segmentation effects for single targets and uses a single threshold for the entire area, resulting in low computational complexity and simple operation. It is the most widely used method in sediment particle size detection image methods. Currently, commonly used global threshold segmentation methods include maximum entropy thresholding and OTUS, also known as the great law thresholding.
[0004] The OTUS algorithm is widely used in threshold segmentation. Its principle is to compare the inter-class variance of the grayscale values of two regions. If the inter-class variance of the two regions is the largest, it indicates a significant difference between the background and the target. The corresponding grayscale value at this time is the optimal threshold for image segmentation. It is theoretically simple, has a clear physical meaning, and can dynamically and adaptively determine the image segmentation threshold. However, this method is not effective for segmenting pixel histograms without obvious double peaks. It cannot generate a good threshold for images with a large difference in target and background area or a small difference in target and background grayscale values. Furthermore, the one-dimensional global threshold segmentation method only considers the grayscale value of the pixel itself, not other spatial information in the neighborhood, and ignores the edge noise present in the image. Therefore, in practical applications, two-dimensional maximum entropy and OTUS are often used for image segmentation. Summary of the Invention
[0005] The purpose of the present invention is to provide a fast particle image segmentation method based on two-dimensional minimum intra-class variance to solve the problem that the existing methods have poor target extraction effect when performing single-target image segmentation such as sediment particles.
[0006] In order to solve the above problems, the solution to be adopted in the present invention is:
[0007] A fast particle image segmentation method based on two-dimensional minimum intra-class variance includes the following steps:
[0008] S1 collects original sediment particle images;
[0009] S2 constructs a two-dimensional grayscale function and establishes a two-dimensional matrix of the pixel's own grayscale value and the neighborhood average grayscale value, where the neighborhood average grayscale value is expressed as:
[0010]
[0011] Among them, g ij is the average gray value of the neighborhood, which is an integer;
[0012] r represents the selected neighborhood step size, which is an odd number always greater than 0;
[0013] img[i][j] represents the grayscale value at (i, j) in the image, which is an integer greater than or equal to 0;
[0014] S3 randomly selects thresholds s and t and divides the image into four regions A, B, C, and D, where region A and region B correspond to the target domain and background domain respectively, expressed as:
[0015] A={img[i][j]∈Z,g ij ∈Z|0≤img[i][j]≤s,0≤g ij <t}
[0016] B={img[i][j]∈Z,g ij ∈Z|s <img[i][j]<256,t≤g ij <256}
[0017] The areas where the grayscale function deviates from the diagonal are generally noise and edges, that is, areas C and D. If the frequency of occurrence of these areas is 0, the frequencies of occurrence of areas A and B are:
[0018]
[0019] P B =1-P A
[0020] Where P(x,y) represents the frequency of the pixel whose central gray value is x and whose neighboring gray value is y appearing in the image;
[0021] S4 introduces the concept of minimum intra-class variance, that is, the smaller the variance of the grayscale values of each pixel in the same class area, the more evenly distributed the grayscale values in the area, indicating that they may come from the same object. That is, the thresholds s and t corresponding to the minimum intra-class variance are found to quickly separate the background and the target better.
[0022] S5 combines the inter-class variance to assign weights to the two thresholds s and t respectively, and obtains the final threshold TH;
[0023] S6 outputs the image segmentation result with the threshold TH;
[0024] S7 image reprocessing.
[0025] In step S2, in constructing a two-dimensional grayscale function, the grayscale value of each fixed pixel in the image is denoted as X, and the average grayscale value of the neighborhood is denoted as Y. The value range of X and Y is [0, 255], covering the entire grayscale level. The probability that different X values and different Y values appear simultaneously in an image is denoted as P. Then, X and Y are regarded as two-dimensional discrete random variable distributions.
[0026] Step S4 introduces the minimum intra-class method, and calculates the internal expectation vector and variance vector of region A and region B respectively based on the two-dimensional discrete random variable distribution:
[0027]
[0028]
[0029]
[0030]
[0031] Where x is the grayscale value of a pixel in the area;
[0032] y is the average gray value of the neighborhood corresponding to this pixel;
[0033] s is the threshold in the x direction, and t is the threshold in the y direction, both of which are in the range [0, 255].
[0034] P(x,y) is the number of times the x value and the corresponding y value appear simultaneously in an image;
[0035] P A is the number of all pixels included in area A;
[0036] E A is the expected vector inside area A, E A0(st) (s, t) represents the expected value in the x direction, E A1(st) (s, t) represents the expected value in the y direction, abbreviated as E A0 ,E A1;
[0037] D A is the variance vector inside region A, D A0(st) (s, t) represents the variance value in the x direction, D A1(st) (s,t) represents the expected value in the y direction;
[0038] P B is the number of all pixels included in area B;
[0039] E B is the expected vector inside region B, E B0(st) (s, t) represents the expected value in the x direction, E B1(st) (s, t) represents the expected value in the y direction, abbreviated as E B0 ,E B1 ;
[0040] D B is the variance vector inside region B, D B0(st) (s, t) represents the variance value in the x direction, D B1(st) (s,t) represents the expected value in the y direction.
[0041] The step S4 determines the thresholds s and t corresponding to the minimum intra-class variance, specifically: when the sum of the moduli of the variances of the two vectors is the minimum,
[0042] |D| min ≤D free
[0043]
[0044] At this time, the corresponding thresholds s and t are the optimal thresholds.
[0045] In step S3, the frequency P of region A appears A , Expected E A and variance D A Use the following recursive formula:
[0046] P st (s+1,t+1)=P st (s,t)+P s (t+1)+P t (s+1)+P (s+1)(t+1)
[0047] E st (s+1,t+1)=E st (s,t)+E s (t+1)+E t (s+1)+E (s+1)(t+1)
[0048] D st (s+1,t+1)=D st (s,t)+D s (t+1)+D t (s+1)+D (s+1)(t+1)
[0049] Step S5 specifically comprises: combining the one-dimensional inter-class variance to respectively calculate the inter-class variance corresponding to the threshold s and the inter-class variance corresponding to the threshold t:
[0050] The inter-class variance σ1 and σ2 of the threshold s are:
[0051]
[0052]
[0053] The inter-class variance σ3 and σ4 of threshold t are:
[0054]
[0055]
[0056] Wherein, μ is the average gray value of the original image,
[0057] Px is the frequency of occurrence of pixels with gray value x,
[0058] ω0 and ω1 represent the weight of each region in the total region;
[0059] The weights S1 and S2 of the two thresholds are calculated according to the inter-class variance corresponding to the threshold s and threshold t:
[0060]
[0061] S2=1-S1
[0062] Wherein, σ0 is the gray value variance of the original image;
[0063] The final threshold is:
[0064] TH=S1×s+S2×t
[0065] TH is the final threshold.
[0066] The image reprocessing in step S7 includes:
[0067] The opening operation of first corrosion and then expansion is used to remove the noise with higher brightness in the image;
[0068] The cavities inside the particles are filled with flooding water;
[0069] The watershed algorithm is used to segment the adhered particles.
[0070] The fast particle image segmentation method based on two-dimensional minimum intra-class variance of the present invention has the following technical advantages compared with existing segmentation methods:
[0071] First, the present invention provides a fast particle image segmentation method based on two-dimensional minimum intra-class variance, which performs segmentation from a global perspective without destroying the connectivity of the target itself. The operation is relatively simple and the principle is clear.
[0072] Second, the present invention not only considers the grayscale value of the pixel at the center of the image, but also the spatial information of the neighboring pixels. Finally, it uses dimensionality reduction and combines the inter-class variance of the two thresholds for analysis, so as to better cluster the target area and the background area. Ultimately, it can provide a better segmentation effect for other image recognition tasks such as sediment particle detection, and provide the optimal binary image for subsequent image processing.
[0073] Third, for fixed thresholds s and t, when calculating the frequency PA of occurrence in region A and the variance of the two parts, it is not necessary to repeat the calculation from x=1, y=1 each time, thereby speeding up the operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to clearly illustrate the implementation cases of the present invention or the technical solutions in the prior art, the present invention is described in detail by the following specific implementations and drawings. The drawings described below are only some implementation cases in the process of the present invention.
[0075] Figure 1 This is a flow chart of a fast particle image segmentation method based on two-dimensional minimum intra-class variance provided by the present invention;
[0076] Figure 2 It is a specific schematic diagram of constructing a two-dimensional grayscale function;
[0077] Figure 3 It is the two-dimensional grayscale function pixel distribution map of the Cameraman image;
[0078] Figure 4 This is the effect diagram of Cameraman image segmentation using traditional OTUS;
[0079] Figure 5 It is a segmentation effect diagram of the method of the present invention;
[0080] Figure 6 is the original sediment particle image;
[0081] Figure 7 This is the segmentation effect of the original sediment particle image using traditional OTUS;
[0082] Figure 8 This is a diagram showing the segmentation effect of the original sediment particle image using the method of the present invention;
[0083] Figure 9 It is the image of sediment particles after image reprocessing;
[0084] Figure 10 It is the two-dimensional grayscale function diagram of the original sediment particle image;
[0085] Figure 11 is the grayscale histogram of the original sediment particle image;
[0086] Figure 12 This is the segmentation effect diagram before image processing;
[0087] Figure 13 This is the segmentation effect diagram after image reprocessing. DETAILED DESCRIPTION
[0088] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0089] In order to solve the problems of inaccurate and unstable segmentation effects of traditional threshold segmentation algorithms for images containing noise and background target areas that are difficult to distinguish, the present invention proposes a two-dimensional minimum intra-class variance fast particle image segmentation method.
[0090] like Figure 1 FIG. 1 is a flow chart of a method provided by the present invention, wherein the process includes:
[0091] S1 collects original sediment particle images;
[0092] S2 constructs a two-dimensional grayscale function;
[0093] S3 randomly selects thresholds s and t to divide the image into target domain A and background domain B;
[0094] S4 introduces the concept of minimum intra-class variance to find the optimal thresholds s and t
[0095] S5 combines the inter-class variance to assign weights to the two thresholds s and t respectively, and obtains the final threshold TH;
[0096] S6 outputs the image segmentation result with the threshold TH;
[0097] S7 image reprocessing.
[0098] In S2, a two-dimensional grayscale function is constructed. The embodiment of the present invention provides a pixel point and nine surrounding grids as its neighborhood space. If an image with a resolution of h×w and a grayscale of 256 is used, its pixel matrix is expressed as
[0099]
[0100]
[0101] Among them, t ij is the gray value at (i, j) in the image, and its neighborhood space is t (i-1)(j-1) , t (i-1)j , t (i-1)(j+1) , t i(j-1) , t i(j+1) , t (i+1)(j-1) , t (i+1)j , t (i+1)(j+1) And the gray value of the center pixel of tij itself, g ij is the average grayscale value of the neighborhood at (i, j) in the image.
[0102] like Figure 2 As shown, the horizontal coordinate X represents the average grayscale value of the neighborhood at (i, j), and the vertical coordinate Y represents the grayscale value at (i, j) itself, as shown in Figure 3 As shown, the coordinate system corresponds to the spatial distribution of all pixels in the image. Figure 2 It is the projection of the pixel point on the x and y coordinates. t is the segmentation threshold of the horizontal coordinate, and s is the segmentation threshold of the vertical coordinate. Draw a vertical line parallel to the x-axis and y-axis at X=t and Y=s respectively, dividing the entire area into four parts: A, B, C, and D. A represents the target area, that is, the sediment particles or other objects of interest to be extracted; B represents the background area. A and B are expressed as a set
[0103] A={img[i][j]∈Z,g ij ∈Z|0≤img[i][j]≤s,0≤g ij <t}
[0104] B={img[i][j]∈Z,g ij ∈Z|s <img[i][j]<256t≤g ij <256}
[0105] Generally, the pixels of an image are concentrated near the line y = x, indicating that the image contains less noise, the lighting is relatively uniform, and the image quality is good. Conversely, if the pixels of an image are distributed far away from the line, it may indicate that the image itself has uneven lighting and a lot of noise.
[0106] The method provided by the present invention divides the image into regions, regards the frequency of occurrence of pixels distributed in the boundary area of the grayscale function as 0, and incorporates them into the background area B for comprehensive calculation. In this way, when performing the image segmentation operation, the edge noise in the image is also processed, and at the same time, the thresholds s and t corresponding to the minimum intra-class variance are found more quickly.
[0107] The frequencies of the target area A and the background area B appearing in the image are:
[0108]
[0109]
[0110] P(x,y) represents the frequency of the pixel with the central gray value x and the neighborhood gray value y in the image.
[0111] S4 introduces the concept of minimum intra-class variance. The traditional minimum intra-class variance is based on the grayscale histogram, and the threshold is determined by minimizing the sum of the intra-class variances of the target area and the background area. The basic idea is:
[0112] Assuming that the original image has 255 gray levels, the number of pixels corresponding to a gray level is ni, and the total number of image pixels is N, the frequency of occurrence of each gray level can be obtained as:
[0113]
[0114] Randomly select the threshold thresh in the grayscale range and divide the image grayscale into two categories, namely G0 and G1, whose grayscales are represented as
[0115] G0={img[i][j]|0≤img[i][j]≤thresh}
[0116] G1={img[i][j]|thresh <img[i][j]<255}
[0117] The initial value of thresh is the minimum value corresponding to the existence of grayscale. The ratios of G0 and G1 are:
[0118]
[0119]
[0120] Then the expectations of G0 and G1 are:
[0121]
[0122]
[0123] The variances of G0 and G1 are:
[0124]
[0125]
[0126] Therefore, the sum of the within-class variance is:
[0127] σ=ω0×σ G0 +ω1×σ G1
[0128] Let thresh take values in the range of [0,255] so that the minimum intra-class variance of the two parts of the image is the optimal threshold of the minimum intra-class variance method, which is expressed as:
[0129]
[0130] The present invention proposes a fast particle image segmentation method based on two-dimensional minimum intra-class variance. On the basis of one-dimensional intra-class variance, the grayscale information of the pixel neighborhood space is taken into account, and the variance of the two-dimensional discrete random variable distribution is used to reflect the discrete degree of the image grayscale value. If the grayscale change is more uniform, the modulus of the vector variance in the region is smaller, and the clustering effect is better.
[0131] The expected value E of the grayscale vector of the two regions A and B of the image A and E B Expressed as:
[0132]
[0133]
[0134] The grayscale vector variance D of the two regions A and B of the image A and D B Expressed as:
[0135]
[0136]
[0137] The modulus D of the intra-class variance of the vector of the entire image free Expressed as:
[0138]
[0139] Finally, the optimal threshold discriminant function of the particle image fast segmentation method based on two-dimensional minimum intra-class variance provided by the present invention is:
[0140]
[0141]
[0142] When calculating each pair of thresholds s and t, the frequency PA of area A and the expectation and variance of the two parts must be recalculated. The calculation is complex and time-consuming. In order to achieve fast segmentation, an iterative method is adopted to reduce the repeated calculation process and improve calculation efficiency.
[0143] The frequency of occurrence of region A is P A , Expected E A and variance D A Use the following recursive formula:
[0144] P st (s+1,t+1)=P st (s,t)+P s (t+1)+P t (s+1)+P (s+1)(t+1)
[0145] E st (s+1,t+1)=E st (s,t)+E s (t+1)+E t (s+1)+E (s+1)(t+1)
[0146] D st (s+1,t+1)=D st (s,t)+D s (t+1)+D t (s+1)+D (s+1)(t+1)
[0147] The thresholds s and t calculated in step S4 can be used for segmentation, and the image pixel histogram can be divided into two parts, G0 and G1, with the ratios of the two parts being ω0 and ω1 respectively. Combined with the one-dimensional inter-class variance algorithm, the weights at the thresholds s and t can be calculated respectively.
[0148] First, calculate the expected grayscale μ of the entire image:
[0149]
[0150] In the past, the inter-class variance used μ as the grayscale average value of the entire image. However, the variance of the grayscale value can amplify the fluctuation value of the grayscale in the region and better reflect the discrete degree of the grayscale value in the region. Therefore, the image mean square error is used to represent the grayscale average value of the entire image. The grayscale mean square error σ of the entire image is:
[0151]
[0152] Substitute the two thresholds s and t calculated in step S4 into the variance formula respectively, and the grayscale mean square deviations σ1 and σ2 corresponding to s are obtained as follows:
[0153]
[0154]
[0155] Then the inter-class variance σs corresponding to the threshold s is expressed as:
[0156] σ s 2 =(σ1-σ0) 2 +(σ2-σ0) 2
[0157] Grayscale mean square errors σ3 and σ4 corresponding to t are:
[0158]
[0159]
[0160] Then the inter-class variance σ corresponding to the threshold t t Expressed as:
[0161] σ t 2 =(σ3-σ0) 2 +(σ4-σ0) 2
[0162] Therefore, the weight corresponding to the s threshold is:
[0163]
[0164] The weight corresponding to the t threshold is:
[0165] S2=1-S1
[0166] Finally, the final threshold TH is calculated:
[0167] TH=S1×s+S2×t
[0168] like Figure 4 and Figure 5 The 256×256 pixel Cameraman is segmented using the traditional OTUS threshold segmentation effect diagram and the method of the present invention. According to the minimum intra-class variance calculation, the two thresholds are 89 and 42 respectively. Finally, according to the effect diagram, it can be seen that compared with the traditional OTUS threshold segmentation effect diagram, the method of the present invention has a better effect on the segmentation of the target object, especially for single-target images, which can better extract the part of interest from the background and remove excess noise.
[0169] After the above test, the method of the present invention is used to perform threshold segmentation on the original sediment particle image of 487×512 pixels, and a rendering with better segmentation effect is obtained, as shown in FIG. Figure 8 As shown. Figure 7 and Figure 8 It can be seen that the method provided by the present invention can better separate the shadow part of the particle from the particle itself, thereby reducing the error when detecting the particle size of sediment particles. Figure 9 This is the effect after image reprocessing. This step has done a good job of processing and improving the noise and internal cavities of the sediment that existed in the previous step.
[0170] In step S7, the binary image that still has small noise after segmentation can be further optimized through image reprocessing. The specific steps are as follows:
[0171] The opening operation of first corrosion and then expansion is used to remove the noise with higher brightness in the image;
[0172] The cavities inside the particles are filled with flooding water;
[0173] The watershed algorithm is used to segment the adhered particles.
[0174] It should be noted that by corroding and then dilating the image, white bright spots are eliminated so that the edge contours of sediment particles can be detected more clearly and accurately, reducing measurement errors.
[0175] In this embodiment of the present invention, the floodFill image filling tool in OpenCV is used to fill the internal cavities of the sediment particles. It should be noted that floodFill is suitable for processing cavities within closed shapes. If the edges of the identified particle shapes are not closed, the threshold of the binary image needs to be adjusted to identify the more complete outlines of the sediment particles.
[0176] In one embodiment of the present invention, the method further includes segmenting the contiguous sediment in the image using a bottom-up watershed algorithm that simulates flooding. During this operation, the foreground and background values of the image are determined, superimposed, and the binary image is converted to a grayscale image using cv2.connectedComponents. The grayscale value is represented by the closest distance from the point to the target point. The grayscale value is expanded outward from the center of the target object to the optimal dividing line for each target point, and the dividing line is marked as -1.
[0177] It should be noted that in a complex river environment, sediment particles will inevitably stick together when in motion. The watershed segmentation algorithm is a mathematical morphological segmentation method based on topological theory. It will separate the sediment particles well according to the center of gravity of each particle.
[0178] like Figure 12 The figure shows the effect of threshold segmentation of the original sediment particle image in a specific embodiment. Figure 13 The figure shows the segmentation effect of the original sediment particle image after reprocessing in a specific embodiment.
Claims
1. A fast particle image segmentation method based on two-dimensional minimum intra-class variance, characterized by: The following steps are involved: S1 collects original sediment particle images; S2 constructs a two-dimensional grayscale function and establishes a two-dimensional matrix of the pixel's own grayscale value and the neighborhood average grayscale value, where the neighborhood average grayscale value is expressed as: , Among them, g ij is the average gray value of the neighborhood, which is an integer; r represents the selected neighborhood step size, which is an odd number always greater than 0; img[i][j] represents the grayscale value at (i, j) in the image, which is an integer greater than or equal to 0; S3 randomly selects thresholds s and t and divides the image into four regions A, B, C, and D, where region A and region B correspond to the target domain and background domain respectively, expressed as: , , The areas where the grayscale function deviates from the diagonal are noise and edges, that is, areas C and D. If the frequency of occurrence of these areas is 0, the frequencies of occurrence of areas A and B are: , , Where P(x,y) represents the frequency of the pixel whose central gray value is x and whose neighboring gray value is y appearing in the image; S4 introduces the concept of minimum intra-class variance, that is, the smaller the variance of the grayscale values of each pixel in the same class area, the more evenly distributed the grayscale values in the area, indicating that they may come from the same object. That is, the thresholds s and t corresponding to the minimum intra-class variance are found to quickly separate the background and the target better. S5 combines the inter-class variance to assign weights to the two thresholds s and t respectively, and obtains the final threshold TH; S6 outputs the image segmentation result with the threshold TH; S7 image reprocessing; The step S4 determines the thresholds s and t corresponding to the minimum intra-class variance, specifically: when the sum of the moduli of the variances of the two vectors is the minimum, , , At this time, the corresponding thresholds s and t are the optimal thresholds; Step S5 specifically comprises: combining the one-dimensional inter-class variance to respectively calculate the inter-class variance corresponding to the threshold s and the inter-class variance corresponding to the threshold t: The inter-class variance σ1 and σ2 of the threshold s are: , , The inter-class variance σ3 and σ4 of threshold t are: , , Wherein, μ is the average gray value of the original sediment particle image, Px is the frequency of occurrence of pixels with gray value x, ω0 and ω1 represent the weight of each region in the total region; The weights S1 and S2 of the two thresholds are calculated according to the inter-class variance corresponding to the threshold s and threshold t: , , Wherein, σ0 is the gray value variance of the original sediment particle image; The final threshold is: , TH is the final threshold.
2. The method for fast particle image segmentation based on two-dimensional minimum intra-class variance according to claim 1, characterized in that: In step S2, in constructing a two-dimensional grayscale function, the grayscale value of each fixed pixel in the image is denoted as X, and the average grayscale value of the neighborhood is denoted as Y. The value range of X and Y is [0, 255], covering the entire grayscale level. The probability that different X values and different Y values appear simultaneously in an image is denoted as P. Then, X and Y are regarded as two-dimensional discrete random variable distributions.
3. The method for fast particle image segmentation based on two-dimensional minimum intra-class variance according to claim 1, characterized in that: Step S4 introduces the minimum intra-class method, and calculates the internal expectation vector and variance vector of region A and region B respectively based on the two-dimensional discrete random variable distribution: , , , , Where x is the grayscale value of a pixel in the area; y is the average gray value of the neighborhood corresponding to this pixel; s is the threshold in the x direction, and t is the threshold in the y direction, both of which are in the range [0, 255]. P( x ,y ) is the number of times an x value and the corresponding y value appear simultaneously in an image; P A is the number of all pixels included in area A; E A is the expected vector inside area A, E A0(st) (s, t) represents the expected value in the x direction, E A1(st) (s, t) represents the expected value in the y direction, abbreviated as E A0 ,E A1; D A is the variance vector inside region A, D A0(st) (s, t) represents the variance value in the x direction, D A1(st) ( s, t ) represents the expected value in the y direction; P B is the number of all pixels included in area B; E B is the expected vector inside region B, E B0(st) (s, t) represents the expected value in the x direction, E B1(st) (s, t) represents the expected value in the y direction, abbreviated as E B0 , E B1 ; D B is the variance vector inside region B, D B0(st) (s, t) represents the variance value in the x direction, D B1(st) (s, t) represents the expected value in the y direction.
4. The method for fast particle image segmentation based on two-dimensional minimum intra-class variance according to claim 1, characterized in that: In step S3, the frequency P of region A appears A , Expected E A and variance D A Use the following recursive formula: , , 。 5. The method for fast particle image segmentation based on two-dimensional minimum intra-class variance according to claim 1, characterized in that: The image reprocessing in step S7 includes: The opening operation of first corrosion and then expansion is used to remove the noise with higher brightness in the image; The cavities inside the particles are filled with flooding water; The watershed algorithm is used to segment the adhered particles.
Citation Information
Patent Citations
Method for identifying concrete crack characteristic information
CN103400139A
Obtaining a threshold for partitioning a dataset based on class variance and contrast
WO2007078258A1