## 3 Methodology
### Quantitative Evaluation of Defect Severity  
After completing the clustering step, we obtained different defect types and the three-dimensional coordinates of all defect points. This facilitated the quantification of defect severity. As shown in Figure 11c, defect depth is the easiest to quantify. By traversing all points within the defect region, points with the same x-coordinate correspond to the same standard fitting curve along the y-direction. By substituting their respective y-coordinates into the standard fitting curve, the fitted z-values can be obtained. The difference (residual) between the fitted z-values and the actual z-values represents the defect depth. The maximum residual from all points corresponds to the maximum depth of the defect, highlighting the importance of fitting.  
For length and width, the defect length refers to the distance along the maximum extension direction in the 2D space, while the width refers to the maximum extent in the direction perpendicular to the length. These directions correspond to the first and second principal components in PCA [87], respectively. Specifically, the covariance matrix of the defect point cloud was first computed using PCA, from which eigenvalues were derived. The eigenvector corresponding to the largest eigenvalue represented the longest direction of the defect region (i.e., the length direction). The maximum projection range was then calculated, which represented the defect length. Let the coordinates of a defect point be (\(x_{i}\), \(y_{i}\), \(z_{i}\)), then the relevant calculation expressions are as follows:  
\[\mathbf{M}=\frac{1}{n-1}\sum_{i=1}^{n}(x_{i}-\mu_{x})(x_{i}-\mu_{x})^{T} \tag{20}\]  
where \(\mathbf{M}\) represents the covariance matrix, \(\mu_{x}\) is the mean of the coordinates of the points, and \(n\) denotes the number of points. An eigenvalue decomposition was then performed according to Equation (20) to obtain the eigenvectors:  
\[\mathbf{M}\
u=\lambda\
u \tag{21}\]  
where \(\lambda\) represents the eigenvalues, and \(\
u\) represents the eigenvectors. Assuming \(\
u_{1}\) and \(\
u_{2}\) denote the vectors corresponding to the first and second principal components, respectively, the length (\(L\)) and width (\(\mathbf{W}\)) of the defect can then be calculated using the following expressions:  
\[L=max(\mathbf{P}\cdot\
u_{1})-min(\mathbf{P}\cdot\
u_{1}) \tag{22}\]  
\[W=max(\mathbf{P}\cdot\
u_{2})-min(\mathbf{P}\cdot\
u_{2}) \tag{23}\]  
where \(\mathbf{P}\) represents the point cloud coordinate matrix.  
Notably, we could also quantify irregular areas. As shown in Figure 11b, the contours in the x-direction are ideally straight lines, and the corresponding height values, i.e., z-axis coordinates, are constants. When surface irregularities occur, the fitted contour in the x-direction becomes a line represented by a first-degree polynomial, which forms an angle with the ideal contour line. If this angle exceeds a certain threshold, the contour is considered irregular, and points with z-axis values above or below this constant are marked as defect points. The constant value corresponding to each contour is determined by the average z-axis coordinate value of all points on that contour.  
Figure 11: Illustration of defect quantification analysis: (**a**) defective magnet tile; (**b**) deviation along x-direction; (**c**) deviation along y-direction.