## 2.1 VIS-HSI

The present investigation utilizes VIS-HSI, which is achieved through the integration of an industrial camera (model DFK 33UX265) and a visible hyperspectral algorithm (VISHAS). Operating within the wavelength range of 380 nm to 780 nm, with a spectral resolution of 1 nm, this process necessitates the determination of a conversion matrix that bridges the industrial camera and the spectrometer (Ocean Optics, QE65000), underpinning the establishment of the VIS-HSI methodology (see Supplement 1, Figure S1 for the schematics of the VIS-HSI algorithm). The fundamental premise that underlies VIS-HSI involves the derivation of the aforementioned conversion matrix, which is pivotal in affecting the transmutation of captured digital imagery into hyperspectral format. The calibration of this transformation is realized through meticulous analysis that employs multiple common reference targets. For the purposes of this study, the 24-color card (X-Rite Classic, 24 Color Checker) was selected as the reference object. This choice was based on the inclusion of pivotal hues, such as blue, green, red, and gray, along with a comprehensive representation of prevalent natural colors.

The camera system is susceptible to deviations, such as white balance, engendering potential errors that necessitate rectification prior to subsequent processing stages. To mitigate this issue, a prescribed protocol entails the introduction of a standardized 24-color card into the camera–spectrometer arrangement, resulting in the acquisition of 24-color patch images (utilizing the sRGB color space with an 8-bit depth) alongside the corresponding reflectance spectrum data for the 24-color blocks that span the spectral range of 380 nm to 780 nm. These data are subsequently transposed into the CIE 1931 XYZ color space, (see Section 1 of Supplement 1 for the individual equations used in this study). Within the image processing domain, the captured images (stored in JPEG format, with an 8-bit depth) are initially positioned within the sRGB color space. Prior to transitioning these images into the XYZ color space, the individual R, G, and B values (ranging from 0 to 255) undergo normalization, restricting them to a more compact range of values (0 to 1). A gamma function conversion equation is applied to linearize the sRGB values, subsequently paving the way for their transformation into linear RGB values. Employing a transformation matrix (T), the linear RGB values are seamlessly mapped onto the normalized XYZ values within the XYZ color space. Underscoring that the sRGB color space conventionally adheres to a standardized white point, D65 (XCW, YCW, ZCW), is imperative. This standard does not account for the characterization of a light source’s inherent white point (XSW, YSW, ZSW). Consequently, a critical necessity emerges to subject the acquired XYZ values to a chromatic adaptation transformation matrix. This operation recalibrates the D65 white point to align with the white point characteristic of the illuminating light source, yielding a substantively authentic set of XYZ values under the support of the pertinent measurement light source (XYZCamera).

Within the spectrometric domain, the transformation of reflection spectrum data into the XYZ color gamut space necessitates the establishment of the XYZ color matching function (CMF) in conjunction with the illumination source’s spectrum S(λ). Delineating that the Y component within the XYZ color gamut space directly corresponds to luminance is pertinent, engendering a direct proportionality. This scenario allows for the derivation of the luminance ratio, denoted as “k”, via Eq. 1, which subsequently normalizes the luminance values to a standard of 100. The conversion of reflection spectrum data into the XYZ value (*XYZ**Spectrum*) is achieved through the application of Equations 2 through 4. Upon establishing *XYZ**Camera* and *XYZ**Spectrum*, a multivariate regression analysis is systematically executed to derive the requisite correction coefficient matrix (*C*) for camera calibration. The associated variable matrix (*V*) is subjected to analysis, including the discernment of parameters that can potentially contribute to camera-related discrepancies. These influential factors include, but are not limited to, nonlinearity inherent to the camera’s response characteristics, the presence of dark current within the camera, imprecise color separation that stems from the use of color filters, and the manifestation of color shifts during imaging.

$$k=100/{\int }_{380nm}^{780nm}S\left(\lambda \right)y\left(\lambda \right)d\lambda$$

1

$$X=k{\int }_{380nm}^{780nm}S\left(\lambda \right)R\left(\lambda \right)x\left(\lambda \right)d\lambda$$

2

$$Y=k{\int }_{380nm}^{780nm}S\left(\lambda \right)R\left(\lambda \right)y\left(\lambda \right)d\lambda$$

3

$$Z=k{\int }_{380nm}^{780nm}S\left(\lambda \right)R\left(\lambda \right)z\left(\lambda \right)d\lambda$$

4

After the calibration of the camera is completed, the calibrated 24-color patch XYZ value (*XYZ**Correct*) and the 24-color patch reflection spectrum data (*R**Spectrum*) measured by the spectrometer can be analyzed to obtain the transformation matrix (*M*). *R**Spectrum* is used to find the major principal components through principal component analysis (PCA), and multiple regression analysis is performed on the corresponding principal component scores and *XYZ**Correct*. The most important six sets of principal components are used for the dimensionality reduction of *XYZ**Correct*, which can explain 99.64% of the data variation. The corresponding principal component score can be used for regression analysis with *XYZ**Correct*. In the multivariate regression analysis of *XYZ**Correct* and score, the variable *V**Color* is selected because it has listed all possible combinations of *X, Y*, and *Z*, and *M* is obtained through Eq. 5. Then, *XYZ**Correct* is passed through Eq. 6 to calculate the simulated spectrum (*S**Spectrum*). Finally, *S**Spectrum* is compared with *R**Spectrum*, and the average root-mean-square error (RMSE) of each color patch is 0.63. The difference between *S**Spectrum* and *R**Spectrum* can also be expressed by color difference. The average color difference is 0.75, and distinguishing the color difference is difficult. During reproduction, colors are reproduced accurately.

$$\left[M\right]=\left[Score\right]\times pinv\left(\left[{V}_{Color}\right]\right)$$

5

$${\left[\text{S}\text{S}\text{p}\text{e}\text{c}\text{t}\text{r}\text{u}\text{m}\right]}_{380\sim780\text{n}\text{m}}=\left[EV\right]\left[M\right]\left[{V}_{Color}\right]$$

6

The VIS-HSI technology built through the preceding process can simulate the reflection spectrum from the RGB values captured by an industrial camera.

## 2.2 NIR Hyperspectral Algorithm (NIR-HSA)

The NIR-HSI employed in this study is derived by combining imagery captured by an industrial camera with NIR-HSA. This imaging modality operates within the wavelength range of 900 nm to 1000 nm, with a spectral resolution of 1 nm. NIR-HSI conversion enables imbuing spectral information into images acquired by a NIR camera. In this study, imagery data are obtained through an industrial camera, and the reflectance spectra of distinct material samples are acquired using a halogen lamp. Subsequently, a computational framework is devised for establishing the NIR-HSI technique (see Supplement 1 Figure S2 for the schematics of the NIR-HSI algorithm). The imagery obtained by the industrial camera utilizes its radiative response within the wavelength range of 900 nm to 1100 nm, resulting in the acquisition of reflectance spectra in the NIR spectral domain. The employed reference targets consist of six diverse thickness values of coated glass. These targets are irradiated by a halogen lamp to capture reflectance radiative data uncontaminated by extraneous influences. Camera calibration is excluded in this technique due to the uniformity of the sensing apparatus across the entire spectral range. After the acquisition of the specimens’ reflectance spectra, PCA is performed on these spectra. The first six principal components account for a data variance explanation of 99.79%. These principal components are then utilized to deduce the corresponding principal component scores. These scores are subsequently employed in the regression analysis alongside the NIR spectral domain. Facilitating the alignment of digital values with spectral weights, a spectral reconstruction transformation matrix is created via the generalized inverse matrix method. This matrix transforms image digital values into spectral distributions. By circumventing the necessity for labor-intensive spectral scanning across disparate positions, this matrix enables direct transformation of digital values from the camera into spectral profiles. Finally, the obtained simulated spectra (*S**Spectrum*) are juxtaposed against the measured reflectance spectra, enabling the computation of RMSE for each target specimen. The computed average RMSE is 0.001843.