## 2.2 Recognition of the profile and area of burr

The optical pathway inside drilled holes has minimal reflections due to the use of low-angle lighting when taking micrographs[13]. Therefore, the drilled holes are usually the dark region separating from other regions (see Fig. 3). The profile and area of burr can be obtained by extracting the profile and area of drilled holes. As seen in Fig. 3 (a-h), the detailed procedures are as follows:

(ⅰ) Considering the purpose of the proposed method is to automatically detect CFRPs defects in large quantities, the captured micrographs are converted into the gray images (see Fig. 3b), which could improve the speed of detection.

(ⅱ) Due to the similarity of visual features between noise and defect area, the noise will influence the results of image processing, so image filtering is required. Figure 3 (c) separately gives the filtering results by using three classic filtering algorithms including mean filter, median filter, and Gaussian filter. It clearly shows that the median filter could remove noise effectively. With a 3*3 kernel size of median blur, the pixels covered by the kernel are ordered from smallest to largest, and then take the median of all pixels in the kernel instead of the pixel in the center of a kernel. The noise could be removed to improve image quality.

(ⅲ) From Fig. 3 (d), it can be seen that the captured images have bimodal histograms. To separate the area of drilled holes from the micrographs, a method based on adaptively locating the thresholds on the minima between the histogram peaks is used. First, get all “gray levels – Number of pixels” coordinate points in the histogram and connect them into curve. The first minima on the curve is set as the threshold. Because the curve connected by these coordinate points is not smooth enough, it cannot accurately judge whether the first minima of the curve is the pixel value at the trough. To solve this problem, one-dimensional Gaussian filtering is employed to smooth the curve, and the gray level of the first minima, the desired threshold, can be accurately determined by the argrelextrema function in Python (see Fig. 3e). Then, the micrographs are binarized using captured thresholds with two values, 0 (black) for the background and 255 (white) for the region of drilled holes (see Fig. 3f). Finally, the cv2.fillPoly function in OpenCV is applied to fill small noise region.

(ⅳ) Fig. 3 (g) shows the burr profile (blue) extracted by applying the cv2.findContours function and the information of all profile points can be obtained. Then, cv2.MinEnclosingCircle function is applied to obtain the minimum enclosing circle of drilled hole (nominal hole) using the information. The area of burr is shown in the Fig. 3 (h).

## 2.3 Recognition of the profile and area of delamination

After the recognition of burr, the part of delamination is detected by the following steps:

(ⅰ) Considering the opposite distribution of two defects, the region of burr should be excluded in this process. Therefore, the nominal hole defined by previous step is set as the mask, and then the region of delamination is processed independently. After masking the region of burr, the micrographs mainly include three parts: area of delamination, area of nominal hole (mask) and other area (see Fig. 4a).

(ⅱ) Then the K-means segmentation is adopted to segment the delamination. Here the K-means segmentation method is based on Ref[14, 15]. Rather than calculating the threshold from the final partition, the segmentation result is determined by the number of pixels of three classes (i.e. three parts mentioned in step (ⅰ)).

Let *f*(*x*, *y*) denote the input pixels at the position (*x*, *y*). Considering reducing calculation amount, the input pixels are given normalization (see Fig. 4b). Therefore, The image with resolution of *N* = *m*×*n* can be presented by a data matrix :

$$l\left(x,y\right)=\frac{f(x,y)}{256},$$

1

$${\left[F(x,y)\right]}_{N}=\left[l\left(x,y\right)\right],$$

2

Hence, randomly select three centroids *c**k* (*k* = 1, 2, 3) from the normalized pixels in [*F*(*x*, *y*)]*N*. The method assigns the pixels to the nearest centroid based on the Euclidean distance *d*:

$$d=‖l\left(x,y\right)-{c}_{k}‖,$$

3

After the assignment of all pixels, new cluster centers *c**k* for each cluster are recalculated below:

$${c}_{k}=\frac{1}{k}\sum _{y\in {c}_{k}}\sum _{x\in {c}_{k}}l(x,y),$$

4

Repeat the process until the positions of the cluster centers no longer change. Therefore, *N**del*, *N**nom*, *N**other* respectively refer to number of pixels in area of delamination, area of nominal hole and other area. It can be found from Fig. 4 (a) and (c) that according to the size of order, *N**del* has the fewest number of pixels. Thus, the class of the fewest number of pixels is the target class (i.e. class of delamination). If the pixels are owing to the target class, the gray levels of the pixels are set as 255, if not, the gray levels are set as 0. Figure 4 (d) presents the result by performing the K-means segmentation method. A defined threshold based on area size can remove the remaining small noise (see Fig. 4e).

(ⅲ) The next step to identify the delamination is to extract the contour of delamination. Firstly, the coordinate values of all pixels in the image (in the Cartesian coordinate system, see Fig. 4 (f)) that are classed as delamination pixels are obtained, and then they are converted into polar coordinates, as shown in Fig. 4 (g). The transition can be expressed as Eq. (5), Eq. (6) and Table 1:

$${x}_{i}=i-{x}_{center},$$

5

$${y}_{i}=j-{y}_{center},$$

6

**Table 1 **Coordinate transformation of points in the 4 quadrants

Where (*i*, *j*) and (*x**center*, *y**center*) respectively denote the coordinate position of the pixels in the micrograph and the center point of drilled holes in Cartesian coordinate system. Thus, (*x**i*, *y**i*) refers to the coordinate position of pixel (*i*, *j*) after moving the Cartesian origin coordinate to the center of drilled holes.

In the polar coordinate system, the pole is the center of drilled hole, and the ray *ox* from *o* is the polar axis. The positive direction of polar coordinate system is set to be clockwise, which is same as the scanning direction (see Fig. 4h). With 1°interval of the polar angle, the polar coordinates of all pixels on the ray in this angle are obtained. After obtaining all polar coordinates on 360 rays along the circumstance, a scatter plot is drawn (shown as Fig. 4i). If there have pixels of delamination (i.e. the white pixels in Fig. 4h) at this angle, the pixel with the longest polar radius in the delamination region at this angle is obtained. While if there has no pixel of the delamination region at this angle, the polar radius of the pixel at this angle is set as the drilled hole radius. In this example, the drilled hole radius is 255 pixel. The connecting line of these pixels is the contour of the delamination (see Fig. 4j), and Fig. 4 (k) shows the result of recognition of the contour of delamination.

## 2.4 Quantification of CFRPs defects

After recognizing the CFRPs defects, they need to be evaluated. To date, multiple methods have been approached for quantifying burr and delamination in former researches. For burr damage, burr factor *F**b* is the most commonly used evaluation criterion. It is calculated as expressed in Eq. (7)[16, 17] and shown in Fig. 5(a), (b) and (c)[18].

$${F}_{b}=\frac{{A}_{nom}-{A}_{free}}{{A}_{nom}}\bullet 100=\frac{{A}_{b}}{{A}_{nom}}\bullet 100,$$

7

where *A**nom* denotes the nominal area of drilled hole, *A**free* represents the burr-free area of drilled hole, and *A**b* is the burr area.

For delamination defect, the most conventionally used delamination evaluation criterion is the delamination factor *F**d* proposed by Chen. The delamination factor *F**d* is defined as the ratio of the maximum circle diameter *D**max* to the nominal drilled hole diameter *D**nom*, which can be expressed as Eq. (8)[19] and illustrated in Fig. 5 (d)[20].

$${F}_{d}=\frac{{D}_{max}}{{D}_{nom}},$$

8

The above two convenient evaluation criterions *F**b* and *F**d* are very useful for a fast quantification. Therefore, in this study, *F**b* and *F**d* are used for the evaluation of drilling-induced damages. The pixels of nominal hole and drilled hole are used for extracting *A**nom* and *A**free*, respectively. In addition, the minimum enclosing circle of the drilled hole and the mask are used for calculating *F**d*.