A Novel Four-Step Algorithm for Detecting a Single Circle in Complex Images

Single-circle detection is vital in industrial automation, intelligent navigation, and structural health monitoring. In these fields, the circle is usually present in images with complex textures, multiple contours, and mass noise. However, commonly used circle-detection methods, including random sample consensus, random Hough transform, and the least squares method, lead to low detection accuracy, low efficiency, and poor stability in circle detection. To improve the accuracy, efficiency, and stability of circle detection, this paper proposes a single-circle detection algorithm by combining Canny edge detection, a clustering algorithm, and the improved least squares method. To verify the superiority of the algorithm, the performance of the algorithm is compared using the self-captured image samples and the GH dataset. The proposed algorithm detects the circle with an average error of two pixels and has a higher detection accuracy, efficiency, and stability than random sample consensus and random Hough transform.


Introduction 1.Background
Single-circle detection has many application scenarios, namely for use in automated inspection and assembly, the identification of weld joints and weld seams, PCB hole detection, and non-destructive testing [1][2][3][4][5].For example, only the single circle in the image needs to be detected when welding the inner diameter edges of tube heat exchanger bores utilizing machine vision.In the abovementioned fields, the circles to be detected are usually present in complex images.Complex images are images with multiple contours, intricate textures, mass noise, and various levels of brightness, generally containing a lot of information about edge and structure.Therefore, the task of circle detection in complex images and obtaining the localization and shaping parameters of the circle is more challenging.Widely used circle parameter detection methods include random sample consensus, stochastic Hough transform, and least squares, with good robustness and accuracy [6,7].

Literature Review
Hough transform (HT) has received attention from a wide range of scholars due to its insensitivity to noise and ease of implementation in parallel computing.However, the HT algorithm has a long computation time and requires a large storage space, making circle detection inefficient.To solve this problem, Xu et al. [8] proposed the randomized Hough transform (RHT).The RHT algorithm maps multiple pixels on the edge to a single point in the parameter space.It determines the circle's parameters by randomly obtaining three points in the parameter space, which can significantly reduce the computation time and storage space.Consequently, many scholars have conducted studies based on the RHT algorithm [9,10].Nonetheless, the algorithm uses three points instead of all points along the circle edge in order to determine the circle parameters, which may reduce the detection accuracy.To enhance the probability that the three points belong to the same circle, Wang [11] proposed an improved RHT method integrated with a fitting subpixel circle detection algorithm, where he removed isolated points after edge extraction.The method effectively eliminates the noise and improves circle detection accuracy.To better remove noise and determine the fitted sample points, Jiang [12] proposed an efficient stochastic Hough transform circle detection algorithm based on probabilistic sampling and feature points, which optimizes the methods of determining sample points and finding candidate circles.Experimental results show that the algorithm improves the effectiveness of sampling the fitted sample points and prevents the fake circles from being regarded as candidate circles.Both the RHT algorithm and the improved algorithm based on RHT obtain the circle parameters via random sampling, which is challenging to apply to circle detection in complex images because the number of noise points in complex images is more than the number of feature points at the circle edge.
Randomized sample consensus (RANSAC) was proposed by Fishler and Bolles in 1981 as an iterative uncertainty algorithm for estimating parameters from noise datasets; this has been used in various image processing and computer vision applications [13].When fitting a circle, a part of the sample points is randomly selected as the set of fitted sample points, and a circle is fitted.Kiddee et al. [14] used the RANSAC algorithm to determine the location of the edge feature points in circular weld tracking.Although the algorithm can estimate the parameters of the circle edges, it is only suitable for cases where there are fewer noise points outside of the circle.To solve the problem of excessive noise points outside the circle, Ma et al. [15] proposed a spatial circle center fitting method based on the RANSAC algorithm, which reduces the noise outside the circle and improves the robustness of the circle detection.However, circle detection in complex images is still unable to obtain an excellent fitting effect.
Least squares fitting of circles (LSC) [16][17][18] is the method of fitting a circle by minimizing the sum of the squares of the distances between the sample points and the corresponding points on the fitted circle, which has a high fitting accuracy and faster detection speed compared with the RHT and RANSAC algorithms.However, the results obtained based on the LSC algorithm are easily affected by noise.Therefore, scholars have improved and compared the LSC algorithm.Zhou et al. [19] proposed the MFLS algorithm, which removes the noise points by establishing a mathematical model in polar coordinates and then uses the LSC algorithm for circle fitting.The method has high positioning accuracy.However, the detection results may be seriously affected when the noise points are not entirely removed.To detect the parameters of the punched circle quickly and accurately, Cao et al. [20] proposed a circle fitting method based on LSC and the mean shift algorithm.This algorithm concentrates the center of the fitted circle around the true circle's center in order to obtain the best actual circle.Experiments show that this algorithm detects circles faster than the RHT algorithm.
In addition to the methods mentioned above, AI-based approaches, e.g., deep learning, have also been used in the literature to detect circle contours.Essentially, AI-based circular contour detection methods usually have high accuracy and robustness.However, their performance depends on the algorithms used and the quality of the training data.The recognition results are usually good if the algorithms and models are adequately trained and have good generalization capabilities.However, some false or missed detections may occur for complex or noisy image scenes.
In summary, the increased complexity of images in which the target circles are located leads to some limitations of the detection algorithms.RHT and RANSAC algorithms are designed based on the random sampling method to obtain the fitted circle.They fit the circle by selecting some of the sample points (pixels at the edges) instead of the sample points of the whole circle, which may lead to the selection of sample points that are not representative enough, especially when the sample points contain noise or outliers.The LSC algorithm Sensors 2023, 23, 9030 3 of 23 has high accuracy but is extremely sensitive to noise.In addition, excessive sample points increase the complexity of the least squares' nonlinear optimization computation.Thus, a new single-circle detection algorithm is desired for its application in complex images.

Organization
The rest of the paper is organized as follows: Section 2 states the single-circle detection problem, Section 3 describes the proposed single-circle detection principle, Section 4 performs comparative experiments and results analysis, and Section 5 concludes the paper and discusses the future work.

Problem Statement
Although single-circle detection with a simple background is a typical computer vision problem, which has been well solved in the literature, single-circle detection with a complex environment requires a more efficient and accurate method.The expected detection method addresses the following four issues:

•
The removal of mass noise in the image edge preprocessing stage.Interfering points are an adverse factor affecting the accuracy and efficiency of single-circle detection.Mass noise increases the difficulty of de-noising and main contour detection; therefore, the noise needs to be removed accurately when detecting single circle with a complex background.

•
The selection of sample points for fitting circles.After image edge processing, interfering points affect the fitting results.These interfering points are scattered in a low-density region.In contrast, the sample points of the main contour are connected in an arc and are more tightly connected in a high-density area.Considering the characteristics of the interfering points and sample points, establishing a sample point selection method for fitting candidate circles is another challenge.

•
The iteration of candidate circles and determination of ideal circles.Overfitting and underfitting are prevented via suitable methods during the exact fitting of circles.We need to find an effective and fast iterative solution for the candidate circle, which in turn ensures the quality of the ideal circle.

•
The improvement of output circle detection accuracy.Despite reducing the frequency of overfitting and underfitting occurrences, there may still be an error between the ideal circle and the real-world circle due to the influence of various interfering points.
To improve the accuracy of output circle detection, the effect of interfering points on output circle parameters needs to be further reduced.
Definitions of terms used in the methods are given below.
Definition 1. Candidate circle denotes the circle constructed by fitting during the process in the least squares fitting circles' iteration process.It cannot be directly output as the final result, and needs further analysis and screening.
Definition 2. Ideal circle denotes the last circle fitted by the least square method in Section 3.3.

Definition 3.
Output circle denotes the final circle output, which is expected to be with high accuracy and stability.

Definition 4.
Edge detection denotes a method to extract the edges of an image with a large gradient, which includes the circle edges to be detected and the interference points.
Definition 5. Main contour denotes the target edge to be detected in the image.Definition 6. Sample points denote pixels in an image.In this paper, the corresponding pixels are put into the coordinate system to explain the principle of each algorithm.Therefore, the pixels are called sample points.
Definition 7. Data points in K-means algorithm represent the coordinate values of the center and radius of all candidate circles.

Methods
The algorithm is proposed for single-circle detection, which combines the DBSACN clustering algorithm, the least squares method (LS), and the K-means clustering algorithm.To briefly express our proposed algorithm, it is named as DBLSKCF algorithm.The four steps in the DBLSKCF algorithm respond to the abovementioned four challenges.The complete single-circle detection process is schematically shown in Figure 1.Definition 6. Sample points denote pixels in an image.In this paper, the corresponding pixels are put into the coordinate system to explain the principle of each algorithm.Therefore, the pixels are called sample points.Definition 7. Data points in K-means algorithm represent the coordinate values of the center and radius of all candidate circles.

Methods
The algorithm is proposed for single-circle detection, which combines the DBSACN clustering algorithm, the least squares method (LS), and the K-means clustering algorithm.To briefly express our proposed algorithm, it is named as DBLSKCF algorithm.The four steps in the DBLSKCF algorithm respond to the abovementioned four challenges.The complete single-circle detection process is schematically shown in Figure 1.

•
Step 2. Selection of sample points for fitting curves.

•
Step 3. Iteration of candidate circles and determination of the ideal circles.

•
Step 4. Accuracy improvement of the output circle detection.

Image Edge Preprocessing
Image edge preprocessing is the foundation for extracting target edges and aims to highlight real and valuable information.However, the images often contain noise due to the impact of uncertainties, such as acquisition equipment and lighting conditions.Therefore, image edge processing, which consists of two key steps, Canny edge detection and main contour screening, can significantly improve single-circle detection performance.

Canny Edge Detection
Edge detection is used in many object edge detection applications to observe image features based on a significant change in the gray level.In addition, it can reduce the amount of data in an image while preserving its structural properties [21].Therefore, the classical Canny edge detection algorithm is used for the extraction of edge features in images [22].The edge detection accuracy depends on the thresholds, and a series of preexperiments are conducted to determine the appropriate thresholds.By analyzing the preexperimental results, applicable high and low thresholds are selected to extract information about the target edges.
Differentiation is the basis of gradient computation, which is very sensitive to the image's mutations (generally denotes noise).To improve the accuracy of the detection results, the image needs to be filtered before edge detection to remove interfering points and reduce pseudo edges.Gaussian filtering is effective in smoothing the image and reducing distracting points.

•
Step 2. Selection of sample points for fitting curves.

•
Step 3. Iteration of candidate circles and determination of the ideal circles.

•
Step 4. Accuracy improvement of the output circle detection.

Image Edge Preprocessing
Image edge preprocessing is the foundation for extracting target edges and aims to highlight real and valuable information.However, the images often contain noise due to the impact of uncertainties, such as acquisition equipment and lighting conditions.Therefore, image edge processing, which consists of two key steps, Canny edge detection and main contour screening, can significantly improve single-circle detection performance.

Canny Edge Detection
Edge detection is used in many object edge detection applications to observe image features based on a significant change in the gray level.In addition, it can reduce the amount of data in an image while preserving its structural properties [21].Therefore, the classical Canny edge detection algorithm is used for the extraction of edge features in images [22].The edge detection accuracy depends on the thresholds, and a series of pre-experiments are conducted to determine the appropriate thresholds.By analyzing the pre-experimental results, applicable high and low thresholds are selected to extract information about the target edges.
Differentiation is the basis of gradient computation, which is very sensitive to the image's mutations (generally denotes noise).To improve the accuracy of the detection results, the image needs to be filtered before edge detection to remove interfering points and reduce pseudo edges.Gaussian filtering is effective in smoothing the image and reducing distracting points.
The Gaussian kernel size and the standard deviation affect the filtering effect.The standard deviation in this algorithm uses the default parameter.To determine the optimal Gaussian kernel size, this section performs the filtering process by filtering three complex images with Gaussian kernel sizes of 5 × 5, 7 × 7, 9 × 9, 11 × 11, respectively.The filtered As shown in Figure 2, the Gaussian kernel size is 5 × 5, 7 × 7, and the corresponding edge detection results have many interfering points and pseudo edges around the detected edges.This phenomenon may reduce the single-circle detection accuracy.The filtering effect is better when the Gaussian kernel size is 9 × 9, 11 × 11.Nevertheless, excessive Gaussian kernel size may cause some target edges to be filtered out, which leads to significant deviations in the circle detection results.Thus, the Gaussian kernel size chosen in the DBLSKCF algorithm is 9 × 9.
Sensors 2023, 23, x FOR PEER REVIEW 5 of 23 The Gaussian kernel size and the standard deviation affect the filtering effect.The standard deviation in this algorithm uses the default parameter.To determine the optimal Gaussian kernel size, this section performs the filtering process by filtering three complex images with Gaussian kernel sizes of 5 × 5, 7 × 7, 9 × 9, 11 × 11, respectively.The filtered images are then subjected to edge detection using the Canny edge detection algorithm.The results are as follows.
As shown in Figure 2, the Gaussian kernel size is 5 × 5, 7 × 7, and the corresponding edge detection results have many interfering points and pseudo edges around the detected edges.This phenomenon may reduce the single-circle detection accuracy.The filtering effect is better when the Gaussian kernel size is 9 × 9, 11 × 11.Nevertheless, excessive Gaussian kernel size may cause some target edges to be filtered out, which leads to significant deviations in the circle detection results.Thus, the Gaussian kernel size chosen in the DBLSKCF algorithm is 9 × 9.

Main Contour Screening
Canny edge detection results show that the edges of the main contour are more tightly connected.Meanwhile, the interfering points are mostly irregularly distributed, making it difficult to form a complete edge.Even if these interfering points are connected to form an edge, the length of the edge will be much smaller than the length of the main contour.Based on this feature, the edge lengths are utilized to achieve the main contour screening.Precisely, we can calculate the length of each edge and arrange these lengths in descending order to obtain a sequence of edge lengths.We select a few longer edges to narrow the main contour range and determine the number of retained edges by setting a threshold.The calculation formula is as follows: where C m denotes the set of all edges before sorting,  1 ,  2 , ⋯ ,   represent the edge in the image, C s 0 denotes the set of the first s long edges after sorting,  1 0 ,  2 0 , ⋯ ,   0 denote the first s long edges after sorting, C p s denotes the set of pixels of the edges in C s 0 , and  1  ,  2  , ⋯ ,    denote the pixel at the edge in C p s .Please note that C p s is the pixel set output after the step of image edge preprocessing.

Main Contour Screening
Canny edge detection results show that the edges of the main contour are more tightly connected.Meanwhile, the interfering points are mostly irregularly distributed, making it difficult to form a complete edge.Even if these interfering points are connected to form an edge, the length of the edge will be much smaller than the length of the main contour.Based on this feature, the edge lengths are utilized to achieve the main contour screening.Precisely, we can calculate the length of each edge and arrange these lengths in descending order to obtain a sequence of edge lengths.We select a few longer edges to narrow the main contour range and determine the number of retained edges by setting a threshold.The calculation formula is as follows: where C m denotes the set of all edges before sorting, e 1 , e 2 , The threshold directly affects the accuracy and efficiency of single-circle detection.In the Canny edge detection algorithm, some irrelevant small edges may be detected due to noise, influencing the circle detection process.The DBLSKCF algorithm keeps a few edges with longer lengths to improve the accuracy and efficiency of circle detection.The length of the edges can be used to assess their continuity.Usually, longer edges are more representative of a part of the real-world circle.To determine the optimal number of retained edge, 4-8 long edges are kept for each of the images in Figure 2d, and the results are shown in Figure 3.
The threshold directly affects the accuracy and efficiency of single-circle detection.In the Canny edge detection algorithm, some irrelevant small edges may be detected due to noise, influencing the circle detection process.The DBLSKCF algorithm keeps a few edges with longer lengths to improve the accuracy and efficiency of circle detection.The length of the edges can be used to assess their continuity.Usually, longer edges are more representative of a part of the real-world circle.To determine the optimal number of retained edge, 4-8 long edges are kept for each of the images in Figure 2d, and the results are shown in Figure 3.To better express the significance of retaining different numbers of edges, the denoising ratio is introduced in this paper.As shown in Formula ( 4), the denoising rate indicates the ratio of the number of removed interfering points to the number of detected edge pixels, revealing the denoising ability of the image.The algorithm's performance under different interfering points levels can be evaluated by retaining the comparison experiments with distinct edges.The computational expression is as follows: where   means the number of pixels after edge detection.   indicates the number of pixels in the set C p s and  represents the denoising rate.Main contour screening aims to select the fitted sample points better.If the denoising rate is excessively low, it will lead to many interfering points in the fitted samples, which may reduce the accuracy and efficiency of the fitting.On the contrary, although raising the denoising rate reduces the number of interfering points, it may result in a lack of representative contour points in the fitted sample, adversely affecting the accuracy of the detecting results.The DBLSKCF algorithm integrates the final detection results while increasing denoising to ensure detection efficiency.Additionally, it chooses to retain six edges to obtain accurate fitting results.This strategy enables the DBLSKCF algorithm to obtain better results in real-world circle detection.
Image edge preprocessing improves the accuracy and efficiency of edge detection and provides reliable input data for the subsequent circle detection stage.The steps involved in image edge preprocessing are given in Algorithm 1.To better express the significance of retaining different numbers of edges, the denoising ratio is introduced in this paper.As shown in Formula ( 4), the denoising rate indicates the ratio of the number of removed interfering points to the number of detected edge pixels, revealing the denoising ability of the image.The algorithm's performance under different interfering points levels can be evaluated by retaining the comparison experiments with distinct edges.The computational expression is as follows: where N m means the number of pixels after edge detection.N p s indicates the number of pixels in the set C p s and β represents the denoising rate.Main contour screening aims to select the fitted sample points better.If the denoising rate is excessively low, it will lead to many interfering points in the fitted samples, which may reduce the accuracy and efficiency of the fitting.On the contrary, although raising the denoising rate reduces the number of interfering points, it may result in a lack of representative contour points in the fitted sample, adversely affecting the accuracy of the detecting results.The DBLSKCF algorithm integrates the final detection results while increasing denoising to ensure detection efficiency.Additionally, it chooses to retain six edges to obtain accurate fitting results.This strategy enables the DBLSKCF algorithm to obtain better results in real-world circle detection.
Image edge preprocessing improves the accuracy and efficiency of edge detection and provides reliable input data for the subsequent circle detection stage.The steps involved in image edge preprocessing are given in Algorithm 1.

Selection of Fitting Sample Points
The DBSCAN clustering algorithm separates the main contour sample points and interfering points.The algorithm clusters edges of arbitrary shapes and splits complex and irregularly shaped edges well using two parameters: the neighborhood radius and the minimum number of sample points within the circle determined by this neighborhood radius.
The DBSCAN algorithm clusters sample points into different classes based on the size of their neighborhood density.The clustering principle is shown in Figure 4. Formula ( 5) is used to classify the sample points.If the number of sample points in the neighborhood of sample point A is greater than or equal to the minimum number of sample points, the sample point A is classified as a core point.If the number of the sample points in B's neighborhood are less than the minimum number of sample points, point B is classified as a boundary point.If the number of sample points in N's neighborhood is 0, point N is classified as an outlier point.
where (x c , y c ) represent the coordinates of the sample point, C A denotes the set formed by the core point A, C B represents the set created by the boundary point B, and C N indicates the set created by the outlier point N. n ε indicates the number of sample points in a circle centered at (x c , y c ) with a radius of ε.Please note that after the screening of the fitted samples, the output is the set C A .
4: Calculate the C p s with (3).

Selection of Fitting Sample Points
The DBSCAN clustering algorithm separates the main contour sample point terfering points.The algorithm clusters edges of arbitrary shapes and splits comp irregularly shaped edges well using two parameters: the neighborhood radius and imum number of sample points within the circle determined by this neighborhood The DBSCAN algorithm clusters sample points into different classes based size of their neighborhood density.The clustering principle is shown in Figure 4.If the sample point is marked as the core point, the above clustering proces repeated for the sample points in the neighborhood until all sample points are m Two results occur after image preprocessing: the first is that the longest edg image includes only the main contour, as shown in Figure 5a; the other is that it both the main contour and the outer interfering points, as shown in Figure 5b.If cl results with fewer sample points selected for fitting, they may suffer from If the sample point is marked as the core point, the above clustering process will be repeated for the sample points in the neighborhood until all sample points are marked.
Two results occur after image preprocessing: the first is that the longest edge in the image includes only the main contour, as shown in Figure 5a; the other is that it contains both the main contour and the outer interfering points, as shown in Figure 5b.If clustering results with fewer sample points selected for fitting, they may suffer from image interfering points or broken edges.Therefore, the algorithm proposed in this paper retains the class with the most sample points.However, it is possible that interfering points that are close to the main contour are incorrectly clustered into fitted sample points due to unreasonable values of ε and n minpts .The algorithm specifically related to the selection of the fitted sample points is shown in Algorithm 2.

Candidate Circle Iteration and Ideal Circle Determination
A set of sample points with a main contour is obtained in Section 3.2, and the sample points show certain distributional features.
(1).Sample points on the main contour are connected into superior or inferior arcs.An arc with a central angle of less than or equal to 180° is called inferior arc, as shown in Figure 6a; an arc with a central angle of larger than 180° is called superior arc, as shown in Figure 6b.(2).Besides the sample points of the main contour, a few interfering points are distributed on the outer side of the main contour.Fitting candidate and ideal circles in such cases is studied in this section.

Candidate Circle Iteration and Ideal Circle Determination
A set of sample points with a main contour is obtained in Section 3.2, and the sample points show certain distributional features.
(1).Sample points on the main contour are connected into superior or inferior arcs.An arc with a central angle of less than or equal to 180 • is called inferior arc, as shown in Figure 6a; an arc with a central angle of larger than 180 • is called superior arc, as shown in Figure 6b.

Candidate Circle Iteration and Ideal Circle Determination
A set of sample points with a main contour is obtained in Section 3.2, and the sample points show certain distributional features.
(1).Sample points on the main contour are connected into superior or inferior arcs.An arc with a central angle of less than or equal to 180° is called inferior arc, as shown in Figure 6a; an arc with a central angle of larger than 180° is called superior arc, as shown in Figure 6b.(2).Besides the sample points of the main contour, a few interfering points are distributed on the outer side of the main contour.Fitting candidate and ideal circles in such cases is studied in this section.(2).Besides the sample points of the main contour, a few interfering points are distributed on the outer side of the main contour.Fitting candidate and ideal circles in such cases is studied in this section.
Based on the comparison of the RHT algorithm, RANSAC algorithm, and LSC algorithm in the literature review, the LSC algorithm has a better fitting circle effect.To improve the accuracy and efficiency of single-circle detection, the algorithm uses the residual sum of squares to fit the circles.
It can be seen from Figure 7a, when only the main contour sample points exist in the fitting sample, the fitting results are better.However, the traditional least squares method Sensors 2023, 23, 9030 9 of 23 is more sensitive to the interfering points, leading to errors in the results of the circle fitting, as shown in Figure 7b.To obtain the desired circle fitting results, this section proposes a method to remove the fitted failure points one by one based on the least squares method.This method introduces two parameters: the maximum number of iterations allowed and the critical residual sum of squares, based on the following principle (depicted in Figure 8).
Based on the comparison of the RHT algorithm, RANSAC algorithm, and LSC algorithm in the literature review, the LSC algorithm has a better fitting circle effect.To improve the accuracy and efficiency of single-circle detection, the algorithm uses the residual sum of squares to fit the circles.
It can be seen from Figure 7a, when only the main contour sample points exist in the fitting sample, the fitting results are better.However, the traditional least squares method is more sensitive to the interfering points, leading to errors in the results of the circle fitting, as shown in Figure 7b.To obtain the desired circle fitting results, this section proposes a method to remove the fitted failure points one by one based on the least squares method.This method introduces two parameters: the maximum number of iterations allowed and the critical residual sum of squares, based on the following principle (depicted in Figure 8).As shown in Figure 8 (take the example of three iterations), the upper left interfering points is biased relative to the other interfering points.The first candidate circle is biased to the top left, sensitive to the interfering points, and has a large residual sum of squares.Interfering points outside the candidate circle are removed by comparing the distance from the sample points to the circle's center with the radius.This sample point is kept if the distance is less than the radius.On the contrary, this sample point is deleted, as depicted in Figure 8a.Compared with Figure 8a, the distribution of sample points in Figure 8b are relatively uniform.As shown in Figure 8c, by removing the interfering points outside the candidate circle and fitting a third candidate circle, the fitted candidate circle gradually converges to the real-world circle.The specific iterative process is as follows: ∈ [1, ],  ∈  (6) Based on the comparison of the RHT algorithm, RANSAC algorithm, and LSC algorithm in the literature review, the LSC algorithm has a better fitting circle effect.To improve the accuracy and efficiency of single-circle detection, the algorithm uses the residual sum of squares to fit the circles.
It can be seen from Figure 7a, when only the main contour sample points exist in the fitting sample, the fitting results are better.However, the traditional least squares method is more sensitive to the interfering points, leading to errors in the results of the circle fitting, as shown in Figure 7b.To obtain the desired circle fitting results, this section proposes a method to remove the fitted failure points one by one based on the least squares method.This method introduces two parameters: the maximum number of iterations allowed and the critical residual sum of squares, based on the following principle (depicted in Figure 8).As shown in Figure 8 (take the example of three iterations), the upper left interfering points is biased relative to the other interfering points.The first candidate circle is biased to the top left, sensitive to the interfering points, and has a large residual sum of squares.Interfering points outside the candidate circle are removed by comparing the distance from the sample points to the circle's center with the radius.This sample point is kept if the distance is less than the radius.On the contrary, this sample point is deleted, as depicted in Figure 8a.Compared with Figure 8a, the distribution of sample points in Figure 8b are relatively uniform.As shown in Figure 8c, by removing the interfering points outside the candidate circle and fitting a third candidate circle, the fitted candidate circle gradually converges to the real-world circle.The specific iterative process is as follows: ∈ [1, ],  ∈  (6) As shown in Figure 8 (take the example of three iterations), the upper left interfering points is biased relative to the other interfering points.The first candidate circle is biased to the top left, sensitive to the interfering points, and has a large residual sum of squares.Interfering points outside the candidate circle are removed by comparing the distance from the sample points to the circle's center with the radius.This sample point is kept if the distance is less than the radius.On the contrary, this sample point is deleted, as depicted in Figure 8a.Compared with Figure 8a, the distribution of sample points in Figure 8b are relatively uniform.As shown in Figure 8c, by removing the interfering points outside the candidate circle and fitting a third candidate circle, the fitted candidate circle gradually converges to the real-world circle.The specific iterative process is as follows: For each iteration k, where k represents the current number of iterations and K represents the maximum number of iterations allowed; Q k indicates the residual sum of squares of the kth iteration; a * k , b * k , r * k indicate the center coordinate and radius of the kth iteration, respectively; and n ip denotes the number of sample points used for the iteration.The DBLSKCF algorithm obtains the optimal single-circle parameters by minimizing the residual sum of squares.Formula (6) is used to set a range of values for the number of iterations.The residual sum of squares for each fit is calculated by Formula (7).From Formula (7), it can be seen that where Q * denotes the critical residual sum of squares.(x i , y i ) represent the coordinates of the sample points.r ki denotes the distance from the sample points to the center of the circle at the kth iteration.Please note that after the candidate-circle iteration and ideal-circle determination, the center coordinates and radius of all candidate circles are obtained.
If the number of iterations is less than the maximum number of iterations allowed, or the residual sum of squares is greater than the critical residual sum of squares, then calculate the distance from each sample point to the center of the fitted circle using Formula (9).If the distance is less than the radius of the fitted candidate circle, the sample points are retained for the next fitting of the candidate circle.Instead, the sample points outside the fitted candidate circle are deleted.If K and Q * do not satisfy Formula (9), the iteration will be stopped, and the center coordinates and radius of the candidate circle are outputted.The corresponding algorithm for obtaining candidate and ideal circles are shown in Algorithm 3.
K and Q * are introduced to reduce the frequency with which underfitting or overfitting occurs.However, the numerical settings of the two parameters may lead to underfitting or overfitting.Under the joint action of the two parameters, ideal circle fitting results are shown in Table 1 below: From Table 1, it can be seen that different values affect the ideal circle to various degrees; and therefore, the optimal value of the parameter needs to be determined.In this paper, twenty-six complex images of different types are randomly selected, including dials, wheels, traffic signs, etc., and the plot of the residual sum of squares versus the number of iterations determines the optimal combination.
Theoretically, the result of circle fitting is the best when Q k is close to 0. To prevent overfitting, the value of Q k is set to 0.0005, as well as the value of K to 100.According to Figure 9f, it can be seen that the residual sum of squares in different types of complex images has an identical trend of change.Due to the irregular distribution of the interfering points, the residual sum of squares for the first iteration is large, and the second iteration has a significant decrease, with large changes in the center coordinates and radius of the circle.After four iterations, the residual sum of squares decreases to a relatively stable value.As shown in Figure 9g, only a few images are subjected to the seventh iteration, and the slopes on both sides changed less before and after the sixth iteration.With the increase in the number of iterations during the subsequent iterations, the residual sum of squares ceases to change or decline in a small range.Therefore, we set the maximum number of iterations allowed in the DBLSKCF algorithm to six.The minimum value of the residual sum of squares in the sixth iteration is 0.003, and it makes it most reasonable to set it to 0.003 to make more images with only six iterations in single-circle detection.It balances ideal circle detection accuracy and efficiency with and together.7) and ( 8).3: Calculate the r ki with (9).Theoretically, the result of circle fitting is the best when   is close to 0. To prevent overfitting, the value of   is set to 0.0005, as well as the value of  to 100.According to Figure 9f, it can be seen that the residual sum of squares in different types of complex images has an identical trend of change.Due to the irregular distribution of the interfering points, the residual sum of squares for the first iteration is large, and the second iteration has a significant decrease, with large changes in the center coordinates and radius of the circle.After four iterations, the residual sum of squares decreases to a relatively stable value.As shown in Figure 9g, only a few images are subjected to the seventh iteration, and the slopes on both sides changed less before and after the sixth iteration.With the increase in the number of iterations during the subsequent iterations, the residual sum of squares ceases to change or decline in a small range.Therefore, we set the maximum number of iterations allowed in the DBLSKCF algorithm to six.The minimum value of the residual sum of squares in the sixth iteration is 0.003, and it makes it most reasonable to set it to 0.003 to make more images with only six iterations in single-circle detection.It balances ideal circle detection accuracy and efficiency with and together.

Improvement of Output Circle Detection Accuracy
Section 3.3 determines the ideal circle by Q * and K, reducing the frequency of occurrence of overfitting and underfitting.Error exists between the ideal circle and real-world circle due to various interfering points.To improve the accuracy of output circle detection, this section adopts the K-means clustering algorithm in machine learning to cluster the center coordinates and radius of all candidate circles to achieve the purpose of error compensation for output circle parameters.The clustering process of the K-means clustering algorithm is illustrated in Figure 10.

Improvement of Output Circle Detection Accuracy
Section 3.3 determines the ideal circle by  * and , reducing the frequency of occurrence of overfitting and underfitting.Error exists between the ideal circle and realworld circle due to various interfering points.To improve the accuracy of output circle detection, this section adopts the K-means clustering algorithm in machine learning to cluster the center coordinates and radius of all candidate circles to achieve the purpose of error compensation for output circle parameters.The clustering process of the K-means clustering algorithm is illustrated in Figure 10.According to Figure 10, the data points are clustered into two clusters, and the clustering center is updated by calculating the distance from the data points to the clustering center.The distance is calculated using Formula (10), and the data points are assigned to the cluster with the closest distance.
,  ∈   (10) where   denotes the jth cluster and   denotes the clustering center;   indicates the number of data contained in the jth cluster;   represents the number of clusters;   denotes the data point in   ; and   denotes the distance from the data point to the corresponding clustering center.From the clustering principle, it is necessary to minimize the distance from the data points in each cluster to the corresponding cluster center.  is determined by taking partial derivatives of   to   .As shown in Formulas ( 11) and ( 12): The final clustering result is obtained by a continuous iteration of Formulas ( 11) and (12).In Section 3.3, we can determine that  is 6 and  * is 0.003.However, the final number of iterations may be less than 6.Therefore, the algorithm is discussed in terms of categorization based on the number of data points in the cluster results: (1) Different numbers of data points in the two clustering results.
When the numbers of data points in the two clustering results differ, the algorithm proposed choose the cluster with more data points as the target cluster.The reason is as follows: the K-means clustering algorithm clusters data points based on their distance According to Figure 10, the data points are clustered into two clusters, and the clustering center is updated by calculating the distance from the data points to the clustering center.The distance is calculated using Formula (10), and the data points are assigned to the cluster with the closest distance.
where S j denotes the jth cluster and B j denotes the clustering center; N j indicates the number of data contained in the jth cluster; n k represents the number of clusters; X i denotes the data point in S j ; and D j denotes the distance from the data point to the corresponding clustering center.
From the clustering principle, it is necessary to minimize the distance from the data points in each cluster to the corresponding cluster center.B j is determined by taking partial derivatives of D j to B j .As shown in Formulas (11) and (12): The final clustering result is obtained by a continuous iteration of Formulas ( 11) and (12).In Section 3.3, we can determine that K is 6 and Q * is 0.003.However, the final number of iterations may be less than 6.Therefore, the algorithm is discussed in terms of categorization based on the number of data points in the cluster results: (1) Different numbers of data points in the two clustering results.
When the numbers of data points in the two clustering results differ, the algorithm proposed choose the cluster with more data points as the target cluster.The reason is as follows: the K-means clustering algorithm clusters data points based on their distance from the clustering center.The fitting results for the first few iterations vary widely, and the clustering algorithm clusters these data points into one cluster.In the later iterations, the fitting results change stably.The clustering algorithm will cluster these data points into one cluster, and clustering centers are close to data points.Therefore, the target cluster can be obtained by filtering the number of data points.Clustering results with many data points are obtained through Formula (13).Calculate the mean value of the circle parameter of the cluster using Formula ( 14), which is the result of the error compensation for the output circle, as follows: where C 1 , C 2 indicate the set of data points in the results of the two clusters, respectively.f (•) is a function retaining the set with the most elements.C denotes the set of clustering results with more data points.n c represents the number of data points in set C. (x, y), r are the center coordinates and radius of the output circle, respectively.
(2) Same number of data points in two clustering results.
In this case, the algorithm selects clustering results based on the mean of the candidate circle radius.The reason is shown as follows: The fitting results for the first few iterations vary widely, and the clustering algorithm clusters these data points into one cluster.In the later iterations, the fitting results change stably.The mean of all candidate circles radius lie between the radius corresponding to the center of these two clusters.Formulas ( 15) and ( 16) are used to calculate the radius mean of the candidate circles in the two clustering results, respectively.Formula ( 17) are used to calculate the radius mean of all candidate circles.The target cluster is the cluster corresponding to the clustering result more minor than the mean by Formulas ( 18) and (19).
where r 1 denotes the mean of the radius of the candidate circles in set C 1 , r 2 denotes the mean of the radius of the candidate circles in set C 2 ,and r mean denotes the mean of the radius of all candidate circles.R represents the minimum value in r 1 , r 2 .n 1 and n 2 denote the number of data points in the two clustering results, respectively, and n R denotes the number of data points in the target cluster.Please note that the center coordinates and radius of the output circle are obtained after the improvement of output circle detection accuracy.The corresponding algorithm to obtain a high precision output circle is proposed.Please see Algorithm 4. In this paper, the algorithm that does not use K-means clustering is called the DBLSCF algorithm.The method will be verified via specific experiments in Section 4 to improve the accuracy of output circle.Output: Center coordinates (x, y) and radius r of the output circle.1: Initialize n k = 2. 2: According to the method in Section 3.4, the center coordinates are clustered into C 1 and C 2 , respectively.3: if num(C 1 ) is not equal to num(C 2 ) then 4: Calculate C with (13).5: Calculate (x, y) and r with (14).6: else 7: Calculate r 1 , r 2 and r mean with ( 15), ( 16) and ( 17), respectively.8: if r 1 < r mean then 9: (x, y), r = mean((a end if 13: end if

Experiments and Results
This section compares the DBLSKCF algorithm with the RANSAC, RHT, and DBLSCF algorithms regarding detection accuracy, efficiency, and stability.Two groups of experiments are launched.The first experiments in Section 4.1 are conducted under laboratory conditions, using images captured with various lighting intensities.The experiments are designed to evaluate the stability of the four algorithms under different lighting conditions.Section 4.2 aims to verify the accuracy and efficiency of the DBLSKCF algorithm by the GH dataset [23].The comparative experimental setup is as follows: (1).All experiments are carried out using the same computer.The computer parameters are shown in Table 2. (2).To comparatively validate the detection speed, the four algorithms are terminated as soon as a circle was detected in the image.

Comparison of Stability of Circle Detection
We use a mean light intensity of 650 lx and a standard deviation of 50 lx to simulate variations in light intensity and randomly select twenty-four datasets.The stability of the four algorithms in practical applications is evaluated by comparing the detection results under various light intensity.The edges detected in the experiment are selected to be the inner diameter edges of the steel pipe, accompanied by rust, scratches, and strong reflectivity on the end face.The experimental platform consists of an industrial camera, a white ring light source, and a tube sheet.The experimental platform is shown in Figure 11.
In the experiment, the center coordinates and the radius change are used as stability measures.Under various light intensities, if the center coordinates and radius only change in a small range, it indicates that the algorithm has high stability and can effectively resist external interference.On the contrary, the algorithm is less stable and less resistant to external interference.In the experiment, the center coordinates and the radius change are used as measures.Under various light intensities, if the center coordinates and radius only in a small range, it indicates that the algorithm has high stability and can effective external interference.On the contrary, the algorithm is less stable and less resista ternal interference.
From Figure 12, for the RHT, RANSAC, and DBLSCF algorithms, the algorit cle detection results under different light intensities are highly differentiated, and tection results of the DBLSKCF algorithm maintain almost the same.All results ar in Figure 13.With the increase in light intensity, the circle detection results of t algorithm change unstably.In contrast, the circle detection results of the RANSA rithm tend to be stable.In addition, the circle detection results of the DBLSK DBLSCF algorithms vary within a small range.We use the standard deviation fro 3 to measure the algorithm's stability better.A significant standard deviation i greater variability in the circle detection results, more excellent dispersion, and lo bility.Both in terms of coordinates of x and y, and radius, the detection results of algorithm have the more significant standard deviation and the worst stability.Th tion results of the RANSAC algorithm show substantial variations in the relative phase of light intensity and gradually stabilize with light intensity enhancement.tection results of the DBLSCF and DBLSKCF algorithms change almost synchro But by calculating the standard deviation, it is found that the DBLSKCF algori better stability.Therefore, the DBLSKCF algorithm has better stability and resis external interference.From Figure 12, for the RHT, RANSAC, and DBLSCF algorithms, the algorithm's circle detection results under different light intensities are highly differentiated, and the results of the DBLSKCF algorithm maintain almost the same.All results are shown in Figure 13.With the increase in light intensity, the circle detection results of the RHT algorithm change unstably.In contrast, the circle detection results of the RANSAC algorithm tend to be stable.In addition, the circle detection results of the DBLSKCF and DBLSCF algorithms vary within a small range.We use the standard deviation from Table 3 to measure the algorithm's stability better.A significant standard deviation indicates greater variability in the circle detection results, more excellent dispersion, and lower stability.Both in terms of coordinates of x and y, and radius, the detection results of the RHT algorithm have the more significant standard deviation and the worst stability.The detection results of the RANSAC algorithm show substantial variations in the relatively weak phase of light intensity and gradually stabilize with light intensity enhancement.The detection results of the DBLSCF and DBLSKCF algorithms change almost synchronously.But by calculating the standard deviation, it is found that the DBLSKCF algorithm has better stability.Therefore, the DBLSKCF algorithm has better stability and resistance to external interference.In the experiment, the center coordinates and the radius change are used as stability measures.Under various light intensities, if the center coordinates and radius only change in a small range, it indicates that the algorithm has high stability and can effectively resist external interference.On the contrary, the algorithm is less stable and less resistant to external interference.
From Figure 12, for the RHT, RANSAC, and DBLSCF algorithms, the algorithm's circle detection results under different light intensities are highly differentiated, and the detection results of the DBLSKCF algorithm maintain almost the same.All results are shown in Figure 13.With the increase in light intensity, the circle detection results of the RHT algorithm change unstably.In contrast, the circle detection results of the RANSAC algorithm tend to be stable.In addition, the circle detection results of the DBLSKCF and DBLSCF algorithms vary within a small range.We use the standard deviation from Table 3 to measure the algorithm's stability better.A significant standard deviation indicates greater variability in the circle detection results, more excellent dispersion, and lower stability.Both in terms of coordinates of x and y, and radius, the detection results of the RHT algorithm have the more significant standard deviation and the worst stability.The detection results of the RANSAC algorithm show substantial variations in the relatively weak phase of light intensity and gradually stabilize with light intensity enhancement.The detection results of the DBLSCF and DBLSKCF algorithms change almost synchronously.But by calculating the standard deviation, it is found that the DBLSKCF algorithm has better stability.Therefore, the DBLSKCF algorithm has better stability and resistance to external interference.

Validation of Algorithm Detection Accuracy and Efficiency
To verify the accuracy and efficiency of the algorithm in this paper, we validate it with the GH dataset.The images in the GH dataset cover a variety of scenes and backgrounds, including indoor and outdoor environments, different lighting conditions, and different levels of an object and background clutter.The GH dataset is therefore well suited for testing and training the robustness and generalization of circle detection algorithms.Forty-eight images with a single circle are selected from the GH dataset, each labeled with the corresponding circle parameter.
As seen from Figure 14, the single-circle detection results of the RANSAC, RHT, and DBLSCF algorithms show varying degrees of fitting error, and only the results of the DBLSKCF algorithm are closest to the real-world circle parameters.The four algorithms' circle detection results and running times are specified below.

Validation of Algorithm Detection Accuracy and Efficiency
To verify the accuracy and efficiency of the algorithm in this paper, we validate it with the GH dataset.The images in the GH dataset cover a variety of scenes and backgrounds, including indoor and outdoor environments, different lighting conditions, and different levels of an object and background clutter.The GH dataset is therefore well suited for testing and training the robustness and generalization of circle detection algorithms.Fortyeight images with a single circle are selected from the GH dataset, each labeled with the corresponding circle parameter.
As seen from Figure 14, the single-circle detection results of the RANSAC, RHT, and DBLSCF algorithms show varying degrees of fitting error, and only the results of the DBLSKCF algorithm are closest to the real-world circle parameters.The four algorithms' circle detection results and running times are specified below.
After analyzing Figure 15 and Table 4, the single-circle detection results of the RHT algorithm have high error and low efficiency.Please find Tables A1-A4 in the Appendix A for the data results of the experiments, respectively.The RANSAC algorithm performs better in efficiency, but has a higher error than the DBLSCF and DBLSKCF algorithms because, in the RHT and RANSAC algorithms, the sample points for fitting the circle are chosen randomly, resulting in the selected sample points not being points on the main contour.Since the DBLSCF algorithm outputs an ideal circle as an output circle, the ideal circle may be affected by interfering points, resulting in a significant deviation of the circle parameters.Thus, the circle detection accuracy of the DBLSKCF algorithm is 3-5 times higher than that of the DBLSCF algorithm.The experimental results also justify the K-means clustering algorithm to improve the accuracy of circle detection.Considering the circle detection accuracy and efficiency, the DBLSKCF algorithm is significantly better than the other compared algorithms.After analyzing Figure 15 and Table 4, the single-circle detection results of the RHT algorithm have high error and low efficiency.Please find Tables A1-A4 in the Appendix A for the data results of the experiments, respectively.The RANSAC algorithm performs better in efficiency, but has a higher error than the DBLSCF and DBLSKCF algorithms because, in the RHT and RANSAC algorithms, the sample points for fitting the circle are chosen randomly, resulting in the selected sample points not being points on the main contour.Since the DBLSCF algorithm outputs an ideal circle as an output circle, the ideal circle may be affected by interfering points, resulting in a significant deviation of the circle parameters.Thus, the circle detection accuracy of the DBLSKCF algorithm is 3-5 times higher than that of the DBLSCF algorithm.The experimental results also justify the K-means clustering algorithm to improve the accuracy of circle detection.Considering the circle detection accuracy and efficiency, the DBLSKCF algorithm is significantly better than the other compared algorithms.After analyzing Figure 15 and Table 4, the single-circle detection results of the RHT algorithm have high error and low efficiency.Please find Tables A1-A4 in the Appendix A for the data results of the experiments, respectively.The RANSAC algorithm perform better in efficiency, but has a higher error than the DBLSCF and DBLSKCF algorithms because, in the RHT and RANSAC algorithms, the sample points for fitting the circle are chosen randomly, resulting in the selected sample points not being points on the main contour.Since the DBLSCF algorithm outputs an ideal circle as an output circle, the idea circle may be affected by interfering points, resulting in a significant deviation of the circle parameters.Thus, the circle detection accuracy of the DBLSKCF algorithm is 3-5 times higher than that of the DBLSCF algorithm.The experimental results also justify th K-means clustering algorithm to improve the accuracy of circle detection.Considering the circle detection accuracy and efficiency, the DBLSKCF algorithm is significantly better than the other compared algorithms.

Conclusions
This paper proposes a single-circle detection algorithm, i.e., the DBLSKCF algorithm, that combines Canny edge detection, two clustering algorithms, and improved least squares method.The proposed algorithm has proven to be an excellent solution to single-circle detection in complex images.Compared with RHT, RANSAC, and DBLSCF, DBLSKCF demonstrates clear advantages in detection accuracy and stability.The highlights (and also the core steps) of the detection methods are summarized below: 1. Image edge preprocessing removes as many interfering points as possible while retaining the main contour edge information.2. The DBSCAN algorithm is utilized to cluster the main contours and interfering points into different clusters, from which the cluster with more sample points is extracted as the fitting samples of the candidate circles.3.An improved least square fitting of the circle with the residual sum of squares is raised.
Removing the fitting failure points one by one makes the circle fitting result gradually closer to the real-world circle.4. The K-means clustering algorithm is implemented to cluster the center coordinates and radius of all candidate circles to improve the accuracy of output circle detection.
Performance of the DBLSKCF algorithm: (1).Stability: The standard deviation of the X-coordinate, Y-coordinate, and radius detection results are 2.7 pixels, 2.3 pixels, and 3.27 pixels, respectively.(2).Detection accuracy: The average errors of X-coordinate, Y-coordinate, and radius detection are 1.8 pixels, 1.4 pixels, and 1.9 pixels, respectively.(3).Running time: The average running time is 0.1 s.
By comparing the detection performance with other algorithms, the proposed DBLSKCF algorithm outperforms in detection accuracy and stability.Future work will be carried out in two main perspectives: (1).Adaptively determining the neighborhood radius and the minimum number of sample points within the neighborhood radius in the DBSCAN clustering algorithm.( 2).An improvement of the proposed algorithm to enable multi-circle detection.
subjected to edge detection using the Canny edge detection algorithm.The results are as follows.

Algorithm 1 :
Image Edge PreprocessingInput: The image with a circle outline, the Gaussian kernel size k s , the number of retained edges s, threshold value 1 is th 1 and threshold value 2 is th 2 in Canny edge detection algorithm.Output: Edge pixels under retention.1: Initialize k s = 9, s = 6, th 1 = 200, th 2 = 255.2: Calculate the C m by Canny edge detection algorithm and Formula (1).3: Calculate the C 0 s with (2).4: Calculate the C p s with (3).
(5) is used to classify the sample points.If the number of sample points in the n hood of sample point A is greater than or equal to the minimum number of sampl the sample point A is classified as a core point.If the number of the sample poin neighborhood are less than the minimum number of sample points, point B is c as a boundary point.If the number of sample points in N's neighborhood is 0, p classified as an outlier point.{ (  ,   ) ∈ C A ,   ≥    (  ,   ) ∈ C B , 1 <   <    (  ,   ) ∈ C N ,   = 1 where (  ,   ) represent the coordinates of the sample point, C A denotes the set by the core point A, C B represents the set created by the boundary point B, and cates the set created by the outlier point N.   indicates the number of sample po circle centered at (  ,   ) with a radius of .Please note that after the screenin fitted samples, the output is the set C A .

Algorithm 2 :Figure 5 .Algorithm 2 :
Figure 5. DBSCAN clustering results: (a) main contour; (b) main contour and outer interfering points.Note: Different-colored sample points in the figure represent different clustering results.

Figure 5 .
Figure 5. DBSCAN clustering results: (a) main contour; (b) main contour and outer interfering points.Note: Different-colored sample points in the figure represent different clustering results.

Figure 5 .Algorithm 2 :
Figure 5. DBSCAN clustering results: (a) main contour; (b) main contour and outer interfering points.Note: Different-colored sample points in the figure represent different clustering results.
(a) Main contour sample points (b) Mian contour and interfering sample points
(a) Main contour sample points (b) Mian contour and interfering sample points

Figure 8 .
Figure 8. Principle of the method for removing the fitted failure points one by one based on the least squares method: (a) fitting of the first candidate circle; (b) fitting of the second candidate circle; (c) fitting of the third candidate circle.

Algorithm 3 :
Fit Candidate Circles and Determine Ideal Circles Input: The edge set C A in Algorithm 2, the maximum number of iterations allowed K, the critical residual sum of squares Q * , the iteration number k. Output: Center (a * k ,b * k ) and radius r * k of the candidate circle.1: Initialize K = 6, Q * = 0.003, k = 1.2: Calculate the Q k , (a * k ,b * k ) and r * k with (

Figure 9 .
Figure 9. Determination of the optimal critical residual sum of squares and the maximum number of iterations allowed; (a-e) denote the detection results of circles in different complex scenarios; (f) shows the plot of the residual sum of squares versus the number of iterations; (g) represents the localized zoomed-in view after four iterations in (f).

Figure 9 .
Figure 9. Determination of the optimal critical residual sum of squares and the maximum number of iterations allowed; (a-e) denote the detection results of circles in different complex scenarios; (f) shows the plot of the residual sum of squares versus the number of iterations; (g) represents the localized zoomed-in view after four iterations in (f).

Figure 10 .
Figure 10.Schematic diagram of clustering process of K-means algorithm.(a) Original data points.(b) Start of clustering.(c) Clustering result.

Figure 10 .
Figure 10.Schematic diagram of clustering process of K-means algorithm.(a) Original data points.(b) Start of clustering.(c) Clustering result.

Algorithm 4 :
Improve the Output Circle's Detection Accuracy Input: The k-means algorithm clustering number n k , center (a * k ,b * k ) and radius r * k of the candidate circle in Algorithm 3.

Figure 12 .
Figure 12.Circle detection results under various light intensities.From top to bottom: the light intensity is 598 lx, 645 lx, and 686 lx, respectively.(a) Original image; (b-e) denote the single-circle detection results of the RANSAC, RHT, DBLSCF, and DBLSKCF algorithms, respectively.

Figure 12 .
Figure 12.Circle detection results under various light intensities.From top to bottom: the light intensity is 598 lx, 645 lx, and 686 lx, respectively.(a) Original image; (b-e) denote the single-circle detection results of the RANSAC, RHT, DBLSCF, and DBLSKCF algorithms, respectively.

Figure 12 .Figure 13 .
Figure 12.Circle detection results under various light intensities.From top to bottom: the light intensity is 598 lx, 645 lx, and 686 lx, respectively.(a) Original image; (b-e) denote the single-circle detection results of the RANSAC, RHT, DBLSCF, and DBLSKCF algorithms, respectively.

Figure 13 .
Figure 13.Detection results of four algorithms under various light intensities.(a) X-coordinate change.(b) Y-coordinate change.(c) Radius change.

Figure 15 .
Figure 15.Detection results of different images for four algorithms.(a) X-coordinate error.(b) Ycoordinate error.(c) Radius error.(d) Running time.Note: Where the RHT algorithm has circle detection failures for a few images in the dataset, these are represented by breakpoints.

Figure 15 .
Figure 15.Detection results of different images for four algorithms.(a) X-coordinate error.(b) Ycoordinate error.(c) Radius error.(d) Running time.Note: Where the RHT algorithm has circle detection failures for a few images in the dataset, these are represented by breakpoints.

Table 1 .
Effect of K and Q * on the ideal circle fitting result.

Table 2 .
Specific parameters of the operating computer.

Table 3 .
Standard deviation of circle detection results for four algorithms.

Table 3 .
Standard deviation of circle detection results for four algorithms.

Table 3 .
Standard deviation of circle detection results for four algorithms.

Table 4 .
Comparison of circle detection mean value.

Table 4 .
Comparison of circle detection mean value.
Note:The "-" in the table means that the algorithm did not detect the circle in the corresponding image.
Note:The "-" in the table means that the algorithm did not detect the circle in the corresponding image.
Note:The "-" in the table means that the algorithm did not detect the circle in the corresponding image.