## 2 Materials and Methods
### Method of Establishing the SSC Prediction Model
#### 2.3.1 Establishment of SSC Prediction Model Sample Set  
(1) Hyperspectral image acquisition and correction
1. The acquisition of modeling set samples was as follows. Five grapes were picked randomly and equidistantly from top to bottom in the same vertical direction from the same bunch of grapes (as shown in Figure 6a,b). We picked 5 grapes, working in both vertical directions, from the same bunch of grapes for a total of 10 grapes. A total of 100 grapes from 10 bunches (2 bunches of 20% ripeness, 3 bunches of 50% ripeness, 3 bunches of 70% ripeness, and 2 bunches of 100% ripeness) were collected and arranged in a 5 \(\times\) 5 format in one image (Figure 6c). We used a hyperspectralimager for imaging and turned on the light source, allowing it to warm up for half an hour before imaging to stabilize the current. 2. The acquisition of test set samples was as follows. Five grapes were picked randomly and equidistantly from top to bottom in the same vertical direction from the same bunch of grapes (as shown in Figure 6a,b). We collected 5 grapes based on the same horizontal spacing, that is, 5 \(\times\) 5 = 25 grapes were collected from the same bunch of grapes, forming one set of data. A total of 125 grapes were collected from 5 bunches, and they were placed in the same way as shown in Figure 6c above. We used the hyperspectral imager for imaging and turned on the light source, allowing it to warm up for half an hour before imaging to stabilize the current. 3. The hyperspectral image correction was obtained as follows. After hyperspectral imaging, it was necessary to eliminate the influences of factors such as camera dark current and uneven illumination on the image and obtain a standard reflectance; thus, black and white correction was performed. The all-black calibration image \(I_{dark}\) was obtained by covering the lens, the all-white image \(I_{white}\) was obtained by scanning the standard whiteboard (nominal reflectance is 99%), and the corrected image was obtained according to formula (1) [25], where \(I_{ref}\) is the calibrated image and \(I_{raw}\) is the original hyperspectral image. The calibrated image contained 256 wavelengths of standard reflectance per pixel. \[I_{ref}=(I_{raw}-I_{dark})\ /\ (I_{white}-I_{dark})\] (4) (2) Obtaining the average standard reflectance The average spectral data of the grapes should correspond to the measured soluble solids content; hence, each grape berry must be numbered. For the sake of convenient numbering, in this experiment, we used ENVI 5.3, developed by Research System INC., to process the hyperspectral images of table grapes and extract data from the collected hyperspectral images. Four 20 \(\times\) 20 square regions were selected, being equally spaced for each sample, using the polygon tool as the Region of Interest (RoI). When selecting regions, one should avoid overbright areas and dark-edged areas (as shown in Figure 7). The average spectral reflectance of all pixels in the RoI was taken as the spectral data of a single sample. Figure 6: Hyperspectral image acquisition process (1–5 represent the label number of grapes). (**a**) A bunch of grapes. (**b**) Picked grape samples. (**c**) A set of samples for each hyperspectral image. (3) SSC measurement  
After completing the collection of hyperspectral image samples, according to the Chinese national standard NY/T 2637-2014, \"Refractometric method for determination of total soluble solids in fruits and vegetables\", we squeezed out the grape juice and allowed the juice to drip onto the digital display refractometer mirror window. The data of the digital display refractometer were read and recorded. The measurement was repeated three times for each sample, and the average value was taken as the true value of a single sample [26]. (4) Eliminating outlier samples  
Before selecting characteristic wavelengths and modeling, outlier samples should be eliminated to reduce the impact on the model's performance [27].