# Detection of Defective Features in Cerasus Humilis Fruit Based on Hyperspectral Imaging Technology
## 3 Results and Discussion
### Image Information Detection
#### 3.4.2 Defective Features Identification Algorithm  
It can be seen from the above studies that the characteristic wavebands extracted by CARS are more suitable for the natural damage detection of _Cerasus humilis_ fruit. Considering that there are adjacent bands in the 13 characteristic wavebands extracted by the CARS algorithm, the problem of strong collinearity exists between these adjacent wavebands. According to the corresponding reflectivity value of different wavebands, the waveband with a higher reflectivity value is selected as the optimal characteristic waveband [26]. Therefore, images with characteristic wavebands of 950, 994, 1071,1263, 1336, 1457, 1542, and 1628 nm were selected for the PCA to obtain the first eight PC images of the samples. These were combined with image processing technology and the defect sample of _Cerasus humilis_ fruit was segmented. Take the cracked fruit sample as an example to explain the steps of the defect feature identification algorithm, as shown in Figure 9. Figure 9a shows a hyperspectral image of a cracked fruit sample at the full wavelength range. Figure 9b shows the single-band grayscale images corresponding to the eight characteristic wavebands. It can be seen that the cracked features in the images at 950 nm and 1071 nm are not obvious, meaning they could not be used as feature images. After subjecting the feature band images to PCA, the first seven PC images were obtained, as shown in Figure 9c. PC-1 contains the  
\begin{table}
\begin{tabular}{c c c} \hline
**PCs** & **Characteristic Value** & **Contribution Rate (\%)** \\ \hline
1 & 36,533.0293 & 82.59 \\
2 & 9624.0304 & 98.23 \\
3 & 1429.6619 & 99.67 \\
4 & 820.7365 & 99.89 \\
5 & 213.8658 & 99.93 \\
6 & 87.8165 & 99.96 \\
7 & 11.3969 & 99.99 \\
8 & 2.3585 & 100.00 \\ \hline \end{tabular}
\end{table}
Table 4: The cumulative contribution rate of the first eight principal components of the image.  
most original data information, but most of this information concerned the surface contour. The information on the cracked region in the PC-3 image is the most obvious, and the cracked region can be clearly identified. We can select the gray-scale image at PC-1 for mask processing and obtain the mask templates seen in Figure 9d. However, there are two gaps in the mask template image, which might be caused by strong light shining on the smooth skin of the _Cerasus humilis_ fruit. The two vacant areas that exist are filled using the \"Imfill\" function, resulting in a complete mask template, as shown in Figure 9e. Then, the \"Canny\" edge detection operator was used to identify the edge of the mask image to obtain the contour image of the _Cerasus humilis_ fruit, as shown in Figure 9h. In addition, the cracked region feature of the sample is extracted from the PC-3 image using the \"Regiongrow\" function (the value of the threshold was set as 50). However, there are some small white dots (noise) around the crack characteristics (as shown in Figure 9f), which may be caused by the unreasonable selection of threshold value in the process of \"Regiongrow\". Here, the white dots are removed using the \"Bwareaopen\" function. After this processing, the location of the cracked region features in the sample was obtained, as shown in Figure 9g. Using the \"Imadd\" function, the sample edge contour image (Figure 9g) and the crack feature images (Figure 9h) are added. Finally, we obtain the cracked sample recognition image (Figure 9i), in which the location of the cracked features is provided.