Cylindrical object image counting method based on structure criterion and circle center clustering adaptive fusion
By combining the adaptive fusion method of structural criteria and circle center clustering, the problems of high false detection rate and parameter dependence of cylindrical objects in complex storage environments are solved, and high-precision cylindrical object counting is achieved.
Patent Information
- Application Number
- CN202510995224.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-10-21
AI Technical Summary
Existing technologies have high false detection rates, strong parameter dependence, and insufficient structural judgment in cylindrical object detection in complex storage environments, making it difficult to accurately count in conditions of uneven lighting, reflective interference, and incomplete edges.
An adaptive fusion method based on structural criteria and circle center clustering is adopted. By edge detection and random sampling to estimate the circle radius, the sensitivity is adaptively set. Combined with circle Hough transform and circle center clustering, pseudo-circle interference is screened out to achieve highly robust counting.
It can effectively filter out pseudo circles and incomplete circles in complex image scenes, improve the accuracy and robustness of detection, and is suitable for a variety of image acquisition platforms.
Smart Images

Figure CN120823192A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering. Background Art
[0002] In the fields of warehousing, logistics, industrial monitoring, etc., cylindrical objects (such as pipes, batteries, medicine bottles, etc.) often need to be accurately identified and counted in images due to their regular shapes in order to realize automated inventory management and information processing. With the continuous development of intelligent warehousing technology, vision-based automatic counting methods have become the mainstream means, with the advantages of non-contact, no marking, and high efficiency. However, in the actual captured images, the front end of the cylindrical object appears to be a nearly circular structure due to its horizontal placement. The image is often accompanied by uneven lighting, reflection interference, blurred edges, occlusion, etc., resulting in incomplete circular structure or the generation of pseudo-circles (such as incomplete closed contours formed by reflections or the tail of the object). This causes traditional methods based on edge detection or Hough transform to have a large number of false detections and missed detections, making it difficult to meet industrial-grade counting accuracy requirements.
[0003] Existing circular object detection methods are mostly based on fixed-parameter edge extraction and circle fitting strategies, such as detecting circles using the Hough transform and then performing post-processing based on edge integrity or center distance. Although these methods perform well in ideal scenarios, they lack robustness in complex warehousing environments. Key challenges include: strong parameter dependence: parameters such as the circle radius, edge threshold, and minimum response must be manually set, making them sensitive to image scene changes; inability to adapt to structural changes: inability to effectively determine whether the circular structure is complete or whether the edges are evenly distributed; lack of contextual structure judgment: inability to utilize the regularity of circle center arrangement for hierarchical clustering to eliminate isolated circles or non-target interference; and overall processing rigidity: difficulty integrating image content with structural rules for dynamic judgment and optimization. Therefore, a cylindrical object counting method with adaptability, structural criterion integration, and automatic rejection of pseudo-circle interference is urgently needed. This method can stably and accurately extract the true cylindrical head region under complex lighting and interference conditions, assisting industrial vision systems in intelligent counting and classification. Summary of the Invention
[0004] The purpose of the present invention is to address the deficiencies of the prior art and provide a cylindrical object image counting method based on the adaptive fusion of structure criterion and circle center clustering.
[0005] To achieve the above-mentioned purpose, the present invention adopts the following technical solution: a cylindrical object image counting method based on the adaptive fusion of structure criterion and circle center clustering, comprising the following steps:
[0006] The purpose of the present invention is to address the problems of high false detection rate, strong parameter dependence, and insufficient structural judgment in the existing technology during the cylindrical object detection process. A cylindrical object image counting method based on the adaptive fusion of structural criteria and circle center clustering is proposed to achieve automatic counting capabilities with higher robustness and accuracy. It is particularly suitable for complex storage environments where reflections, occlusions or incomplete edges are present in the image.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] A cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering includes the following steps:
[0009] (1) Convert the original color image into a grayscale image for subsequent edge detection and structure analysis.
[0010] (2) Apply the Canny edge detection algorithm to the grayscale image, extract the edge point map, and randomly sample the edge point positions. The pixel coordinates of all edge points are recorded as the set Where (x i ,y i ) represents the coordinates of the ith edge, N is the total number of edge points; randomly select no more than the preset upper limit M max Preferably, M max It can be set to 1000. When the total number of edge points is less than this value, all are used; otherwise, only the upper limit of the number of points is sampled. Subsequently, the Euclidean distance between all pairs of sampled points is calculated. After removing outliers (such as distances exceeding the 90th percentile), the median is calculated as the estimated diameter of the circle structure, and the radius range is further obtained.
[0011] (3) According to the overall edge density (i.e., the ratio of the number of edge points to the total number of pixels in the image) in the edge map obtained after the grayscale image is processed by the Canny operator, the sensitivity parameters of the circle detection are adaptively set. The higher the sensitivity, the stricter the detection, thereby dynamically adapting to the difference in edge quality in the image.
[0012] (4) Within the radius range estimated in step (2) and the sensitivity set in step (3), circular targets existing in the image are detected based on the circular Hough transform principle to obtain the center coordinates and radius information of all candidate circular areas.
[0013] (5) For each candidate circular area, its circumference is divided into several segments in the angular direction, and the number of edge points in each segment is counted. If the following two conditions are met: at least one-third of the total number of segments (rounded up if not evenly divided) have an edge point number higher than half of the theoretical value of the average distribution of the circumference; and the coefficient of variation (CV) of the edge point number of all segments is less than 0.8, then the candidate circle is considered to be a valid circle with complete structure and uniform edge distribution. The above conditions constitute the structural criterion in the present invention and are used for fusion judgment in subsequent steps.
[0014] (6) Analyze the vertical coordinates of the centers of all candidate circles. If the vertical (y-direction) distance between two candidate circle centers is less than the set pixel threshold, they are classified into the same cluster layer. After clustering, if a candidate circle does not belong to any cluster layer, or its cluster layer contains only a single circle, the circle is considered an isolated interference target and is eliminated. The above-mentioned circle center coordinate clustering judgment rule constitutes the clustering criterion in the present invention and is also used for the subsequent fusion strategy selection.
[0015] (7) Combining the structural criterion and the clustering criterion, the fusion strategy is adaptively selected according to the image edge density ratio (i.e., the ratio of the number of edge points to the total number of pixels in the entire image): when the edge density ratio is less than 0.01, it is considered that the image edge information is insufficient and the edge quality is poor, so the clustering criterion in step (6) is used to screen the candidate circles; when the edge density ratio is greater than 0.05, it is considered that the image edge information is rich and the edge quality is high, so the structural criterion in step (5) is used to screen the candidate circles; if the edge density ratio is between 0.01 and 0.05, the clustering criterion and the structural integrity criterion are jointly used to determine whether the candidate circle is valid.
[0016] (8) Finally, all valid candidate circle centers and radius information that meet the fusion criteria are output, and their number is counted as the number of cylindrical objects in the image.
[0017] The beneficial effects of the present invention are:
[0018] It effectively solves the problems of strong parameter dependence, sensitivity to edge quality, and high false detection rate in traditional methods; it introduces dual structural and spatial criteria to adaptively filter pseudo circles and incomplete circles in complex image scenes; the detection process is adaptive and highly portable, and is suitable for a variety of image acquisition platforms; it can be widely used in scenarios such as warehouse object counting, industrial visual inspection, and image structure analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is the image to be detected;
[0020] Figure 2 is the counting result using the conventional circle detection algorithm;
[0021] Figure 3 It is the counting result of the present invention;
[0022] Figure 4 It is a flowchart of the algorithm. DETAILED DESCRIPTION
[0023] Based on the theory of detection and analysis of circular structures in images, the present invention proposes a method for counting cylindrical objects that combines structural criteria with circle center clustering. Traditional circle detection methods are prone to false detection when there are reflections, occlusions or incomplete edges in the image, and they rely on fixed parameters and lack robustness. The present invention samples the edge points of the image, estimates the typical circle radius range, and adaptively sets the circle detection sensitivity according to the edge density. On this basis, structural integrity analysis is used to determine whether the candidate circles are closed and evenly distributed, and then combined with the vertical coordinate clustering of the circle center, valid targets arranged in the same layer are identified. Finally, an adaptive fusion strategy is used to screen out pseudo circles and complete high-precision counting.
[0024] The present invention adopts a cylindrical object image counting method based on the adaptive fusion of structure criterion and circle center clustering, such as Figure 4 , including the following steps:
[0025] 1. Get a color image such as Figure 1 And convert to grayscale image;
[0026] 2. Apply Canny edge detection to the grayscale image obtained in step 1 to extract edge pixels;
[0027] 3. Randomly sample the edge points obtained in step 2, up to 1000 samples, and calculate the Euclidean distance of each pair of edge points. Then, remove the maximum value of 10% and take the median, and divide it by two to get the radius estimate r , And calculate the minimum radius rmin and maximum radius rmax:
[0028] rmin=0.3×r
[0029] rmax=1.5×r
[0030] The minimum radius rmin and the maximum radius rmax constitute the radius range.
[0031] 4. Calculate the edge ratio by dividing the number of edge points obtained in step 3 by the number of all pixel points, and automatically set the sensitivity of circle detection and the fusion strategy mode accordingly. When the edge ratio is less than 0.01, the fusion strategy is set to strict; when the edge ratio is greater than or equal to 0.01 and less than 0.05, the fusion strategy is set to adaptive; when the edge ratio is greater than or equal to 0.05, the fusion strategy is set to loose. For the sensitivity parameter S in circle detection, the present invention can adaptively set it according to the proportion of edge points in the entire image. For example: when the edge ratio is less than 1%, it is recommended to set S to 0.96; when the edge ratio is between 1% and 5%, it is recommended to set S to 0.94; when the edge ratio is greater than 5%, it is recommended to set S to 0.90. It should be noted that the sensitivity parameter S is not limited to the above specific values. Its value range can be adjusted in the interval [0.90, 0.98] according to different image types and application scenarios. The mapping relationship between sensitivity and edge density can be realized through linear interpolation, adaptive segmentation, machine learning strategies, etc. to adapt to different image characteristics and accuracy requirements.
[0032] 5. Calculate the gradient of the edge points obtained in step 3 using the Sobel operator. The Sobel operator is composed of two 3x3 convolution kernels, one for calculating the horizontal gradient and the other for calculating the vertical gradient. The horizontal and vertical convolution kernels are:
[0033]
[0034] For each edge point (x, y), the convolution operation is performed using the two convolution kernels mentioned above to obtain G x and G y By calculating the unit direction vector:
[0035]
[0036] The candidate center is obtained as Traverse the radius interval (rmin, rmax) obtained in step 3, calculate all possible center positions at each radius value, and establish a three-dimensional parameter space (x a ,y b ,r). Perform cumulative voting based on all possible circles, set a threshold T = S·2πr based on the sensitivity obtained in step 4, remove circles with votes lower than the threshold, and obtain candidate circular areas.
[0037] 6. Segment the circumference of each candidate circle obtained in step 5 by angle. For each candidate circular region, divide the circumference into eight adjacent sectors. Within each sector, count the number of edge points to form an edge point count set n1, n2, ..., n8. Calculate the theoretical expected number of edge points per segment under the ideal edge density of the circle: Where r is the radius of the candidate circle; and calculate the coefficient of variation
[0038] in ε is a small constant to avoid division by zero;
[0039] Then, if the edge point count set of each candidate circle has at least three segments with a number of edge points greater than 0.5E and the coefficient of variation CV of the set is less than 0.8, the circle can be retained.
[0040] 7. Perform cluster analysis on the y-coordinates of all candidate circle centers obtained in step 5. If the y-coordinate difference between two candidate circle centers is less than 15 pixels, they are grouped into the same cluster layer. If a candidate circle center does not belong to any cluster layer, or if the number of centers in its cluster layer is less than 2, the candidate circle is eliminated.
[0041] 8. Based on the fusion strategy mode obtained in step 4, select the fusion criteria to screen valid circular objects. When the fusion strategy is loose, objects that meet the structural integrity and uniformity criteria in step 6 or belong to the cluster layer in step 7 are retained. When the fusion strategy is strict, objects that meet both the structural criteria in step 6 and the clustering conditions in step 7 must be retained. When the fusion strategy is adaptive, if the edge ratio is less than 0.05, only the clustering criteria in step 7 are used; otherwise, the structural criteria in step 6 are used.
[0042] 9. Count the number of valid circular areas as the number of detected cylinders. Figure 2 is the counting result using the conventional circle detection algorithm. The final detection result of the present invention is as follows Figure 3 , the number of cylinders detected is 7, which is significantly better than the existing technology and greatly improves the detection accuracy.
[0043] Taking into account that traditional circle detection methods rely on fixed parameters and are sensitive to interference, this paper proposes an adaptive cylindrical object counting method that combines structure criteria and circle center clustering, which effectively improves recognition accuracy and robustness while simplifying the process.
Claims
1. A cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering, characterized by: The following steps are involved: Step 1: Convert the original color image into a grayscale image; Step 2: Extract edge point map based on grayscale image, randomly sample edge point positions, calculate radius range and edge density of circle structure, and set sensitivity parameters for circle detection; Step 3: Based on the radius range and sensitivity parameters, the circular targets in the image are detected by the circular Hough transform principle to obtain the center coordinates and radius information of all candidate circular areas; Step 4: Based on the candidate circular regions, construct structure criteria and clustering criteria; Step 5: Combining the structure criterion and clustering criterion, select the fusion strategy according to the image edge density ratio to determine whether the candidate circle is valid; Step 6: Output all valid candidate circle centers and radius information, and count their number as the number of cylindrical objects in the image.
2. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 1 is characterized in that: The specific implementation process of step 2 is as follows: Apply the Canny edge detection algorithm to the grayscale image to extract the edge point map; Randomly sample the edge point positions and record the pixel coordinates of all edge points as a set Among them, (x i ,y i ) represents the coordinates of the ith edge, N is the total number of edge points; randomly select no more than the preset upper limit M max The edge points are sampled; then, the Euclidean distance between all pairs of sampling points is calculated, and after removing outliers, the median is calculated as the estimated diameter of the circle structure, and the radius range is obtained; The sensitivity parameter of circle detection is set according to the overall edge density in the edge map obtained after the grayscale image is processed by the Canny operator.
3. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 2 is characterized in that: The radius range is obtained as follows: randomly sample edge points, calculate the Euclidean distance of each pair of edge points, remove the maximum value of 10%, take the median, divide by two to obtain the radius estimate r, and calculate the minimum radius rmin and the maximum radius rmax: rmin=0.3×r rmax=1.5×r The minimum radius rmin and the maximum radius rmax constitute the radius range.
4. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 3 is characterized in that: The sensitivity parameters for setting circle detection are specifically as follows: the edge ratio is calculated by dividing the number of edge points by the number of all pixel points, and the sensitivity of circle detection is set according to the edge ratio. When the edge ratio is lower than 1%, the first level sensitivity S1 is set; when the edge ratio is between 1% and 5%, the second level sensitivity S2 is set; when the edge ratio is higher than 5%, the third level sensitivity S3 is set, and S1>S2>S3.
5. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 4 is characterized in that: The specific implementation process of step 3 is as follows: Perform gradient calculation on edge points and use Sobel operator to calculate edge point gradient; Sobel operator is two convolution kernels, one for calculating horizontal gradient and the other for calculating vertical gradient; For each edge point (x, y), the convolution operation is performed using the two convolution kernels mentioned above to obtain G x and G y , by calculating the unit direction vector: The candidate center is Traverse the radius range (rmin, rmax), calculate all possible circle center positions at each radius value, and establish a three-dimensional parameter space (x a ,y b ,r); perform cumulative voting based on all the obtained circles, set a threshold T = S·2πr, remove circles with votes lower than the threshold, and obtain candidate circular areas.
6. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 5 is characterized in that: The specific implementation process of step 4 is as follows: Structural criterion: For each candidate circular area, its circumference is divided into several segments in equal angular directions, and the number of edge points in each segment is counted. If at least one-third of the total number of segments have an edge point count greater than half of the theoretical average distribution value of the circumference, and the coefficient of variation (CV) of the edge point count of all segments is less than 0.8, then the candidate circle is considered a valid circle with complete structure and uniform edge distribution. Clustering criterion: The vertical coordinates of the centers of all candidate circles are analyzed. If the vertical distance between the centers of two candidate circles is less than the set pixel threshold, they are classified into the same cluster layer. After clustering, if a candidate circle does not belong to any cluster layer, or its cluster layer contains only a single circle, the circle is considered an isolated interference target and is removed.
7. The cylindrical object image counting method based on adaptive fusion of structure criterion and circle center clustering according to claim 6 is characterized in that: The specific implementation process of step 5 is as follows: Combining the structural criterion and the clustering criterion, the fusion strategy is selected according to the image edge density ratio: when the edge density ratio is less than 0.01, the clustering criterion is used to screen candidate circles; when the edge density ratio is greater than 0.05, the structural criterion is used to screen candidate circles; if the edge density ratio is between 0.01 and 0.05, the clustering criterion and the structural integrity criterion are used together to screen candidate circles to determine whether the candidate circle is valid; The edge density is the ratio of the number of edge points to the total number of pixels in the entire image.