# End Face Attitude Detection of Special Steel Bars Based on Improved DBSCAN
## 3 Proposed End Face Attitude Detection Algorithm for Special Steel Bars
### Circle Parameter Clustering Based on Improved DBSCAN  
The circle parameters of the marking results are calculated using the method described in Section 2.2.1, and all circle parameters are shown in Figure 5a. In order to obtain the circumcircle parameters of the steel bar's end face accurately, data filtering is added to DBSCAN as an improved method to reduce the large amount of useless data involved in clustering. The improved DBSCAN implementation steps are as follows:  
1. In order to reduce the large amount of useless data involved in clustering, and the circle parameter filtering is completed according to the following steps: 1. The coordinates of the circle center are set as the X and Y axes, respectively, and the coordinates of the radius are set as the Z axis. At this time, all the circle parameters \((x,y,r)\) are mapped to a three-dimensional coordinate \((x,y,z)\). 2. According to Equation (8), the number of data \(N_{j}\) is counted in the j-th cube, whose side length is \(G\), and the density values of cubes \(DY_{j}\) are acquired. 3. We set the cube density threshold to be \(TH_{cube}\); when density value of a cube is \(DY_{j}<TH_{cube}\), delete all data points in the cube, otherwise reserve them. The data filtering of the circle parameter data is completed. The result of the filtering can be seen in Figure 5b, and the same color in Figure 5b indicates that the filtered circle parameter data belong to the same connected region. After filtering, most of the invalid circle parameters are filtered out. 2. The core object, clustering number, unvisited sample set, and cluster division are initialized to \(\Omega=\phi\), \(k=0\), \(\Gamma=D\), and \(C=\phi\), respectively. 3. For \(j=1,2,\cdots,m\), all core objects are found as follows: 1. The sample number \(\left|N_{\varepsilon}(d_{j})\right|\) of the \(\varepsilon-\) neighborhood subsample set of \(d_{j}\) is calculated using distance measurements. 2. If the number of samples in the subsample set satisfies \(\left|N_{\varepsilon}(d_{j})\right|>Min\)_Pts_, the sample \(d_{j}\) is added to the core object sample set \(\Omega=\Omega\cup\left\{d_{j}\right\}\). 4. If the core object is \(\Omega=\phi\), the algorithm is ended, otherwise go to step (5). 5. In the core object set \(\Omega\), a core object \(A\) is selected randomly; the current cluster core object set, clustering number, the current cluster sample set. and the unvisited sample set are updated to \(\Omega_{\text{cur}}=\left\{A\right\}\), \(k=k+1\), \(C_{k}=\left\{A\right\}\), and \(\Gamma=\Gamma-\left\{A\right\}\), respectively. 6. If the current cluster core object queue \(\Omega_{\text{cur}}=\phi\), the current cluster \(C_{k}\) is generated, and the cluster division and the new core object set are updated to \(C=\left\{C_{1},C_{2},\cdots,C_{k}\right\}\) and \(\Omega=\Omega-C_{k}\), respectively, then go to step (4). 7. A core object \(A^{\prime}\) is fetched from the current cluster core object queue \(\Omega_{\text{cur}}\), the sample number \(N_{\varepsilon}(A^{\prime})\) of the \(\varepsilon-\) neighborhood subsample set is found according to the distance neighborhood; let \(\Delta=N_{\varepsilon}(A^{\prime})\cap\Gamma\), and the current cluster sample set, the unvisited sample set, and the current cluster core object queue are updated to \(C_{k}=C_{k}\cup\Delta\), \(\Gamma=\Gamma-\Delta\), and \(\Omega_{\text{cur}}=\Omega_{\text{cur}}\cup(\Delta\cap\Omega)-A^{\prime}\), then go to step (6). The output results are cluster division \(C=\left\{C_{1},C_{2},\cdots,C_{k}\right\}\), the final clustering results are shown in Figure 5c, and the same color data in Figure 5c indicate that they belong to the same clustering result. According to Figure 5, the DBSCAN clustering method with a dedicated filter significantly reduces interference from non-circular parameters. Due to the reduction in the amount of data involved in the calculation, the algorithm's clustering efficiency is also improved.