## 2 Materials and Methods
### Region of Interest (ROI) Selection and Extraction of Average Spectrum  
To build up a mask image, the calibrated image was used to find an optimal single band. The dimension can be reduced and data redundancy can be removed from the calibrated data to present suitable HSI and spectral data. Principal component analysis (PCA) is an unsupervised, linear data-reduction algorithm that can yield characteristic features by using score (scattering) and loading (coefficient) vectors. A line plot of the PCA coefficients represents the optimal bands of the molecular functional group [19].  
By using the calibrated image, spectrum data of the flour samples were selected and extracted. Each modality image has a different size and spectral bands. The dimensions of VNIR, fluorescence, and SWIR images were 502 horizontal pixels \(\times\) 520 vertical pixels \(\times\) 125 bands, 502 \(\times\) 520 \(\times\) 65, and 640 \(\times\) 520 \(\times\) 224, respectively. The spectrum data were analyzed using PCA, and the loading and score vectors were plotted in the 2D space.  
Figure 2 illustrates the ROI segmentation using SWIR hyperspectral images. Figure 2a presents the PCA score images, and Figure 2b,c present the line plots of the loading vectors (coefficient) of PC1 and PC2 and their corresponding peak images, respectively. A mask image was constructed using the histogram method, which implements the flour portion as one and background as zero (Figure 2d). The 10 th band image (1016 nm) was selected to determine the optimal threshold to separate the ROI from the background (Figure 2e). The black and white mask images were constructed (Figure 2f), and they visually present the eight selected ROI regions as red rectangles (Figure 2g). The VNIR and fluorescence images also used the same procedure of mask construction by using the 10 th band image (465 nm), and their threshold values from the histogram were calculated as 5000 and 120, respectively. By using the mask image, all images were segmented and the average spectrum of the identified flour regions was identified using the extracted spectral data as a representative of each modality. A total of 93,118 SWIR data were used for the development of the classification model; these were divided into training (N = 46,559) and testing (N = 46,559) data for calibrating and validating the model. The developed model was compared to accuracy (\(A\)) and [PERSON]'s kappa coefficient (\(K\)) based on confusion matrix [3]. [PERSON]'s kappa coefficient ranges from 0 to 1; the closer it is to 1, the better is the classification result based on the following calculation: \(K=\left(A_{o}-A_{c}\right)/\left(1-A_{c}\right)\), where \(A_{o}\) is the observed accuracy and \(A_{c}\) is the chance agreement. Figure 3 depicts the flowchart of the development of the data processing and prediction model. Finally, we obtained a full spectra matrix comprising VNIR, fluorescence, and SWIR images of 75,308 samples \(\times\) 125 bands, 76,886 samples \(\times\) 65 bands, and 93,118 samples \(\times\) 224 bands, respectively.  
The PCA allowed us to obtain the representation of the multivariate information, and it was used for dimensional reduction without supervision. In this study, PCA was used for selecting an optimal wavelength for classification of the grain flour samples. By using the extracted full spectra matrix of each modality, we could obtain the PCA results, as shown in Figure 4. The PCA results of VNIR and SWIR indicated that mungbean starch (MS, gray color) covered other samples on each PC combination (Figure 4a,c). In contrast, the fluorescence images of the two PC spaces showed distinguishable clusters (Figure 4b). In the space of PC1 and PC2 for fluorescence range, the grain flour sample clusters were observed to be separate from each other; the proportion of the variance explains by the PC1 was 71% and PC2 was 26%. VNIR and SWIR demonstrated the proportion of the variance from PC1 and PC2 as 91%, 8% and 65%, 19%, respectively.  
Figure 2: _Cont._