## 2 Materials and Methods
### Hyperspectral Images Acquisition and Processing  
To develop a non-destructive and fast method for green jujube chilling injury detection with the aim of extending storage period, a line-scan hyperspectral imaging system was used to acquire the hyperspectral images over the range of 380-1023 nm. The system consisted of a CCD camera (C8484-05G, Hamamatsu (Hamamatsu-shi, Japan)), an imaging spectrograph (ImSpectorV10, Spectral Imaging Ltd., Oulu, Finland), a 17 mm fixed focal lens (Xenoplan, Schneider Optics, Hauppauge, NY, USA), two line light sources (Fiber-Lite DC950 Illuminator, Dolan Jenner Industries Inc., Boxborough, MA, USA), and a mobile platform. The samples were placed on the mobile platform, and hyperspectral images were collected at the speed of 8 mm/s (no deformation of shape) and 20 mm/s (about 50% deformation of shape) of 35 cm working distance, respectively. After imaging, the surface condition of each sample was inspected to avoid any possible errors. Hyperspectral images were then corrected using a flat-field correction using Equation (1) as  
\[R=\frac{I_{sample}-I_{dark}}{I_{reference}-I_{dark}} \tag{1}\]  
where \(R\), \(I_{sample}\), \(I_{dark}\), and \(I_{reference}\) were the corrected, original, dark current, and reference images, respectively. The dark current was obtained by covering the lens, while the reference images were collected from a white Teflon bar (\(\sim\)99.9% reflectance) (Specim, Spectral Imaging Ltd., Oulu, Finland). In order to obtained different spectral resolutions of hyperspectral images, four spectral resolutions [2 \(\times\) 2 (1.25 nm), 2 \(\times\) 4 (2.51 nm), 2 \(\times\) 8 (5.03 nm), and 2 \(\times\) 16 (10.08 nm)] were used for analysis. After that, a mask was generated to remove the background, before each sample was cropped automatically using a minimum enclosing rectangle. Additionally, hyperspectral images with wavelength lower than 430 nm were removed because of low signal-to-noise ratio (\(SNR\)). Since the green jujube size was similar to spheroidicity with smooth peel on surface, and was easy to saturate, the inpainting operation on specular reflection region was carried out before deriving mean spectra from each sample. The position of specular reflection region was detected from the spectral image at 680 nm by creating a mask with a selected threshold value. In this study, Criminisi algorithm was executed to reconstruct the lost regions of all the spectral images by iterating the following three steps until all pixels were filled [14]:  
1. Compute patch priorities: \[P(p)=C(p)\cdot D(p)\] (2) where \(C(p)\) and \(D(p)\) were the confidence term and data term, respectively, and they were defined as: \[C(p)=\frac{\sum_{y\in\Psi_{p}\cap(I-\Omega)}C(q)}{\left|\Psi_{p}\right|}\] (3) \[D(p)=\frac{\left|I_{p}^{\perp}\cdot n_{p}\right|}{\alpha}\] (4) where \(\Psi_{p}\), \(\left|\Psi_{p}\right|\), \(n_{p}\), \(\alpha\), \(I_{p}^{\perp}\), \(I\), and \(\Omega\) were regarded as square template at point \(p\) to be filled, the area of \(\Psi_{p}\), unit vector, normalization factor, the isophotes direction at point \(p\), entire image, and the target region, respectively. 2. Once the patch with the highest priority (\(\Psi_{p}\)) was found, the texture and structure were propagated by coping the most best-matching patch (\(\Psi_{\vartheta}\)) in candidate source region to the position based on sum of squared differences (SSD) as: \[\Psi_{\vartheta}=arg\min_{\Psi_{p}\in\varnothing}d(\Psi_{p},\ \Psi_{q})\] (5)
3. Update confidence values \(C(p)\) and repeat step 1-3 until done. Finally, the peak signal-to-noise ratio (\(PSNR\)) between the original and inpainting images was calculated to evaluate the performance of inpainting operation. Since the chilling injury usually affects the whole surface of the fruit, thus the whole green jujube was considered as the region of interest (ROI) to extract the mean spectral reflectance.