Quantitative prediction of moisture content distribution in acetylated wood using near-infrared hyperspectral imaging

The uptake of moisture severely affects the properties of wood in service applications. Even local moisture content variations may be critical, but such variations are typically not detected by traditional methods to quantify the moisture content of the wood. In this study, we used near-infrared hyperspectral imaging to predict the moisture distribution on wood surfaces at the macroscale. A broad range of wood moisture contents were generated by controlling the acetylation degree of wood and the relative humidity during sample conditioning. Near-infrared image spectra were then measured from the surfaces of the conditioned wood samples, and a principal component analysis was applied to separate the useful chemical information from the spectral data. Moreover, a partial least squares regression model was developed to predict moisture content on the wood surfaces. The results show that hyperspectral near-infrared image regression can accurately predict the variations in moisture content across wood surfaces. In addition to sample-to-sample variation in moisture content, our results also revealed differences in the moisture content between earlywood and latewood in acetylated wood. This was in line with our recent studies where we found that thin-walled earlywood cells are acetylated faster than the thicker latewood cells, which decreases the moisture uptake during the conditioning. Dynamic vapor sorption isotherms validated the differences in moisture content within earlywood and latewood cells. Overall, our results demonstrate the capabilities of hyperspectral imaging for process analytics in the modern wood industry.


GRAPHICAL ABSTRACT Introduction
Wood has long been a dominant structural material for many service applications. Like other natural materials, its hygroscopic nature means that it tends to absorb moisture from the surrounding environment. The presence of a large number of hydrophilic functional groups in wood attracts the water molecules, resulting in compromised dimensional stability and biological resistance against fungal decay [1,2]. Wood's moisture content continuously adapts to the relative humidity present in the external atmosphere. The constant variations in moisture content influence wood performance, which is a major limitation for several applications. Various methods have been developed to control the wood moisture content such as surface hydrophobization [3], high-temperature heat treatment [4], and chemical modification of bulk wood [5,6]. Wood that has been through chemical modification with acetic anhydride proved to be significantly more dimensionally stable, durable, and resistant to decay [7]. In acetylation, the free hydroxyl groups of wood are esterified with acetyl groups, which causes swelling in cell walls and reduces the adsorption of water [8]. The resultant change in adsorption tendency of the chemically modified wood needs to be addressed to better understand the water interaction with wood. Traditional gravimetric methods can only determine the bulk moisture content based on the mass changes but fail to explain the localized distribution of moisture within the wood structure [9]. For this, imaging spectroscopy-based methods are required to estimate the detailed spatial distribution of water molecules and their interaction with wood cell walls in the presence of a modification agent.
In this regard, hyperspectral near-infrared (NIR) imaging is an appropriate method to study structural and chemical changes within the wood [10][11][12]. The NIR images are three-way datasets, where two dimensions render the spatial mapping of the chemical analytes, while the third dimension contains spectral variables. Hyperspectral NIR imaging coupled with chemometrics provides a statistical way to segregate the individual components from overlapping spectral fingerprints in a multivariate fashion [13]. Multivariate data analysis-based regression models can be developed on hyperspectral image data to reliably determine the concentrations of chemical analytes within the object [14]. The application of NIR imaging has been established in areas such as geological mapping [15], agriculture and food quality [16,17], and pharmaceutical active ingredient identification [18], but it has a limited implementation in the process analytics of modern wood science problems [19].
Recently, NIR imaging has been applied to characterize the surface chemical changes in response to moisture uptake and loss in wood. The real-time natural drying process has been investigated with combined visual and NIR hyperspectral imaging [20]. Spatial mapping revealed that the moisture content at the outer edges of wood samples decreased faster than at the center. It also differentiated the drying behavior of earlywood and latewood regions. Moreover, a time series natural drying process has been monitored using NIR hyperspectral imaging on thermally modified wood [21]. It indicated that the 1966-2244 nm wavelength region with extended multiplicative scatter correction and first-order derivation can estimate and visualize the intrasample spatial distribution and average moisture content. Wood anisotropy and surface texture quality also affected the estimation of moisture content [22]. It was found that NIR-based models developed on transverse surfaces had superior performance in predicting moisture content accurately. Hyperspectral NIR imaging and chemometrics have been recently used to reveal wood acetylation at macroscopic scales [23]. The weight percentage gain attained after anhydride modification was predicted at pixel level based on the cross-sectional surface scans. Predicted imaging showed the differences in acetylation of earlywood and latewood regions. NIR imaging is not restricted to assessing the moisture content in the small woodblocks. It has also been applied on large boards which makes it a rapid and digitalized accessing tool for the evaluation of local moisture content variations [24].
This study was conducted in line with our recent work [2], where we utilized NIR hyperspectral imaging estimation to quantify the differences in acetylation degree within woodblocks at pixel level. Unsupervised principal component analysis suggested differences in the moisture content of earlywood and latewood due to acetylation degree, but these differences were not quantified as it was not the main research focus. Now we extended this work by quantifying the distribution of moisture content on the wood surface using NIR hyperspectral imaging. Acetylation (0-17% weight percent gain, WPG) was used as a tool to generate moisture variations within the samples and to create localized differences in earlywood and latewood regions. Our approach enables the visualization of moisture differences in radial and cross-sectional directions. We developed two separate partial least squares image regression models to compare the moisture content differences in radial and cross-sectional surfaces. The obtained results showed a significant reduction in moisture content with increasing acetylation WPG (%). We also found considerably higher moisture content in latewood regions of the wood surface. The illustrated differences in earlywood and latewood regions of predicted images were complemented with dynamic vapor sorption isotherms. We propose a digitalized imaging method to determine the moisture content variation at surface level. Our results suggested a high potential for the application of near-infrared imaging with certain upscaling at an industrial scale.

Sample preparation
Samples were cut from kiln-dried boards of Scots pine (Pinus sylvestris L.) sapwood with dimensions of 15 9 15 9 15 mm 3 (radial x tangential x longitudinal). An experimental design was developed to select the optimum number of samples where the acetylation and relative humidity were varied at three discrete levels (Fig. 1a). The samples were conditioned over saturated salt solutions in the 0-95% relative humidity range. Two additional levels were also included in both variables within the design range. Five replicates at each design location were prepared. Three samples were used as the calibration set and two as the test set. In total, 65 imaging samples were distributed at 13 experimental design locations.
Wood blocks were extracted with acetone using a Soxhlet apparatus for 6 h and then oven dried at 103°C for 24 h. The initial mass of the samples was determined. Blocks were impregnated with neat acetic anhydride under vacuum at room temperature for 2 h. The acetylation reaction was performed in a reaction flask under reflux at 120°C for 0, 20, 30, 60 and 360 min to create samples with increasing WPGs (Fig. 1c). The reaction was terminated by placing the reaction flask in an ice bath. Anhydride was removed and the samples were rinsed with acetone and soaked in fresh acetone for 24 h. The acetylated samples were Soxhlet extracted, dried in the oven for 24 h and then weighed to determine their final dry mass.
Different saturated aqueous salt solutions were prepared to investigate the effect of acetylation degree and relative humidity on moisture content. Silica gel, potassium carbonate, sodium chloride, potassium chloride and deionized water were used to create the relative humidity levels of approximately 0, 43, 75, 91 and 95%, respectively [25]. The corresponding moisture content varies with the degree of acetylation. However, the resulting moisture content decreased at any given relative humidity as the WPG values increased (Fig. 1b). The experimental setup contains samples placed on a holder in a plastic container with a salt solution at the base with no direct contact with the wood surface. The samples were conditioned for 8 weeks to reach equilibrium. The moisture content was calculated as Eq. (1): where W RH is mass (g) at specific RH (%) level in equilibrium state, W A is dry mass (g) of acetylated samples, and W O is initial dry mass (g) of wood blocks.

Hyperspectral near-infrared imaging
Cross-sectional and radial surfaces of conditioned samples were scanned under the hyperspectral infrared camera. Samples were removed from the plastic container and immediately measured with a SWIR spectral camera. The camera was equipped with OLES macro lens with the focal length of 73.3 mm, a field of view of 10 mm and nominal pixel size of 26 9 26 lm 2 . Two halogen lamps with a polychromatic light source were arranged in line. A HgCdTe detector array with a grating prism monochromator collects the reflected wavelength from the samples. A calibrated reflectance target was scanned along with the samples [26,27]. The images were acquired in a line-scanning mode which include 384 pixels and 881 frames. Image acquisition time was 10 ms per line, resulting in approximately 8.81 s per image. The spectral range of 1000-2500 nm was continuously recorded at 5.56 nm intervals, providing 267 variables. The samples were weighed before scanning and placed back into the plastic containers to re-equilibrate for further use.

Image calibration and transformation
All images were captured in reflectance mode, and the backgrounds were removed using principal component analysis [28] on raw images. A median filter [29] with a moving window of 3 9 3 pixels was applied to remove the effect of saturated and dead pixels. Region of interest (ROI) was masked by choosing the equivalent number of pixels in rectangular coordinates from the center of each sample image which generated images of dimension 451 9 376 pixels. Each pixel was corrected with measured SpectraIon reflectance target and dark current intensities. All images were converted into absorbance using A = log 10 (1/r) where r describes unitless reflectance values and A the estimated absorbance values. Five replicates were scanned to access the maximum variations among the samples at each design location. One image from each location was selected based on the minimum deviation from the mean measured moisture content (%)and combined into an image mosaic in a way where acetylation degree varies in the horizontal axis and relative humidity changes vertically (Fig. 1a). The wavelengths outside the range 1100-2400 nm were excluded, and the final mosaic contained dimension of 1335 9 1125 pixels. The image mosaic was preprocessed with standard normal variate (SNV) [30] transformation and mean centering. Standard normal variate scaled the data with mean zero and unit standard deviation in a rowwise fashion. Principal component analysis was performed on mosaic following singular value decomposition [12,31] algorithm. Principal components explaining the maximum variation within the data were chosen, and score vectors were reshaped back to image dimensions.

Partial least square image regression
Hyperspectral image regression dataset was prepared based on the design of experiments. Individual image was comprised of 169,125 pixels rows and 267 spectral variables in columns which is significantly more objects than the wavelength variables. Therefore, three average spectra per sample were calculated. Experimental design contained 13 points with 5 replicate images which provide 65 images in total and 195 average spectra. Similar design approach was implemented on the radial surface scanned images ( Fig. S.1). Average spectra were converted into absorbance. Moreover, out of 5 replicate images, 3 were assigned to calibration set and 2 were used as test set. Calibration and test sets were comprised of 117 and 78 average spectral objects. Calibration set was processed with SNV, mean centering for the purpose of hyperspectral image regression model.
Regression models based on the hyperspectral images provide a possibility to predict the unknown analyte concentrations at individual pixel level [26,32,33]. A calibration model was developed based on the partial least squares regression [32] method using SIMPLS algorithm [34,35] which determines the partial least squares (PLS) factors considering linear combination of original variables. The general equation of regression model is Eq. (2): where y represents a n 9 1 vector consisting of mean centered analyte concentration, X denotes n 9 m matrix including mean centered average spectra, b is regression model coefficients of m 9 1 dimension, and e belongs to model residuals. The SIMPLS method provides a numerically stable solution within limited PLS factors and degree of orthogonality of score vectors [35]. The root-mean-squared errors of calibration (RMSEC) and prediction (RMSEP) were calculated based on the test set [12]. In addition, an image test set was utilized to determine the RMSEP of the pixel population. A prediction map was generated to evaluate the over-fitting of test images [36]. Equation (3): where y i represents the measured moisture WPG value of sample,ŷ i are predicted values of individual pixels, n p are the total number of image pixels, and k is the test set images. Data analysis and image segmentation were performed with in-house Matlab scripts, and plots were generated in OriginPro.

Dynamic vapor sorption (DVS)
The revealed local variations in predicted images were validated with dynamic vapor sorption measurements. Three samples were chosen from the intermediate level of the experimental design with acetylation WPGs of 0, 8.5, 17% and at constant relative humidity of 75% (Fig. 1a). Blocks were waterimpregnated for 1 h, and tangential sections of earlywood and latewood with a constant thickness of 20 lm were cut with a sliding microtome.
where W RH is the sample mass (g) after conditioning at specific relative humidity, W A represents dry mass (g) of the acetylated sample. WPG ace belongs to the weight percentage gain caused by the acetylation (%).
Moisture content was corrected with the factor of mass gain caused by the modification agent. This corrected moisture content was associated with the mass of absorbed water to the dry wood mass. The schematic illustration of methodology is shown in (Fig. 2).

Results and discussion
Radial and cross-sectional surfaces were scanned with a NIR hyperspectral camera to determine the moisture content distribution within the woodblocks. Sample images measured at different relative humidity and acetylation levels were first analyzed with principal component analysis (PCA). The PCA model identified the differences in relative humidity among the acetylated samples within the mosaic. PC1 explained the highest variances which revealed the information related to moisture distribution within the sample mosaic. It also demonstrated the differences in moisture content between earlywood and latewood regions. Thin-walled earlywood cells acetylated faster than the thick-walled latewood cells, which decreased the moisture content in earlywood regions. PC2 and PC3 explained 14-18% variance and primarily illustrated the chemical information related to acetylation and moisture content. The first principal component on cross-sectional surfaces explained 77% variance which was mostly related to moisture content (Fig. 3a). The radial surface had comparatively higher absorbance because of its smooth surface texture, and PC1 explained 85% variation (Fig. 3b). Similar chemical information is associated with both image mosaics. Higher relative humidity samples showed positive pixel score values which were related to peaks at 1390-1410 nm and 1905-1925 nm based on the loading vectors. Peaks at 1390-1410 nm showed first overtone of absorption of OH groups of all wood components which decreased with the increased WPG caused by acetylation Figure 2 Schematic illustration of process flow for the determination of moisture content with NIR hyperspectral imaging. [12,37,38]. Water can be associated with three bands centered at 1923, 1969, and 2033 nm. These bands belongs to the three states of water molecules such as free water, molecules with one OH occupied in hydrogen bonding and molecules with two OH engaged in hydrogen bonding [37,39,40]. Negative extremes values in the 2267-2279 nm range were difficult to assign because several band shifts were observed in this region. Peaks at 2267 nm and 2269 nm were tentatively assigned to lignin in softwood. Cellulose and hemicellulose were assigned to the 2272 nm band that can be shifted to higher wavelengths in acetylated wood [37]. The first principal component explained the chemical information related to moisture content within the samples and differences in earlywood and latewood cells.
PC2 on the cross-sectional surface mosaic explained 14% of the variation and illustrated chemical changes related to wood acetylation and moisture content (Fig. S.2). The radial surface mosaic showed similar chemical information with 11% variance explained. The bands at approximately 1136-1145 nm were related to the second overtone of the C-H stretching vibration of methyl groups and aromatics in lignin [37]. An increase in the number of acetyl ester groups can cause higher intensity bands in the region of 1156-1183 nm [37].
The peak at 1195 nm was assigned to cellulose and/or CH 3 groups from lignin [41]. A dominant peak was observed in the cross-sectional loading vector at 1340-1365 nm. It can be tentatively allocated to CH 3 groups in acetyl ester groups in hemicellulose. Bands associated with negative loadings at 1470-1484 nm and 2060-2080 nm were assigned to semi-crystalline or crystalline regions in cellulose [42]. The positive loadings with extreme scores at 1910-1926 nm were associated with OH asymmetric stretching and O-H deformation in water [43]. The band appearing at 2236-2250 nm suggested an increase in acetyl groups in acetylated wood [37]. The recent in-line study also reported similar results related to wood acetylation analyzed with hyperspectral imaging [23]. PC3 in both mosaics explained 2-4% of variation and distinctly identified acetylation related bands (Fig. S.3). Peaks at 1141, 1410, 1720, and 2240-2255 nm were related to CH 3 groups associated with aromatic moieties in lignin or methyl groups of acetyl esters in hemicellulose. The corresponding positive scores increased with acetylation WPG (%).

Hyperspectral image regression
The calibration data set was preprocessed, and the spectra were colored based on absorbance intensities and measured moisture content (Fig. 4a). A distinct shift in mean centered spectra was observed at 1905-1925 nm as the moisture content changed. Three untreated samples out of five replicates at 95% relative humidity were discarded on the basis of model residuals and visual inspection. Mold growth was observed on the sample surfaces with time, which resulted in increased variation in moisture content within the replicates. To avoid calibration bias, those samples were removed from the calibration set. In total, 111 screened objects with corresponding moisture content were selected to build the partial least square regression model (PLSR). The test set was comprised of 75 objects. The average prediction error of calibration (RMSEC), test set prediction error (RMSEP) and prediction of test image pixels were calculated to avoid the overfitting of the models. Model diagnostics determined the minimum individual pixels prediction error (RMSEP img ) at 4 latent variables (Fig. 4b). The measured and predicted root mean square error of calibration and test sets were 0.66% and 0.62% (Fig. 4d). The regression vector has a chemical meaning comprised of the bands related to moisture content and acetylation (Fig. 4c).
Bands in the region of 1181-1198 nm were dominated by the second overtone C-H stretching bond vibration and assigned to CH 3 groups in hemicellulose acetyl esters [37,41]. Phenolic hydroxyl groups can generally be detected at 1410 nm [37]. Bands at 1564-1586 nm were assigned to the crystalline regions in cellulose [44]. Spectral shift in the range of 1855-1925 nm separated the acetylation related bands from water. The bands at 1923 nm, 1969 nm and 2033 nm indicated the presence of water and showed higher coefficient values in the regression vector [40,45]. The 2267-2279 nm band range was assigned to CH 3 groups, cellulose, and hemicellulose [46]. The model vector was used to predict the moisture content of the final image mosaic which was preprocessed with SVN transformation and mean-centered (Fig. 5a). The corresponding image pixel histograms were plotted against the predicted moisture content (Fig. 5b). The measured and average pixel predicted moisture values were used to determine the accuracy of the developed model. Predicted images illustrated the variation in moisture content as a function of acetylation WPG (%). The average predicted pixel population at 95% relative humidity showed 36% higher moisture content in untreated wood compared to the sample with 17% WPG. Similarly, the moisture content decreased by 40% in samples with 17% WPG at a relative humidity of 75% compared to the untreated sample. This indicated that a significant decrease in moisture content can be observed with the increase in acetylation WPG (%). Moreover, the predicted images also showed the difference in moisture content between earlywood and latewood regions. The thin-walled earlywood regions acetylated more extensively than the thickwalled latewood regions [12,23]. Therefore, the pixels belonging to latewood regions exhibited higher moisture content. Similar results have been reported recently in the context of water accessibility in acetylated wood [2,47].
A separate partial least squares regression model was developed on radial surface scanned images. The samples at 75% RH and 8.5% WPG were compared to analyze the differences in the predicted moisture content of earlywood and latewood regions in radial and cross-sectional surfaces (Fig. 6a). The averages of pixel populations were nearly identical. However, a wide range of predicted moisture content was observed in the earlywood and latewood regions of the cross-sectional surface (Fig. 6b). On the radial surface, the earlywood and latewood differences were more distinct and visible in the pixel histogram. This was the result of high surface roughness on cross-sectional surfaces compared to the radial surfaces.

Dynamic vapor sorption
The predicted images highlighted the differences in moisture content between earlywood and latewood regions. The differences were experimentally validated with dynamic vapor sorption measurements. Three samples were picked with 0, 8.5 and 17% WPG from the middle row of the predicted final mosaic (Fig. 5a). Sorption isotherms were measured from carefully isolated sections of earlywood and latewood. The presence of acetyl groups within the wood cell walls reduced the available space for the water molecules [2]. Sorption isotherms of earlywood and latewood regions indicated differences in respective moisture absorption within the hygroscopic range (0-95%) (Fig. 7). An insignificant difference was recorded in the absorption behavior of reference untreated earlywood and latewood regions, but the difference increased with an increase in acetylation WPG (%). Below ca. 95% RH, all modified samples showed a lower MC R compared to the reference samples. It was observed that the latewood regions of samples modified to 8.5 and 17% WPG showed higher moisture content compared to the earlywood regions, which is a consequence of the stronger acetylation of earlywood cells as shown in previous studies [12,23]. Three further replicates were sectioned from the earlywood and latewood regions of the 8.5% WPG wood block and their sorption isotherms were determined. A replicate standard error was estimated by the pooling over the different relative humidity levels and the earlywood and latewood samples (Fig. S.4). This pooled standard error was 0.03% within the 0-95% relative humidity range. The differences in measured moisture contents in (a) (b) Figure 6 a PLS predicted images comparison of crosssection surface and radial surface at 75% relatively humidity and 8.5% WPG.
b Predicted pixels histogram of corresponding images where the blue line represents mean predicted pixels.
earlywood and latewood were found statistically significant (p \ 0.01) based on paired t tests for both acetylated samples (Fig. 7, Table S.1). The differences in the reference sample earlywood and latewood were found statistically insignificant (p = 0.54, Table S.1). These results were in line with the DVS observations shown in Fig. 7.
The moisture content of earlywood and latewood measured by dynamic vapor sorption was corrected with the average WPG of the modified samples, because the distinct mass increase in earlywood and latewood regions was unknown. This may have enhanced the observed difference in moisture content, because we can expect that earlywood had a WPG above sample average, whereas latewood had a WPG below sample average. Nonetheless, the moisture content difference between earlywood and latewood observed by dynamic vapor sorption was smaller than in the predicted images. One potential reason is that it was difficult to obtain pure latewood sections because the latewood regions were much thinner than the earlywood and the cell wall thickness was constantly changing. Moreover, the models were calibrated on the average object level and used for the prediction of individual pixels which can slightly overestimate the moisture content. Overall, NIR hyperspectral imaging revealed the variation in wood moisture content at surface level that cannot be spatially resolved by traditional methods.

Conclusion
We have demonstrated how hyperspectral NIR imaging quantified the moisture content in chemically modified wood. We used acetylation as a tool to create moisture content variation within the wood samples. Our approach not only reliably estimated the overall surface moisture content but also identified local moisture differences between earlywood and latewood regions in the wood samples. In general, traditional gravimetric methods fail to address the localized chemical variation within wood. Based on our results, the spatial pixel predictions based on NIR imaging slightly overestimated the local moisture content in earlywood and latewood regions compared to what we measured with dynamic vapor sorption measurements. These artefacts were potentially generated by the calibration procedure, which was based on the average concentrations of the wood samples. Moreover, the separate WPGs of earlywood and latewood regions were unknown. Hence, the sorption isotherms were corrected with the bulk WPG obtained from earlywood and latewood. In the future, these issues should be addressed while developing the regression models for the prediction of moisture content in wood. We expect that more machine vision-based methods with certain upscaling similar to what we presented here must be considered in the field of modern wood science.

Acknowledgements
Financial support from the FinnCERES is acknowledged. Near-infrared hyperspectral imaging was performed at VTT Technical Research Centre of Finland. Author is thankful to their research team who helped to acquire the spectral imaging equipment in a short time. Special thanks go to Daniela Altgen for her hard work in preparing the vector illustrations of the graphical abstract.

Authors' contributions
MA: conceptualization, methodology, experimental design, software, image acquisition, image analysis and segmentation, dynamic vapor sorption, vector illustrations, original manuscript writing-review and editing. MA: conceptualization, methodology, image interpretation, DVS data interpretation, reviewing manuscript and editing. MM: conceptualization, methodology, imaging acquisition, review image analysis, data interpretation, reviewing manuscript and editing. Tiina Belt: data interpretation, reviewing manuscript and editing. LR: conceptualization, resources, writing and reviewing, project administration, and funding acquisition. DA: vector illustrations.

Funding
Open Access funding provided by Aalto University. This work was a part of the Academy of Finland's Flagship Programme under Projects No. 318890 and 318891 (Competence Center for Materials Bioeconomy, FinnCERES).

Data availability
Data sets and in-house scripts can be provided for the purpose of research by the corresponding author on reasonable request.

Declarations
Conflict of interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Numerical computation and illustrations Numerical computation and data plotting were performed on commercial software package Matlab (The mathworks. Inc.), PLS Toolbox (Eigen Research, Inc.) and OriginPro (Originlab Corp.). The vector illustrations were prepared using professional software Adobe Illustrator.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licen ses/by/4.0/.