## 2 Materials and Methods
### Developed Algorithm for Foreign Material Detection
#### 2.5.2. Blob-Level Classification and Data Fusion  
Spatially connected FM pixels obtained from the pixel-level classification with the VNIR and SWIR spectral data were treated as FM blobs. For the data fusion, we used a spatial image registration technique in order to find the spatially matched blobs between the VNIR and SWIR images. The image registration was based on a non-rigid image alignment algorithm called diffeomorphic demons such that the region-boundaries of the VNIR and SWIR's fillet segmentation images were spatially matched. This algorithm estimated the displacement field of the fillet segmentation images and registered a VNIR image and a SWIR image. A fillet segmentation image was obtained by thresholding such that a fillet region became the foreground. The fillet segmentation for the VNIR was based on two band ratios (700 nm/450 nm and 450 nm/560 nm) and thresholding. The SWIR image segmentation was undertaken with thresholding at the 1200 nm waveband. The rotation, scale, and translation were estimated and performed prior to image registration to match the aspect ratios and the centroids of the fillet segmentation images from each system. The registration technique compensated for minor deformations in shape during the transformation process to another system, which increased the registration accuracy. Following this, the estimated displacement field was applied to all the band images in the VNIR range and reconstructed a new VNIR hyperspectral spectral image. Through this image registration, it was easier to find matched blobs between two modalities, although the pixel-level registration suffered from errors due to the non-flat and pliable properties of chicken meat. Once the matched blobs were found, spectra of both modalities were fused. These fused spectral data are called Fusion data (VNIR + SWIR data) and this procedure corresponds to the data-level fusion, which combines the entire data.  
All matched blobs were used to classify whether each pair of matched blobs belonged to the chicken fillet or the FM group through the spectral angle mapper (SAM). The reference spectra for the SAM were the muscle and fat spectra in the meat group (Fusion-data SAM model). In developing the SAM model, the reference spectra of muscle and fat were obtained from the average values of 30 muscle spectra and 10 fat spectra obtained from ROIs of the VNIR and SWIR data. The spectral pretreatment was performed to the averaged spectra. The pretreated data were combined into single spectra of muscle and fat representing Fusion data. The SAM model determined a spectral similarity between the blob spectrum in question and the reference spectra (muscle and fat) by calculating a spectral angle between the spectra by treating them as vectors. The blobs detected only by VNIR or SWIR were also classified by the SAM. Finally, when matched blobs were found, the Fusion-data SAM model was used for the classification. When the unmatched blobs were found, the VNIR-data SAM (SAM only in the VNIR range) or SWIR-data SAM model (SAM only in the SWIR range) were used to classify these unmatched blobs. Then, the final Fusion classification result was acquired by fusing the results from all three models (Fusion-data SAM, VNIR-data SAM, and SWIR-data SAM model) by logical operation. If either model classifies FM, the output was FM, and this procedure corresponds to the decision-level fusion, which combines the results of separated models. The classification model development procedure was carried out using MATLAB R2020b software (The MathWorks, Inc., Natick, MA, USA).