# Coal-Rock Data Recognition Method Based on Spectral Dimension Transform and CBAM-VIT
## 2 Materials and Methods  
### Spectral Data Conversion to RGB Images  
Near-infrared instruments are prone to random noise, instrument deviation, and external interferences such as sample background and scattered light. These factors can cause spectral shift or drift, potentially compromising the accuracy and precision of the model. To mitigate these issues, appropriate spectral preprocessing steps are necessary to enhance the prediction ability and stability of the model. In this section, A multi-signal-to-RGB image conversion method is proposed to efficiently merge three types of spectral preprocessing data into a single RGB image to obtain fusion information. The proposed method is illustrated in Figure 1.  
Step 1: Use the spectral acquisition device to collect the spectral data of the coal-rock and measure ten times to obtain the average value. According to the performance of the instrument, each sample datum is a \"1 \(\times\) 155\" matrix. Raw data can be expressed as follows:  
\[Xraw=\{x_{1},x_{2}\cdots x_{n}:x_{i}\in R^{1\times 155}\} \tag{1}\]  
Step 2: Convert the spectral raw data into RGB three-channel data by using the first-order differential, second-order differential, and standard normal transformation preprocessing methods.  
\[\text{R channel. y}_{\text{fit}}=\frac{-2\text{y}_{\text{j}-2}-\text{y}_{ \text{j}-1}+\text{y}_{\text{j}+1}+\text{y}_{\text{j}+2}}{10\lambda},\text{ j }=1,\,2\ldots 155 \tag{2}\]  
\[\text{G channel. y}_{\text{sec}}=\frac{-2\text{y}_{\text{j}-2}-\text{y}_{ \text{j}-1}+2\text{y}_{\text{j}+1}+\text{y}_{\text{j}+2}}{7\lambda^{2}},\text { j }=1,\,2\ldots 155 \tag{3}\]  
\[\text{B channel. y}_{\text{SNV}}=\frac{\text{y}_{\text{j}-\overline{Y}_{\text{i}}}}{ \sqrt{\frac{1}{\text{p}-1}\sum_{\text{j}=1}^{\text{p}}\left(\text{y}_{\text{i }}-\overline{\text{y}}_{\text{i}}\right)^{2}}} \tag{4}\]  
\[\overline{\text{y}}_{\text{i}}=\frac{1}{\text{p}}\sum_{\text{j}=1}^{\text{p}} \text{y}_{\text{ij}}\]  
Figure 1: Data conversion schematic.  
In the formula, \(y_{\text{fr}}\) and \(y_{\text{sec}}\) are the reflectance after the first-order differential and second-order differential, respectively; \(y_{\text{j}}\) is the reflectance of the j-th wavelength point; \(\lambda\) is the wavelength interval, \(y_{\text{sw}}\) is the reflectance after standard normal variable transformation; \(y_{\text{ij}}\) is the reflectance of the i-th sample at the j-th wavelength point; \(\overline{y_{\text{i}}}\) is the average reflectance of the i-th sample; and p is the number of spectral wavelength points.  
After this step, a modified three-channel signal is generated, which has a lower dimensionality compared to the original signal and contains only the main information.  
Step 3: Convert the obtained three-channel signals into pixel matrices and normalize their values.  
After processing, each value in the pixel matrix is normalized between 0 and 255.  
\[x^{*}=\frac{x-x\_mean}{x\_max-x\_min}\times 255 \tag{5}\]  
Step 4: Fuse the three normalized pixel matrices into one RGB pixel matrix to generate an RGB image, thereby obtaining feature-level fusion information.  
The pixel matrix of an RGB image can be expressed as RGBM(a, b, Crgb) = (\(x^{*}\), Crgb), * = 1, 2, 3.  
Step 5: The RGB images represented as the RGB pixel matrix RGBM(a, b, Crgb) are divided into three parts: training, validation, and testing.