Introduction

To achieve efficient use of plantation forests, the computer-assisted dyeing and color-matching technologies are used to improve inferior materials and imitate valuable materials (Guan 2011; Guan et al. 2010). Using the method based on Bayesian normalization algorithm and Levenberg–Marquardt (LM) algorithm to improve the traditional BP neural network has improved the accuracy of the simulation concentration and the generalization of the network (Nie et al. 2008), but the network convergence speed has not been significantly improved, and the training sample size is large. Based on the application of the improved RBF neural network in wood dyeing and color-matching technology, the generalization ability of the network is gradually improved to a certain extent (Guan et al. 2016). In traditional algorithms, evolutionary calculations in swarm intelligence are used to improve various problems in neural network modeling, aiming to solve the local limit problem of traditional BP neural networks in learning and training (Ji 2013), which can improve the learning accuracy. The convergence speed, to a certain extent, is superior to conventional neural network learning algorithms. The fixed parameters are set based on the Friele model, and different methods are used to predict and fit the reflectance and the reflection formula to obtain a color-matching result with a small color difference (Ma et al. 2017). The Friele model has a good prediction effect on multi-channel rotor spinning wool blended fabrics (Kielmann and Mai 2016), but this model has not been used in the direction of wood veneer dyeing. The Stearns–Noechel algorithm is used to establish a prediction model for each sample, and the model parameters are modified. Using this model can make the prediction of color measurement more accurate, greatly reduce the color difference of color matching, and improve the color-matching effect (Wang 2017). The adaptive cross factor and mutation factor are used to enhance the global search ability while increasing the convergence speed. The optimal value of the parameter M in the Stearns–Noechel model is determined by the method of loop iteration (Wei et al. 2020). The prediction accuracy of this method has been improved.

Aiming at the current problems of low dyeing efficiency, poor accuracy, and poor repeatability in wood dyeing, a hyperspectral wood dyeing color-matching algorithm based on the Friele model and Stearns–Noechel model of particle swarm optimization was proposed. First, according to the dyeing requirements, the dye solution was prepared to dye 82 stained veneers, and then, 14 from the 82 stained veneers were randomly selected as experimental samples. According to the data obtained from the reflectance curve, MATLAB was used to calculate the Friele model and Stearns–optimal parameters of Noechel model, and then, particle swarm algorithm was used to optimize the Friele model and Stearns–Noechel model, followed by MATLAB to calculate the parameters in a loop to obtain the best parameters. Finally, the best formulas of the two optimization algorithms were compared and the optimization algorithm with the highest degree of fit was selected.

Materials and methods

Experimental materials

In this study, Fraxinus mandshurica veneer was selected as the dyeing substrate. It was purchased from Harbin City, Heilongjiang Province, China. It was air-dried and cut into 60 mm × 40 mm × 0.5 mm (L × T × R) veneers. The red wing wood, black sour wood, and black wing wood in the natural veneer booklet of Deqing Langsheng Decoration Materials Co., Ltd., were selected as color-matching standards. Some of the natural veneers are shown in Fig. 1.

Fig. 1 
figure 1

Standard samples of natural wood: red wing wood, black sour wood, and black wing wood

Experimental methods

The dyes used in this experiment are industrial dyes reactive red X-3B, reactive yellow X-RG, and reactive brilliant blue. The dye penetrant JFC, fixing agent (anhydrous sodium carbonate), dye accelerator (anhydrous acetic acid), sodium chloride, and hydrochloric acid were purchased from Beijing Chemical Plant, Beijing, China. According to a certain color-mixing ratio, mixed color dyes were obtained. From 82 dyed wood veneer samples, 14 three-color mixed samples with different mass ratios were randomly selected as experimental samples for experimental verification, and the best parameter values of each mixed color sample were obtained. The different qualities of the mixed color samples are shown in Table 1.

Table 1  Mass ratio of mixed dye

The effect diagram obtained by selecting a single dye substrate of each component per unit concentration is shown in Fig. 2.

Fig. 2 
figure 2

Fragment of Fraxinus mandshurica bleached veneer and single-component dyed veneer

Results and discussion

According to the existing dyeing scheme, the dyes are mixed and dissolved in hydrochloric acid solution in different mass ratios, and dye penetrant JFC, fixing agent (anhydrous sodium carbonate), dye accelerant (anhydrous acetic acid), and sodium chloride are added to make the dyeing solution and single plate dyeing experiment. The veneers of different colors can be dyed according to different mixing ratios, the color value of each dyed veneer and raw materials is detected, and the color difference is fitted according to the reflectance curve, and the feasibility of the simulation wood dyeing prediction scheme is realized through optimization algorithm experiments.

Particle swarm optimization

Particle swarm optimization algorithm is an intelligent algorithm. Its principle is to imitate the best advantage of bird swarms or fish swarms to find a suitable position in the swarm. The fitness is the evaluation factor of its algorithm, where each particle has its corresponding fitness (Lin et al. 2013). Considering that this point is suitable for fitting the spectral reflection curve, this algorithm is selected for optimization and correction. The fitness function is as follows:

$${\text{fit}}_{p} = \sum\limits_{j = 400,j = j + 5}^{800} {\left| {f^{s} (\lambda_{j} ) - f^{t} (\lambda_{j} ) - \sum\limits_{i = 1}^{N} {c_{i} f(\lambda_{j} )} } \right|}$$
(1)

where \({\text{fit}}_{p}\) represents the fitness value of the pth individual in the particle group, and N represents the number of monochrome types participating in color matching, where \(\sum\nolimits_{i = 1}^{N} {c_{i} \le 1}\), N = 3.

Formula prediction based on optimized Friele model parameters

Friele model and determination of optimal parameter Q

The computer-assisted color matching of wood veneer dyeing mainly studies the optical model algorithm of multi-dye component mixed color matching and single group distribution color. The different dyes are mixed according to a certain concentration ratio. In theory, there is a certain additive relationship. Therefore, it is assumed that there is an intermediate function \(f\left[ {R(\lambda )} \right]\) about the spectral reflectance. When a single-component dye is mixed at different mass concentrations, the mixed dyes and the composition of the mixed color are mixed. The relationship between mixed dyes and single-color dyes of each component (Zhu 2019) is:

$$f\left[ {R_{{\text{m}}} (\lambda )} \right] = \sum\limits_{i = 1}^{n} {c_{i} f[R_{i} (\lambda )]}$$
(2)

where \(R_{{\text{m}}} (\lambda )\) represents the reflectance of the mixed dye liquor at a wavelength of λ; \(R_{i} (\lambda )\) represents the reflectance of each single-component dye at a wavelength of λ; \(c_{i}\) represents the concentration ratio of each component dye, \(\sum {c_{i} = 1} ,n = 3\).

In 1952, Friele conducted many experiments according to formula (2) and finally obtained the function formula about \(R(\lambda )\), namely the Friele model (Friele 1952). This paper investigated the color mixing dyes based on the Friele model and used MATLAB combined with the least square method to achieve full spectrum color matching. The Friele model is:

$$f[R(\lambda )] = e^{{ - Q[1 - R(\lambda )]^{2} /2R(\lambda )}}$$
(3)

where \(R(\lambda )\) represents the reflectance at a wavelength of λ; Q is a variable parameter value. The core link of the Friele model is to determine the Q value in the algorithm and predict the initial formulation of fixed parameters.

In this paper, experiments on 82 mixed color samples were used to solve the Q value when the minimum matching color difference was reached, and the optimal parameter Q value was 0.415.

Formula prediction with fixed parameters

This paper used the reflection spectrum matching algorithm (Yang et al. 2018; Li et al. 2014) to calculate the initial formula based on the target spectral data. To achieve the color spectrum matching, it was required to achieve the same spectral reflectance curve as the standard sample reflectance curve:

$$R_{{\text{m}}} (\lambda ) \approx R_{{\text{s}}} (\lambda )$$
(4)

where \(R_{{\text{m}}} (\lambda )\) is the reflectance of the standard sample at a wavelength of λ; \(R_{{\text{s}}} (\lambda )\) is the reflectance of the matched sample at a wavelength of λ.

The initial formula was solved according to the reflection spectrum matching algorithm, the minimum value of the color difference was calculated by the least square method, and the spectral reflectance curve was fitted to minimize the difference between the standard sample spectral reflectance curve and the matching sample spectral reflectance curve, which is

$$f[R_{{\text{m}}} (\lambda )] \approx f[R_{{\text{s}}} (\lambda )] = c_{1} f[R_{1} (\lambda )] + c_{2} f[R_{2} (\lambda )] + ... + c_{n} f[R_{n} (\lambda )]$$
(5)

where \(n = 3\), and the deviation was calculated by the method of least squares. According to the color measurement range of the chromatograph (400-700 nm), the wavelength interval is 20 nm, according to the formula:

$$\Delta = \min \left\{ \sum\limits_{\lambda = 400}^{{{7}00}} {\left[ {f[R_{s} (\lambda )] - c_{1} f[R_{1} (\lambda )] - c_{2} f[R_{2} (\lambda )] - c_{3} f[R_{3} (\lambda )]} \right]}^{2} \right\}$$
(6)

Standard color samples \(F_{m} = \left[ \begin{gathered} f(R_{400}^{m} ) \hfill \\ f(R_{420}^{m} ) \hfill \\ ... \hfill \\ f(R_{700}^{m} ) \hfill \\ \end{gathered} \right]\) and fitted color samples \(F_{s} = \left[ \begin{gathered} f(R_{400}^{s} ) \hfill \\ f(R_{420}^{s} ) \hfill \\ ... \hfill \\ f(R_{700}^{s} ) \hfill \\ \end{gathered} \right]\) were set to \(C = \left[ \begin{gathered} c_{1} \hfill \\ c_{2} \hfill \\ ... \hfill \\ c_{3} \hfill \\ \end{gathered} \right]\) constituting monochromatic dyes in the concentration ratio data \(F = \left[ \begin{gathered} f(R_{400}^{1} )f(R_{400}^{2} )...f(R_{400}^{n} ) \hfill \\ f(R_{420}^{1} )f(R_{420}^{2} )...f(R_{420}^{n} ) \hfill \\ \begin{array}{*{20}c} {...} & {\begin{array}{*{20}c} {} & {...} \\ \end{array} } & {\begin{array}{*{20}c} {} & {...} \\ \end{array} } & {\begin{array}{*{20}c} {} & {...} \\ \end{array} } \\ \end{array} \hfill \\ f(R_{700}^{1} )f(R_{700}^{2} )...f(R_{700}^{n} ) \hfill \\ \end{gathered} \right]\).

In addition, \(F_{m} \approx F_{s}\),

$$F_{m} \approx F \times C$$
(7)

The least square method was used to solve the equations to get \(C = (F^{T} \times F)^{ - 1} \times F^{T} \times F_{m}\), and obtain the spectral dye concentration formula.

Optimization of Friele model prediction equation

To make the experimental equation more accurate, this study combined the particle swarm algorithm to modify and improve the original model, cyclically calculate the parameters to obtain the optimal value, and fit the spectral reflectance curve to calculate whether the color difference is greater than 1. The specific process is shown in Fig. 3.

Fig. 3
figure 3

Optimized Friele model prediction formula flowchart

Optimization of Stearns–Noechel model parameter prediction

Spectral color-matching algorithm

The reflectance of the raw material measured by the hyperspectral, that is, the reflectance of the standard sample, is recorded as \(R_{m} (\lambda )\). It is assumed that at a specific wavelength, the following equation holds

$$f[R_{{\text{m}}} (\lambda )] = \sum {c_{i} } f[R_{i} (\lambda )]$$
(8)

where \(R_{{\text{m}}} (\lambda )\) represents the reflectance of the dye solution at a wavelength of λ, that is, the reflectance of the standard sample; \(R_{i} (\lambda )\) represents the reflectance of each component dye at a wavelength of λ; \(c_{i}\) represents the concentration ratio of each component's dye, \(\sum {c_{i} = 1}\).

To achieve color spectral matching, the spectral reflectance of the calculated sample (matching sample) is the same as that of the standard sample, and the dye solutions are mixed with different concentration ratios and different colors, that is,

$$f[R_{{\text{m}}} (\lambda )] = f[R_{{\text{s}}} (\lambda )]$$
(9)

where \(R_{{\text{s}}} (\lambda )\) is the reflectance of the matched sample at a wavelength of zero.

The deviation is determined by the least square method. According to the color measurement range of the chromatography (400-700 nm), the wavelength interval is 20 nm, according to the formula:

$$\Delta = \min \left\{ \sum\limits_{\lambda = 400}^{{{7}00}} {\left[ {f[R_{s} (\lambda )] - c_{1} f[R_{1} (\lambda )] - c_{2} f[R_{2} (\lambda )] - c_{3} f[R_{3} (\lambda )]} \right]}^{2} \right\}$$
(10)

The column vector \(F_{{\text{m}}}\) represents the \(f[R_{{\text{m}}} (\lambda )]\) value of the standard sample; the column vector A represents the concentration ratio of different monochromatic dyes; the matrix \(\phi\) represents the \(f[R_{i} (\lambda )]\) value of the monochromatic dye.

The above conversion matrix form is expressed as:

$$\begin{aligned} F_{s} & = \phi \cdot A \\ \Delta & = \min \left[ {(F_{m} - \phi A)^{T} (F_{m} - \phi A)} \right] \\ \end{aligned}$$
(11)

Because \(\Delta\) tends to be extremely small, the partial derivatives to the concentration ratio are all zero, and thus,

$$\begin{aligned} \phi^{T} \cdot \phi \cdot A & = \phi^{T} \cdot F_{m} \\ A & = (\phi^{T} \cdot \phi )^{ - 1} \phi^{T} \cdot F_{m} \\ A & = \phi^{ - 1} F_{m} \\ \end{aligned}$$
(12)

The concentration ratio A of monochrome dyes of different colors can be obtained.

Determination of Stearns–Noechel model parameter M

In 1944, Stearns and Noechel proposed a model of colored fiber reflectance addition and color mixing in Duntley through a large number of experiments and used black and white wool fibers for color mixing experiments (Ma et al. 2018). They proposed an empirical equation called Stearns–Noechel model:

$$f\left[ {R(\lambda )} \right] = \frac{1 - R(\lambda )}{{M\left[ {R(\lambda ) - 0.01} \right] + 0.01}}$$
(13)

where M is a variable and \(R(\lambda )\) is the reflectance at a wavelength of λ.

From Eq. (13), the relationship between the reflectance \(R(\lambda )\) and the intermediate function \(f\left[ {R(\lambda )} \right]\) can be derived as follows:

$$R(\lambda ) = \frac{{0.01(M - 1)f\left[ {R(\lambda )} \right] + 1}}{{Mf\left[ {R(\lambda )} \right] + 1}}$$
(14)

According to Eq. (14), the determination of the value of the unknown parameter M in the equation is the first problem to be solved.

The specific idea of solving the value of unknown parameter is the reflectance of the mixed dye obtained by the color measurement, using MATLAB to cyclically assign the parameter M, fitting the spectral reflectance, and combining the spectral reflectance to find the optimal value of M when the color difference is the smallest. In this experiment, the optimal parameter M value was calculated based on the 14 groups of three-color mixed dyes with different concentration ratios, that is, M = 0.48.

Optimizing the prediction formula of the Stearns–Noechel model

To make the final experimental equation more accurate, the original model was modified and improved in this study. The specific experimental process is shown in Fig. 4.

Fig. 4
figure 4

Calculation of the color difference using optimized algorithm model

As shown in the flowchart in Fig. 4, the spectral color-matching algorithm based on the Stearns–Noechel model corrects the fitted reflectance curve to obtain the dyeing formula, that is, the concentration ratio of each monochrome dye and the fitted color difference value. Among them,

$$\Delta c = \left[ \begin{gathered} c_{1} \hfill \\ c_{2} \hfill \\ ... \hfill \\ c_{j} \hfill \\ \end{gathered} \right]\,\,\,\,\Delta f = f[R_{{\text{s}}} (\lambda )] - f[R_{{\text{m}}} (\lambda )]$$
(15)

where \(c_{j}\) indicates the concentration of the \(j\)th dye, \(R_{{\text{s}}} (\lambda )\) indicates the spectral reflectance of the formula, \(R_{{\text{m}}} (\lambda )\) indicates the spectral reflectance of the standard sample, \(\Delta c\) indicates the difference in the proportion of the dyes in each component, and \(\Delta f\) indicates the difference between the formula reflectance and the standard sample reflectance. To improve the accuracy of the correction, \(\Delta c\) is a correction variable that reduces \(\Delta f\) to 0; thus,

$$\Delta c = (f[R_{{\text{m}}} (\lambda )]^{T} f[R_{{\text{m}}} (\lambda )])^{ - 1} f[R_{{\text{m}}} (\lambda )]^{T} \{ f[R_{{\text{s}}} (\lambda )] - f[R_{{\text{m}}} (\lambda )]\}$$
$$\Delta f = f[R_{s} (\lambda )] - f[R_{m} (\lambda )] = f[R_{m} (\lambda )]\Delta c$$
(16)

The basic idea of the particle swarm optimization algorithm is that the algorithm based on particle swarm optimization initializes the particle swarm parameters after determining the fitting correction coefficient, randomly generates particle swarm concentration \(c_{j}\)\((j \in [1,N])\) in the feasible solution space, and then corrects the individual particle position, and adjusts the generation according to the particle swarm algorithm. The concentration formula is then subjected to color difference fitting. Finally, the color difference value within the specified range was obtained and the monochrome density ratio and the fitted color difference value were outputs.

The algorithm steps are as follows:

  1. (1)

    Determine the standard color and solve the correction coefficient \(a_{1} ,a_{2} ,a_{3}\) through polynomial fitting;

  2. (2)

    Initialize the particle swarm algorithm parameters. Randomly generate an initial population of \(c = \{ c_{1} ,c_{2} ,...,c_{N} \}\) in the feasible solution space based on the actual problem, and calculate the fitness value of each particle through the fitness function, of which \(c_{j}\)\((j \in [1,N])\) randomly generated concentration formulas to be sought;

  3. (3)

    Correct the individual particle position and perform the particle swarm algorithm adjustment on the formula generated in Step (2) to generate a new concentration formula;

  4. (4)

    Check the end condition, set the end condition to \(\left| {fit_{p} } \right| < Error\) or reach the maximum number of iterations, and check whether the end condition is met. If not, repeat Step (3).

Calculation of color difference

According to Eq. (5), \(f[R_{{\text{s}}} (\lambda )]\) was obtained, and Eq. (3) was used to calculate \(R_{{\text{s}}} (\lambda )\) in reverse, which was the reflectance of the initial formula fitting color at the wavelength of λ. \(R_{{\text{m}}} (\lambda )\) was also obtained. Different illuminations adversely affect color difference evaluation of textile images in dyed fabrics. Therefore, an integrated particle swarm optimization based on rotating forest (RF) and sparse least square support vector regression (RF-PSO-SLSSVR) was proposed to establish an accurate illumination correction model (Zhou et al. 2019). In addition to the lighting conditions, the factors affecting chromatic aberration also need to be classified. In addition to the lighting conditions, the factors affecting chromatic aberration also need to be classified. To mitigate the problem of low classification accuracy in solid color printing and dyeing, a color difference classification model based on the differential evolution (DE) improved whale optimization algorithm (WOA) for extreme learning machine (ELM) optimization, and the model has strong generalization ability (Zhou et al. 2020). At the same time, the color difference classification is based on the establishment of a color difference classification model for printing and dyeing products, and a gray wolf algorithm optimization support vector machine based on the differential evolution model is proposed (Zhou et al. 2018). This method has high classification accuracy, good stability, and generalization ability. Thus, the experimental results were evaluated using the CIEDE2000 color difference evaluation standard. The CIEDE2000 color difference formula is a color evaluation formula proposed by the International Commission on Illumination in 2000. It introduced different parameters to adjust the weight of the color differences of \(\Delta L\), \(\Delta C\), and \(\Delta H\) in the total color difference. Because of the difference between the color evaluation measurement data and the visual result, there is a difference between the color evaluation method and the shape. The evaluation method is shown in formula (17):

$$\Delta E = \sqrt {\left( {\frac{\Delta L}{{K_{L} S_{L} }}} \right)^{2} + \left( {\frac{\Delta C}{{K_{C} S_{C} }}} \right)^{2} + \left( {\frac{\Delta H}{{K_{H} S_{H} }}} \right)^{2} + R_{T} \left( {\frac{\Delta C}{{K_{C} S_{C} }}} \right)\left( {\frac{\Delta H}{{K_{H} S_{H} }}} \right)}$$
$$\Delta L = L_{1} - L_{2}$$
$$\Delta C = C_{1} - C_{2}$$
$$\Delta H = 2\sqrt {C_{1} \cdot C_{2} } \sin \left( {\frac{\Delta h}{2}} \right)$$
$$R_{{\text{T}}} = - \,2\sin \left( {2\theta } \right)\left( {\frac{{\overline{C}^{7} }}{{\overline{C}^{7} + 25^{7} }}} \right)^{0.5}$$
(17)

where \(K_{L}\), \(K_{C}\), \(K_{H}\) are correction coefficients related to the experimental conditions, \(S_{L}\), \(S_{C}\), and \(S_{H}\) are weight coefficients for correcting the uniformity of the color space, \(R_{{\text{T}}}\) is a rotation function that corrects the deflection of the elliptical principal axis of the tolerance in the blue region of the color space, \(L = L^{*}\) brightness, chroma, \(C = \sqrt {a^{2} + b^{2} }\), \(a = \left( {1 + G} \right) \times a^{*}\), \(b = b^{*}\) adjustment factor \(G = 0.5 \times \left( {1 - \sqrt {\frac{{\overline{{C_{ab}^{*} }}^{7} }}{{\overline{{C_{ab}^{*} }}^{7} + 25^{7} }}} } \right)\), hue \(h = \arcsin \left( {b/a} \right)\), rotation angle \(\theta = 30\exp \left[ { - \left( {\frac{{\overline{h} - 275}}{25}} \right)^{2} } \right]\).

The fitted color difference values of different mixed dye mass ratios are calculated according to formula (17). Table 2 shows the fitted color difference based on the spectrum, Table 3 shows the fitted color difference based on the optimized Friele model, and Table 4 shows the fitted color difference based on the optimized Stearns–Noechel model. The fitted color difference of the Stearns–Noechel model was optimized. Comparing the ΔE values in the table, it can be found that the average color difference of the predicted formula of the optimized Stearns–Noechel model is smaller, so the accuracy of this optimization method is higher.

Table 2  Prediction formula based on spectral model
Table 3  Optimized Friele model prediction formula
Table 4  Optimized Stearns–Noechel model prediction formula

The sample area of natural wood is selected, as shown in Fig. 5A–C representing the detection area selected from the red wing wood, black sour wood, and black wing wood samples, respectively, and the veneer renderings obtained by dyeing according to the sample area. Using hyperspectral equipment to detect the sample veneer, the spectral reflectance curve of each sample veneer is shown in Fig. 6.

Fig. 5
figure 5

Sampling points of natural wood samples and staining effect diagrams of corresponding points

Fig. 6 
figure 6

Spectral reflectance curve of precious wood

Table 5 shows the reflectance data of the sample veneer and the dyed veneer. Fitting the reflectance curve according to the reflectance data is shown in Fig. 7. It can be seen from the error comparison of fitting reflectance curve in Fig. 7 and data analysis in Table 5 that the revised model used in this paper can effectively improve the color-matching efficiency and accuracy compared to the original model. From the color difference results, when the parameter values were fixed, the average fitted color difference was 0.8202. After improving and optimizing the Friele model, the average fitted color difference was 0.7287. After improving and optimizing the Stearns–Noechel model, the average fitted color difference was 0.6482. The color difference result was ideal and close to the real formula, indicating that the color-matching effect of the dyeing was greatly improved after the model was improved. By a comparison, the particle swarm improved Stearns–Noechel model was more accurate for wood color matching than the Friele model.

Table 5  Reflectance of precious tree species
Fig. 7 
figure 7

Comparison diagram of fitting reflectivity error of precious tree species

Conclusion

The hyperspectral color-matching process was established using the particle swarm optimization Friele model, through the circular calculation of unknown parameters Q by MATLAB. The fixed parameter Q value with the smallest color difference was selected as the optimal parameter prediction equation. The average fitted color difference was 0.7287. Based on the particle swarm optimization Stearns–Noechel model for the hyperspectral color matching, through the loop calculation of unknown parameter M by MATLAB, the fixed parameter M with the smallest color difference was selected as the optimal parameter prediction equation. The average fitted color difference was 0.6482. The color-matching performance was improved, which was close to the real formula. The optimized Stearns–Noechel algorithm enhanced the dyeing efficiency and accuracy. The color-matching result was more accurate, which is applicable to the wood dyeing industry and has good potential for the practical production.