# Identification and Evaluation of Composition in Food Powder Using Point-Scan Raman Spectral Imaging
## 2 Materials and Methods
### Spectral Analysis and Image Processing  
Spectral analysis and image processing algorithms were carried out using Matlab (MathWorks, Natick, MA, USA) and ENVI software (Exelis Visual Information Solutions, Boulder, CO, USA). First of all, each three-dimensional hyperspectral sample image was converted into two-dimensional Raman spectral data. To eliminate fluorescence background from the spectra, an 8 th order polynomial curve was generated that resembled the fluorescence spectra and this curve was then subtracted from  
Figure 1: Mixture sample packed in sample holder. the original Raman spectra [31]. The corrected spectra were then decomposed using a self modeling mixture analysis (SMA) algorithm to extract Raman signatures of the sample components. SMA is a series of algorithm that is used to decompose mixed spectral data to obtain pure component spectra and their corresponding contributions [37; 38]. The purity function in the PLS_Toolbox (Eigenvector Research, Inc., Wenatchee, WA, USA) was used for spectral analysis. The basic formulas for SMA are as follows:  
\[\mathrm{D}=\mathrm{C}\mathrm{S}^{\mathrm{T}}+\mathrm{E} \tag{1}\]  
where D is a (m \(\times\) n) matrix of mixed spectral data; C is the contribution matrix (m \(\times\) k); S\({}^{\mathrm{T}}\) is the transpose of S (n \(\times\) k), which represents the matrix of pure component spectra; k is the number of analytes present in the data; and E is the residual error. The contribution C can be estimated using the spectral intensities (columns of D). As C and D are known, S can be calculated using the following equation:  
\[\mathrm{S}=\mathrm{D}^{\mathrm{T}}\mathrm{C}\mathrm{\ (CTC)}^{-1} \tag{2}\]  
where S represents the estimated pure component spectra. Next, the estimated contribution C* can be calculated by the following equation:  
\[\mathrm{C}^{*}=\mathrm{D}\mathrm{S}\mathrm{\ (}\mathrm{S}^{\mathrm{T}}\mathrm{S )}^{-1}. \tag{3}\]  
In the purity function, it is desirable to define an appropriate offset level. The offset level is determined by the maximum of the mean of the variable. An offset level of 5 was used in the purity function, which corresponds to a 5% \(\times\) (maximum intensity) offset value in the original SMA method [37]. For each sample concentration, the 17,664 \(\times\) 1024 spectral matrix was decomposed to extract pure component spectra and corresponding score vectors. Each of the score vectors (17,644 \(\times\) 1) corresponding to mixture components was converted into a two-dimensional contribution image (92 \(\times\) 192) matching the original spatial dimensions of the Raman hyperspectral sample image. After extracting the pure component spectra and corresponding contribution maps, each component was identified using the spectral information divergence (SID) method, which compares the dissimilarity between two spectra by relative entropy [39]. Matlab code was developed for SID calculation based on the following formulas:  
\[\mathrm{P}=\mathrm{X}/\mathrm{sum}\mathrm{\ (X)} \tag{4}\]  
\[\mathrm{Q}=\mathrm{Y}/\mathrm{sum}\mathrm{\ (Y)} \tag{5}\]  
where X (975 \(\times\) 1) is the reference spectrum, Y (975 \(\times\) 1) is the spectrum resolved from SMA, and P and Q are probability values of X and Y, respectively. The relative entropy (i.e., information divergence) of Y with respect to X can be calculated as  
\[\mathrm{D}\mathrm{(X}\mathrm{\|Y)}=\mathrm{P}^{*}\mathrm{\ \log\ (P./Q)}. \tag{6}\]  
Similarly, the relative entropy of X with respect to Y can be calculated as  
\[\mathrm{D}\mathrm{(Y}\mathrm{\|X)}=\mathrm{Q}^{*}\mathrm{\ \log\ (Q./P)} \tag{7}\]  
where P\({}^{\prime}\) and Q\({}^{\prime}\) are the transpose matrices of P and Q, respectively. (P./Q) and (Q./P) are element by element matrix divisons in Matlab. The SID value can be calculated as  
\[\mathrm{SID}\mathrm{\ (X,Y)}=\mathrm{D}\mathrm{(X}\mathrm{\|Y)}+\mathrm{D}\mathrm{ (Y}\mathrm{\|X)}. \tag{8}\]  
A smaller SID value means there is less disparity between the two spectra.