Solid wood floor color classification method based on improved SSA-BP neural network
By improving the SSA-BP neural network and combining it with Arnold mapping and Levy flight strategy to optimize the BP neural network, the problem of incomplete feature extraction in solid wood flooring color classification was solved, and the automation and accuracy of solid wood flooring color classification were achieved, with the classification accuracy reaching 96.15%.
Patent Information
- Application Number
- CN202510921602.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-10-17
AI Technical Summary
Existing solid wood floor color classification methods ignore or eliminate the influence of wood grain on color classification, feature extraction is not comprehensive enough, classification accuracy is not high, and traditional algorithm selection leads to poor classifier performance.
An improved SSA-BP neural network was used to extract the characteristic parameters of solid wood floor images, and the weights and thresholds of the BP neural network were optimized by combining Arnold mapping and Levy flight strategy. The improved SSA algorithm was used for training and prediction, which solved the problem that the SSA algorithm was prone to falling into local optimal solutions and improved the classification accuracy.
The automation and accuracy of solid wood floor color classification have been achieved, the detection accuracy has been improved, the global search capability and convergence speed of the algorithm have been enhanced, and the classification accuracy has reached 96.15%.
Smart Images

Figure CN120808014A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine vision, in particular to a solid wood floor color classification method based on improved SSA-BP neural network. BACKGROUND
[0002] Solid wood floor has unique color and texture of wood, so there is color difference, which affects the aesthetic degree of floor laying. In actual factory production, it is necessary to classify solid wood floor by color to ensure that the floor color is uniform during decoration and meet different needs of consumers. The traditional solid wood floor classification method is still manual visual inspection, which is greatly affected by subjective factors, and the classification standard is not uniform, and the classification speed and accuracy are difficult to meet the requirements. In order to improve the intelligent level of solid wood floor production process, using machine vision technology to classify the floor color can better ensure the accuracy of classification.
[0003] There are few researches on solid wood floor color classification using machine vision technology at home and abroad, most of which are used for wood color classification. Hu et al. classified wood color features using support vector machine, and the classification accuracy could reach 90%; Shivashankar S et al. constructed texture features based on color histogram, and used K nearest neighbor classifier to classify wood; Ding Kun proposed a feature extraction method based on probability, and used extreme learning machine to classify the color of solid wood floor, with an accuracy of 97.78%, but the image quality requirement was high; Wang Jinya used grey wolf optimization extreme learning machine to classify and identify solid wood floor, and the highest recognition accuracy of 3 color grades was 92.7%.
[0004] Through research, it is found that the existing floor color classification methods all ignore or eliminate the influence of wood grain on color classification, and the feature extraction is not comprehensive enough, and in the selection of classification method, the algorithm still selects the traditional classifier, and the classification accuracy is not high. SUMMARY
[0005] The present application provides a solid wood floor color classification method based on improved SSA-BP neural network, which can classify the solid wood floor into light color, medium color and dark color in indoor environment, solve the problem that SSA algorithm is easy to fall into local optimal solution, improve the accuracy of solid wood floor color classification, and realize the automation of solid wood floor production.
[0006] Technical scheme: A solid wood floor color classification method based on improved SSA-BP neural network, comprising the following steps:
[0007] Step 1: Obtain the image of solid wood floor to be color classified;
[0008] Step 2: Preprocess the image of solid wood floor to be color classified to obtain a preprocessed floor image;
[0009] Step 3: Extract the required feature parameters from the preprocessed floor image, including the first moment color average value of each channel in the RGB space and the HSV space, the second moment variance of each channel in the RGB space and the HSV space, the gray average value of the floor image after removing the wood grain, the wood grain gray average value and the wood grain proportion of the floor image after removing the wood grain;
[0010] Step 4: Input the feature parameters obtained in Step 3 into the pre-trained improved SSA-BP neural network to obtain a color classification result; the color classification result includes light color, medium color and dark color;
[0011] The pre-trained improved SSA-BP neural network is obtained according to the following steps:
[0012] Step 1: Determine the topological structure of the BP neural network; the topological structure of the BP neural network includes an input layer, a hidden layer and an output layer;
[0013] Step 2: Optimize the initial weights and thresholds of the BP neural network using the improved SSA algorithm; SSA simulates the foraging and anti-predation behavior of sparrows, constantly updates the individual position, finds the optimal solution, and obtains the optimized initial weights and thresholds;
[0014] Step 3: Use the optimized initial weights and thresholds to train the BP neural network through the back propagation algorithm, constantly adjust the weights and thresholds, make the BP neural network output gradually approach the expected value, and obtain the pre-trained improved SSA-BP neural network;
[0015] The improved SSA algorithm includes the following steps:
[0016] Step 2_1: Initialize the sparrow population parameters, including population size, maximum iteration number, safety value, initial position and best position;
[0017] Step 2_2: Define the mean square error average value of the BP neural network training set and test set as the fitness value, calculate the fitness value of the sparrow individual, select the minimum value as the best fitness, and the corresponding sparrow individual position is the optimal position;
[0018] Step2_3: Sparrows are divided into three different roles of discoverer, joiner and scout; update the position of sparrow according to the role of itself; wherein, the position update of the scout is optimized by using Levy flight strategy; Step2_4: update the best fitness value and the optimal position; update the fitness value, record the best fitness value after each iteration, select the global optimal position after completing the maximum iteration number, otherwise continue iteration.
[0019] Step2_5: determine whether the maximum iteration number is reached, if yes, obtain the global optimal position, if not, execute Step2_2.
[0020] Further, the number of hidden layer nodes that minimizes the mean square error of the training set is taken as the number of hidden layers in the BP neural network.
[0021] Further, in Step2_1, the population is initialized according to the following steps:
[0022] Randomly generate initial population X i =[x i1 ,...,x id ], wherein i=1,2,...,N is the number of sparrows, d is the dimension of data to be optimized, and randomly generate initial population Y i =[y i1 ,...,y id ]; based on Arnold mapping, the two randomly generated populations X i and Y i are mapped and combined into a new population; the first N of the fitness values of the new population are taken as the initial population.
[0023] Further, the Arnold mapping is represented as:
[0024]
[0025] In the formula, a and b are fixed parameters.
[0026] Further, the position update of the discoverer is represented as:
[0027]
[0028] In the formula, t is the current iteration number, j=1,2,...,d, iter max is the maximum iteration number; alpha is a random number in (0,1), R2 is a warning value in (0,1), ST is a safety value in [0.5,1]; Q is a random number subject to normal distribution, and L is a 1xd matrix with all elements being 1.
[0029] Further, the position update of the joiner is represented as:
[0030]
[0031] wherein, is the optimal position and the worst position of the discoverer, A is a 1xd matrix of all 1 or -1 elements, and L is a 1xd matrix of all 1.
[0032] Further, the position update of the scout is optimized by using the Levy flight strategy, and the position update of the scout is specifically as follows:
[0033] The position update of the scout is as follows:
[0034]
[0035] wherein, is the global optimal position, θ is a step parameter, and θ obeys a standard normal distribution, P is in [-1, 1[, f i , f g , f ω are respectively a current fitness value of the individual, a global optimal fitness value and a global worst fitness value, and ε is a minimum constant;
[0036] wherein, the Levy calculation formula is as follows:
[0037]
[0038] wherein, Γ is a gamma function, e is a constant, and r1 and r2 are random numbers in [0, 1].
[0039] Beneficial effects: compared with the prior art, the present application has the following advantages:
[0040] (1) the method of the present application extracts the feature parameters of the solid wood floor image, trains and predicts the solid wood floor image by using the SSA-BP neural network, and obtains the floor color; the SSA algorithm is used to optimize the weight and threshold value of the BP neural network, and the Arnold mapping and Levy strategy are used to improve the SSA algorithm, so that the accuracy of the solid wood floor color classification can be effectively improved;
[0041] (2) the method of the present application optimizes the BP neural network by using the SSA algorithm, and uses the optimized BP neural network for solid wood floor color detection, so that the accuracy of the detection can be improved, and the solid wood floor color detection automation can be realized; by combining the SSA algorithm with the BP neural network, the global search ability of the SSA algorithm is used to solve the problem that the BP neural network is prone to falling into a local optimal solution;
[0042] (3) The method of the present invention improves the SSA algorithm by introducing Arnold mapping to improve the initial population of the SSA algorithm and introducing Levy flight strategy to improve the sparrow update position, thereby improving the population quality, enhancing the algorithm convergence speed, and improving the algorithm search range and efficiency, thereby enhancing the global search capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of a solid wood floor color classification method using an improved SSA-BP neural network proposed by the present invention;
[0044] Figure 2 Comparison chart of true value and predicted value of three algorithms;
[0045] Figure 3 This is a comparison chart of the prediction errors of the three algorithms;
[0046] Figure 4 This is a working model diagram of the virtual simulation mechanical system of the solid wood floor sorting device;
[0047] Figure 5 This is the overall structure diagram of the solid wood floor sorting device;
[0048] Figure 6 This is the control system schematic. DETAILED DESCRIPTION
[0049] The technical solution of this embodiment will now be further described with reference to the accompanying drawings and embodiments.
[0050] Example 1:
[0051] like Figure 1 As shown, this embodiment proposes a solid wood floor color classification method using an improved SSA-BP neural network. In solid wood floor color detection, extracting floor feature parameters is the foundation and key to the detection results. This embodiment takes into account the influence of factors such as lighting, hue, saturation, and wood grain. It extracts color features in RGB and HSV spaces, calculates the grayscale values of the wood grain and floor, and establishes a solid wood floor feature parameter vector. Finally, an improved sparrow search algorithm is used to optimize the weights and thresholds of the BP neural network, train and predict the feature parameters, and achieve rapid and accurate classification of solid wood floors into light, medium, and dark colors. Each step is now further explained.
[0052] Step 1: Use a visual sensor to collect images of solid wood floors, preprocess the images, extract feature parameters, and construct a data set. The specific operations include:
[0053] The floor image is segmented from the solid wood floor image to filter out the background effect, and then the image is median filtered to reduce noise, remove redundant information in the image, and improve the classification accuracy.
[0054] From the pre-processed solid wood floor image, the first moment and the second moment of each channel in RGB space and HSV space are extracted, and the first moment color average and the second moment variance are taken as characteristic parameters. In the gray image, the wood grain in the solid wood floor image is segmented by OTSU (maximum inter-class variance method), and then the average gray value T of the floor image after removing the wood grain is calculated gray , the average gray value B of the wood grain gray , and the proportion P of the wood grain are taken as characteristic parameters. Table 1 shows the characteristic parameters extracted from three solid wood floor images of different colors selected at random. For data processing convenience, the first moment and the second moment of H, S and V are multiplied by 100.
[0055] Table 1 Characteristic parameters of solid wood floor of different colors
[0056]
[0057] According to the above steps, 1000 solid wood floor images are pre-processed and the characteristic parameters are extracted, wherein the solid wood floor images and the color classification standard are provided by the floor factory.
[0058] After extracting the characteristic parameters, a data set is established, wherein 80% is a training set and 20% is a test set, and then all the data are normalized.
[0059] Step 2: Determine the topology structure of BP neural network; according to the extracted characteristic parameters, the input layer node of BP neural network is 15 and the output layer node is 1, i.e. the color category of solid wood floor. The number of nodes in the hidden layer affects the efficiency and speed of the algorithm, so the number of nodes in the hidden layer is found by traversing the hidden layer node number to find the minimum mean square error of the training set as the best hidden layer node number. The transfer function between the input layer and the hidden layer selects the S-type function tansig, and the linear function purelin is selected between the hidden layer and the output layer. Other parameters are given by training effect, as shown in the following table:
[0060] Table 2 Neural network related parameters
[0061] Network parameter Parameter values net.trainParam.epochs (number of training epochs) 1000 net.trainParam.lr (learning rate) 0.01 net.trainParam.goal (training target minimum error) 0.00001 net.trainParam.show (display frequency) 25 net.trainParam.mc (momentum factor) 0.01 net.trainParam.min_grad (minimum performance gradient) 10 -6 ]] net.trainParam.max_fail (maximum number of failures) 6
[0062] Step 3: Initialize sparrow swarm parameters;
[0063] According to the training results, the sparrow swarm related parameters in SSA are set, including population size, maximum iteration number, safety value, initial position, best position, etc.
[0064] In the SSA algorithm, it is assumed that the randomly generated initial population is X i =[x i1 ,...,x id], where i = 1, 2,..., N is the number of sparrows, and d is the data dimension to be optimized. Since SSA randomly generates an initial population, it leads to uneven population distribution, affecting the convergence speed. Therefore, the embodiment improves the initialization population based on Arnold mapping, maps two randomly generated populations X i i and Y max after mapping calculation, and merges them into a new population. The top N optimal solutions are selected as the initial population of sparrows according to the fitness value of the new population, improving the diversity of the population and enhancing the global search ability of the algorithm. The Arnold mapping expression is:
[0065]
[0066] where a and b are fixed parameters, set as a = b = 1.
[0067] Step 4: Calculate the fitness value of the sparrow individual. The fitness function is the average mean square error of the training set and the test set of the BP neural network. The smaller the fitness function value, the more accurate the training, and the minimum fitness value is selected as the best fitness. The corresponding sparrow position is the optimal position.
[0068] Step 5: Update the sparrow individual position.
[0069] In the SSA algorithm, sparrow individuals can be divided into three different roles: discoverers, joiners, and scouts. They constantly improve their search strategies by observation and learning to find food.
[0070] where the position of the discoverer is updated as follows:
[0071]
[0072] where t is the current iteration number, j = 1, 2,..., d, iter max is the maximum iteration number; a e (0, 1) is a random number, R2 e (0, 1) is a warning value, ST e [90.5, 1] represents a safety value; Q is a random number following a normal distribution, and L is a 1 x d matrix with all elements being 1.
[0073] where the joiner will monitor or seize food according to the position of the discoverer, and the position update is as follows:
[0074]
[0075] where is the optimal position and the worst position of the discoverer, A is a 1 x d matrix with all elements being 1 or -1, and L is a 1 x d matrix with all elements being 1.
[0076] Wherein, the initial position of the scout is randomly generated, the scout will give an early warning and gather to the safe area when danger comes, and the position is updated as follows:
[0077]
[0078] In the formula, is the global optimal position, θ is the step parameter, and obeys the standard normal distribution, P ∈ [-1, 1], f i , f g , f ω are the current fitness value, the global best fitness value and the global worst fitness value of the individual respectively, and ε is a minimum constant.
[0079] Since the SSA algorithm is prone to fall into local extremum, the Levy flight strategy is used to optimize the position of the scout in the embodiment. The step length of the Levy strategy obeys the heavy-tailed probability distribution, and its characteristics are that it can perform small-step random walk for a long time, and occasionally large steps will also occur. Therefore, in finding the optimal solution, the Levy strategy can perform local search in a short distance and global search in a long distance, solving the problem that the SSA may fall into local optimum. The position update formula of the scout is improved to obtain:
[0080]
[0081] In the formula, the Levy calculation formula is as follows:
[0082]
[0083]
[0084] In the formula, Γ is the gamma function, e is a constant, and r1 and r2 are random numbers in [0, 1].
[0085] Step 6: update the best fitness value and the optimal position;
[0086] Step 7: the SSA algorithm is terminated when the maximum number of iterations is reached, otherwise the iteration is continued.
[0087] Step 8: the optimal weight value and threshold value obtained by the SSA algorithm are brought into the BP neural network, and the weight value and threshold value are updated again to reach the target error;
[0088] Step 9: The test set is predicted by the optimized BP neural network to obtain the color category of the solid wood floor. The BP neural network, the SSA-BP neural network, and the improved SSA-BP neural network proposed in this embodiment are used to predict the color of the solid wood floor. The following table shows the prediction errors of each algorithm. It can be seen that among the three algorithms, the corresponding error of the improved SSA-BP neural network proposed in this embodiment is the lowest, and the error of the BP neural network is the highest.
[0089] Table 3: Error summary of each algorithm
[0090]
[0091] Figure 2 The comparison chart of the true value, the BP, the SSA-BP, and the improved SSA-BP prediction values is shown. It can be seen that the improved SSA-BP prediction value is closest to the true value, and the SSA-BP and the improved SSA are not much different. Most of the prediction values are close to the true value, and only a few samples deviate from the true value more, but it does not affect the final classification result. It reflects the applicability and accuracy of the SSA algorithm for solid wood floor color detection.
[0092] Figure 3 The deviation between the prediction values of the BP, the SSA-BP, and the improved SSA-BP and the true value is shown. It can be seen that the improved SSA-BP error is the smallest, and the BP error is larger. At the same time, the final classification result is analyzed. The accuracy of the BP neural network in the color detection of the solid wood floor is 87.18%, the accuracy of the SSA-BP is 89.74%, and the accuracy of the improved SSA-BP is 96.15%. It can be seen that the improved SSA-BP neural network algorithm proposed in this embodiment can improve the convergence speed and enhance the accuracy of the algorithm. The field research on Jiangsu Zhenjiang Shengxiang floor finds that the current floor color classification still relies on traditional manual visual inspection method, which has the problems of low efficiency and difficult to guarantee the classification accuracy. Therefore, realizing the intelligent automatic classification of the color of the solid wood floor has become a key technology that needs to be solved by enterprises.
[0093] The method proposed in this embodiment is used for solid wood floor color detection, Figure 4 A virtual simulation mechanical system work model diagram of the sorting device is shown. The industrial robot is the center equipment, the visual sorting work station 1, the conveying mechanism 2, and the workbench 4 are the peripheral equipment. The solid wood floor enters the camera area through the conveyor belt. The camera obtains the floor image and detects and classifies it. Then the digital signal is converted from the light signal of different categories. The mechanical hand 3 sends the floor of the corresponding category to the specific area according to the corresponding digital signal, and stacks the floor to realize the color classification and sorting of the solid wood floor.
[0094] Figure 5The whole structure of the solid wood floor sorting device includes a visual sorting workstation 1, a conveying mechanism 2, a mechanical arm 3 and a workbench 4, Figure 6 The control system is used for communication control of the industrial robot and the peripheral equipment through a CRMA 15 / 16 communication interface. The specific detection process is as follows:
[0095] 1. The solid wood floor enters the visual sorting workstation through the conveying mechanism;
[0096] 2. The industrial camera acquires the floor image and stores it in the industrial computer, extracts the features for detection and classification, and uses 001, 010 and 100 to represent light color, medium color and dark color respectively;
[0097] 3. The color category number is converted into a digital signal through the Modbus communication protocol and sent to the industrial robot;
[0098] 4. The industrial robot uses its mechanical arm and visual recognition system to grasp the solid wood floor to the position where the corresponding color is located and stack it.
[0099] The algorithm in this embodiment is used in the solid wood floor sorting device to realize automatic classification of the floor color. Simulation experiments show that the device has high classification accuracy, good sorting efficiency and can be accurately placed at the target position, fully meeting the actual application requirements.
Claims
1. A solid wood floor color classification method based on an improved SSA-BP neural network, characterized by: The following steps are involved: Step 1: Obtain the solid wood floor image to be color-classified; Step 2: Preprocess the color-classified solid wood floor image to obtain a preprocessed floor image; Step 3: Extract required feature parameters from the preprocessed floor image. The feature parameters include: the first-order moment color average of each channel in RGB space and HSV space, the second-order moment variance of each channel in RGB space and HSV space, the grayscale average of the floor image after removing wood grain, the grayscale average of the wood grain in the floor image after removing wood grain, and the wood grain proportion. Step 4: Input the feature parameters obtained in step 3 into the pre-trained improved SSA-BP neural network to obtain color classification results; the color classification results include: light color, medium color and dark color; The improved SSA-BP neural network after pre-training is obtained according to the following steps: Step 1: Determine the topological structure of the BP neural network; the topological structure of the BP neural network includes an input layer, a hidden layer, and an output layer; Step 2: Use the improved SSA algorithm to optimize the initial weights and thresholds of the BP neural network. SSA simulates the foraging and anti-predation behavior of sparrows, continuously updates individual positions, and searches for the optimal solution to obtain the optimized initial weights and thresholds. Step 3: Use the optimized initial weights and thresholds to train the BP neural network through the back propagation algorithm, and continuously adjust the weights and thresholds so that the BP neural network output gradually approaches the expected value, thus obtaining the improved SSA-BP neural network after pre-training; The improved SSA algorithm includes the following operations: Step 2_1: Initialize the sparrow population parameters, including population size, maximum number of iterations, safety value, initial position, and optimal position; Step 2_2: Define the average mean square error of the BP neural network training set and the test set as the fitness value, calculate the fitness value of the individual sparrow, select the value with the smallest fitness value as the optimal fitness, and the corresponding individual sparrow position is the optimal position; Step 2_3: Sparrows are divided into three different roles: discoverer, joiner, and scout. Based on their roles, the sparrows update their positions. The Levy flight strategy is used to optimize the scout's position update. Step 2_4: Update the best fitness value and optimal position; update the fitness value, record the best fitness value after each iteration, select the global optimal position after completing the maximum number of iterations, otherwise continue to iterate. Step2_5: Determine whether the maximum number of iterations has been reached. If so, the global optimal position is obtained. If not, execute Step2_2.
2. The solid wood floor color classification method based on the improved SSA-BP neural network according to claim 1 is characterized by: The number of hidden layer nodes that minimizes the mean square error of the training set is used as the number of hidden layers in the BP neural network.
3. The solid wood floor color classification method based on the improved SSA-BP neural network according to claim 1 is characterized by: In Step 2_1, initialize the population by following these steps: Randomly generate the initial population X i =[x i1 ,...,x id ], where i = 1, 2, ..., N is the number of sparrows, d is the dimension of the data to be optimized, and the initial population Y is randomly generated i =[y i1 ,...,y id ]; Based on Arnold mapping, two randomly generated populations X i 、Y i After mapping calculation, they are merged into a new population; according to the fitness value of the new population, the first N are taken as the initial population.
4. The solid wood floor color classification method based on the improved SSA-BP neural network according to claim 3 is characterized by: The Arnold map is expressed as: Where a and b are fixed parameters.
5. The solid wood floor color classification method based on the improved SSA-BP neural network according to claim 1 is characterized by: The location update of the discoverer is expressed as: Where t is the current iteration number, j = 1, 2, ..., d, iter max is the maximum number of iterations; α∈(0,1) is a random number, R2∈(0,1) is the warning value, ST∈[0.5,1] represents the safety value; Q is a random number that obeys the normal distribution, and L is a 1×d matrix with all elements set to 1.
6. The solid wood floor color classification method based on an improved SSA-BP neural network according to claim 1, characterized in that: The location update of the joiner is expressed as: Where, are the optimal and worst positions of the finder, A is a 1×d matrix with all elements 1 or -1, and L is a 1×d matrix with all elements 1.
7. The method for solid wood floor color classification based on an improved SSA-BP neural network according to claim 1, characterized in that: The Levy flight strategy is used to optimize the scout's position update, specifically including: The position update of the scout is expressed as: Where, is the global optimal position, θ is the step size parameter, obeys the standard normal distribution, P∈[-1,1], f i 、f g 、f ω are the individual current fitness value, the global best fitness value and the global worst fitness value respectively, and ε is a minimum constant; The Levy calculation formula is as follows: Where Γ is the gamma function, e is a constant, and r1 and r2 are random numbers in [0,1].