## 2 Principle
### Multispectral Image Reconstruction Method
#### 2.2.2 Improved Method to Reduce Computation Time  
The time-consuming nature of reconstruction is mainly caused by the spatial point-by-point optimization calculation. In the above method, each pixel is processed independently. Here, we apply spatial similarity to reduce the calculation times. Considering the change trend of spectral values, cosine angles are used to indicate the spatial similarity. Then, segment linear calibration is used to correct the recovery bias. The procedure mainly includes the following steps. Step 1: Categorize the spatial region using cosine similarity. Cosine similarity is a metric used to measure the similarity of two vectors ([PERSON] et al., 2015). It is particularly concerned with orientation. Assume the known detected images are \(I_{1},I_{2},\cdots I_{N}\), where \(N\) is the number of LEDs with different wavebands. Every pixel can be expressed as a vector with \(N\) values. If two pixels have similar spectra, the cosine angle of two vectors will be zero or small. Select the first pixel (\(x=1\), \(y=1\)) as a reference: the intensity of the reference pixel is \(\mathbf{I}_{ref}(x,y)=[I_{1}(x,y),I_{2}(x,y),\cdots I_{N}(x,y)]\). Calculate the similarity between the reference pixel and other pixels: \(\mathbf{I}_{pixel}(x^{\prime},y^{\prime})=[I_{1}(x^{\prime},y^{\prime}),I_{2}(x ^{\prime},y^{\prime}),\cdots I_{N}(x^{\prime},y^{\prime})]\). \[sim=\text{acos}\left(\frac{\mathbf{I}_{ref}\cdot\mathbf{I}_{pixel}^{T}}{\| \mathbf{I}_{ref}\|\cdot\|\mathbf{I}_{pixel}\|}\right) \tag{5}\]  
If the \(sim\) is smaller than the threshold value, \(th\), the pixel (\(x^{\prime},y^{\prime}\)) is regarded as the same category as the reference pixel (\(x,y\)). The threshold value, \(th\), is an important parameter that will be discussed in the Simulation Section. Step 2: Optimization at the similar region. Calculate the mean intensity of the same category pixels. Then, solve the minimization problem of Equation (4) and obtain the optimal, \(\sigma_{opt}\). After this, the spectral reflectance, \(S^{\prime}\), can be obtained. \[\mathbf{I}=\left(\mathbf{I}_{ref}+\ldots+\mathbf{I}_{num}\right)\Bigg{/}_{num} \tag{6}\]  
\[S^{\prime}=\sum_{k=1}^{K}\sigma_{opt}b_{k}(\lambda) \tag{7}\]  
where \(\mathbf{I}_{ref},\ldots,\mathbf{I}_{num}\) are the pixels of the same category as the reference pixel, \(num\) is the pixel number of this category, and \(S^{\prime}\) is the recovered spectral reflectance. Step3: Segment linear calibration. For each pixel among the same category, calculate the intensity, \(\mathbf{I}_{pixel}^{\prime}\), using \(S^{\prime}\) and Equation (1). Then, the error between the calculated intensity, \(\mathbf{I}_{pixel}\), and the actual detected intensity, \(\mathbf{I}_{pixel}\), is known. The spectral reflectance can be adjusted in segments using the scale value, \(scale(t)\). Here, \(N=5\) corresponds to the five types of LEDs and the wavelength is divided into five ranges for calibration. \[scale(t)=\mathbf{I}_{pixel}\Bigg{/}_{\mathbf{I}_{pixel}}^{\prime}\quad t=1, \ldots N \tag{8}\]  
Substituting Equation (8) into Equation (1), Equation (9) is obtained. \(S_{\lambda}\) is the calibrated spectral reflectance. \[\sum_{\lambda}S_{\lambda}R_{\lambda}(t)=\sum_{\lambda}S^{\prime}{}_{\lambda} R_{\lambda}(t)\cdot scale(t) \tag{9}\]  
\[S_{\lambda}=S^{\prime}{}_{\lambda}\cdot scale(t) \begin{cases}\lambda=1, \ldots L_{1}&t=1\\ \lambda=L_{1}+1,\ldots L_{2}&t=2\\ \ldots&\ldots\\ \lambda=L_{N-1}+1,\ldots L&t=N\end{cases}  \tag{10}\]  
The segment nodes \(L_{1}\), \(L_{2}\),..., are based on the spectral response of the LEDs and detectors. According to the spectral curve in Figure 2, the segment nodes of the wavelength can be easily set as 490, 570, 600, and 640 nm, which can also be adjusted according to the actual situation. After the segment calibration, a simple window-moving smooth process is applied to obtain a smooth spectral curve, especially at the segment nodes. Step 4: Process other similar spatial regions by the same procedure as Step 1 to Step 3.