An image detection method applied to water-soluble fertilizer production

By acquiring images of water-soluble fertilizer particles using an industrial camera, and combining grayscale processing, adaptive threshold segmentation, and grayscale gradient features, segmentation lines are generated to cut through the adhesion region, and the boundaries are morphologically repaired. This solves the problem of large detection errors in water-soluble fertilizer particles in traditional methods and achieves high-precision particle size calculation.

CN121391833BActive Publication Date: 2026-05-19STANLEY FERTILIZER (PINGYUAN) CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
STANLEY FERTILIZER (PINGYUAN) CO LTD
Filing Date
2025-11-28
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Traditional image detection methods cannot effectively segment adhering water-soluble fertilizer particles, resulting in large errors in particle size detection. Furthermore, edge detection is prone to edge breakage or oversegmentation, making it impossible to accurately detect water-soluble fertilizer particles.

Method used

Industrial cameras were used to acquire images of water-soluble fertilizer granules. The granules and background were initially separated by grayscale processing and adaptive threshold segmentation. Segmentation lines were generated by combining connected component analysis and grayscale gradient features to cut the adhesion areas. Morphological repair was then performed to optimize the boundaries of individual granules and calculate the actual particle size.

Benefits of technology

Accurate identification of adhesion areas and optimization of individual particle boundaries improve the accuracy and practicality of water-soluble fertilizer particle detection, meeting the real-time quality control requirements of the production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121391833B_ABST
    Figure CN121391833B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image detection, and more particularly to an image detection method applied to water-soluble fertilizer production, comprising: obtaining an original image containing particles and background; performing gray scale processing on the original image to convert it into a single-channel gray scale image, segmenting the gray scale image to obtain a binary image containing block aggregate regions, and calculating the area and equivalent diameter of each connected domain in the binary image; when the equivalent diameter of a connected domain exceeds a preset maximum single-particle diameter threshold, determining that the connected domain is a sticking particle region, extracting the internal gray scale gradient distribution features of the identified sticking particle region; cutting the sticking region along the potential segmentation line to obtain multiple independent single-particle regions; performing morphological repair on the edges of the segmented single-particle regions to obtain optimized single-particle boundaries, and calculating the actual particle size of each particle based on the optimized single-particle boundaries. The present application solves the detection problem caused by the block aggregate formed by the sticking of water-soluble fertilizer particles.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image detection, specifically relating to an image detection method applied to the production of water-soluble fertilizers. Background Technology

[0002] Water-soluble fertilizer solid granules often exhibit "multi-particle adhesion" due to granulation processes such as fluctuations in binder dosage or moisture absorption, appearing as "blocky aggregates" in images. Traditional threshold segmentation, such as grayscale thresholding, can only distinguish between "particle regions" and "background," failing to segment the boundaries of adhered particles. For example, when multiple particles adhere, the image data may be misjudged as a single large-diameter "super-large particle," resulting in a particle size detection error exceeding 50%. If edge detection algorithms are forcibly used, the gradual grayscale gradient at the adhesion points leads to the loss of boundary features, resulting in "broken edges" or "oversegmentation" in the segmentation results, making accurate detection of water-soluble fertilizer particles impossible. Summary of the Invention

[0003] The purpose of this invention is to provide an image detection method for water-soluble fertilizer production, so as to solve the problems mentioned in the background art.

[0004] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0005] An image detection method for use in water-soluble fertilizer production includes the following steps:

[0006] Industrial cameras were used to continuously photograph water-soluble fertilizer solid granules on the production line to obtain raw images containing the granules and the background.

[0007] The original image is converted to grayscale to a single-channel grayscale image, and image noise is removed.

[0008] The grayscale image is segmented to obtain a binarized image containing the blocky aggregate region, thus achieving preliminary separation of the granular region from the background;

[0009] Calculate the area and equivalent diameter of each connected component in the binarized image; when the equivalent diameter of a connected component exceeds a preset threshold for the maximum diameter of a single particle, the connected component is determined to be a region of adherent particles.

[0010] For the identified adherent particle regions, the internal gray-level gradient distribution features are extracted; at the adhesion sites where the gray-level gradient meets the satisfactory threshold, potential segmentation lines are generated based on the approximately circular shape of the particles; the adhesion regions are cut along the potential segmentation lines to obtain multiple independent single-particle regions.

[0011] Morphological restoration is performed on the edges of the segmented single-particle regions to obtain optimized single-particle boundaries;

[0012] Based on the optimization of single-particle boundaries, the actual particle size of each particle is calculated to complete the detection.

[0013] Furthermore, the method of using an industrial camera to continuously photograph the water-soluble fertilizer solid particles on the production line to obtain the original image containing the particles and the background is as follows: select an appropriate industrial area array camera and adjustable focus lens according to the production line conveying speed and particle distribution density, fix the camera directly above the conveyor belt with the lens perpendicular to the conveyor belt, arrange light sources symmetrically on both sides of the camera and use diffuse reflection illumination, adjust the camera exposure time, pre-calibrate the focal length and calibrate the ratio coefficient between image pixels and actual size.

[0014] Furthermore, the process of converting the original image to grayscale to a single-channel grayscale image and removing image noise specifically involves: for the original RGB image containing water-soluble fertilizer particles and the background, a weighted average method is used for grayscale conversion based on the particle color characteristics, converting the three-channel color image into a single-channel grayscale image. When removing image noise, a Gaussian filtering algorithm is used. The size of the filtering kernel is determined based on the previously calibrated ratio coefficient between image pixels and actual size and the pixel size corresponding to the particles in the image. At the same time, the standard deviation of the Gaussian function is set to suppress noise and preserve the grayscale details of particle edge contours and adhesion areas.

[0015] Furthermore, the grayscale image is segmented to obtain a binary image containing blocky aggregate regions, achieving preliminary separation of granular regions from the background. Specifically, for the grayscale image preprocessed by grayscale conversion and Gaussian filtering, an adaptive threshold segmentation algorithm based on local pixel grayscale distribution is adopted. A sliding window is set according to the average pixel diameter of the particles. Within the window, a local weighted mean or Gaussian weighted mean is calculated as a benchmark and a threshold offset is superimposed to obtain a dynamic threshold. Pixels with grayscale values ​​higher than the threshold are determined to be granular regions, and those lower are background regions. The image is converted into a binary image, with granular regions containing blocky aggregates represented by 1 and background represented by 0. Then, isolated noise points are removed through morphological erosion.

[0016] Furthermore, the calculation of the area and equivalent diameter of each connected component in the binarized image is specifically as follows: for the binarized image after thresholding and morphological erosion, 8-neighborhood connectivity analysis is used to extract all connected components. The regions with a pixel value of 1 are scanned row by row, and adjacent pixels are classified into the same connected component and uniquely numbered. When calculating the area of ​​each connected component, the total number of pixels is counted and converted into the actual area based on the previously calibrated pixel-to-actual-size ratio coefficient. The equivalent diameter is converted into the equivalent circular diameter based on the actual area of ​​the connected component and the assumption that the particles are approximately circular.

[0017] Furthermore, when the equivalent diameter of a connected region exceeds a preset threshold for the maximum diameter of a single particle, the connected region is determined to be a region of adherent particles. Specifically, the preset threshold for the maximum diameter of a single particle is determined based on the production process parameters of water-soluble fertilizer and historical statistical data on the particle diameter of qualified products. The maximum diameter is calculated from the actual diameter of a single particle sample produced under normal conditions and then multiplied by a safety factor to obtain the initial threshold. The equivalent diameter of the connected region in the binarized image is compared with the preset threshold. If the equivalent diameter is greater than the threshold, it is marked as a region of adherent particles and its feature parameters are recorded. If it is less than or equal to the threshold, it is determined to be a normal single particle region and proceeds to the subsequent edge repair and particle size calculation steps.

[0018] Furthermore, for the identified adherent particle regions, the internal gray-level gradient distribution features are extracted. Specifically, for the adherent particle regions marked by connected component analysis, a sub-image of this region is cropped from the preprocessed gray-level image, and the boundary of the sub-image is expanded to include the gray-level transition information of the adherent region and the edges. The Sobel operator is used to calculate the gray-level gradients in the horizontal and vertical directions of the sub-image respectively. Based on the horizontal and vertical gradient values, the gradient magnitude and direction of each pixel are calculated and standardized to generate a gradient magnitude map and gradient direction map of the adherent region. The gradient magnitude map is subjected to median filtering to suppress noise and retain the local gradient distribution features. Finally, the gradient magnitude distribution histogram and the main gradient direction of the adherent region are statistically analyzed.

[0019] Furthermore, at the adhesion region with a satisfactory gray-level gradient threshold, a potential segmentation line is generated based on the approximately circular shape of the particles. Specifically, this involves: determining the satisfactory gray-level gradient threshold based on the histogram of gradient magnitude in the adhesion region and statistical data; thresholding the gradient magnitude map of the adhesion region to retain low-gradient areas; determining the adhesion core region through morphological dilation; performing Euclidean distance transformation on the binary sub-image of the adhesion region to determine the center coordinates and approximate radius of the potential single particle; setting an initial segmentation line based on the center line and the approximately circular shape of the particles; adjusting the direction of the segmentation line according to the main gradient direction; extracting and refining the skeleton of the initial segmentation line and removing erroneous line segments not in the adhesion core region to generate the potential segmentation line.

[0020] Furthermore, the step of cutting the adhesion region along the potential segmentation line to obtain multiple independent single-particle regions involves: cutting along the potential segmentation line in the binarized sub-image of the adhesion region; setting the segmentation line pixels to the background value to break the adhesion region; scanning to confirm the integrity of the segmentation line and filling in incomplete line segments during cutting; re-performing connected component analysis to mark the potential single-particle regions after cutting; calculating the minimum bounding rectangle of each region; regenerating segmentation lines for the remaining adhesion parts and cutting them to conform to the single-particle morphology; and finally mapping the coordinates of the single-particle regions back to the original binarized image to preserve the position and grayscale features.

[0021] Furthermore, the morphological repair of the segmented single-particle region edges to obtain optimized single-particle boundaries is specifically as follows: for the segmented independent single-particle region binary sub-image, firstly, morphological opening operation is performed to remove isolated noise blocks, then morphological closing operation is performed to fill edge gaps, then mean filtering is used to smooth slightly jagged edges, then the repaired contour is extracted and the shape is verified by roundness. If it does not meet the requirements, the closing operation structuring element is adjusted and repaired again. Finally, the coordinates of the repaired contour are mapped back to the original binary image.

[0022] Furthermore, the step of calculating the actual particle size of each particle based on the optimized single particle boundary and completing the detection is as follows: For the optimized single particle boundary after morphological repair, the chain code contour tracking algorithm is used to extract the complete edge contour of each single particle and record the pixel coordinates. Based on the contour data, the actual area and perimeter of the single particle are calculated, and the actual particle size is calculated using the formula for the equivalent diameter of an approximate circle.

[0023] This invention discloses an electronic device, comprising:

[0024] At least one processor; and

[0025] A memory communicatively connected to the at least one processor; wherein,

[0026] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the data processing procedure of the image detection method described above for water-soluble fertilizer production.

[0027] Beneficial effects: This method effectively solves the traditional detection problems caused by the "blocky aggregates" formed by the adhesion of water-soluble fertilizer particles. Traditional grayscale thresholding methods are prone to misjudging adhered particles as "oversized particles," and edge detection is prone to "broken edges" or "oversegmentation." This method, however, ensures image quality through industrial camera acquisition and preprocessing. Adaptive thresholding is used to initially separate particles from the background, and then connected component analysis is used to accurately identify the adhesion area. Combining grayscale gradient features and the approximately circular shape of the particles, a segmentation line is generated to cut the adhesion area. Subsequently, edge repair is used to optimize the boundary of individual particles, and finally, the actual particle size is accurately calculated. This meets the real-time quality control requirements of water-soluble fertilizer production lines and greatly improves the accuracy and practicality of detection. Attached Figure Description

[0028] Figure 1 This is a flowchart of an image detection method for water-soluble fertilizer production according to the present invention. Detailed Implementation

[0029] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0030] This application discloses an image detection method applied to water-soluble fertilizer production, such as... Figure 1 An image detection method for use in water-soluble fertilizer production includes the following steps:

[0031] Industrial cameras were used to continuously photograph water-soluble fertilizer solid granules on the production line to obtain raw images containing the granules and the background.

[0032] The original image is converted to grayscale to a single-channel grayscale image, and image noise is removed.

[0033] The grayscale image is segmented to obtain a binarized image containing the blocky aggregate region, thus achieving preliminary separation of the granular region from the background;

[0034] Calculate the area and equivalent diameter of each connected component in the binarized image; when the equivalent diameter of a connected component exceeds a preset threshold for the maximum diameter of a single particle, the connected component is determined to be a region of adherent particles.

[0035] For the identified adherent particle regions, the internal gray-level gradient distribution features are extracted; at the adhesion sites where the gray-level gradient meets the satisfactory threshold, potential segmentation lines are generated based on the approximately circular shape of the particles; the adhesion regions are cut along the potential segmentation lines to obtain multiple independent single-particle regions.

[0036] Morphological restoration is performed on the edges of the segmented single-particle regions to obtain optimized single-particle boundaries;

[0037] Based on the optimization of single-particle boundaries, the actual particle size of each particle is calculated to complete the detection.

[0038] The process involves using an industrial camera to continuously photograph the solid granules of water-soluble fertilizer on the production line, acquiring original images containing both the granules and the background. Specifically, based on the conveying speed and particle distribution density of the water-soluble fertilizer production line, an industrial area array camera with a resolution of no less than 20 megapixels is selected, paired with an 8-50mm adjustable focus lens to ensure clear capture of the edge contours and adhesion details of the granules. The camera frame rate is set to 15-30fps to match the normal conveying speed of the production line (0.5-2m / s), avoiding blurry granule images or missed shots due to insufficient frame rate.

[0039] The camera is fixedly mounted 1.2-1.8m directly above the conveyor belt on the production line, with the lens perpendicular to the conveyor belt surface. Two sets of high-brightness LED strip light sources are symmetrically arranged on both sides of the camera, with the illumination angle adjusted to 30-45°. Diffuse illumination is used to avoid glare from the water-soluble fertilizer granules, preventing light spots or shadows due to uneven lighting, thus ensuring stable grayscale differences between the granules and the background in the original image. Based on the common white, light gray, or light brown color characteristics of water-soluble fertilizer granules, the camera exposure time is adjusted to 50-200μs to prevent excessive exposure from causing motion blur in the moving granules. Simultaneously, the camera focal length is pre-calibrated to ensure clear imaging of the granules on the conveyor belt surface, and the ratio of image pixels to actual size is calibrated (e.g., 1 pixel corresponds to 0.02mm of actual size), providing an accurate benchmark for subsequent particle size calculations.

[0040] The process involves converting the original image to grayscale, transforming it into a single-channel grayscale image, and removing image noise. Specifically, for the RGB original image containing water-soluble fertilizer particles and the background captured by the industrial camera, a weighted average method is used for grayscale processing based on the common white, light gray, or light brown color characteristics of water-soluble fertilizer particles. The grayscale value is calculated using the formula: Gray = 0.299 × R channel value + 0.587 × G channel value + ... A 0.114×B channel value is used to convert a three-channel color image into a single-channel grayscale image. The grayscale value range after conversion is standardized to 0-255, which not only fully preserves the grayscale difference features between particles and the background, but also avoids the loss of particle edge and adhesion details caused by single-channel conversion. When removing image noise, a Gaussian filtering algorithm is used. Based on the previously calibrated image pixel to actual size ratio coefficient, the filter kernel size is determined according to the pixel size corresponding to the water-soluble fertilizer particles in the image. If the average particle diameter corresponds to 10-20 pixels in the image, a 5×5 filter kernel is selected, and if it corresponds to 20-30 pixels, a 7×7 filter kernel is selected. At the same time, the standard deviation of the Gaussian function is set to 1.0-1.5, so that the filtering process can effectively suppress random noise in the production environment and camera sensor noise, while preserving the grayscale details of particle edge contours and adhesion areas to the maximum extent. This avoids excessive smoothing, which would cause the subsequent grayscale gradient distribution feature extraction to fail, and provides clear and stable preprocessed image data for the subsequent adaptive threshold segmentation step.

[0041] The grayscale image is segmented to obtain a binary image containing the blocky aggregate region, achieving preliminary separation of the particle region from the background. Specifically, for the grayscale image after grayscale conversion and Gaussian filtering preprocessing, an adaptive threshold segmentation algorithm based on local pixel grayscale distribution is employed. This algorithm dynamically adjusts the segmentation threshold according to the lighting conditions of different regions of the image, adapting to potential local brightness differences in water-soluble fertilizer particles within the image. In practice, a sliding window is set centered on each pixel in the image. The window size is determined based on the previously determined average pixel diameter of the particles. If the average particle diameter corresponds to 10-20 pixels, the window size is set to 15×15; if it corresponds to 20-30 pixels, it is set to 25×25. This ensures that the window can cover the local area of ​​a single particle or adhered particles without causing blurring of local features due to an excessively large window.

[0042] Within each window, the weighted average or Gaussian weighted average of local pixels is calculated as a benchmark, and then a preset threshold offset is superimposed. The offset is determined based on the average grayscale difference between the particles and the background, and is usually set to 5-15, so that the segmentation threshold is automatically adjusted in different window areas.

[0043] Pixels with grayscale values ​​higher than the dynamic threshold within the window are identified as granular regions, and pixels with grayscale values ​​lower than the threshold are identified as background regions, thereby converting the grayscale image into a binary image. Granular regions (including blocky aggregates) are represented by pixel value 1, and background regions are represented by pixel value 0.

[0044] After segmentation, morphological erosion is used to remove any isolated noise points in the binarized image. A 3×3 rectangular structuring element is selected as the erosion kernel, and only one erosion operation is performed to avoid excessive erosion of particle edges, ensuring the overall morphology of the blocky aggregates is preserved intact. The final binarized image must satisfy the preliminary separation between the particle region (including the blocky aggregates formed by adhesion) and the background region, providing a clear basis for subsequent connected component analysis.

[0045] The calculation of the area and equivalent diameter of each connected component in the binarized image is specifically implemented as follows: for the binarized image after threshold segmentation and morphological erosion, an 8-neighborhood connectivity analysis algorithm is used to extract all connected components. By scanning the regions with a pixel value of 1 in the image line by line, adjacent pixels in the horizontal, vertical and diagonal directions are grouped into the same connected component and given a unique number, ensuring that each independent granular region or block aggregate is accurately marked.

[0046] When calculating the area of ​​each connected component, the total number of pixels contained in each connected component is counted. Then, based on the previously calibrated ratio coefficient between image pixels and actual size (e.g., 1 pixel corresponds to 0.02 mm), the number of pixels is converted into the actual area, i.e., actual area = total number of pixels × (ratio coefficient). 2The unit is uniformly mm. 2 The calculation results are rounded to two decimal places to ensure accuracy.

[0047] The equivalent diameter is calculated based on the actual area of ​​the connected region. Assuming the particles are approximately circular, the formula is: Equivalent diameter = 2 × (Actual area / π). 1 / 2 The area of ​​each connected region is converted into the diameter of an equivalent circle in mm, and the result is rounded to three decimal places. This quantifies the size characteristics of the connected regions and provides an accurate numerical basis for subsequent comparison with the preset maximum diameter threshold of a single particle to determine whether it is a region of adherent particles.

[0048] The calculation of the area and equivalent diameter of each connected component in the binarized image in this application relies solely on the "neither 0 nor 1" pixel information of the binarized image, without utilizing the grayscale distribution characteristics of the grayscale image after preprocessing the water-soluble fertilizer particles. At the same time, it assumes that the particles are perfectly round, ignoring the actual characteristics of water-soluble fertilizer particles that are "approximately round but have slight elliptical / irregular shapes", which can easily lead to errors in the equivalent diameter.

[0049] Therefore, this application further proposes a method for calculating the morphological parameters of connected components based on weighted geometric moments, including the following steps:

[0050] For the input data:

[0051] Binarized image of water-soluble fertilizer granules (Adaptive thresholding and morphological erosion have been completed.) ,in Represents pixels It belongs to the connected component. (Indicates background)

[0052] With binarized images coordinate-aligned preprocessed grayscale image (Grayscale conversion and Gaussian filtering have been completed) , representing pixels The gray value reflects the local density of the particles.

[0053] Associating connected components with grayscale information, and for binarized images The marked number Connected components (Obtained through 8-neighborhood connectivity analysis), extract grayscale image. Zhongyu Regions where coordinates completely overlap That is, only retain Corresponding grayscale value Construct connected components "Binary-Gray" Associated Dataset .

[0054] Calculate the weighted geometric moments of connected components based on associated datasets. The zeroth-order weighted geometric moment (reflecting the weighted area), the first-order weighted geometric moment (reflecting the centroid, assisting in morphological analysis), and the second-order weighted geometric moment (reflecting the morphological distribution, used to correct the equivalent diameter) are given by the following formulas:

[0055] (1) Zeroth order weighted geometric moments , ;

[0056] Gray-level normalization coefficient , grayscale values Normalization to To avoid excessively large moment values ​​due to differences in grayscale levels;

[0057] Connected components Inner pixel The grayscale value represents the local density of the particles, and is therefore assigned a higher weight.

[0058] Binarized pixel values ​​(here) (This is only used to filter pixels within a connected region);

[0059] It is a connected component The "grayscale weighted area" is more effective than the traditional pixel count area in reflecting the actual mass distribution of particles.

[0060] (2) First-order weighted geometric moments , ,

[0061] ;

[0062] ;

[0063] These are the x and y coordinates in the pixel coordinate system (origin is the top left corner of the image); other parameters are the same as the zeroth moment.

[0064] First-order weighted geometric moments reflect connected regions "Grayscale weighted center coordinates" , in , This provides a benchmark for subsequent calculations of the second moment.

[0065] (3) Second-order weighted geometric moments , , ,

[0066] ;

[0067] ;

[0068] ;

[0069] , These are the horizontal and vertical offsets from the pixel to the weighted center; other parameters are the same as the zeroth moment.

[0070] , These represent the "weighted moments of inertia" in the x and y directions, respectively. These represent the cross moment of inertia, which together are used to determine the degree to which a particle deviates from its circular shape.

[0071] Then calculate the weighted area. With the corrected equivalent diameter :

[0072] Weighted area ,

[0073] ;

[0074] Connected components The average gray value within, ( For connected components The total number of pixels is used to offset the effect of grayscale weight on area and restore the actual physical area.

[0075] The actual physical area of ​​an image pixel. ( The previously calibrated "pixel-to-actual-size ratio coefficient", such as / pixel);

[0076] For connected components The corresponding actual physical area of ​​water-soluble fertilizer granules (unit: ), compared to the traditional "pixel count" "More accurate because it takes into account the local density differences of particles."

[0077] Then correct the equivalent diameter. ;

[0078] First, calculate the shape correction factor. (Reflecting the degree to which the particles deviate from their round shape):

[0079] ;

[0080] , This indicates that the particles are perfectly round. and ), The larger the particle size, the closer it is to an elliptical or irregular shape.

[0081] Recalculate the corrected equivalent diameter:

[0082] ;

[0083] Scene adaptability coefficient, determined statistically based on the actual morphology of water-soluble fertilizer granules. The more stable the granulation process, The smaller the value, the more it is used to quantify the impact of morphological deviation on the equivalent diameter;

[0084] Pi (taken as 3.1416);

[0085] For connected components The corresponding actual equivalent diameter of water-soluble fertilizer particles (unit: mm) corrects the error of the traditional "perfect circle assumption" and better fits the approximately circular but imperfect shape of water-soluble fertilizer particles. This method corrects the equivalent diameter by taking into account morphological deviations, and the error is reduced compared with the traditional method.

[0086] When the equivalent diameter of a connected region exceeds a preset threshold for the maximum diameter of a single particle, the connected region is determined to be a region of adherent particles. Specifically, the preset threshold for the maximum diameter of a single particle is determined based on the production process parameters of water-soluble fertilizer and statistical data on the particle diameter of historical qualified products. First, single particle samples of water-soluble fertilizer produced normally for more than three consecutive batches are collected. The actual diameter of at least 5,000 independent single particles is obtained through image detection. The maximum diameter value is calculated and multiplied by a safety factor of 1.2-1.5 as the initial threshold. For example, if the maximum diameter of the sample is 3.0 mm, the initial threshold is set to 3.6-4.5 mm.

[0087] This threshold needs to be stored in the parameter configuration module of the backend image processing system, allowing operators to dynamically adjust it according to the differences in particle size of different types of water-soluble fertilizers. The adjustment step size is set to 0.1mm to ensure accuracy.

[0088] For each connected component obtained through connected component analysis in the binarized image, its calculated equivalent diameter is compared with a preset threshold. When the equivalent diameter is greater than the threshold, the system automatically marks the connected component as an adherent particle region and records its position coordinates, equivalent diameter, area, and other feature parameters, providing definite target region information for subsequent segmentation processing of adherent regions. If the equivalent diameter is less than or equal to the threshold, it is determined as a normal single particle region, and directly proceeds to the subsequent edge repair and particle size calculation steps, thereby achieving accurate differentiation between adherent particle regions and normal single particle regions.

[0089] The process involves extracting the internal grayscale gradient distribution features of the identified adherent particle regions. Specifically, for the adherent particle regions marked by connected component analysis, a sub-image of this region is first cropped from the preprocessed grayscale image. The sub-image boundary extends outward by 5-8 pixels beyond the connected component boundary to ensure complete inclusion of the grayscale transition information of the adherent region and its edges. The Sobel operator is used to calculate the grayscale gradients of the sub-image in the horizontal and vertical directions. The horizontal gradient is obtained by convolving the sub-image with a 3×3 Sobel horizontal convolution kernel, and the vertical gradient is calculated using a 3×3 Sobel vertical convolution kernel. Zero-padding is used during convolution to maintain the sub-image size. Based on the horizontal and vertical gradient values, the gradient magnitude is calculated using the formula: Gradient Magnitude = √(Horizontal Gradient Magnitude) / (Horizontal Gradient Magnitude) * ... 2 +Vertical gradient 2 The gradient magnitude of each pixel is calculated using the formula gradient direction = arctan(vertical gradient / horizontal gradient), where the gradient direction is represented by an angle and normalized to the range of 0-180°. The gradient magnitude is then normalized to the range of 0-255, generating gradient magnitude and gradient direction maps for the adhered regions. Regions with lower gradient magnitudes (usually less than 30) correspond to adhered areas with gentle gray-level gradients, while regions with higher gradient magnitudes (usually greater than 80) correspond to obvious particle edges. To reduce noise interference with gradient features, a 3×3 median filter is applied to the gradient magnitude map, suppressing isolated noise points while preserving the local distribution characteristics of the gradient. Finally, the histogram of gradient magnitude distribution and the main direction of gradient direction within the adhered regions are statistically analyzed. The gradient magnitude histogram is used to identify the concentrated distribution range of low-gradient adhered regions, while the main direction of gradient direction is used to determine the overall direction of particle edges, providing a quantitative gray-level gradient distribution basis for subsequent generation of potential segmentation lines based on the approximately circular shape of particles.

[0090] In the process of identifying adhesion regions with satisfactory gray-scale gradients, potential dividing lines are generated based on the approximately circular shape of the particles. Specifically, this involves first determining a satisfactory gray-scale gradient threshold based on the previously extracted gradient amplitude histogram of the adhesion region and statistical data. This threshold must fall within the gradient amplitude range corresponding to adhesion regions with gentle gray-scale gradients. Based on the gray-scale gradient characteristics of water-soluble fertilizer particles, the threshold is typically set between 25 and 35. It also supports dynamic adjustment based on gray-scale differences between different batches of particles, with an adjustment step size of 1, ensuring accurate screening of adhesion regions with gradient amplitudes below this threshold. Subsequently, the gradient amplitude of the adhesion region is... The image is segmented using a threshold, retaining pixel regions with gradient magnitudes below a satisfactory threshold. Then, a morphological dilation operation is performed on this region using a 3×3 rectangular structuring element to eliminate small-scale gradient noise gaps, creating continuous connected channels in the adhesion areas and determining the location and extent of the adhesion core region. Next, an Euclidean distance transformation is performed on the binary sub-image corresponding to the adhesion region, calculating the Euclidean distance from each pixel to the nearest background pixel. The pixel with the largest distance transformation value is the center of the potential single particle. These points with the largest distance transformation values ​​are clustered using 8-neighborhood connectivity analysis to determine the center coordinates of each potential single particle.

[0091] Simultaneously, the maximum distance transformation value is multiplied by the previously calibrated ratio coefficient between image pixels and actual size to obtain the approximate radius of the corresponding potential single particle. Then, the center line is calculated based on the center coordinates of each potential single particle. According to the approximate circular shape of the particle, the initial position of the segmentation line is set between the two center lines, and the distance from each center is equal to the position of the approximate radius of the corresponding potential single particle. Then, based on the main direction of the gradient direction of the previously extracted adhesion region, the direction of the segmentation line is adjusted to make the direction of the segmentation line consistent with the gradient direction of the particle edge, so as to avoid the segmentation line passing through the edge region of non-adhesion particles.

[0092] Finally, a skeleton extraction algorithm is performed on the initial segmentation line region to refine the segmentation line to a single pixel width. At the same time, by comparing the positional relationship between the segmentation line pixels and the adhesion core region, erroneous segmentation line segments that do not fall within the adhesion core region are eliminated. This ensures that the generated potential segmentation lines are completely located at the adhesion parts corresponding to the grayscale gradient satisfaction threshold and can accurately separate different potential single particle regions, providing a precise path basis for subsequent cutting of adhesion regions along the segmentation lines.

[0093] The process involves cutting the adhesion region along the potential segmentation line to obtain multiple independent single-particle regions. Specifically, for the generated single-pixel-width potential segmentation line, a cutting operation is performed in the binarized sub-image corresponding to the adhesion region. By changing the value of all pixels on the segmentation line from 1 (particle region) to 0 (background region), the originally connected adhesion region is broken along the segmentation line.

[0094] During the cutting process, a pixel-by-pixel scanning method is used to confirm whether the dividing line completely penetrates the adhesion area. If there are dividing line segments that are not completely penetrated, linear interpolation is performed based on the gradient direction of their two endpoints and the direction of adjacent dividing lines to complete the cutting path and ensure that the cutting path is continuous and complete.

[0095] After the segmentation is completed, the sub-image is re-analyzed with 8-neighborhood connectivity. Each independent connected region formed after segmentation is marked as a potential single-particle region. The number of pixels in each region is counted and its minimum bounding rectangle is calculated. If the aspect ratio of the minimum bounding rectangle of a region exceeds 1.5, it is determined to be a residual adhesive part that is not completely segmented. Supplementary segmentation lines need to be regenerated based on the gray-level gradient distribution characteristics inside the region and segmented again until the aspect ratio of the minimum bounding rectangle of all regions is less than 1.5, ensuring that each region obtained after segmentation conforms to the approximate circular shape of a single particle.

[0096] Finally, the coordinates of each individual particle region obtained after segmentation are mapped back to the original binary image, preserving its positional information and grayscale features. This provides independent and complete individual particle region data for subsequent edge morphology restoration steps.

[0097] The morphological repair of the edges of the segmented single-particle regions yields optimized single-particle boundaries. Specifically, for each independent single-particle region binary sub-image obtained after cutting along the potential segmentation line, morphological opening is first performed using a 3×3 rectangular structuring element. Through erosion followed by dilation, isolated noise blocks with an area of ​​less than 5 pixels generated during the cutting process are removed, avoiding interference from these tiny noises with edge extraction while preserving the main outline of the single-particle region to the maximum extent. Next, morphological closing is performed, again using a 3×3 rectangular structuring element. If there is a gap with a width of less than 2 pixels at the edge of the single-particle region, the gap is first filled through the dilation step of the closing operation, and then the original width of the edge is restored through the erosion step, ensuring that the gap is completely filled without causing excessive expansion of the particle boundary.

[0098] For the slight jagged edges that still exist after the closing operation, a 5×5 neighborhood mean filter is used to smooth the edge pixel coordinates. The average coordinate of each edge pixel and its 8 neighboring non-background pixels is calculated, and the position of the edge pixel is updated to make the edge contour closer to the approximate circular shape of water-soluble fertilizer particles. Then, the complete contour of the repaired single-particle region is extracted, and its shape is verified to meet the requirements of a single particle by calculating the perimeter and area of ​​the contour. Specifically, the roundness formula (roundness = 4π × area / perimeter) is used. 2 If the circularity is less than 0.7, it means that there is still a deviation in the edge repair. The structure element of the closing operation needs to be adjusted to a 5×5 rectangular structure element and the repair operation needs to be re-executed until the circularity is greater than or equal to 0.7.

[0099] Finally, the contour coordinates of the repaired single-particle region are mapped back to the coordinate system of the original binary image. Based on the previously calibrated ratio coefficient between image pixels and actual size, it is ensured that the optimized single-particle boundary can accurately reflect the actual edge morphology of the particle and provide clear and accurate boundary data for subsequent calculation of the actual particle size, thus avoiding deviations in particle size calculation due to edge defects.

[0100] The detection process involves optimizing the single-particle boundaries and calculating the actual particle size of each particle. Specifically, for the optimized single-particle boundaries obtained through morphological restoration, a chain code-based contour tracking algorithm is used to extract the complete edge contour of each single-particle region. This ensures that the contour pixels are continuous and free of redundancy. Simultaneously, the coordinate information of each pixel on the contour is recorded, maintaining consistency with the original image coordinate system. This allows for subsequent size conversion based on a previously calibrated ratio between image pixels and actual size (e.g., 1 pixel corresponds to 0.02 mm). Next, the actual area and perimeter of each single particle are calculated based on the extracted contour data. The actual area is calculated by multiplying the total number of pixels enclosed by the contour by a ratio. 2 The result is in mm. 2 The result is rounded to two decimal places; the perimeter is obtained by calculating and summing the Euclidean distances between adjacent pixels on the contour, in mm, and the result is rounded to three decimal places.

[0101] Subsequently, the formula for calculating the equivalent diameter corresponding to the approximate circular shape is adopted: Equivalent diameter = 2 × (actual area / π). 1 / 2 Substitute the calculated actual area into the formula to obtain the actual particle size of each single particle, in mm. The result is retained to three decimal places to ensure consistency with the accuracy of the equivalent diameter calculation of the connected domain in the previous stage.

[0102] After obtaining the actual particle size, based on the previously verified single particle morphology roundness standard (roundness ≥ 0.7), the particle size of each particle is effectively screened. If the roundness of a particle is still less than 0.7, or the actual particle size exceeds the preset qualified particle size range of the water-soluble fertilizer product, such as 1.0-3.0mm, this range can be dynamically adjusted in the system according to different product specifications, then it is marked as an abnormal particle and is not included in the normal particle size statistics.

[0103] Finally, for the images continuously captured on the production line, the actual particle size of all normal particles in each frame is statistically analyzed. The average particle size, standard deviation of particle size, maximum particle size, and minimum particle size in that frame are calculated, and a particle size distribution histogram is generated. At the same time, the number of all normal particles and abnormal particles within a set time period, such as 1 minute, is accumulated and statistically analyzed. The particle pass rate is calculated as: pass rate = number of normal particles / total number of particles × 100%. The above detection data, including individual particle size details, statistical indicators, pass rate, and particle size distribution chart, is transmitted to the production line monitoring terminal in real time, allowing operators to view the detection results in real time. If the pass rate is lower than a preset threshold, such as 95%, or if continuous abnormal particle sizes are observed, the system automatically triggers an early warning prompt, reminding operators to check production process parameters, such as binder dosage and granulation temperature. This completes the entire detection process for water-soluble fertilizer particles, from boundary optimization to particle size calculation and production monitoring, ensuring accurate detection results and meeting the real-time quality control requirements of the production line.

[0104] It is evident that the method of the present invention can be implemented by a computer program, and the computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer program causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer program can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0105] Therefore, it can be understood that this invention discloses an electronic device, comprising:

[0106] At least one processor; and

[0107] A memory communicatively connected to the at least one processor; wherein,

[0108] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the data processing procedure of the image detection method described above for water-soluble fertilizer production.

[0109] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An image detection method applied to water-soluble fertilizer production, characterized in that, Including the following steps: Industrial cameras were used to continuously photograph water-soluble fertilizer solid granules on the production line to obtain raw images containing the granules and the background. The original image is converted to grayscale to a single-channel grayscale image, and image noise is removed. The grayscale image is segmented to obtain a binarized image containing the blocky aggregate region, thus achieving preliminary separation of the granular region from the background; Calculate the area and equivalent diameter of each connected component in the binarized image; when the equivalent diameter of a connected component exceeds a preset threshold for the maximum diameter of a single particle, the connected component is determined to be a region of adherent particles. For the identified adherent particle regions, the internal gray-level gradient distribution features are extracted; at the adhesion sites where the gray-level gradient meets the satisfactory threshold, potential segmentation lines are generated based on the approximately circular shape of the particles; the adhesion regions are cut along the potential segmentation lines to obtain multiple independent single-particle regions. Morphological restoration is performed on the edges of the segmented single-particle regions to obtain optimized single-particle boundaries; Based on the optimization of single-particle boundaries, the actual particle size of each particle is calculated to complete the detection. In the adhesion region at the gray-level gradient satisfaction threshold, potential segmentation lines are generated based on the approximately circular shape of the particles. Specifically, the gray-level gradient satisfaction threshold is determined based on the gradient amplitude histogram of the adhesion region and statistical data. The gradient amplitude map of the adhesion region is thresholded to retain low gradient regions. The adhesion core region is determined by morphological dilation. Euclidean distance transformation is performed on the binary sub-image of the adhesion region to determine the center coordinates and approximate radius of the potential single particle. Initial segmentation lines are set according to the center line and the approximately circular shape of the particles. The direction of the segmentation lines is adjusted according to the main gradient direction. The skeleton of the initial segmentation lines is extracted, refined, and erroneous line segments not in the adhesion core region are removed to generate potential segmentation lines.

2. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The process of converting the original image to grayscale to a single-channel grayscale image and removing image noise involves the following steps: For the original RGB image containing water-soluble fertilizer particles and the background, a weighted average method is used for grayscale processing based on the particle color characteristics, converting the three-channel color image into a single-channel grayscale image. When removing image noise, a Gaussian filtering algorithm is used. The size of the filtering kernel is determined based on the previously calibrated ratio coefficient between image pixels and actual size and the pixel size corresponding to the particles in the image. At the same time, the standard deviation of the Gaussian function is set to suppress noise and preserve the grayscale details of particle edge contours and adhesion areas.

3. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The grayscale image is segmented to obtain a binary image containing blocky aggregate regions, achieving preliminary separation of granular regions from the background. Specifically, for the grayscale image preprocessed by grayscale conversion and Gaussian filtering, an adaptive threshold segmentation algorithm based on local pixel grayscale distribution is adopted. A sliding window is set according to the average pixel diameter of the particles. The local weighted mean or Gaussian weighted mean is calculated within the window as a benchmark and a threshold offset is superimposed to obtain a dynamic threshold. Pixels with grayscale values ​​higher than the threshold are determined to be granular regions, and those lower are background regions. The image is converted into a binary image, with granular regions containing blocky aggregates represented by 1 and background represented by 0. Then, isolated noise points are removed by morphological erosion.

4. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The calculation of the area and equivalent diameter of each connected component in the binarized image is as follows: For the binarized image after thresholding and morphological erosion, 8-neighborhood connectivity analysis is used to extract all connected components. The regions with a pixel value of 1 are scanned row by row, and adjacent pixels are classified into the same connected component and uniquely numbered. When calculating the area of ​​each connected component, the total number of pixels is counted and converted into the actual area based on the previously calibrated pixel-to-actual-size ratio coefficient. The equivalent diameter is converted into the equivalent circular diameter based on the actual area of ​​the connected component and the assumption that the particles are approximately circular.

5. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, When the equivalent diameter of a connected region exceeds a preset threshold for the maximum diameter of a single particle, the connected region is determined to be a region of adherent particles. Specifically, the preset threshold for the maximum diameter of a single particle is determined based on the production process parameters of water-soluble fertilizer and the statistical data of particle diameters of historical qualified products. The maximum diameter is calculated from the actual diameter of a single particle sample produced under normal conditions and then multiplied by a safety factor to obtain the initial threshold. The equivalent diameter of the connected region in the binarized image is compared with the preset threshold. If the equivalent diameter is greater than the threshold, it is marked as a region of adherent particles and its feature parameters are recorded. If it is less than or equal to the threshold, it is determined to be a normal single particle region and proceeds to the subsequent edge repair and particle size calculation steps.

6. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The process involves extracting the internal grayscale gradient distribution features of the identified adherent particle regions. Specifically, for the adherent particle regions marked by connected component analysis, a sub-image of this region is cropped from the preprocessed grayscale image, and the sub-image boundary is expanded to include the grayscale transition information of the adherent region and its edges. The Sobel operator is used to calculate the grayscale gradients in the horizontal and vertical directions of the sub-image. Based on the horizontal and vertical gradient values, the gradient magnitude and direction of each pixel are calculated and standardized to generate a gradient magnitude map and a gradient direction map of the adherent region. The gradient magnitude map is then subjected to median filtering to suppress noise and retain the local gradient distribution features. Finally, the gradient magnitude distribution histogram and the main gradient direction within the adherent region are statistically analyzed.

7. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The process of cutting the adhesion region along the potential segmentation line to obtain multiple independent single-particle regions involves: cutting along the potential segmentation line in the binarized sub-image of the adhesion region; setting the segmentation line pixels to the background value to break the adhesion region; scanning to confirm the integrity of the segmentation line and filling in incomplete line segments during cutting; re-performing connected component analysis to mark the potential single-particle regions after cutting; calculating the minimum bounding rectangle of each region; regenerating segmentation lines for the remaining adhesion parts and cutting them to conform to the single-particle morphology; and finally mapping the coordinates of the single-particle regions back to the original binarized image to preserve their position and grayscale features.

8. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The morphological restoration of the segmented single-particle region edges to obtain optimized single-particle boundaries is specifically as follows: For the segmented independent single-particle region binary sub-image, firstly, morphological opening operation is performed to remove isolated noise blocks, then morphological closing operation is performed to fill edge gaps, then mean filtering is used to smooth slightly jagged edges, then the restored contour is extracted and the shape is verified by roundness. If it does not meet the requirements, the closing operation structuring element is adjusted and restored again. Finally, the coordinates of the restored contour are mapped back to the original binary image.

9. The image detection method for water-soluble fertilizer production according to claim 1, characterized in that, The process of optimizing single-particle boundaries and calculating the actual particle size of each particle to complete the detection involves the following steps: For the optimized single-particle boundaries after morphological repair, a chain code contour tracking algorithm is used to extract the complete edge contour of each single particle and record the pixel coordinates. Based on the contour data, the actual area and perimeter of the single particle are calculated, and the actual particle size is calculated using the formula for the equivalent diameter of an approximate circle.