# Quantitative Evaluation Method for the Severity of Surface Fuzz Defects in Carbon Fiber Prepreg
## 2 Materials and Methods  
### Selection of Defective Pixels  
The first step in the proposed method involves converting the color image into a grayscale image, followed by the selection of defective pixels based on the grayscale representation. Due to the inherently uneven surface color distribution in carbon fiber prepreg, global grayscale thresholding proves insufficient for effectively distinguishing defects from the background while suppressing noise and illumination variations. To address this challenge, a localized thresholding strategy is adopted, taking into account the characteristics of the prepreg background--specifically, its irregular horizontal variations and relatively subtle vertical changes. In this approach, the average grayscale value of a local region is utilized as the threshold for segmentation, thereby improving the robustness and accuracy of defect pixel identification under varying background conditions. To determine whether a given pixel contains a fuzz defect, a local grayscale analysis is performed. Specifically, the average grayscale value of a \((2\times\mathrm{p}+1)\times(2\times\mathrm{p}+1)\) neighborhood centered at the target pixel is calculated. This process is equivalent to applying a mean filter using a square convolution kernel of size \((2\times\mathrm{p}+1)\times(2\times\mathrm{p}+1)\), which helps suppress local noise and smooth intensity variations for more reliable defect detection. The mathematical formulation for the mean grayscale value is given by the following:  
\[\mathrm{img}_{\mathrm{mean}}(\mathrm{x},\mathrm{y})=\frac{1}{(2\times\mathrm{ p}+1)^{2}}\sum_{\mathrm{i=x-y}}^{\mathrm{x+p}}\sum_{\mathrm{j=y-p}}^{\mathrm{y+p}} \mathrm{img}(\mathrm{i},\mathrm{j}) \tag{1}\]  
In Equation (1), \(\mathrm{m}\times\mathrm{n}\) represents the dimension of the input grayscale image, where \(\mathrm{m}\) and \(\mathrm{n}\) represent the number of rows and columns, respectively. The \(\mathrm{img}_{\mathrm{mean}}\) is generated from the original image by applying a mean filter with convolution kernels of size \((2\times\mathrm{p}+1)\times(2\times\mathrm{p}+1)\), thereby achieving local intensity smoothing and background balance. Average the pixel grayscale values along the row direction of the image to generate an \(\mathrm{a1}\times\mathrm{n}\) vector. The method is to repeatedly fill the image and calculate the average grayscale of \(\mathrm{m}\times(2\times\mathrm{p}+1)\) pixels centered on the pixel to obtain an \(\mathrm{a1}\times\mathrm{n}\) sequence, as follows:  
\[\mathrm{meangray1}(\mathrm{y})=\frac{1}{(2*\mathrm{p}+1)*\mathrm{m}}\sum_{ \mathrm{i=1}}^{\mathrm{m}}\sum_{\mathrm{j=y-p}}^{\mathrm{y+p}}\mathrm{img}( \mathrm{i},\mathrm{j}) \tag{2}\]  
Here, the \(\mathrm{i}\)-th element in the summation corresponds to the \(\mathrm{i}\)-th row, and \(\mathrm{j}\) spans the \((2\times\mathrm{p}+1)\) pixel window centered at column \(\mathrm{y}\). This operation provides a column-wise reference of the average grayscale value, which is used for subsequent thresholding. Based on the results of Equations (1) and (2), a binary mask is constructed to identify the fuzz defect regions. The mask is defined using a threshold criterion that compares the local mean grayscale value \(\mathrm{img}_{\mathrm{mean}}\) ith mean gray, as follows:  
\[\mathrm{mask1}(\mathrm{x},\mathrm{y})= \begin{cases}1,\mathrm{img}_{\mathrm{ mean}}(\mathrm{x},\mathrm{y})>\mathrm{meangray1}(\mathrm{y})*1.1\\ 0,\mathrm{img}_{\mathrm{mean}}(\mathrm{x},\mathrm{y})<\mathrm{meangray1}( \mathrm{y})*1.1\end{cases}  \tag{3}\]  
The resulting image mask1 is the mask of the fuzz region selected through the first threshold. For images with a ratio of \(\mathrm{m}\) to \(\mathrm{n}\) greater than 3, using the average grayscale of the pixels as the threshold is too high due to the excessive presence of fuzz areas within the \(\mathrm{m}\times(2\times\mathrm{p}+1)\) pixels. The maximum value of \(\mathrm{m}\) is 4096, and the maximum value of \(\mathrm{n}\) is 1366.