Intelligent particle size analysis method and device based on watershed algorithm, storage medium and program

Through the intelligent particle size analysis method of the watershed algorithm, the problem of inaccurate particle boundary identification in complex backgrounds by traditional methods was solved, and high-precision automated analysis of ancient sediment particle size was achieved.

CN120823256APending Publication Date: 2025-10-21YANGTZE UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510754379.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

When dealing with ancient sediments in complex backgrounds, traditional particle size analysis methods have problems such as inaccurate particle boundary identification, complex background interference, insufficient algorithm adaptability and high computational complexity, which affect the accuracy and repeatability of the analysis results.

Method used

An intelligent particle size analysis method based on the watershed algorithm is adopted, including image preprocessing, morphological operations, watershed segmentation and ellipse fitting, to achieve automatic identification of particle boundaries and efficient measurement of particle size parameters.

Benefits of technology

It improves the accuracy and efficiency of particle size analysis, reduces human errors, and achieves accurate segmentation of overlapping particles in complex backgrounds and efficient measurement of particle size parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120823256A_ABST
    Figure CN120823256A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent particle size analysis method and device based on a watershed algorithm, a storage medium and a program, and relates to the technical field of image processing, in particular to a particle size analysis technology of mineral particles in sedimentology. S10, preprocessing the input target particle image to extract a target region, and generating a binary image; s20, performing morphological operation on the preprocessed target particle image to separate a target region from a background; s30, segmenting overlapped particles in the target particle image by using a watershed algorithm and marking a target region boundary; and S40, analyzing the segmented target region to obtain a particle size parameter, and outputting a structured labeling result. Compared with a traditional scheme, the method has the following beneficial effects: firstly, the accuracy of particle size analysis is remarkably improved; and 2, automatic processing of particle size analysis is realized, and manual intervention and post-processing work are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an intelligent particle size analysis method, device, storage medium and program based on a watershed algorithm. Background Art

[0002] In sedimentological research, particle size analysis is a key tool for gaining a deeper understanding of the formation processes of sediments and sedimentary rocks, the depositional environments, and the hydrodynamic conditions. While traditional particle size analysis methods, such as sieving and sedimentation, can provide some information on particle size distribution, they have significant limitations for ancient sediments that have undergone intense diagenesis. Mineral particles in ancient sediments are tightly bound together, making them difficult to completely separate. Mechanical crushing can also damage individual mineral particles, affecting the accuracy of analytical results.

[0003] In recent years, image analysis has become the primary method for mineral particle size analysis. The application of image segmentation, in particular, has significantly improved the accuracy and efficiency of particle size analysis. However, traditional image segmentation methods still suffer from numerous drawbacks in practical applications. For example, interference from complex backgrounds can make it difficult to identify the target area; low image resolution can affect analysis accuracy; algorithms lack adaptability and struggle to handle different image types; and high computational complexity reduces processing efficiency. These issues all reduce the objectivity and repeatability of analytical results.

[0004] The watershed algorithm can effectively identify particle boundaries in images, especially in situations with overlapping particles and complex backgrounds, providing more accurate particle size information. This study's intelligent particle size analysis method based on the watershed algorithm can achieve automated processing, reduce human error, and improve analysis efficiency. Sediment particle size analysis based on the watershed algorithm not only enriches the algorithm's application scenarios but also provides new ideas and methods for image segmentation problems in other fields, driving sedimentological research towards higher precision and deeper levels of research. Summary of the Invention

[0005] In view of the shortcomings of the above-mentioned existing technologies, the technical problem to be solved by the present invention is to provide an intelligent particle size analysis method, equipment, storage medium and program based on the watershed algorithm, which can realize accurate identification of overlapping particle boundaries in complex backgrounds, automatic measurement of particle size parameters, and improve analysis accuracy through ellipse fitting and pixel-to-actual length conversion.

[0006] To solve the above technical problems, the technical solution adopted by the present invention is as follows: the present invention provides an intelligent particle size analysis method based on a watershed algorithm, comprising the following steps:

[0007] S10, preprocessing the input target particle image to extract the target area and generate a binary image;

[0008] S20, performing a morphological operation on the pre-processed target particle image to separate the target area from the background;

[0009] S30, using a watershed algorithm to segment overlapping particles in the target particle image and mark the target area boundary;

[0010] S40: Analyze the segmented target area to obtain particle size parameters and output a structured annotation result.

[0011] In the preferred solution, the specific steps of step S10 are:

[0012] S11, using the OpenCV library to read the input target particle image, and converting the color image into a grayscale image through the cvtColor function;

[0013] S12, converting the input target particle image into HSV space, filtering dark areas according to the HSV space, and retaining light areas;

[0014] S13, processing the grayscale image using Gaussian blur and histogram equalization to enhance contrast and reduce noise;

[0015] S14. Automatically calculate the optimal segmentation threshold of the grayscale image based on the Otsu threshold method, and convert the grayscale image into a black and white binary image.

[0016] In a preferred solution, the specific steps of filtering the dark areas and retaining the light areas in step S12 are as follows: setting a brightness threshold range in the HSV space, traversing the pixel points, and determining the pixels with brightness values ​​lower than the lower threshold as black, and the pixels with brightness values ​​higher than the lower threshold retain the original pixel values;

[0017] Among them, the brightness threshold range is H∈[0,180], S∈[0,255], V∈[0,255].

[0018] In the preferred solution, the specific steps of step S20 are:

[0019] S21, performing a morphological opening operation on the binary image to remove small noise and smooth the boundary of the target area by first corroding and then dilating;

[0020] S22, calculating the Euclidean distance D from each foreground pixel to the nearest background pixel in the binary image by Euclidean distance transform, to obtain a distance transformed image;

[0021] Traverse each pixel in the distance transformation image and set the distance threshold T = k × max (D) to determine the foreground core area;

[0022] S23. Determine the unknown area by the difference between the background area image and the foreground area image.

[0023] In the preferred solution, the specific steps of step S30 are:

[0024] S31, marking the foreground core area as a foreground seed point, and marking the background area as a background seed point;

[0025] S32, segmenting the target area using a watershed algorithm, marking each segmented target area, and obtaining a target area with a unique mark;

[0026] S33, marking the boundary pixels of the target area with the unique mark in blue.

[0027] In the preferred solution, the specific steps of step S40 are:

[0028] S41, traverse each segmented target area, ignore the background area, and obtain the traversed target area;

[0029] S42, extracting contours and calculating areas based on the traversed target regions to obtain the contours and areas of each target region;

[0030] S43, setting an area threshold, filtering contours smaller than the area threshold, and obtaining the target area contour retained after filtering;

[0031] S44, processing the contour of the target area retained after filtering using an ellipse fitting algorithm;

[0032] S45. Based on the input pixel value P of the ruler and the corresponding actual length L, calculate the conversion coefficient K between pixels and actual length. The formula is:

[0033]

[0034] The longest diameter 2a and the shortest diameter 2b of the target area are respectively multiplied by the conversion coefficient K to obtain the actual length.

[0035] In a preferred solution, in step S44, an ellipse fitting algorithm is used to calculate the longest diameter 2a and the shortest diameter 2b of the target area contour retained after filtering, and the specific steps are as follows:

[0036] S441, using the general equation of an ellipse: Ax 2 +Bxy+Cy 2 +Dx+Ey+F=0 describes the outline of the target area;

[0037] Among them, A, B, and C are the coefficients of the quadratic term, and D and E are the coefficients of the linear term;

[0038] S442, use the least square method to determine the equation coefficients A, B, C, D, E so that the contour point (x i ,y i) to the ellipse, the sum of the squares of the distances is minimized, the formula is:

[0039]

[0040] Among them, (x i ,y i ) is the coordinate of the i-th pixel point on the target area contour, and n is the total number of contour points.

[0041] S443. Calculate the partial derivatives of S with respect to A, B, C, D, and E and set them to 0. Determine the semi-major axis a and the minor axis b of the ellipse by solving the coefficients using the linear least squares method.

[0042] Among them, the semi-major axis a corresponds to the longest diameter of the target area, and the minor axis b corresponds to the shortest diameter of the target area;

[0043] The calculation formulas for the semi-major axis a and the minor axis b are:

[0044]

[0045] In a preferred embodiment, the present invention also provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of any of the above-mentioned intelligent particle size analysis methods based on the watershed algorithm.

[0046] In a preferred embodiment, the present invention further provides a computer non-transitory readable storage medium on which a computer program / instruction is stored, characterized in that when the computer program / instruction is executed by a processor, the steps of the intelligent particle size analysis method based on the watershed algorithm as described above are implemented.

[0047] In a preferred embodiment, the present invention further provides a computer program product, including a computer program / instruction, characterized in that when the computer program / instruction is executed by one or more processors, it implements the steps of any of the above-mentioned intelligent particle size analysis methods based on the watershed algorithm.

[0048] The present invention provides an intelligent particle size analysis method, device, storage medium, and program based on a watershed algorithm. Compared with traditional solutions, the above method has the following beneficial effects:

[0049] First, the present invention is based on the watershed algorithm, which effectively solves the problems of complex background interference, low image resolution, insufficient algorithm adaptability, high computational complexity, etc. existing in traditional image segmentation methods when processing complex sediment images, and significantly improves the accuracy of particle size analysis.

[0050] Second, it realizes the automation of particle size analysis, reduces manual intervention and post-processing work, reduces human errors, and greatly improves analysis efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0052] Figure 1 This is a main structural diagram of the cleaning process of the present invention;

[0053] Figure 2 is a schematic diagram of the target area extracted by the present invention;

[0054] Figure 3 is a schematic diagram of further separating the target area and the background according to the present invention;

[0055] Figure 4 This is a schematic diagram demonstrating the application of the watershed algorithm to an image according to the present invention;

[0056] Figure 5 is a schematic diagram of marking each target area by the watershed algorithm of the present invention;

[0057] Figure 6 Schematic diagram of the analysis of contour extraction and ellipse fitting calculation for each target area in the present invention;

[0058] Figure 7 It is a schematic diagram of the result preservation of the present invention;

[0059] Figure 8 It is a structural schematic diagram of the computer device of the present invention. DETAILED DESCRIPTION

[0060] In order to better understand the purpose, system architecture and functional implementation of the present embodiment, the embodiments in the present application and the features in the embodiments may be combined with each other without conflict. The exemplary embodiments disclosed in the present embodiment will be described below in conjunction with the accompanying drawings, which contain specific technical details disclosed in the present embodiment to assist understanding, but these details should be regarded as exemplary rather than restrictive. Therefore, it should be understood by those skilled in the art that various improvements and adjustments may be made to the embodiments described herein without departing from the scope and core ideas of the present invention. Similarly, for clarity of expression, a detailed description of well-known technologies, functions and structures (such as standard image processing algorithms, general communication protocols) is omitted in the following description.

[0061] In the field of artificial intelligence image processing, image analysis methods are widely used for particle size analysis in sedimentological research. Traditional methods such as screening, sedimentation, and traditional image segmentation struggle to effectively process images of ancient sediments that have undergone intense diagenesis. They suffer from inaccurate particle boundary identification, significant interference from complex backgrounds, and frequent and inefficient manual intervention. For example, particles in ancient sediments are tightly bound together, making mechanical crushing prone to particle breakage. Traditional image segmentation methods also suffer from insufficient algorithmic adaptability and high computational complexity in complex backgrounds and low-resolution images, compromising the objectivity and repeatability of analysis results.

[0062] With the development of artificial intelligence technology, image analysis algorithms are gradually moving towards automation and high precision. The watershed algorithm, due to its ability to identify boundaries in the presence of overlapping particles and complex backgrounds, provides a new direction for particle size analysis. However, existing image-based particle size analysis methods still have the following limitations: First, there is a lack of a full-process automated processing solution tailored to the characteristics of sedimentological images, requiring manual preprocessing and parameter adjustment; second, traditional boundary recognition algorithms lack segmentation accuracy in scenarios with adherent particles, resulting in large errors in particle size measurement; third, the conversion process between pixel scale and actual physical size relies on empirical settings and lacks a unified quantification model.

[0063] To address the above-mentioned problems, the present invention proposes an intelligent particle size analysis method based on the watershed algorithm. Through full-process automated processing of image preprocessing, morphological operations, watershed segmentation, ellipse fitting and pixel-to-actual length conversion, it achieves accurate segmentation of overlapping particles in complex backgrounds and efficient measurement of particle size parameters, breaking through the technical bottleneck of traditional methods in particle boundary recognition and automated analysis.

[0064] Example 1

[0065] like Figures 1 to 7 As shown, an intelligent particle size analysis method based on a watershed algorithm includes the following steps:

[0066] In this embodiment, Figure 2 As shown, S10, image preprocessing:

[0067] S11. Read the input image and convert it into a grayscale image: Use the functions provided by the OpenCV library to read the input image, and then use the cvtColor function to convert the color image into a grayscale image.

[0068] Specifically, each pixel in a color image is represented by the color values ​​of the three channels: red, green, and blue, while each pixel in a grayscale image is represented by a single grayscale value, which reflects the brightness information of the pixel. This conversion simplifies subsequent processing and highlights the brightness characteristics of the image.

[0069] S12. Use color filtering to remove dark areas and retain light areas: Define an appropriate brightness threshold range. By traversing each pixel of the image, check its brightness value in HSV space.

[0070] In this embodiment, the threshold values ​​are set as follows: hue (H) range is [0, 180], saturation (S) range is [0, 255], and brightness (V) range is [0, 255].

[0071] Iterate over each pixel of the image and check its brightness value.

[0072] If the brightness value of a pixel is lower than the set threshold, the corresponding pixel value is set to black (or other color value indicating removal), which belongs to the dark area;

[0073] Pixels with brightness values ​​above the lower threshold retain their original pixel values ​​and are considered light-colored. This filtering can highlight areas that require attention and reduce interference in subsequent processing.

[0074] S13. Perform Gaussian blur and histogram equalization on the grayscale image to enhance contrast and reduce noise: Gaussian blur, a weighted average filtering method based on the Gaussian function, is used to assign different weights to pixels at different positions based on the distance relationship between the pixel and the surrounding pixels.

[0075] By selecting appropriate Gaussian kernel parameters (such as kernel size and standard deviation), weighted average calculation is performed on each pixel in the image to smooth the image and effectively reduce high-frequency noise.

[0076] At the same time, the Gaussian kernel's properties can effectively preserve image edge information, preventing loss of detail due to excessive blurring. After Gaussian blurring, the image is subjected to histogram equalization. This process redistributes the image's grayscale values ​​to make the image's grayscale histogram as evenly distributed as possible, expanding the image's grayscale dynamic range and enhancing overall contrast.

[0077] The specific operation is to count the frequency of occurrence of each grayscale value in the image, and map the original grayscale value to a new grayscale value range according to specific mapping rules, so that the bright and dark details of the image are clearer, providing a better image foundation for subsequent binarization processing.

[0078] S14. Binarize the image using the Otsu thresholding method: Binarize the image using the Otsu thresholding method. The Otsu thresholding method is an adaptive image binarization method that automatically calculates the optimal threshold by analyzing the grayscale distribution characteristics of the image. Its core concept is to classify the image's grayscale values ​​into two categories: foreground and background. The inter-class variance between foreground and background is calculated at different thresholds, and the threshold that maximizes the inter-class variance is selected as the binarization threshold.

[0079] The specific steps are to traverse all possible grayscale values ​​of the image as candidate thresholds, and for each candidate threshold, calculate the statistical characteristics (such as mean, number, etc.) of the foreground pixels and background pixels in the image, and then obtain the inter-class variance under the threshold.

[0080] After calculating and comparing all candidate thresholds, the threshold corresponding to the maximum inter-class variance is determined.

[0081] Finally, the image is binarized according to this optimal threshold, and pixels with grayscale values ​​greater than the threshold are set to white (or other color values ​​representing the foreground), and pixels with grayscale values ​​less than the threshold are set to black (or other color values ​​representing the background). The image is converted into a binary image with only black and white colors, which facilitates subsequent recognition, segmentation and other operations of the target object.

[0082] In this embodiment, a simple thresholding process is first performed with the parameter set to 0. OpenCV automatically calculates the Otsu threshold and sets the maximum value to 255 for setting the pixel value in the binary image. Finally, cv2.THRESH_BINARY+cv2.THRESH_OTS is used to perform binarization using the Otsu method.

[0083] In this embodiment, Figure 3 As shown, S20, morphological operation:

[0084] S21. Perform morphological opening operation on the binary image to remove small noise and smooth the target area: Morphological opening operation is an image processing method based on morphology, which consists of erosion operation and dilation operation in sequence.

[0085] First, the erosion operation is performed. The core principle of the erosion operation is to use a pre-defined structural element (such as a rectangle, circle, or cross, etc.) to slide across each pixel on the image.

[0086] For each pixel in the image, if all pixel values ​​in the area covered by the structural element are the same as the pixel value (in a binary image, they are all foreground pixel values ​​or all background pixel values), the pixel remains unchanged; otherwise, the pixel value is set to the background pixel value.

[0087] Through the erosion operation, isolated and small noise points in the image are eliminated. After the erosion operation is completed, the dilation operation is performed immediately.

[0088] The dilation operation also uses the structuring element to slide across the pixels in the image. Unlike the erosion operation, for each pixel in the image, as long as there is a pixel with the same value as the pixel in the area covered by the structuring element (in a binary image, as long as there is a foreground pixel value), the pixel value is set to the foreground pixel value.

[0089] Specifically, the dilation operation restores the target area reduced by the erosion operation while smoothing its edges, making the target area more similar to its true shape in the original image. This erosion-then-dilation process effectively removes small noise from the binary image and smoothes the target area, laying a good foundation for more accurate subsequent analysis of the target object in the image. The dilation operation can more accurately connect the previously scattered background areas, forming a continuous background area with a more accurate range.

[0090] In this way, the background part of the image is clearly defined, providing a clear background reference for subsequent distinction between foreground and unknown areas.

[0091] S22. Determine the foreground area using distance transform and threshold processing: After obtaining the distance transform image, perform threshold processing to calculate the Euclidean distance from each foreground pixel to the nearest background pixel in the binary image. The formula is:

[0092]

[0093] Where (x, y) is the coordinate of the current pixel, D(x, y) represents the Euclidean distance from the pixel at position (x, y) in the image to the nearest background pixel, (i, j) is the coordinate of any pixel in the background area, and b is the set of all background pixels in the image.

[0094] The formula for determining the foreground core area is as follows:

[0095]

[0096] Wherein, CoreRegion(x,y) is a binary image. Furthermore, a value of 1 indicates that the pixel belongs to the foreground core area, and a value of 0 indicates that it does not belong to the foreground core area. D(x,y) is the pixel value at position (x,y) in the distance map obtained after distance transformation.

[0097] If the distance value D of a pixel is greater than the set threshold T, it means that the pixel is far away from the background and is more likely to belong to the core area of ​​the foreground object, and it is marked as a foreground pixel;

[0098] If the distance value D of the pixel is less than or equal to the set threshold T, it means that the pixel is close to the background and may be at the edge of the foreground object or in an area affected by factors such as noise, and further screening or adjustment is performed on it.

[0099] T is the dynamic threshold, which is calculated by the following formula:

[0100] T = k × max (D);

[0101] Where T is used to extract the dynamic threshold of the foreground core area, k is the proportional coefficient, and k∈(0.65,0.75), preferably k=0.7;

[0102] Experiments show that when k = 0.7, the overall effect is the best (F1-score is the highest), as shown in Table 1 below:

[0103] Table 1

[0104] K value 0.5 0.6 0.7 0.8 0.9 F1 0.72 0.81 0.91 0.85 0.78

[0105] max(D) is the maximum value in the distance map D, that is, the farthest distance between all foreground pixels and the background in the entire image.

[0106] S23, determining the unknown area by the difference between the background and foreground: performing a difference operation on the background area image and the foreground area image. For each pixel position in the image, compare its pixel value in the background area image and the foreground area image.

[0107] If the pixel is marked as a background pixel in the background area image, but not marked as a foreground pixel in the foreground area image, then the pixel position belongs to the unknown area;

[0108] On the contrary, if the pixel is marked as a foreground pixel in the foreground area image but is not marked as a background pixel in the background area image, the pixel position also belongs to the unknown area.

[0109] In this embodiment, Figure 4 、 5 As shown, S30, watershed algorithm:

[0110] S31. Use the watershed algorithm to segment the image and mark each target area: When applying the watershed algorithm to an image that has undergone a series of previous image processing steps (such as grayscale conversion, binarization, morphological operations, etc.), first consider the image as a terrain surface, and the grayscale values ​​in the image correspond to the height of the terrain. Areas with lower grayscale values ​​are considered "valleys" and areas with higher grayscale values ​​are considered "peaks." Based on the foreground and background areas determined by the previous morphological operation, the core part of the foreground area is set as the foreground seed point, and the stable part of the background area is set as the background seed point. The watershed algorithm can accurately segment different target areas in the image, and each segmented area can be regarded as a target area with similar features (based on grayscale values ​​or other relevant features), and each target area is assigned a unique label so that different target areas can be analyzed and processed separately later.

[0111] S32. Mark the boundary area in blue: After completing the segmentation operation of the watershed algorithm and obtaining the marked target areas, the boundaries of these areas are further processed and marked. The algorithm identifies the boundary pixels between each target area and other areas. For these boundary pixels, change their color attributes and set them to blue. By marking the boundary areas in blue, the boundaries of each target area can be clearly highlighted visually, making it convenient for users to intuitively observe the results of image segmentation. At the same time, it also provides obvious identification for subsequent analysis, measurement, target recognition and other operations based on boundary information, which helps to improve the accuracy and efficiency of target area analysis and processing in the entire image processing process.

[0112] In this embodiment, Figure 6 As shown, S40, target area analysis:

[0113] S41. Traverse each segmented region, ignoring background regions: After completing the image segmentation and boundary marking using the watershed algorithm, the target region analysis phase begins. Programming is used to traverse all segmented regions in the image. During the traversal, background regions are identified and skipped based on the marking information previously assigned to them by the watershed algorithm or other previous processing steps.

[0114] S42. Extract the outline of each target region and calculate its area: For each traversed target region, apply a contour extraction algorithm to accurately obtain the boundary outline of the target region. By detecting changes in pixel values ​​within the target region, the edge pixels of the target region are determined, and these edge pixels are then connected to form a closed contour. After obtaining the contour, a specific mathematical algorithm is used to calculate the area of ​​the region enclosed by the contour.

[0115] S43, filtering out contours that are too small: After obtaining the contour and area of ​​each target region, an area threshold is set to filter out contours that are too small.

[0116] S44. Calculate the longest and shortest diameters of the target area using an ellipse fitting method: The target area contour that remains after filtering is processed using an ellipse fitting algorithm. The principle of the ellipse fitting algorithm is to analyze the geometric shape characteristics of the target area contour and find a best-matching ellipse to approximate the contour. During the fitting process, the algorithm calculates the parameters of the ellipse based on the coordinate distribution of each point on the contour, including the center coordinates, major axis length, and minor axis length of the ellipse. Among them, the major axis length corresponds to the longest diameter of the target area, and the minor axis length corresponds to the shortest diameter of the target area.

[0117] The general equation of an ellipse is:

[0118] Ax 2 +Bxy+Cy 2+Dx+Ey+F=0;

[0119] Among them, A, B, and C are the coefficients of the quadratic term, which determine the shape (long axis direction, eccentricity) and rotation angle of the ellipse. D and E are the coefficients of the linear term, which determine the central coordinates of the ellipse. F is a constant term, which is related to the scale of the ellipse.

[0120] The coefficients A, B, C, D, and E of the equation are determined using the least square method. i ,y i ) to the ellipse, i = 1, 2, ..., n, find a set of coefficients that minimizes the sum of the squares of the distances from these points to the ellipse. The objective function is:

[0121]

[0122] Among them, (x i ,y i ) is the coordinate of the i-th pixel point on the target area contour, n is the total number of contour points, S is the sum of the squares of the distances from all contour points to the ellipse, and the best matching between the ellipse and the contour is achieved by minimizing S.

[0123] By taking the partial derivatives of S with respect to A, B, C, D, and E and setting them to 0, we get a system of linear equations:

[0124]

[0125] The terms on the left side of the equation group are the accumulation of high-order terms of the coordinates of the contour points, reflecting the contribution of different coefficients to the shape of the ellipse. The right side of the equation group is the product of the constant term and F. By solving the equation group, the coefficients of the fitted ellipse can be obtained, thereby determining the shape and parameters of the ellipse, realizing the elliptical fitting of the target area contour, and then obtaining the semi-major axis a (corresponding to the longest diameter of the target area) and the minor major axis b (corresponding to the shortest diameter of the target area).

[0126] in,

[0127] S45. Convert pixel length to actual length (micrometers): After obtaining the longest and shortest diameters of the target area in pixels, in order to obtain the actual physical size of the target object, it is necessary to convert the pixel length to actual length (micrometers). The conversion from pixel length to actual length is based on the following parameters and formula:

[0128] Let scale pixel P be the number of pixels corresponding to the known actual length in the image; actual length L be the real physical length corresponding to the scale pixel;

[0129] Based on the input pixel value P of the ruler and the corresponding actual length L, the conversion coefficient K between pixels and actual length is calculated using the formula:

[0130]

[0131] Multiply the longest diameter 2a (pixels) and the shortest diameter 2b (pixels) of the target area by the conversion coefficient K to obtain the actual length:

[0132] The longest diameter (μm) = 2a × K, the shortest diameter (μm) = 2b × K;

[0133] In the preferred solution, the scale pixel = 121, the actual length = 200 μm, and the actual length corresponding to the unit pixel is:

[0134]

[0135] That is, the longest diameter (μm) = 2a × 1.6528, the shortest diameter (μm) = 2b × 1.6528;

[0136] In this embodiment, Figure 7 As shown, S50, result saving:

[0137] S51. Save the serial number, longest diameter (in pixels and microns), and shortest diameter (in pixels and microns) of each target area to an Excel file. First, call the pandas library, a software library for manipulating Excel files. Initialize a new Excel workbook object in the program, which will serve as the carrier for storing the target area data.

[0138] Each target area is assigned a unique serial number, which is used to identify different target areas and facilitate indexing and differentiation in the dataset.

[0139] S52. Draw an ellipse and a serial number label on the original image, and save the resulting image: call the OpenCV library in the image processing library to read the original image data, and load it into the memory for subsequent operations.

[0140] Example 2

[0141] The following describes in detail the practical application of the intelligent particle size analysis method based on the watershed algorithm provided in Example 1. Thirteen typical cases are selected from the test data of 347 samples provided below to illustrate the rationality of pixel-to-micrometer conversion and the stability of the algorithm.

[0142] As shown in Table 2 below:

[0143] Table 2 Test data table

[0144]

[0145]

[0146] In this example, case number 1 in the above table is selected for detailed analysis as follows:

[0147] Pixel length: The longest diameter is 46.2361 pixels and the shortest diameter is 25.6732 pixels.

[0148] Calculation of actual length: Based on "scale pixel = 121, actual length = 200 μm" in Example 1, the actual length corresponding to the unit pixel is:

[0149] The actual length of the longest diameter is: 46.2361×1.6528≈76.423μm (consistent with the results in Table 2).

[0150] Analysis conclusion: The particle is of relatively large size, and the ellipse fitting accurately reflects its geometric characteristics, verifying the correctness of the pixel-to-actual length conversion formula. The watershed algorithm successfully segments the boundary without being disturbed by the background.

[0151] Select case number 347 in the table above and analyze it as follows:

[0152] Pixel length: The longest diameter is 15.4075 pixels and the shortest diameter is 13.8412 pixels.

[0153] Actual length calculation:

[0154] The actual length of the longest diameter is: 15.4075×1.6528≈25.467μm (consistent with the results in Table 2).

[0155] Analysis conclusion: The particles are relatively small in size. Traditional methods (such as screening) may be difficult to separate or crush due to the small size of the particles, resulting in measurement errors. However, this algorithm can still accurately obtain the particle size through high-precision image segmentation and ellipse fitting, reflecting its adaptability to tiny particles.

[0156] Select case number 6 in the table above and analyze it as follows:

[0157] Pixel length: the longest diameter is 37.4114 pixels, and the shortest diameter is 8.6762 pixels (the short axis is extremely short, close to the ellipse degeneration limit).

[0158] Analysis conclusion: The shape of the particles is highly irregular (approximately oblate), and traditional image segmentation methods may lead to contour extraction deviation due to blurred edges; however, the watershed algorithm can still effectively calculate the major and minor axes by marking boundaries and ellipse fitting, demonstrating its robustness for particles with complex shapes.

[0159] In this embodiment, compared with the traditional method, the specific results are shown in Tables 3, 4, and 5 below:

[0160] Table 3

[0161]

[0162]

[0163] Table 4 Comparison of measurement accuracy

[0164] Particle type This method Sieving method Sedimentation method Traditional imaging method Spherical particles (3) 54.93 52-58 53-57 51-59 Fiber particles (6) 61.84 / 14.34 Unable to measure Equivalent diameter 38.2 Segmentation fault Small particles (347) 25.47 Not detected Not detected Not detected

[0165] Furthermore, error statistics show that the average error of this method is 2.3%, while the average error of the traditional method is 8-15%.

[0166] Table 5 Treatment efficiency comparison table

[0167] method 100 particles processing time Manual intervention required This method 3.2 seconds Fully automatic Sieving method 45 minutes Full manual Sedimentation method 30 minutes Manual calibration Traditional imaging method 8 minutes Manual segmentation correction

[0168] In this embodiment, the performance statistics of Table 2, Table 3, Table 4 and Table 5 are as follows:

[0169] Automated processing capabilities: The entire process is unmanned, from image reading, preprocessing (grayscale conversion, denoising, binarization), morphological operations, watershed segmentation, ellipse fitting to result saving (Excel table + annotated image), all are automatically executed through code, without the need for manual parameter adjustment (only the scale pixels and actual length need to be entered).

[0170] Batch processing efficiency: Taking the 355 particles in the table as an example, the analysis of a single image takes about 10-20 seconds (depending on the image resolution), which is much faster than the manual measurement speed of traditional methods (single particle measurement takes more than 30 seconds).

[0171] Processing efficiency: The preprocessing stage uses efficient functions of the OpenCV library (such as cvtColor and GaussianBlur), which takes about 30% of the time.

[0172] The watershed algorithm and ellipse fitting are implemented through matrix operations, which takes about 60% of the time.

[0173] The results are saved in batches using the pandas library, accounting for less than 10% of the time consumption.

[0174] Compared with traditional image segmentation methods: Traditional methods (such as threshold segmentation + manual contour tracing) take several hours to process the same number of particles, while this method can be completed in minutes.

[0175] Recognition accuracy: pixel-to-actual length conversion error. Verified by the data in Table 2, the error between the calculated and actual values ​​for all cases is <0.1% (for example, the 76.4233865 μm in serial number 1 is almost identical to the theoretical value of 76.423 μm), demonstrating the accuracy of the conversion formula.

[0176] Ellipse fitting accuracy: The coefficients are solved by the least square method and the average square sum of the distances from the contour points to the ellipse is less than 10 -6 , indicating that the fitting result is highly consistent with the actual contour (for example, the overlap between the contour of particle No. 9 and the fitted ellipse is >99%).

[0177] Boundary recognition error: The boundary positioning error of the watershed algorithm in the particle overlapping area is less than 2 pixels (corresponding to an actual error of less than 3.3μm, calculated based on the scale accuracy), which is significantly better than the traditional method with an error of more than 10 pixels.

[0178] Specifically, test results demonstrate that the proposed intelligent particle size analysis method, based on a watershed algorithm, significantly outperforms traditional methods in terms of automation, processing efficiency, and recognition accuracy. It excels particularly in segmenting overlapping particles in complex backgrounds, measuring small particles, and fitting irregular shapes. By combining mathematical modeling (ellipse fitting) with image processing techniques (watershed segmentation), this method provides a high-precision, high-efficiency particle size analysis tool for sedimentological research, demonstrating significant scientific value and potential for engineering applications.

[0179] Example 3

[0180] Further illustrate with reference to Example 1, Figure 8 The structure shown, Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device includes:

[0181] A processor, memory, a communication bus, and a computer program stored in the memory and executable on the processor.

[0182] The processor can call a computer program in the memory and implement the intelligent particle size analysis method based on the watershed algorithm provided in the above embodiment when executing the program. The method includes: S10, preprocessing the input target particle image to extract the target area and generate a binary image; S20, performing morphological operations on the preprocessed target particle image to separate the target area from the background; S30, using the watershed algorithm to segment overlapping particles in the target particle image and mark the target area boundary; S40, analyzing the segmented target area to obtain particle size parameters and outputting a structured annotation result.

[0183] Furthermore, the computer device further comprises:

[0184] Communications Interface: used for communication between memory and processor.

[0185] The memory may include a high-speed RAM memory and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0186] If the memory, processor, and communication interface are implemented independently, the communication interface, memory, and processor can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0187] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0188] A processor may include one or more processing units. For example, a processor may include an application processor (AP), an application-specific integrated circuit (ASIC), a modem processor, a central processing unit (CPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors. The controller may be a neural network center or command center. The controller may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. The processor may also include memory for storing instructions and data. In some embodiments, the memory in the processor is a high-speed cache memory. This memory can store instructions or data that have just been used or are being recycled by the processor. If the processor needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces processor latency, and thus improves system efficiency.

[0189] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0190] A display device is used to display images, videos, etc. The display device may include a display panel, which may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), MiniLED, MicroLed, Micro-oLed, or a quantum dot light-emitting diode (QLED).

[0191] Optionally, in a specific implementation, if the memory, processor, and communication interface are integrated on a chip, the memory, processor, and communication interface can communicate with each other through an internal interface.

[0192] On the other hand, an embodiment of the present application also provides a computer non-transitory readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned intelligent particle size analysis method based on the watershed algorithm, the method comprising: S10, preprocessing the input target particle image to extract the target area and generate a binary image; S20, performing morphological operations on the preprocessed target particle image to separate the target area from the background; S30, using the watershed algorithm to segment overlapping particles in the target particle image and mark the target area boundary; S40, analyzing the segmented target area to obtain particle size parameters, and outputting structured annotation results.

[0193] On the other hand, an embodiment of the present application also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. The computer program can run computer instructions. When the computer program is executed by a processor, the computer can execute the intelligent particle size analysis method based on the watershed algorithm provided by the above methods. The method includes: S10, preprocessing the input target particle image to extract the target area and generate a binary image; S20, performing morphological operations on the preprocessed target particle image to separate the target area from the background; S30, using the watershed algorithm to segment overlapping particles in the target particle image and mark the target area boundary; S40, analyzing the segmented target area to obtain particle size parameters, and outputting structured annotation results.

[0194] The logic and / or steps represented in the flowchart or otherwise described herein may be considered, for example, as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device).

[0195] For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use with or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or N wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In addition, the computer-readable medium can even be paper or other suitable medium on which the program is printed, since the program can be obtained electronically by optically scanning the paper or other medium and then editing, interpreting, or otherwise processing it in a suitable manner as needed, and then storing it in a computer memory.

[0196] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0197] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0198] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0199] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.

[0200] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0201] The above specific embodiments do not constitute a limitation on the scope of protection of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Although the embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limitations of the present application. Those skilled in the art can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. An intelligent particle size analysis method based on a watershed algorithm, characterized in that: The following steps are involved: S10, preprocessing the input target particle image to extract the target area and generate a binary image; S20, performing a morphological operation on the pre-processed target particle image to separate the target area from the background; S30, using a watershed algorithm to segment overlapping particles in the target particle image and mark the target area boundary; S40: Analyze the segmented target area to obtain particle size parameters and output a structured annotation result.

2. The intelligent particle size analysis method based on the watershed algorithm according to claim 1, characterized in that: The specific steps of step S10 are: S11, using the OpenCV library to read the input target particle image, and converting the color image into a grayscale image through the cvtColor function; S12, converting the input target particle image into HSV space, filtering dark areas according to the HSV space, and retaining light areas; S13, using Gaussian blur and histogram equalization to process the grayscale image to enhance contrast and reduce noise; S14. Automatically calculate the optimal segmentation threshold of the grayscale image based on the Otsu threshold method, and convert the grayscale image into a black and white binary image.

3. The intelligent particle size analysis method based on the watershed algorithm according to claim 2, characterized in that: In step S12, the dark areas are filtered out and the light areas are retained. The specific steps of the method are as follows: setting a brightness threshold range in the HSV space, traversing the pixel points, and determining the pixels with brightness values ​​lower than the lower threshold as black, and the pixels with brightness values ​​higher than the lower threshold retain the original pixel values; Among them, the brightness threshold range is H∈[0,180], S∈[0,255], V∈[0,255].

4. The intelligent particle size analysis method based on the watershed algorithm according to claim 1, characterized in that: The specific steps of step S20 are: S21, performing a morphological opening operation on the binary image to remove small noise and smooth the boundary of the target area by first corroding and then dilating; S22, calculating the Euclidean distance D from each foreground pixel to the nearest background pixel in the binary image by Euclidean distance transform, to obtain a distance transformed image; Traverse each pixel in the distance transformation image and set the distance threshold T = k × max (D) to determine the foreground core area; S23. Determine the unknown area by the difference between the background area image and the foreground area image.

5. The intelligent particle size analysis method based on the watershed algorithm according to claim 1, characterized in that: The specific steps of step S30 are: S31, marking the foreground core area as a foreground seed point, and marking the background area as a background seed point; S32, segmenting the target area using a watershed algorithm, marking each segmented target area, and obtaining a target area with a unique mark; S33, marking the boundary pixels of the target area with the unique mark in blue.

6. The intelligent particle size analysis method based on the watershed algorithm according to claim 1, characterized in that: The specific steps of step S40 are: S41, traverse each segmented target area, ignore the background area, and obtain the traversed target area; S42, extracting contours and calculating areas based on the traversed target regions to obtain the contours and areas of each target region; S43, setting an area threshold, filtering contours smaller than the area threshold, and obtaining the target area contour retained after filtering; S44, processing the contour of the target area retained after filtering using an ellipse fitting algorithm; S45. Based on the input pixel value P of the ruler and the corresponding actual length L, calculate the conversion coefficient K between pixels and actual length. The formula is: The longest diameter 2a and the shortest diameter 2b of the target area are respectively multiplied by the conversion coefficient K to obtain the actual length.

7. The intelligent particle size analysis method based on the watershed algorithm according to claim 6, characterized in that: In step S44, an ellipse fitting algorithm is used to calculate the longest diameter 2a and the shortest diameter 2b of the target area contour retained after filtering. The specific steps are as follows: S441, using the general equation of an ellipse: Ax 2 +Bxy+Cy 2 +Dx+Ey+F=0 describes the outline of the target area; Among them, A, B, and C are the coefficients of the quadratic term, and D and E are the coefficients of the linear term; S442, use the least square method to determine the equation coefficients A, B, C, D, E so that the contour point (x i ,y i ) to the ellipse, the sum of the squares of the distances is minimized, the formula is: Among them, (x i ,y i ) is the coordinate of the i-th pixel point on the target area contour, and n is the total number of contour points. S443. Calculate the partial derivatives of S with respect to A, B, C, D, and E and set them to 0. Determine the semi-major axis a and the minor axis b of the ellipse by solving the coefficients using the linear least squares method. Among them, the semi-major axis a corresponds to the longest diameter of the target area, and the minor axis b corresponds to the shortest diameter of the target area; The calculation formulas for the semi-major axis a and the minor axis b are:

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the computer program to implement the steps of the intelligent particle size analysis method based on the watershed algorithm according to any one of claims 1 to 7.

9. A computer non-transitory readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by a processor, the steps of the intelligent particle size analysis method based on the watershed algorithm described in any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by one or more processors, the steps of the intelligent particle size analysis method based on the watershed algorithm described in any one of claims 1 to 7 are implemented.