Wood density detection method and system, computer equipment and storage medium
By combining terahertz spectroscopy with machine learning, the problems of low efficiency, high destructiveness, and insufficient cross-species detection accuracy in traditional wood density detection have been solved, achieving high-precision, non-destructive wood density detection that is suitable for forestry processing and wood quality assessment.
Patent Information
- Application Number
- CN202511467967.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-10-15
AI Technical Summary
Existing methods for detecting wood density are complex, destructive, highly sensitive to the environment, and lack spatial resolution. Furthermore, existing spectral models have poor stability, making it difficult to achieve accurate cross-species detection.
The time-domain spectral signal of the radial section of wood samples was acquired using a terahertz time-domain spectral system. It was converted into a frequency domain spectrum by fast Fourier transform. The terahertz refractive index of the frequency domain spectral features was extracted by combining the non-information variable elimination technique. The XGBoost model was used for training, and the model hyperparameters were optimized to improve the detection accuracy.
It achieves high-precision, non-destructive, and rapid wood density detection, improves cross-species detection accuracy, meets actual production needs, and is suitable for forestry processing and wood quality assessment.
Smart Images

Figure CN120948286A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of wood testing and analysis, and specifically relates to a method, system, computer equipment, and storage medium for wood density testing. Background Technology
[0002] Wood density is not only a key parameter characterizing the physical quality and mechanical properties of wood, but it also reflects the growth characteristics of trees. Therefore, accurate measurement of wood density is crucial for evaluating wood physical properties, grading materials, optimizing drying processes, and controlling product quality.
[0003] Existing methods for wood density testing mainly include the drainage method, mechanical stress method, X-ray density testing method, and near-infrared spectroscopy. However, these methods still have limitations such as complex procedures, destructive sample handling, high environmental sensitivity, and insufficient spatial resolution. The common drainage method involves weighing the wood sample, immersing it in water, and calculating the volume of the wood using the mass of the displaced water, thus determining the wood sample's density. This method is accurate but cumbersome, time-consuming, and cannot achieve real-time measurement. Mechanical force-based testing methods, such as using the Pilodyn method to test the basic density of living trees, suffer from anisotropy due to differences in growth rates among different tree species and even within the same species, leading to complex testing factors. Furthermore, the regression curve of density for one species cannot be applied to other species. While micro-drilling resistance instruments can quickly probe the internal structure of wood, they leave through-holes on the wood surface during measurement, constituting a micro-destructive test, and their results are affected by factors such as the wood diameter. X-ray density testing can determine wood density, but it requires a stringent testing environment. In addition, radiation can be harmful to human health, necessitating safety precautions. In addition, although non-destructive testing techniques such as near-infrared spectroscopy can detect wood density, their accuracy needs to be improved, and they are difficult to accurately reflect the fine internal structure and density changes of wood.
[0004] Existing technologies combine near-infrared spectroscopy (NIR) with machine learning algorithms. This invention collects near-infrared spectra of wood and uses PCA and PLS-R algorithms to build models for predicting wood density. For example, Alves et al. used NIR and X-ray data to establish a partial least squares regression (PLS-R) model for predicting the density of pine core wood. ARRIEL et al. used NIR data to establish a partial least squares regression (PLS-R) model for predicting the density of eucalyptus wood. However, wood has a complex composition, and its internal structure varies greatly in terms of spectral absorption and reflection across different wavelengths. When relying solely on spectral information for wood density prediction, the model's stability is significantly lacking, resulting in large fluctuations in prediction results. This makes it difficult to guarantee consistent and accurate predictions, and it cannot meet the needs of precise density detection for different types of wood in actual production. Summary of the Invention
[0005] To address the problems of low accuracy and significant loss in wood density prediction, this invention provides a wood density detection method, system, computer equipment, and storage medium.
[0006] To achieve the above objectives, the present invention provides a method for detecting wood density, comprising: Prepare radial section wood chip samples of the wood to be tested.
[0007] The time-domain spectral signal of the radial section wood chip sample was acquired using a terahertz time-domain spectral system; the time-domain spectral signal was converted into a frequency domain spectrum and a phase spectrum using a Fast Fourier Transform (FFT); based on the frequency domain spectrum and phase spectrum, the frequency domain spectral characteristics of the 0.2THz-1THz frequency band of the wood radial section sample were calculated; and the terahertz refractive index of the frequency domain spectral characteristics was extracted using the Uninformation Variable Elimination (UVE) technique.
[0008] The terahertz refractive index is input into a preset model to obtain the predicted density value of the wood to be tested.
[0009] Preferably, the preset model is an XGBoost model, and before inputting the terahertz refractive index into the XGBoost model, the method further includes: Low-density fast-growing tree species and high-density Pterocarpus species were prepared as radial section wood chip samples. The radial section wood chip samples were placed in a constant temperature and humidity chamber, and the true density label of the samples was determined by the water displacement method. Terahertz refractive index of radial section wood chip samples from low-density fast-growing tree species was selected. The terahertz refractive index of the radial section wood chip samples and the corresponding true density labels of the samples were input into Elastic Regression (ENR), Random Forest (RF), and Extreme Gradient Boosting (XGBoost) models for training. During training, the learning rate and regularization term weights of the ENR model were optimized using the Particle Swarm Optimization (PSO) algorithm. The maximum depth and number of trees of the RF and XGBoost models were also optimized using the PSO algorithm. The terahertz refractive index of radial section wood chip samples of low-density fast-growing tree species is input into the trained model for prediction. Based on the prediction results, the optimal pre-trained model is initially selected as XGBoost. The optimal pre-trained model XGBoost is then optimized to obtain the final test XGBoost model.
[0010] Preferably, optimizing the optimal pre-trained XGBoost model to obtain the final test XGBoost model includes: Key features were extracted from radial section wood chip samples of low-density fast-growing tree species and high-density Pterocarpus species, respectively. The maximum depth and number of trees in XGBoost were optimized using the Particle Swarm Optimization (PSO) algorithm; the optimal model XGBoost was calibrated by introducing a learning rate; the key features of radial section wood chip samples of low-density fast-growing tree species and high-density Pterocarpus species were input into the optimized XGBoost model for training, and the training prediction results of wood density were obtained. Using the wood density training prediction results and the actual density labels, the cross-species determination coefficient R² and the root mean square error (RMSE) index are calculated respectively. When both R² and RMSE meet the preset thresholds, the XGBoost model is determined to be the final test XGBoost model.
[0011] Preferably, before extracting the terahertz refractive index of the frequency domain spectral features using the Uninformation Variable Elimination (UVE) technique, the method further includes preprocessing the frequency domain spectral features of each radial section wood chip sample. Specifically, this includes calculating the feature similarity of the frequency domain spectral features of any two radial section wood chip samples and uniformly distributing the results of all samples according to the feature similarity calculation using a hierarchical KS algorithm.
[0012] The present invention also provides a wood density detection system, comprising: The sample collection module is used to prepare radial section wood chip samples of the wood to be tested.
[0013] The feature extraction module is used to acquire the time-domain spectral signal of the radial section wood chip sample using a terahertz time-domain spectral system; convert the time-domain spectral signal into a frequency domain spectrum and a phase spectrum using a Fast Fourier Transform (FFT); calculate the frequency domain spectral features of the 0.2THz-1THz frequency band of the wood radial section sample based on the frequency domain spectrum and phase spectrum; and extract the terahertz refractive index of the frequency domain spectral features using a no-information variable elimination (UVE) technique.
[0014] The model application module is used to input the terahertz refractive index into a preset model to obtain the predicted density value of the wood to be tested.
[0015] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps in the wood density detection method.
[0016] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, is capable of executing any of the steps in the wood density detection method.
[0017] The wood density detection method provided by this invention has the following beneficial effects: This invention first prepares radial section wood chip samples of the wood to be tested; then, it collects the time-domain spectral signal of the wood radial section sample. The time-domain spectral signal can obtain information about the internal microstructure of the wood, has a certain degree of penetration into the wood, and will not cause physical damage to the wood, thus avoiding the destruction of wood samples by traditional detection methods and ensuring that the subsequent use value of the wood is not affected; frequency-domain spectral features are extracted from the time-domain spectral signal; the terahertz refractive index of the frequency-domain spectral features is extracted and input into a preset model to obtain the predicted density value of the wood to be tested; the key frequency-domain features show good performance in the density detection of different tree species, effectively improving the accuracy of cross-species detection. Attached Figure Description
[0018] To more clearly illustrate the embodiments of the present invention and its design, the accompanying drawings required for these embodiments will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0019] Figure 1 This is a flowchart of a wood density detection method according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating the model selection and application of the wood density detection method according to an embodiment of the present invention. Detailed Implementation
[0020] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical invention of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0021] like Figure 2As shown, this invention discloses a non-destructive testing technology for wood density based on the fusion of terahertz spectroscopy and machine learning, aiming to solve the problems of low efficiency and high destructiveness of traditional testing methods. The study selected fast-growing tree species and high-density species of the *Pterocarpus* genus as samples. Radial section wood chips were prepared and placed in a constant temperature and humidity chamber to equilibrate to constant mass. The true density was determined using the displacement method and used as the label value. The time-domain spectra of the samples were acquired using a terahertz time-domain spectroscopy system (QT-TRS1000), converted into frequency and phase spectra by Fast Fourier Transform (FFT), and 560 initial refractive index features in the 0.2THz-1THz frequency band were calculated. The Uninformationless Variable Elimination (UVE) method was used to screen 73 key features from the initial features. Subsequently, the performance of three models was compared, and finally, the XGBoost model, tuned by the Particle Swarm Optimization (PSO) algorithm, was selected for training. The contribution of key features to the prediction results was quantitatively analyzed using SHAP values. Test results show that the model performs excellently in cross-species timber density prediction, with a coefficient of determination (R²) of 0.9862 and extremely low root mean square error, achieving high-precision, non-destructive, and efficient timber density detection. This technology can be widely applied in forestry processing, timber quality assessment, and other scenarios, providing an innovative technical approach for timber characteristic analysis and possessing significant practical value.
[0022] This invention provides a method for detecting wood density, specifically as follows: Figure 1 As shown, it includes: Samples were prepared from timber from three fast-growing tree species (Chinese fir, poplar, and eucalyptus). The radial sections of the timber were prepared to a size of 20 mm (transverse) × 20 mm (longitudinal) × 20 mm (tangential). All samples were equilibrated in a constant temperature and humidity chamber (20±1℃, 50±2% RH) until their mass was constant. The basic density of the timber was determined according to GB / T1927.5-2021 using the water displacement method.
[0023] Terahertz time-domain spectroscopy (THDTS1000) was used to acquire terahertz spectra of radial sections of wood samples with different densities. Each sample was scanned five times and the average value was taken to reduce testing error. The time-domain signal of the sample and the reference signal were converted into frequency-domain and phase spectra using Fast Fourier Transform (FFT). The reference signal was a sampling signal with air as the medium, used as a reference condition to assist in the sampling of the sample, thereby calculating the terahertz refractive index of the wood sample. The calculation formula is as follows.
[0024] ; in, d For sample thickness, c At the speed of light, Angular frequency, This represents the phase difference.
[0025] By acquiring microstructural information about wood through terahertz time-domain spectroscopy and combining it with advanced machine learning algorithms for data mining and analysis, a precise correlation model between wood density and terahertz refractive index can be established. In cross-species wood density prediction, the test set R² reaches 0.9846, which is further improved to 0.9862 after feature selection using the UVE algorithm, far exceeding the accuracy of existing similar technologies. Terahertz waves have a certain degree of penetrability to wood without causing physical damage, avoiding the destruction of wood samples by traditional detection methods and ensuring that the subsequent use value of the wood is not affected.
[0026] The specific steps for spectral data preprocessing include: Given the low signal-to-noise ratio of optical guide antennas in the 0-0.2THz frequency band, band selection was performed on the processed sample dataset, and the sample refractive index was selected as a feature in the band range of 0.2THz-1THz.
[0027] A hierarchical KS (Knowledge, Skill, and Sort) method was used to partition the dataset, with 80% allocated to the training set and the remainder to the test set. The datasets from each tree species were then merged. The KS algorithm is based on the Euclidean distance of the sample spectral features. It iteratively selects the sample with the largest Euclidean distance from the existing training set samples, ensuring uniformity of sample distribution in the feature space. Samples not selected in the training set naturally form the test set. (Euclidean distance is used here.) The calculation formula is as follows: ; in, , M For the number of samples, and For two different samples, N The number of spectral features of the sample. i This is the index of the number of spectral features in the sample.
[0028] Based on the extracted band range of 0.2THz-1THz, a model was trained using the training set. The algorithm was then trained using the training set and the trained model to obtain prediction results for the test set. Specific steps included: selecting multiple regression models for training the timber density prediction model, including Elastic Regression Network (ENR), Random Forest (RF), and Extreme Gradient Boosting (XGBoost). Hyperparameter optimization was performed on the three models using Particle Swarm Optimization (PSO). The PSO algorithm parameters were set as follows: inertia weight ω=0.8, cognitive factor c1=1.5, and social factor c2=2.3. Model evaluation and performance comparison were conducted using the test set results.
[0029] In this embodiment, Particle Swarm Optimization (PSO) is used for hyperparameter tuning of models such as ENR, RF, and XGBoost. For ENR, the complexity of the model is controlled and the bias and variance are balanced by adjusting the weight ratio of the learning rate and regularization term. For ensemble decision tree models such as RF and XGBoost, the main hyperparameters optimized include the number of trees (n_estimators) and the maximum depth (max_depth), which are used to control the model's fitting ability and complexity.
[0030] After evaluating the optimal XGBoost model, the XGBoost prediction model is optimized by fusing multi-tree species spectral data and UVE feature selection. The specific steps are as follows: Three high-density Pterocarpus species—Angola rosea, dye rosea, and sandalwood rosea—were selected and combined with wood samples from three fast-growing tree species. The data set division method and spectral band selection for the three Pterocarpus species were based on those for the fast-growing tree species.
[0031] To further improve the performance of the XGBoost model, the Uninformative Variable Elimination (UVE) method was used for feature selection to identify the features that contribute most to wood density prediction. The UVE method removes redundant and irrelevant features, reducing model complexity and improving training efficiency and generalization ability. For 560 original refractive index feature frequencies in the 0.2THz-1THz frequency band, after multiple tests, 87% was determined as the optimal feature selection threshold, ultimately selecting 73 key feature frequencies.
[0032] An XGBoost timber density prediction model was built using selected features. Besides optimizing the XGBoost hyperparameters with PSO, parameters such as learning rate and subsample ratio were introduced to suppress overfitting and improve the model's generalization performance. The training set was input into the optimized model to obtain the corresponding prediction results, which were then compared with actual measurements to evaluate the model's prediction accuracy. The coefficient of determination (R²) was used as the evaluation metric. 2 The model's performance was evaluated using metrics such as root mean square error (RMSE). Based on the optimized XGBoost model and combined with terahertz time-domain spectral data, a fast and high-precision wood density prediction system was established, applicable to wood density prediction for different tree species, providing a scientific basis for accurate assessment of forestry resources and wood processing. The study covers various types of wood, including fast-growing tree species and high-density Pterocarpus spp. wood. The constructed model showed good performance in wood density detection for different tree species, effectively solving the problem of significant accuracy decline in existing technologies when detecting wood across different tree species.
[0033] The Uninformation Variable Elimination (UVE) technique was used to screen the refractive indices corresponding to key feature frequencies from the frequency domain spectral features. Furthermore, the SHAP value was used to quantify the contribution of each frequency point in conjunction with these 73 key feature frequencies, analyzing the intensity and direction of the feature's influence on the model output, thereby identifying key feature frequencies that significantly contribute to the prediction results. The SHAP method allows for in-depth analysis of the model prediction process, clarifying the contribution of different refractive indices to wood density prediction, and providing a strong basis for model optimization and further understanding of the relationship between wood's internal structure and density.
[0034] This invention enables high-precision, non-destructive, rapid, and universally applicable wood density detection, effectively solving the problems of destructiveness, low efficiency, poor real-time performance of traditional detection methods, as well as the high cost, instability, and lack of universality of existing similar technologies. It meets the practical needs of forestry management, wood processing, ecological monitoring, and other fields for accurate wood density detection.
[0035] Based on the same inventive concept, the present invention also provides a wood density detection system, comprising: The sample collection module is used to prepare radial section wood chip samples of the wood to be tested.
[0036] The feature extraction module is used to acquire the time-domain spectral signal of the radial section wood chip sample using a terahertz time-domain spectral system; convert the time-domain spectral signal into a frequency domain spectrum and a phase spectrum using a Fast Fourier Transform (FFT); calculate the frequency domain spectral features of the 0.2THz-1THz frequency band of the wood radial section sample based on the frequency domain spectrum and phase spectrum; and extract the terahertz refractive index of the frequency domain spectral features using a no-information variable elimination (UVE) technique.
[0037] The model application module is used to input the terahertz refractive index into a preset model to obtain the predicted density value of the wood to be tested.
[0038] This invention also provides a computer device. At the hardware level, the computer device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the wood density detection method provided above.
[0039] The present invention also provides a computer-readable storage medium storing a computer program that can be used to execute the wood density detection method provided above.
[0040] Specific limitations regarding the calculation system for wood density testing methods can be found in the limitations of wood density testing methods described above, and will not be repeated here. Each module in the aforementioned wood density testing system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0041] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. Furthermore, the above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for detecting wood density, characterized in that, include: Prepare radial section wood chip samples of the wood to be tested; The time-domain spectral signal of the radial section wood chip sample was acquired using a terahertz time-domain spectral system; the time-domain spectral signal was converted into a frequency domain spectrum and a phase spectrum using a fast Fourier transform (FFT); based on the frequency domain spectrum and phase spectrum, the frequency domain spectral characteristics of the 0.2THz-1THz frequency band of the wood radial section sample were calculated. The terahertz refractive index of the frequency domain spectral features was extracted using the uninformed variable elimination (UVE) technique. The terahertz refractive index is input into a preset model to obtain the predicted density value of the wood to be tested.
2. The method for detecting wood density according to claim 1, characterized in that, The preset model is an XGBoost model. Before inputting the terahertz refractive index into the XGBoost model, the following steps are also included: Low-density fast-growing tree species and high-density Pterocarpus species were prepared as radial section wood chip samples. The radial section wood chip samples were placed in a constant temperature and humidity chamber, and the true density label of the samples was determined by the water displacement method. Terahertz refractive index of radial section wood chip samples from low-density fast-growing tree species was selected. The terahertz refractive index of the radial section wood chip samples and the corresponding true density labels of the samples were input into Elastic Regression (ENR), Random Forest (RF), and Extreme Gradient Boosting (XGBoost) models for training. During training, the learning rate and regularization term weights of the ENR model were optimized using the Particle Swarm Optimization (PSO) algorithm. The maximum depth and number of trees of the RF and XGBoost models were also optimized using the PSO algorithm. The terahertz refractive index of radial section wood chip samples of low-density fast-growing tree species is input into the trained model for prediction. Based on the prediction results, the optimal pre-trained model is initially selected as XGBoost. The optimal pre-trained model XGBoost is then optimized to obtain the final test XGBoost model.
3. The method for detecting wood density according to claim 2, characterized in that, The optimization of the optimal pre-trained XGBoost model to obtain the final test XGBoost model includes: Key features were extracted from radial section wood chip samples of low-density fast-growing tree species and high-density Pterocarpus species, respectively. The maximum depth and number of trees in XGBoost were optimized using the Particle Swarm Optimization (PSO) algorithm; the optimal model XGBoost was calibrated by introducing a learning rate; the key features of radial section wood chip samples of low-density fast-growing tree species and high-density Pterocarpus species were input into the optimized XGBoost model for training, and the training prediction results of wood density were obtained. Using the wood density training prediction results and the actual density labels, the cross-species determination coefficient R² and the root mean square error (RMSE) index are calculated respectively. When both R² and RMSE meet the preset thresholds, the XGBoost model is determined to be the final test XGBoost model.
4. The method for detecting wood density according to claim 1, characterized in that, Before extracting the terahertz refractive index of the frequency domain spectral features using the Uninformation Variable Elimination (UVE) technique, the method further includes preprocessing the frequency domain spectral features of each radial section wood chip sample. Specifically, this includes calculating the feature similarity of the frequency domain spectral features of any two radial section wood chip samples and uniformly distributing the results of all samples according to the feature similarity calculation using a hierarchical KS algorithm.
5. A wood density detection system, characterized in that, include: The sample collection module is used to prepare radial section wood chip samples of the wood to be tested; The feature extraction module is used to acquire the time-domain spectral signal of the radial section wood chip sample using a terahertz time-domain spectral system; convert the time-domain spectral signal into a frequency domain spectrum and a phase spectrum using a fast Fourier transform (FFT); and calculate the frequency domain spectral features of the 0.2THz-1THz frequency band of the wood radial section sample based on the frequency domain spectrum and phase spectrum. The terahertz refractive index of the frequency domain spectral features was extracted using the uninformed variable elimination (UVE) technique. The model application module is used to input the terahertz refractive index into a preset model to obtain the predicted density value of the wood to be tested.
6. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is loaded by the processor, it is able to perform the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method for detecting amino acid content in grain by use of terahertz frequency-domain spectrum technology
CN104330384A
Wood identification method based on reflection type terahertz time-domain spectroscopy
CN117347309A
Terahertz spectrum and machine learning combined trace organic matter type and concentration detection method
CN120594440A
Method for qualitative and quantitative determination of key substances in mixture based on terahertz spectrum
US20200217790A1