关键词:
k-nearest neighbors
摘要:
To address the difficulty of detecting moldy walnuts and the problem of low detection efficiency, a nondestructive method based on fused features of X-ray and visual images was proposed to accurately distinguish four grades of moldy walnuts: moldy both internally and externally, moldy internally and normal externally, normal internally and moldy externally, and normal both internally and externally. First, the gray-level co-occurrence matrix (GLCM) was used to extract texture features from X-ray and visual images, and the first and second moments of the visual images were computed in different color spaces to comprehensively capture the internal and external moldiness characteristics of walnuts in order to construct an original moldy walnut feature set. Subsequently, using competitive adaptive reweighted sampling (CARS) and successive projection algorithm (SPA), the extracted features were optimized to construct a walnut feature set sensitive to different degrees of moldiness. On this basis, an extreme learning machine (ELM) model and a K-nearest neighbors (KNN) model were developed for moldy walnut classification, and the performance of the classification models under different feature sets was compared through experiments to verify the feasibility of fusing X-ray and visual image features for detecting moldy walnuts. The experimental results showed that the ELM model developed using SPA optimized feature set had the best performance. The accuracy and recall for the test set, and the harmonic mean of precision and recall (F1) value of the model were 90.32%, 92.58%, and 91.29%, respectively. The average specificity and Kappa coefficient values were 97.02% and 88.44%, respectively, indicating high ability to discriminate both majority and minority moldy walnuts. This study provides a theoretical reference for the comprehensive and accurate identification of the internal and external moldiness of walnuts, as well as the development of online non-destructive testing sy