## 3 Results and Discussion
### Post-Processing and Visualization of Prediction Results  
The histogram of frequency of predicted concentrations of the pixels of samples with peanut contaminant in concentrations of 0%, 3%, and 10% is presented in Figure 5. As shown in Figure 5, the predicted concentration values of pixels within one sample had large deviations, which were greater than the tested concentration gradients, and led to the poor visualization results. This was considered to be caused by the noise and because the models that were used were developed based on the average spectra of ROIs. However, as shown in Figure 5, the mean of predicted values (shown in white values and white vertical lines) were near to the actual concentrations. Hence, considering the homogeneity of the samples, the lower and upper thresholds defined as 95% confidence interval of the mean of the predicted values were used to correct the predicted values.  
Visualization results of the corrected predicted values based on different multispectral PLSR models were shown in Figure 6. All of the visualization results demonstrated clear discrimination among samples with contamination concentrations of 1%, 3%, 5% and 10%, although the corrected predicted values were not very accurate. As shown in Figure 6b, the visual map of the PLSR model based on the 14 wavelengths for predicting walnut contaminant showed the best discrimination results, where even samples with concentrations of 0.5% and pure flour could also be identified. For the other visual maps (shown in Figure 6a,c,d), the prediction results of pure flour samples showed relatively large prediction errors, and the predicted concentration values showed false positives. For all of the multispectral PLSR models, the samples with walnut contaminants were predicted more accurately than those with peanut contaminants. Overall, visual prediction maps graphically displayed the contamination concentration variation between samples and even within one sample, which is impossible for the naked eye and common industrial cameras. Moreover, the visualization results demonstrated the main advantage of HSI over the conventional spectroscopy for not only chemical composition, but also for the spatial contaminant detection of peanut and walnut powders in whole wheat flour.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline \multicolumn{1}{c}{**Contaminant**} & \
\begin{tabular}{c} **Selection** \\ **Method** \\ \end{tabular} &
\begin{tabular}{c} **Number of** \\ **Wavelengths** \\ \end{tabular} & \multicolumn{2}{c}{**Wavelengths**} \\ \hline \hline \multirow{3}{*}{Peanut} & UVE & 16 & 994, 1022, 1057, 1151, 1182, 1196, 1200, 1203, 1207, 1249, 1368, 1386, 1421, 1485, 1521, 1545 \\  & SPA & 10 & 988, 998, 1012, 1154, 1203, 1214, 1368, 1457, 1489, 1588 \\ \hline \multirow{3}{*}{Walnut} & UVE & 14 & 1005, 1036, 1085, 1102, 1109, 1113, 1127, 1140, 1144, 1245, 1249, 1252, 1252, 1256, 1330 \\  & SPA & 9 & 1109, 1179, 1337, 1368, 1464, 1581, 1599, 1667, 1674 \\ \hline \multirow{3}{*}{Peanut + walnut} & UVE & 17 & 1022, 1186, 1193, 1196, 1200, 1203, 1207, 1210, 1231, 1249, 1252, 1256 \\  & SPA & 11 & 1256 1372, 1390, 1606, 1613, 1638 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Selected feature wavelengths for the peanut-contaminated flour, walnut-contaminated flour, and a combination of both, based on UVE and SPA selection methods, respectively.  
Figure 5: Histogram of frequency of predicted results of the pixels of peanut-contaminated samples in concentrations of 0% (**a**); 3% (**b**); and 10% (**c**) based on the multispectral model using the 16 wavelengths.  
Figure 6: Visualization maps of the corrected predicted values based on multispectral PLSR models for predicting (**a**) peanut contaminant using the 16 wavelengths; (**b**) walnut contaminant using the 14 wavelengths, and the general multispectral PLSR model for predicting (**c**) peanut and (**d**) walnut contaminant using the 17 wavelengths.