# Laser Spot Centering Algorithm of Double-Area Shrinking Iteration Based on Baseline Method
## 3 Realization Principle of Proposed Approach
### Spot Center Locating Method  
In accordance with the definition of ISO standards, the laser spot centroid and beam width can be calculated using the first-order moment and the second-order moment, respectively [22]. Our method makes improvements on this basis to search for the effective spot area iteratively under the premise of eliminating background noise effectively to enable a more precise computation of spot center.  
The approach uses the background noise baseline and the OTSU method to binarize the collected laser spot image. Then, the eight-neighbor connectivity algorithm is used to process the binary image and define the connected domain with the largest area as the first spot area \(I_{1}\) and the second spot area \(I_{2}\). \(D_{x}\) and \(D_{y}\) are the spot area diameters in the x- and y-directions, respectively. The result is shown in Figure 4.  
The initial spot center and radius can be obtained by calculating the pixels in the spot area according to Equations (12) and (13) after determining the initial spot area.  
\[\left\{\begin{array}{l}C_{xx}=\frac{\sum\limits_{i=1}^{\frac{n}{\sum \limits_{j=1}^{n}}i\times\left(I_{k}(i,j)-S_{k}\right)}}{\sum\limits_{i=1}^{ \frac{n}{\sum\limits_{j=1}^{n}}i\times\left(I_{k}(i,j)\right)}}\\ C_{yk}=\frac{\sum\limits_{i=1}^{\frac{n}{\sum\limits_{j=1}^{n}}i\times\left( I_{k}(i,j)-S_{k}\right)}}{\sum\limits_{i=1}^{\frac{n}{\sum\limits_{j=1}^{n}}i \times\left(I_{k}(i,j)\right)}}\\ \end{array}\right., \tag{12}\]  
\[\left\{\begin{array}{l}R_{xx}=2\times\sqrt{\frac{\sum\limits_{i=1}^{\frac{n} {\sum\limits_{j=1}^{n}}i\left(i-C_{xh}\right)^{2}\times\left(I_{k}(i,j)-S_{k} \right)}}}{\sum\limits_{i=1}^{\frac{n}{\sum\limits_{j=1}^{n}}i\left(I_{k}(i,j) -S_{k}\right)}}\\ R_{yk}=2\times\sqrt{\frac{\sum\limits_{i=1}^{\frac{n}{\sum\limits_{j=1}^{n}}i \left(j-C_{yk}\right)^{2}\times\left(I_{k}(i,j)-S_{k}\right)}}{\sum\limits_{i= 1}^{\frac{n}{\sum\limits_{j=1}^{n}}i\left(I_{k}(i,j)-S_{k}\right)}}}\\ \end{array}\right., \tag{13}\]  
where \(k=1\) represents the first spot area, and \(k=2\) represents the second spot area. (\(C_{xk}\), \(C_{yk}\)) represents the center coordinates. \(R_{xk}\) is the spot radius in the x-axis direction, and \(R_{yk}\) is the spot radius in the y-axis direction. \(S_{k}\) is the spot noise baseline. The first  
Figure 4: Center location method of laser spot area shrinking iteration.  
spot noise baseline is the background noise baseline (i.e., \(S_{1}=B\)). The second spot noise baseline is the average value of all the pixel values that are lower than the background noise baseline in the effective area obtained after doubling the second spot area, and, if no pixel value exists below the background noise baseline in the effective area of the light spot, then \(S_{2}=B\).  
Given an initial value \(\xi\), if \(R_{x1}-R_{x2}>\xi\), \(R_{y1}-R_{y2}>\xi\), then the x-axis direction of the first spot area is reduced by \(R_{x1}-\frac{D_{x1}}{4}\), and the y-axis direction of the first spot area is reduced by \(R_{y1}-\frac{D_{y1}}{4}\), the x-axis direction of the second spot area is extended by \(R_{x2}-\frac{D_{y2}}{4}\), and the y-axis direction of the second spot area is extended by \(R_{y2}-\frac{D_{y2}}{4}\). When the spot area is changed, the spot center and radius are recalculated iteratively until the radius difference between the two spots is less than \(\xi\), then the iterative convergence condition is met, and the final real spot center is obtained. The real spot center takes the mean value that corresponds to the center of the two spot areas. The same result can be obtained, and, if \(R_{x2}-R_{x1}>\xi\), \(R_{y2}-R_{y1}>\xi\), then the principle is the same.