A new circle detection method
By employing neighborhood density clustering and virtual connected region generation methods, the problem of instability in traditional circle detection algorithms under complex scenarios is solved, achieving high accuracy and robustness in circle parameter detection.
Patent Information
- Application Number
- CN202211265339.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-17
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-10-17
AI Technical Summary
Traditional circle detection algorithms are easily affected by occlusion and noise in complex scenes, resulting in unstable detection. In particular, they are difficult to accurately detect small-radius circles and real images when there is occlusion, noise or complex background.
By performing initial neighborhood density clustering of circular parameters, most arcs belonging to the same circle are clustered into one class, generating a virtual connected region. Then, secondary calculation and clustering of circular parameters are performed. Finally, the circular parameters are verified to ensure the accuracy and robustness of the detection.
It achieves accurate acquisition of circle parameters in complex scenarios, with good anti-interference performance, high accuracy, and strong robustness, and can effectively detect circles in complex backgrounds.
Smart Images

Figure CN115511865B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of pattern recognition algorithm, and particularly relates to a novel circle detection method. BACKGROUND
[0002] With the development of computer technology, images become the carrier of expression and transmission of real world scenes, and the detection of circular targets in images is a basic problem in computer vision and pattern recognition. Circle detection is widely used in spacecraft, industrial component measurement, iris positioning, nanoparticle research, cell analysis, robot technology, traffic signs, automatic statistics of rod materials and other fields. Therefore, the research on circle detection method has important practical value and significance.
[0003] The most classic circle detection method is Hough Transform (HT), which converts the estimation of circle parameters into the intersection of multiple three-dimensional conical spaces, and the highest peak in the accumulator is the final determined circle parameter. However, HT occupies a large amount of memory space, is time-consuming, and is sensitive to noise, especially in the presence of complex background. Unlike HT, Random Circle Detection (RCD) randomly selects four edge points in each iteration, calculates the circle parameters using distance criteria, and then performs evidence collection and verification. Although RCD improves the calculation efficiency, it still needs multiple attempts to generate candidate circles. However, for images with occlusion, noise or complex scenes, the probability of randomly sampling points from the same circle is very small. Many methods have also appeared that use the geometric properties of circles for circle parameter detection, such as ray, gradient, symmetry, intersection line, and inscribed triangle. However, as pointed out in the literature, ray calculation requires setting multiple parameter points for multiple calculations when calculating the power peak histogram; gradient calculation combines differentiation, making the gradient more sensitive to noise than edge points; the use of symmetry is based on the assumption of a complete circle, so it is not suitable for occlusion and noise scenes; intersection line needs to be a chord of the same circle, which is also limited in complex scenes; when there is a large occlusion for a large diameter circle, the inscribed triangle method also has difficulty in ensuring accuracy and effectiveness. Intelligent optimization algorithms have also been widely applied in circle detection, such as genetic algorithms, evolutionary algorithms, and deep learning. These methods have achieved good results in application environments, but still have certain limitations, such as the inability to detect small radius circles well, and poor extraction performance in real images. SUMMARY
[0004] The application solves the instability problem caused by shielding, noise and complex scene in the traditional circle detection algorithm, and provides a novel circle detection method.
[0005] To solve the above technical problems, the technical scheme adopted by the application is as follows: a novel circle detection method is performed according to the following steps:
[0006] Step 1) corner point detection and corrosion
[0007] First, the Harris corner point detection method is used to detect the corner point position, and the corner point position is corroded, so that the intersection and the position with the broken line in the original image are completely disconnected;
[0008] Step 2) connected region marking
[0009] After the corner point position is corroded, in order to accurately detect the circle in the image, the corroded image is marked according to the following steps:
[0010] 2.1 use ImageEdge to represent the binary image, use ImageLabel to represent the marking matrix, and LValue represents the marking variable, the initial value is set as LValue=2, find the first point with a value of 1 in the binary image ImageEdge, mark the point as ImageLabel(i,j)=LValue, then search all pixel point coordinates with a value of 1 in the 8-neighborhood of the point, and save the pixel point coordinate information into the stack space;
[0011] 2.2 take out a position point in the stack space in step 2.1, and set the position point of the marking matrix ImageLabel as LValue, simultaneously search all pixel point coordinates with a value of 1 in the 8-neighborhood of the position point, and save the corresponding coordinate information into the stack space;
[0012] 2.3 repeat step 2.2 until all point coordinate information stored in the stack is taken out, and complete the marking of the 8-neighborhood connected region once;
[0013] 2.4 Find the next pixel with a value of 1 in the binary image and update the label variable LValue = LValue + 1. Set the position of the label matrix ImageLabel to LValue. Then, continue to search for all pixels with a value of 1 in the 8-neighborhood of the pixel and save the coordinate information of the pixel into the stack space. Proceed to step 2.2 until all pixels with a value of 1 in the binary image ImageEdge have been traversed, completing the labeling of the connected regions and obtaining the label matrix ImageLabel.
[0014] 2.5 Calculate the size of each connected region in the ImageLabel label matrix, set the extraction threshold for connected regions to 20, delete connected regions below the threshold, and obtain a new label matrix after deletion, denoted as FImageLabel;
[0015] Step 3) Calculation of circular parameters of connected regions
[0016] To accurately detect circles against complex backgrounds, the circle parameters are calculated based on the labeled connected regions obtained so far. The specific steps are as follows:
[0017] 3.1 Extracting a connected component C from the labeled image FImageLabel i ;
[0018] 3.2 In the connected region C i Randomly select a point Then at point Randomly select a second point on the same connected region at a distance greater than or equal to 1 / 3 of the length. Finally, in relation to A third point is randomly selected from the same connected region where the distance between two points is greater than or equal to 1 / 3 of the length.
[0019] 3.3 Based on the definition of the circle parameter of a connected region, it can be calculated that... To reduce computational complexity and avoid the potential for excessively large values when the three points are approximately on a straight line, the algorithm requires that (x, y, r) satisfy formula (9). Simultaneously, the markers of connected regions are added to the data of the circle parameters (x, y, r) satisfying formula (9), resulting in (x, y, r, C). i And store, where C i is the label of the connected region, W is the image width, H is the image height, and the total number of circle parameters obtained for each connected region is 3 times the size of the connected region.
[0020]
[0021] 3.4 Take out the next block of the labeled image FImageLabel connected region C i+1 Go to step 3.2, continue to calculate the circular parameters of the new connected region, until all the connected regions are traversed, and the circular parameter calculation of all the connected regions is completed.
[0022] Step 4) Calculate the density distribution of the circular parameter data
[0023] According to the density definition of the circular parameter, the density distribution of the circular parameter data is calculated, and the specific steps are as follows:
[0024] 4.1 According to the maximum values MaxX, MaxY, MaxZ and the minimum values MinX, MinY, MinZ of the X, Y, Z three coordinate axes of the circular parameter, the circular parameter data is divided into multiple density cubic blocks with interval G;
[0025] 4.2 According to formula (7), the density value of each density cubic block is calculated,
[0026]
[0027] Where N is the number of data d in the cubic block j, and G is the edge length of the cubic block. j i,j
[0028] 4.3 Establish an effective density block storage space, calculate the effectiveness of each density cubic block according to the effective density block formula (8), and set 1 for the effective one and clear zero for the invalid one;
[0029]
[0030] Where D is the density threshold, and according to formula (8), the density block ED greater than or equal to the threshold D is called the effective density block and is set to 1, and the density block ED less than the threshold D is called the invalid density block and is cleared to zero. TH TH j TH j
[0031] Step 5) Neighborhood clustering density class method
[0032] After obtaining the effective density block, the amount of circular parameter data is greatly reduced, in order to further determine the circular to which these circular parameter data belong, the neighborhood clustering method is used for calculation, and the specific steps are as follows:
[0033] 5.1 Neighborhood definition: there are 27 elements in a 3x3x3 neighborhood in three-dimensional space, and there are 26 elements adjacent to the center core element;
[0034] 5.2 Initialize the neighborhood clustering cluster number k=2, initialize the unvisited sample set Γ=ED, and cluster division C=φ.
[0035] 5.3 Randomly select one effective density block A1 on the effective density block ED, initialize the current cluster sample set C k-1 ={A1}, update the unvisited sample set Γ=Γ-{A1}, search all effective density blocks in the neighborhood of the effective density block A1, and save the position information of all effective density blocks in the neighborhood of A1;
[0036] 5.4 Take out one effective density block A i saved, and search all effective density blocks in the neighborhood of the effective density block A i , and save the position information of the corresponding effective density blocks together, update the current cluster sample set C k-1 ={A1,A i} and the unvisited sample set Γ=Γ-{A1,A i};
[0037] 5.5 Repeat step 5.4 until all effective density blocks in the storage space are taken out, and the current neighborhood effective density block clustering cluster C k-1 is generated;
[0038] 5.6 If Γ=φ, the algorithm ends, otherwise update the cluster division C={C1,C2,…,C k-1}, update k=k+1, and go to step 5.3;
[0039] 5.7 After the effective density block clustering is completed, according to the clustering number of the effective density block, the data in the same density block is set as the same clustering number, that is, the clustering operation of the circle parameter data is completed;
[0040] Step 6) Optimization of density clustering results
[0041] Each effective circle parameter data has its classification mark number, and the percentage of circle parameter data with the same class mark number in the total data amount is calculated DP i , and the threshold DP TH is set, then the classified data is optimized according to formula (10), after optimization, the noise points of the effective density block are basically removed, and the concentrated circle parameter data is left, and the remaining circle parameter data is re-labeled with a classification number;
[0042]
[0043] Step 7) Generation of virtual connected region
[0044] In order to further accurately obtain the center and radius parameters of the detected circle, the circular arcs belonging to the same clustering result are marked as the same connected region. The connected region is not a real connected relationship, and thus the connected region of the non-real connected relationship is defined as a virtual connected region. The generation method of the virtual connected region is shown in equation (11), wherein CirVCA j represents the virtual connected region generated by the jth data of the neighbor clustering result, CA ji represents the ith circular arc in the jth data of the neighbor clustering result.
[0045] CirVCA j = UCA ji (11)
[0046] Step 8) Calculation of the circle parameters of the virtual connected region and clustering
[0047] The virtual connected region marking result is obtained through step 7). The circular arcs belonging to the same circle are marked as the same data. At this time, the circular arcs belonging to the same circle are regarded as a connected region, and thus a virtual connected region is obtained. The circle parameter data is calculated twice according to the method in step 3). The density distribution of the circle parameter data is calculated according to the method in step 4). Then, the neighborhood density clustering calculation is performed according to the method in step 5), and the final clustering result is obtained.
[0048] Step 9) Determination of the circle parameters of each circle
[0049] Each clustering region is composed of a plurality of circle parameter points. The selection of which point as the circle parameter of the circle also determines the accuracy of the circle detection. In theory, the closer to the actual circle parameter position, the greater the data density, and the farther from the actual circle parameter position, the sparser the data density. Therefore, the core point position of the data should be the minimum distance to other circle parameter points. The sum of the distances of point P i to all clustering points is calculated according to equation (12), wherein N is the number of circle parameter points of the current clustering region. Then, the circle parameter point corresponding to the minimum value of SP i is taken as the circle parameter of the clustering region, and thus the circle parameter of the circle corresponding to the current clustering region is obtained.
[0050]
[0051] Step 10) Verification of the circle parameters
[0052] In order to ensure the correctness of the circle parameter data, the obtained circle parameters are verified. Since the obtained circle parameters are all in units of pixels, the number of pixel points SPN iThen, the i-th circle is drawn according to the circle parameter of the i-th circle, and the number of pixel points CPN corresponding to the edge information of the circle on the circumference track of the circle is counted i The true or false of the circle is determined according to formula (13), the circle parameter of the true circle is reserved, otherwise, the true or false of the circle is determined according to formula (13), the circle parameter of the true circle is reserved, otherwise, the final detection result is obtained by deleting the circle parameter of the true circle.
[0053]
[0054] The advantages and positive effects of the present application are as follows: the method is mainly used for circle parameter detection in a complex scene, and aims to solve the instability problem caused by shielding, noise and complex scene in the traditional circle detection algorithm. The method of the present application clusters most of the circular arcs belonging to the same circle into a class through initial circle parameter neighborhood density clustering, generates a virtual connected region, then performs secondary calculation and clustering of the circle parameter on the virtual connected region, realizes more accurate acquisition of the circle parameter calculation of each circle, and finally verifies the circle parameter to obtain the circle parameter of the real circle. The experimental results show that the algorithm has the characteristics of good anti-interference, high accuracy and strong robustness. BRIEF DESCRIPTION OF DRAWINGS
[0055] Figure 1 The binary image and its connected region labeling result are shown in (a) and (b) respectively.
[0056] Figure 2 The corner detection and erosion results are shown in (a), (b) and (c) respectively.
[0057] Figure 3 The connected region labeling result is shown in (a).
[0058] Figure 4 The circle parameter calculation result is shown in (a).
[0059] Figure 5 The circle parameter density block division result is shown in (a).
[0060] Figure 6 The effective density block labeling result is shown in (a).
[0061] Figure 7 The circle parameter data in the effective density block is shown in (a).
[0062] Figure 8 The three-dimensional neighborhood schematic diagram is shown in (a), (b) and (c).
[0063] Figure 9 The effective density block optimization result is shown in (a).
[0064] Figure 10 The connected region circle parameter data clustering result is shown in (a).
[0065] Figure 11 Label the results for virtual connected regions.
[0066] Figure 12 The results of the circular parameter display for the virtual connected region after the quadratic circular parameter calculation are shown.
[0067] Figure 13 This is the clustering result of the virtual connected region circular parameters after the quadratic circular parameter calculation.
[0068] Figure 14 This is the circle detection result of an embodiment of the present invention. Detailed Implementation
[0069] To make the objectives, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below.
[0070] To better understand the circle detection method of the present invention, before proceeding with the description, the circle parameters and circle parameter density of the connected region are defined.
[0071] Definition of circular parameters of connected regions
[0072] Figure 1 This is a binary image and its connected component labeling results. Each connected component in the labeling results is represented by a gray level and labeled with C1, C2, ... C1. n Label the connected regions, where C represents any segment of the marked region on the circumference. Establish an image coordinate system with the bottom left corner of the image as the origin, the horizontal direction to the right as the positive X-axis, and the vertical direction upwards as the positive Y-axis. Then, point P on the image... 1C (x 1C ,y 1C ), P 2C (x 2C ,y 2C ), P 3C (x 3C ,y 3C () is a connected region C whose interval is greater than G. L Three arbitrary points, where G L It is 1 / 3 of the maximum length of the connected region.
[0073] Depend on Figure 1 It is known that randomly selecting points to calculate circle parameters in complex backgrounds will yield many invalid circle parameter data. Therefore, in this invention, based on a certain connected region, when the distance is greater than or equal to G, the circle parameter is calculated. L Under the condition of P, P was randomly extracted. 1C P 2C P 3C Three points are used to define the circle parameters of the connected region, which are determined by the three points. These circle parameters are expressed by formulas (1), (2), and (3).
[0074]
[0075]
[0076] where a = (x 1C +x 3C ) / 2, b = (y 1C +y 3C ) / 2, c = (x 1C +x 2C ) / 2, d = (y 1C +y 2C ) / 2, k 12 = (y 1C -y 2C ) / (x 1C -x 2C ), k 13 = (y 1C -y 3C ) / (x 1C -x 3C ), obviously, when k 12 = k 13 , three points are on the same line, and the effective circle parameters cannot be obtained, so the calculation results of this case are discarded.
[0077] Definition of circle parameter density
[0078] Suppose the circle parameter sample set is D = (d1, d2, …, d m ), then the circle parameter density description is defined as follows:
[0079] 1) Establish the coordinate system: for d i ∈ D, d i is a three-dimensional data (x, y, r), establish a three-dimensional coordinate system (X, Y, Z), that is, map the circle parameter data (x, y, r) to the three-dimensional coordinates (x, y, z).
[0080] 2) Division of density blocks: in order to represent the density of the distribution of the circle parameter data, take the maximum values MaxX, MaxY, MaxZ and the minimum values MinX, MinY, MinZ in X, Y, Z directions respectively, set the interval distance as G, draw planes respectively by formulas (4), (5), (6), then establish multiple cubic blocks with side length G.
[0081] x = kG, k is an integer, and
[0082] y = mG, m is an integer, and
[0083] z = nG, n is an integer, and
[0084] 3) Density calculation in density block: for any d i ∈ D, must fall in a certain cubic block j, denoted as d i,j , set the number of data d i,j in cubic block j as N j , then the density of cubic block j is defined as formula (7)
[0085]
[0086] 4) Effective density block: set the density threshold D TH , according to formula (8), the density block ED TH greater than or equal to the threshold D j is called an effective density block and is set to 1, and the density block ED TH less than the threshold D j is called an invalid density block and is cleared to zero.
[0087]
[0088] The above defines the circle parameters and the circle parameter density of the connected region first, and on the basis of the definition, the circle detection method based on neighborhood clustering of the present application is introduced in detail as follows:
[0089] Step 1) Corner point detection and erosion
[0090] For real images, edge detection is needed, in order to avoid the influence of the advantages and disadvantages of edge detection algorithms, a complex synthetic image is used to illustrate the algorithm in this embodiment, such as Figure 2 (a), the circular arc of the circle to be detected may intersect the background or the circular arc of other circles to be detected at multiple places, if the circle parameters are directly calculated, not only the calculation amount is large, but also it is difficult to guarantee the accuracy, in order to more accurately detect the circle, the Harris corner point detection method is used to detect the position of the corner point before calculation, the detection result is shown in Figure 3 (b), and the position of the corner point is eroded, so that the intersection points and the positions with fold lines in the original image are completely disconnected, the segmentation result of these connected regions is shown in Figure 3 (c).
[0091] Step 2) Connected region marking
[0092] After the corner point position is eroded, the result of Figure 2 (c) is obtained, in order to accurately detect the circle in the image, first, the eroded image is marked according to the following steps.
[0093] 2.1) Use ImageEdge to represent Figure 2(c) the binary image is labeled as ImageLabel, and the label variable is LValue, which is initially set as LValue = 2. The first pixel with value 1 in the binary image ImageEdge is labeled as ImageLabel(i, j) = LValue. Then, all the pixels with value 1 in the 8-neighborhood of the pixel are searched, and the coordinates of the pixels are saved in the stack space.
[0094] 2.2) A position in the stack space in 2.1) is taken out, and the position in the label matrix ImageLabel is set as LValue. Then, all the pixels with value 1 in the 8-neighborhood of the pixel are searched, and the coordinates of the pixels are saved in the stack space.
[0095] 2.3) Step 2.2) is repeated until all the pixel coordinates saved in the stack space are taken out, and the labeling of the 8-neighborhood connected region is completed.
[0096] 2.4) The next pixel with value 1 in the binary image is searched, and the label variable LValue is updated as LValue = LValue + 1. The position in the label matrix ImageLabel is set as LValue. Then, all the pixels with value 1 in the 8-neighborhood of the pixel are searched, and the coordinates of the pixels are saved in the stack space. Step 2.2) is entered until all the pixels with value 1 in the binary image ImageEdge are traversed, and the labeling of the connected region is completed. The label matrix ImageLabel is obtained.
[0097] 2.5) The size of each connected region in the label matrix ImageLabel is counted, and the extraction threshold of the connected region is set as 20. The connected regions below the threshold are deleted, and the new label matrix is denoted as FImageLabel.
[0098] In order to better represent the labeling result of the connected region, each different value in the label matrix is represented by different gray scale. The gray scale labeled image is obtained as Figure 3 .
[0099] Step 3) Calculation of the connected region circle parameters
[0100] In order to accurately detect the circle in the complex background, the calculation method of the connected region circle parameters is defined in the foregoing, Figure 3 The labeling result of the connected region is obtained in (c). The specific calculation steps of the circle parameters are as follows:
[0101] 3.1) A connected region C in the labeled image FImageLabel is extracted i ;
[0102] 3.2) In the connected region C i Randomly take a point P 1Ci on the same connected region C 1Ci with the distance greater than or equal to 1 / 3 length position Finally, randomly take a third point on the same connected region C with the distance greater than or equal to 1 / 3 length position
[0103] 3.3) According to the definition of the circular parameters of the connected region, the circular parameters (x, y, r) of the circle determined by the three points can be calculated In order to reduce the calculation amount and avoid the problem of super large value that may occur when the three points are approximately on a straight line, the algorithm requires that (x, y, r) satisfy formula (9), and the label number of the connected region is added to the circular parameter (x, y, r) data that satisfies formula (9) to obtain (x, y, r, C i ) and store it, where C i is the label number of the connected region, W is the image width, H is the image height, and the total number of circular parameters obtained by each block of the connected region is 3 times the size of the connected region.
[0104]
[0105] 3.4) Take the next block of the connected region C i+1 of the labeled image FImageLabel, go to step 3.2), continue to calculate the circular parameters of the new connected region, until all connected regions are traversed, and the circular parameter calculation of all connected regions is completed, and the calculation result is as follows Figure 4 .
[0106] Step 4) Calculate the density distribution of the circular parameter data
[0107] According to the density definition of the circular parameter in the foregoing, the density distribution of the circular parameter data is calculated.
[0108] 4.1) According to the maximum values MaxX, MaxY, MaxZ and the minimum values MinX, MinY, MinZ of the X, Y, Z three coordinate axes of the circular parameter, the circular parameter data is divided into multiple density cubic blocks with an interval G, and the result is as follows Figure 5 .
[0109] 4.2) According to formula (7), the density value of each density cubic block is calculated.
[0110] 4.3) Establish an effective density block storage space, calculate the effectiveness of each density cubic block according to the effective density block formula (8), set 1 for the effective one and clear 0 for the invalid one, and the effective density block label result is as follows Figure 6 .
[0111] Step 5) neighborhood clustering method
[0112] After obtaining the effective density block, from Figure 7 As can be seen, the amount of data of the circle parameters is greatly reduced. In order to further determine the circle to which the circle parameter data belongs, the present application proposes a neighborhood clustering method, and the specific steps are as follows:
[0113] 5.1) neighborhood definition: there are 27 elements in a 3x3x3 neighborhood in three-dimensional space, such as Figure 8 (a) There are 26 red elements adjacent to the center core element, according to the relationship between the center element and the adjacent element, the 26-neighborhood, 18-neighborhood and 6-neighborhood shown in Figs. 8(a), 8(b) and 8(c) are generally used in three-dimensional space, and the 26-neighborhood of Fig. 8(a) is used in this embodiment. Figure 8 Figure 8 (a).
[0114] 5.2) Initialize the neighborhood clustering cluster number k=2, initialize the unvisited sample set Γ=ED, and cluster partition C=φ.
[0115] 5.3) Randomly select an effective density block A1 on the effective density block ED, initialize the current cluster sample set C k-1 ={A1}, update the unvisited sample set Γ=Γ-{A1}, search all effective density blocks in the neighborhood of the effective density block A1, and save the position information of all effective density blocks in the neighborhood of A1;
[0116] 5.4) Take out one of the saved effective density blocks A i , and search all effective density blocks in the neighborhood of the effective density block A i , and save the position information of the corresponding effective density blocks, update the current cluster sample set C k-1 ={A1,A i} and the unvisited sample set Γ=Γ-{A1,A i}.
[0117] 5.5) Repeat step 5.4), until all effective density blocks in the storage space are taken out, and the current neighborhood effective density block clustering cluster C k-1 is generated.
[0118] 5.6) If Γ=φ, the algorithm ends, otherwise update the cluster partition C={C1,C2,…,C k-1}, update k=k+1, and go to step 3).
[0119] 5.7) After completing the effective density block clustering, according to the clustering number of the effective density block, the data in the same density block is set as the same clustering number, that is, the clustering operation of the circle parameter data is completed, and the clustering result is as shown inFigure 9 .
[0120] Step 6) Optimize density clustering results
[0121] Depend on Figure 6 Based on the effective density block labeling results, some independent density blocks exist. We consider these effective density blocks to be noise points, which interfere with the classification results. Therefore, we will further optimize the classification results. Currently, each effective circle parameter data has its own classification label number. We will count the percentage of circle parameter data with the same class label number in the total data volume. i Set threshold DP TH Then, the classification data is optimized according to formula (10). After optimization, the noise points of the effective density blocks are basically removed, leaving the circular parameter data that are concentrated together. The remaining circular parameter data are then re-labeled with classification numbers. The optimization results of the effective density blocks and the corresponding data are as follows: Figure 10 .
[0122]
[0123] Step 7) Generation of virtual connected components
[0124] After optimizing the neighborhood clustering calculation, all the circular parameter data were divided into different classes based on density and neighborhood relationships. Figure 10 It can be seen that the circular parameter data clustered into the same class basically come from one or more arcs of the same circle. This also shows that the neighborhood clustering method can effectively detect circles. Since the convergence of circular parameter data obtained from multiple independent arcs is generally worse than the accuracy of circular parameters obtained from multiple arcs participating in the calculation at the same time, in order to obtain the center and radius parameters of the detected circle more accurately, the arcs where the data belonging to the same cluster result are located are marked as the same connected region. This connected region is not a real connected relationship. Therefore, in this invention, this non-real connected region is defined as a virtual connected region. The method for generating virtual connected regions is as shown in formula (11), where CirVCA j CA represents the virtual connected region generated from the j-th class of neighbor clustering results. ji The i-th arc in the j-th class of the neighbor clustering results. The final generated connected region is as follows: Figure 11 .
[0125] CirVCA j =UCA ji (11)
[0126] Step 8) Calculation and clustering of circular parameters of virtual connected regions
[0127] From the above steps, we obtain the virtual connected region labeling result in step 7). Arcs belonging to the same circle are labeled as the same type of data. At this point, arcs belonging to the same circle are considered as a connected region as described above, thus obtaining a virtual connected region. Generally, a virtual connected region consists of one or more connected regions. In this case, the circle parameters calculated by the method described above are more accurate, and the data concentration is denser, making it easier to accurately obtain the circle parameters. Therefore, the circle parameter data is calculated a second time according to the method in step 3). The calculation result is shown in the figure below. Figure 12 As shown, with Figure 4 The comparison shows that the circle parameter data from the second calculation is both denser and has significantly fewer discrete circle parameter data points. This further demonstrates that the first clustering essentially preserved the edge connected regions of the arcs, while edge connected regions that differed significantly from the arcs were deleted. Then, neighborhood density clustering was performed again using the method in step 5), yielding the final clustering result as shown below. Figure 13 The clustering results show that the circular parameter dataset is concentrated in 30 unrelated regions. These 30 regions actually represent Figure 2 (a) contains 30 circles of different sizes.
[0128] Step 9) Determining the parameters of each circle
[0129] like Figure 7 As shown in (b), each cluster region consists of several circular parameter points. The selection of which point as the circular parameter of the circle determines the accuracy of the circle detection. Theoretically, the closer the location is to the actual circular parameter, the greater the data density, while the farther away the location is from the actual circular parameter, the sparser the data density. Therefore, the core point of the data should have the minimum distance to other circular parameter points. The point P can be calculated using formula (12). i The sum of distances to all cluster points, where N is the number of circular parameter points in the current cluster region, and then SP is taken. i The circle parameter point corresponding to the minimum value is used as the circle parameter of the cluster region, which means that the circle parameter of the circle corresponding to the current cluster region is obtained.
[0130]
[0131] Step 10) Verification of circle parameters
[0132] To ensure the accuracy of the circle parameter data, the calculated circle parameters are verified. Since the currently obtained circle parameters are all in pixels, the number of pixels (SPN) of the virtual connected regions involved in the calculation in the i-th circle is counted. i Then, draw a circle using the circle parameters of the i-th circle, and count the number of pixels (CPN) corresponding to the edge information of the circle on the circumference trajectory of that circle. i, the true or false of the circle is determined according to formula (13), the circle parameters of the true circle are reserved, otherwise, the final detection result is obtained. The circle detection result is shown in Figure 14 Wherein, the red part represents the circle detection result, and the result shows that all the circles contained in the image are accurately detected, and the case that part of the circle center is outside the image is also contained.
[0133]
[0134] The main contributions of the present application are (1) a circle parameter calculation method for connected marking areas is proposed; (2) a neighborhood density clustering algorithm is proposed, which provides a new method for circle parameter detection; (3) according to the neighborhood density clustering algorithm, circle detection in multiple scenes is realized, and the experimental results show that the algorithm has good adaptability to complex scenes, occlusion, noise and the like.
[0135] The embodiments of the present application are described in detail above, but the present application is not limited to the above-mentioned embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the purpose of the present application.
Claims
1. A novel circle detection method characterized by: The following steps are taken: Step 1) Corner detection and erosion First, the Harris corner detection method is used to detect the position of the corner, and the position of the corner is eroded to completely disconnect the intersection and the position of the broken line in the original image; Step 2) Connected region labeling After the corner position is eroded, in order to accurately detect the circle in the image, the eroded image is labeled according to the following steps: 2.1 Use ImageEdge to represent the binary image, ImageLabel to represent the label matrix, and LValue to represent the label variable, the initial value is set to LValue = 2, find the first point with pixel value 1 in the binary image ImageEdge, and mark it as ImageLabel(i,j) = LValue, then search for all pixel points with pixel value 1 in the 8-neighborhood of the point, and save the coordinate information of the pixel points into the stack space; 2.2 Take out a position point in the stack space in step 2.1, and set the position point of the label matrix ImageLabel to LValue, and search for all pixel points with pixel value 1 in the 8-neighborhood of the position point, and save the corresponding coordinate information into the stack space; 2.3 Repeat step 2.2 until all the point coordinate information stored in the stack is taken out, and complete the labeling of the 8-neighborhood connected region; 2.4 Find the next pixel point with pixel value 1 in the binary image, and update the label variable LValue = LValue + 1, set the position point of the label matrix ImageLabel to LValue, then continue to search for all pixel points with pixel value 1 in the 8-neighborhood of the pixel point, and save the coordinate information of the pixel points into the stack space, go to step 2.2, until all the pixel points with pixel value 1 in the binary image ImageEdge are traversed, complete the labeling of the connected region, and get the label matrix ImageLabel; 2.5 Count the size of each connected region in the label matrix ImageLabel, set the extraction threshold of the connected region, the threshold is set to 20, and the connected region below the threshold is deleted, and the new label matrix is denoted as FImageLabel after deletion; Step 3) Connected region circle parameter calculation In order to accurately detect the circle in the complex background, according to the labeling result of the connected region obtained, the specific calculation of the circle parameter is carried out, and the specific steps are as follows: 3.1 Extracting a connected component C in the labeled image FImageLabel i ; 3.2 In the connected region C i Take a random point on the line segment Then take a second point on the same connected region at a distance greater than or equal to 1 / 3 the length of the line segment Finally take a third point on the same connected region at a distance greater than or equal to 1 / 3 the length of the line segment Finally take a third point on the same connected region at a distance greater than or equal to 1 / 3 the length of the line segment Finally take a third point on the same connected region at a distance greater than or equal to 1 / 3 the length of the line segment 3.3 According to the definition of the circle parameters of the connected region, the following can be calculated The circle parameters (x, y, r) of the circle determined by three points, in order to reduce the amount of calculation and avoid the problem of super large value that may occur when three points are approximately on a straight line, the algorithm requires (x, y, r) to satisfy formula (9), and the label number of the connected region is added to the circle parameters (x, y, r) data that satisfy formula (9) to obtain (x, y, r, C i ) and store, where C i is the label number of the connected region, W is the image width, H is the image height, and the total number of circle parameters obtained by each connected region is 3 times the size of the connected region. 3.4 Take out the next block connected region C of the marked image FImageLabel i+1 , go to step 3.2, continue to calculate the circle parameters of the new connected region, until all the connected regions are traversed, and the circle parameter calculation of all the connected regions is completed; Step 4) Calculate the density distribution of the circle parameter data According to the definition of the density of the circle parameter, the density distribution of the circle parameter data is calculated, and the specific steps are as follows: 4.1 According to the maximum values MaxX, MaxY, MaxZ and the minimum values MinX, MinY, MinZ of the X, Y, Z three coordinate axes of the circle parameter, divide the circle parameter data into multiple density cubes with interval G; 4.2 According to formula (7), the density value of each density cube is calculated, wherein N j the number of data d within the cubic block j i,j G is the edge length of the cubic block; 4.3 Establish an effective density block storage space, calculate the effectiveness of each density cube according to the effective density block formula (8), and set 1 for the effective one and 0 for the invalid one; wherein D TH is a density threshold, and density blocks ED TH greater than or equal to the threshold D j are called valid density blocks and are set to 1, and density blocks ED TH less than the threshold D j are called invalid density blocks and are set to 0. Step 5) Neighborhood aggregation density class method After the effective density block is obtained, the data amount of the circle parameter is greatly reduced. In order to further determine the circle to which the circle parameter data belongs, the neighborhood clustering method is used for calculation, and the specific steps are as follows: 5.1 Neighborhood definition: there are 27 elements in the neighborhood of 3x3x3 in three-dimensional space, and there are 26 elements adjacent to the center core element; 5.2 Initialize neighborhood clustering cluster number k=2, initialize unvisited sample set Γ=ED, cluster partition C=φ; 5.3 Randomly select one effective density block A1 on the effective density block ED, initialize the current cluster sample set C k-1 ={A1}, update the unvisited sample set Γ = Γ - {A1}, search all effective density blocks in the neighborhood of the effective density block A1, and save the position information of all effective density blocks in the neighborhood of A1; 5.4 Take out one of the saved effective density blocks A i Simultaneously search for the effective density block A i Collect all valid density blocks within the neighborhood of the cluster sample set C, and save the location information of the corresponding valid density blocks to update the current cluster sample set C. k-1 ={A1,A i } and the unvisited sample set Γ=Γ-{A1,A i }; 5.5 Repeat step 5.4 until all valid density blocks in the storage space are taken out, the valid density block cluster C of the current neighborhood is clustered k-1 is generated; 5.6 If Γ = φ, then the algorithm ends, otherwise update the cluster partition C = {C1, C2,..., C k-1}, update k = k + 1, and go to step 5.
3. 5.7 After the clustering of the effective density block is completed, the data in the same density block is set as the same cluster number according to the cluster number of the effective density block, that is, the clustering operation of the circle parameter data is completed; Step 6) Optimization of density clustering results Each valid circle parameter data has its classification mark, and the percentage of circle parameter data with the same classification mark in the total data is DP i , set threshold DP TH , then optimize the classification data according to formula (10), after optimization, the noise points of the effective density block are basically removed, and the circle parameter data concentrated together is left, and then the remaining circle parameter data is re-labeled with a classification mark; Step 7) Generation of virtual connected region In order to further accurately obtain the center and radius parameters of the detected circle, the circular arcs belonging to the same clustering result are marked as the same connected region. The connected region is not a real connected relationship, and thus the connected region of the non-real connected relationship is defined as a virtual connected region. The generation method of the virtual connected region is shown in formula (11), wherein CirVCA j represents the virtual connected region generated by the jth data of the neighbor clustering result, CA ji the ith circular arc in the jth data of the neighbor clustering result; CirVCA j = UCA ji (11) Step 8) Calculation and clustering of circle parameters of virtual connected region Through step 7), the virtual connected region marking result is obtained, and the circular arc belonging to the same circle is marked as the same class of data. At this time, the circular arc belonging to the same circle is regarded as a connected region, that is, a virtual connected region is obtained. According to the method in step 3) above, the circle parameter data is calculated twice, and the density distribution of the circle parameter data is calculated according to the method in step 4), and then the neighborhood density clustering calculation is performed according to the method in step 5), and the final clustering result is obtained; Step 9) Determination of circle parameters of each circle Each clustering area is composed of several circle parameter points, and selecting which point as the circle parameter of the circle also determines the accuracy of the circle detection. In theory, the closer to the actual circle parameter position, the greater the data density, and the farther away from the actual circle parameter position, the sparser the data density. Therefore, the core point position of the data should be the minimum distance to other circle parameter points, which is calculated by formula (12) i The sum of distances from point P to all clustering points, where N is the number of circle parameter points in the current clustering area, and then taking the minimum value of SP i The circle parameter point corresponding to the minimum value is taken as the circle parameter of the clustering area, that is, the circle parameter of the circle corresponding to the current clustering area is obtained. Step 10) Verification of circle parameters In order to ensure the correctness of the circle parameter data, the circle parameters obtained are verified. Since the circle parameters obtained are in pixel units, the pixel points of the virtual connected region participating in the calculation in the ith circle are counted SPN i Then, the circle is drawn according to the circle parameters of the ith circle, and the pixel points of the corresponding circle edge information on the circle circumference track are counted CPN i The true or false of the circle is determined according to formula (13), the circle parameters of the true circle are reserved, otherwise, the circle parameters are deleted, and the final detection result is obtained.