Wood surface color defect detection method based on semantic segmentation network
By using a semantic segmentation network method in the detection of wood surface color defects, combined with HRNet and multi-branch feature coding module, the problems of inaccurate detection edges and high computing resources in the prior art are solved, and efficient wood color defect detection is achieved , significantly reduces labor costs and improves recognition rate.
Patent Information
- Application Number
- CN202411497680.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-01-03
AI Technical Summary
In the detection of color defects on wood surface, the problems of inaccurate edge segmentation, high computing resources consumption, inability to achieve accurate pixel-level segmentation, and limited detection effects on complex defect types in the detection of wood surface color defects.
Using a semantic segmentation network-based method, HRNet is used as the basic network structure, and combining multi-branch feature coding modules and parallel multi-resolution architecture, the detection ability of wood color defects is enhanced through multi-scale feature cross-fusion and multi-branch feature extraction.
Automatic detection of wood color defects is realized, the detection robustness and recognition rate is improved, labor costs are significantly reduced, and subtle details are effectively identified.
Smart Images

Figure CN119251585A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of industrial wood defect detection, and in particular to a wood surface color defect detection method based on a semantic segmentation network. Background Art
[0002] Wood color defects are a common natural defect that not only affects the integrity of the wood's appearance, but also reduces the impact strength of the wood and even causes rot. They need to be removed to ensure the quality and safety of the wood.
[0003] Color defects have low contrast and the defect color presents a gradient feature. In particular, the color of the defect edge is almost the same as the wood base color, making it difficult to distinguish the defect boundary, resulting in inaccurate edge segmentation results. Some defects are in the form of long and thin strips, and the defect area becomes very small at both ends, making it difficult to be completely segmented, resulting in missed detection. Therefore, accurate detection of color defects is challenging.
[0004] Using machine learning methods to detect color defects on the wood surface can not only effectively avoid the interference of human subjective factors, but also significantly improve the accuracy and efficiency of detection. Therefore, developing an automated detection method for color defects on the wood surface is of great significance to the development of the wood industry.
[0005] The Chinese patent application number is: CN202110276650.9, and the name is: A method for identifying and segmenting wood defects based on improved Mask R-CNN. This method realizes the identification and segmentation of wood defects by improving the MaskR-CNN model. It mainly includes data set acquisition, sample balance, data expansion, network structure selection and training, model optimization and other steps. It is suitable for automated detection on wood processing lines. However, this method has high requirements for computing resources during the training process, and cannot achieve accurate pixel-level segmentation when processing defects. At the same time, this method cannot effectively detect color defects on the wood surface, which limits its application in more complex defect types.
[0006] The Chinese patent application number is: 202310927878.9, and the name is: A method for identifying wood surface defects. The method analyzes the connected domain in the grayscale image on the grayscale image of the wood surface, extracts brightness and angle features, and then determines the defect area. This method relies on traditional image processing technology and has weak performance against complex backgrounds, noise, and diverse defect types, making it difficult to achieve high-precision classification and detection. In addition, it lacks adaptability and cannot be optimized and improved through large amounts of data, and has limited effect when dealing with more diverse wood surface defects (such as color, texture, etc.). Summary of the invention
[0007] The present invention proposes a wood surface color defect detection method based on a semantic segmentation network, which can effectively realize the recognition of wood color defects when applied to wood surface color defect detection.
[0008] The present invention adopts the following technical solutions.
[0009] A wood surface color defect detection method based on a semantic segmentation network is disclosed. The detection method is based on a wood surface color defect detection model, which uses HRNet as a basic network structure and a multi-branch feature encoding module MFEM as a coding layer of the network. A parallel multi-resolution architecture is used in the basic network HRNet to prevent the low-contrast discoloration defect features of the wood surface image from being diluted, and the global representation of fuzzy features is enhanced by repeated cross-fusion of multi-scale features in the parallel multi-resolution architecture, thereby improving the robustness of wood surface color defect detection. In the multi-branch feature encoding module, multiple branches are used to concurrently extract features to generate a feature map with complementary characteristics, so as to enhance the network's recognition ability of subtle details of defects.
[0010] The detection method comprises the following steps:
[0011] Step S1, image acquisition and preprocessing, generating a wood surface color defect dataset;
[0012] Step S2, building the MFE-HRNet structure model;
[0013] Step S3, training a wood surface color defect detection model;
[0014] Step S4: Using the trained model for wood surface color defect detection.
[0015] Step S1 includes the following steps:
[0016] Step S1-1, image acquisition: acquiring a wood image through a line array camera;
[0017] Step S1-2, image cutting: according to the width of the wood image, the wood image is cut into a rectangle with a length-to-width ratio of 2:1;
[0018] Step S1-3, data set preparation: manually add pixel-level labels to wood images with color defects to prepare a wood surface color defect data set.
[0019] In step S2, the MFE-HRNet structural model includes a basic network HRNet and a parallel multi-resolution architecture; the encoder part of the basic network HRNet consists of two consecutive convolutional layers with a step size of 2 and a kernel size of 3×3. After each convolutional layer, batch normalization BN and rectified linear unit activation function ReLU are performed. Thereby reducing the computational cost of the network;
[0020] The parallel multi-resolution architecture consists of 4 branches, each branch corresponds to a different resolution. Each branch uses multiple 3×3 convolutions, followed by batch normalization BN and rectified linear unit activation function ReLU. The number of feature map channels of each branch increases layer by layer, and feature exchange and fusion are achieved between branches through upsampling and downsampling. The low-resolution feature map is upsampled by bilinear interpolation, and the high-resolution feature map is downsampled by convolution with a kernel size of 3×3 and a step size of 2. After fusion, features of different resolutions are added pixel by pixel and activated by ReLU.
[0021] The resolutions of the four branches of the parallel multi-resolution architecture are The number of feature map channels of each branch is 64, 128, 256, and 512 respectively.
[0022] The multi-branch feature encoding module includes the following steps when working:
[0023] Step A1: Pass a 7×7 convolutional layer with a stride of 1 to keep the original image resolution unchanged and convert the number of channels from 3-channel RGB to the final output channel number C. The feature map passes through three parallel encoding branches: convolutional encoding branch ConvDown, average pooling encoding branch AvgDown, and slice encoding branch CutDown;
[0024] Step A2, convolutional coding branch ConvDown: After the feature map is processed by group convolution with a step size of 1 and a convolution kernel of 3×3, it is downsampled using a depthwise separable convolution with a step size of 2 and a convolution kernel of 3×3, followed by a batch normalization BN operation;
[0025] Step A3, average pooling encoding branch AvgDown: After the feature map is downsampled by the average pooling module, a convolution layer with a convolution kernel of 3×3 is used for feature extraction, followed by a batch normalization BN operation.
[0026] Step A4, Slice Encoding Branch CutDown: By slicing adjacent pixels and then cascading, the number of feature map channels is Increase to C, the resolution decreases from H×W to
[0027] Step A5: After the feature maps obtained by the three branches are spliced together along the channel dimension, a convolution operation with a convolution kernel of 1×1 is applied to reduce the dimension at the channel level;
[0028] Step A6: The downsampled twice feature map is passed through three parallel encoding paths, namely ConvDown branch, CutDown branch and MaxDown branch; the newly added MaxDown branch includes a maximum pooling downsampling module, a convolution with a convolution kernel of 3×3, and batch normalization BN.
[0029] Step S3 comprises the following steps:
[0030] Step S3-1. Parameter initialization setting: During the training process, the image size is adjusted to H i ×W i The number of training rounds, initial learning rate and batch size are also set to a, b and c respectively. The cosine annealing learning rate adjustment strategy (CosineAnnealing) is used to update the learning rate, and the Adam optimizer is used for parameter optimization. During the training phase, a variety of data augmentation strategies are applied, including random cropping, random brightness adjustment and random rotation;
[0031] Step S3-2. Start training: randomly select the color defect data set and input it into the MFE-HRNet structure network;
[0032] Step S3-3. Update parameters: Use the cross-entropy loss function (Cross-Entropy Loss) suitable for pixel-level classification tasks as the loss function; during the training process, calculate the loss value between the prediction map and the label map, and then propagate the error layer by layer through backpropagation, and gradually update the weight parameters in the MFE-HRNet network to minimize the loss function. The specific loss function formula is as follows:
[0033]
[0034] Among them, C represents different categories, x i Represents the i-th element of the true label, y i Represents the probability that the model predicts that x belongs to the i-th category;
[0035] Step S3-4. Output model: Repeat steps S3-2 and S3-3. When the number of training times reaches the set value, stop training and output the model with the smallest loss value.
[0036] The beneficial effects of the present invention are:
[0037] (1) The present invention proposes a method for detecting wood surface color defects based on a semantic segmentation network, which realizes the automated detection of wood color defects and significantly reduces labor costs.
[0038] (2) A parallel multi-resolution architecture is designed to prevent the dilution of low-contrast discoloration defect features. The global representation of fuzzy features is enhanced through repeated cross-fusion of multi-scale features, which improves the robustness of wood surface color defect detection.
[0039] (3) A multi-branch feature encoding module was designed. Different downsampling paths extract features in different ways and perform effective fusion and complementation to avoid the loss of key features, effectively retain the detailed features of the defect edge, enhance the network's ability to recognize subtle details of the defect, and effectively improve the recognition rate of crack detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0041] Attached Figure 1 It is a schematic diagram of the MFE-HRNet network structure of the present invention;
[0042] Attached Figure 2 Schematic diagram of the structure of the multi-branch feature encoding module (MFEM) of the present invention;
[0043] Attached Figure 3 This is a schematic diagram of the slice coding branch (CutDown) structure of the present invention;
[0044] Attached Figure 4 This is a schematic diagram of the detection results of the wood surface color defect model described in the present invention. DETAILED DESCRIPTION
[0045] As shown in the figure, a method for detecting color defects on wood surface based on semantic segmentation network is provided. The detection method is based on a wood surface color defect detection model, which uses HRNet as the basic network structure and a multi-branch feature encoding module MFEM as the encoding layer of the network. A parallel multi-resolution architecture is used in the basic network HRNet to prevent the low-contrast discoloration defect features of the wood surface image from being diluted. The global representation of fuzzy features is enhanced by repeated cross-fusion of multi-scale features in the parallel multi-resolution architecture, thereby improving the robustness of wood surface color defect detection. In the multi-branch feature encoding module, features are extracted concurrently with multiple branches to generate feature maps with complementary characteristics, thereby enhancing the network's ability to recognize subtle details of defects.
[0046] The detection method comprises the following steps:
[0047] Step S1, image acquisition and preprocessing, generating a wood surface color defect dataset;
[0048] Step S2, building the MFE-HRNet structure model;
[0049] Step S3, training a wood surface color defect detection model;
[0050] Step S4: Using the trained model for wood surface color defect detection.
[0051] Step S1 includes the following steps:
[0052] Step S1-1, image acquisition: acquiring a wood image through a line array camera;
[0053] Step S1-2, image cutting: according to the width of the wood image, the wood image is cut into a rectangle with a length-to-width ratio of 2:1;
[0054] Step S1-3, data set preparation: manually add pixel-level labels to wood images with color defects to prepare a wood surface color defect data set.
[0055] In step S2, the MFE-HRNet structural model includes a basic network HRNet and a parallel multi-resolution architecture; the encoder part of the basic network HRNet consists of two consecutive convolutional layers with a step size of 2 and a kernel size of 3×3. After each convolutional layer, batch normalization BN and rectified linear unit activation function ReLU are performed. Thereby reducing the computational cost of the network;
[0056] The parallel multi-resolution architecture consists of 4 branches, each branch corresponds to a different resolution. Each branch uses multiple 3×3 convolutions, followed by batch normalization BN and rectified linear unit activation function ReLU. The number of feature map channels of each branch increases layer by layer, and feature exchange and fusion are achieved between branches through upsampling and downsampling. The low-resolution feature map is upsampled by bilinear interpolation, and the high-resolution feature map is downsampled by convolution with a kernel size of 3×3 and a step size of 2. After fusion, features of different resolutions are added pixel by pixel and activated by ReLU.
[0057] The resolutions of the four branches of the parallel multi-resolution architecture are The number of feature map channels of each branch is 64, 128, 256, and 512 respectively.
[0058] The multi-branch feature encoding module includes the following steps when working:
[0059] Step A1: Pass a 7×7 convolutional layer with a stride of 1 to keep the original image resolution unchanged and convert the number of channels from 3-channel RGB to the final output channel number C. The feature map passes through three parallel encoding branches: convolutional encoding branch ConvDown, average pooling encoding branch AvgDown, and slice encoding branch CutDown;
[0060] Step A2, convolutional coding branch ConvDown: After the feature map is processed by group convolution with a step size of 1 and a convolution kernel of 3×3, it is downsampled using a depthwise separable convolution with a step size of 2 and a convolution kernel of 3×3, followed by a batch normalization BN operation;
[0061] Step A3, average pooling encoding branch AvgDown: After the feature map is downsampled by the average pooling module, a convolution layer with a convolution kernel of 3×3 is used for feature extraction, followed by a batch normalization BN operation.
[0062] Step A4, Slice Encoding Branch CutDown: By slicing adjacent pixels and then cascading, the number of feature map channels is Increase to C, the resolution decreases from H×W to
[0063] Step A5: After the feature maps obtained by the three branches are spliced together along the channel dimension, a convolution operation with a convolution kernel of 1×1 is applied to reduce the dimension at the channel level;
[0064] Step A6: The downsampled twice feature map is passed through three parallel encoding paths, namely ConvDown branch, CutDown branch and MaxDown branch; the newly added MaxDown branch includes a maximum pooling downsampling module, a convolution with a convolution kernel of 3×3, and batch normalization BN.
[0065] Step S3 comprises the following steps:
[0066] Step S3-1. Parameter initialization setting: During the training process, the image size is adjusted to H i ×W i The number of training rounds, initial learning rate and batch size are also set to a, b and c respectively. The cosine annealing learning rate adjustment strategy (CosineAnnealing) is used to update the learning rate, and the Adam optimizer is used for parameter optimization. During the training phase, a variety of data augmentation strategies are applied, including random cropping, random brightness adjustment and random rotation;
[0067] Step S3-2. Start training: randomly select the color defect data set and input it into the MFE-HRNet structure network;
[0068] Step S3-3. Update parameters: Use the cross-entropy loss function (Cross-Entropy Loss) suitable for pixel-level classification tasks as the loss function; during the training process, calculate the loss value between the prediction map and the label map, and then propagate the error layer by layer through backpropagation, and gradually update the weight parameters in the MFE-HRNet network to minimize the loss function. The specific loss function formula is as follows:
[0069]
[0070] Among them, C represents different categories, x i Represents the i-th element of the true label, y i Represents the probability that the model predicts that x belongs to the i-th category;
[0071] Step S3-4. Output model: Repeat steps S3-2 and S3-3. When the number of training times reaches the set value, stop training and output the model with the smallest loss value.
Claims
1. A method for detecting wood surface color defects based on a semantic segmentation network, characterized in that: The detection method is based on a wood surface color defect detection model, which uses HRNet as the basic network structure and a multi-branch feature encoding module MFEM as the encoding layer of the network; a parallel multi-resolution architecture is used in the basic network HRNet to prevent the low-contrast discoloration defect features of the wood surface image from being diluted, and the global representation of fuzzy features is enhanced by repeated cross-fusion of multi-scale features in the parallel multi-resolution architecture, thereby improving the robustness of wood surface color defect detection; in the multi-branch feature encoding module, multiple branches are used to concurrently extract features to generate feature maps with complementary characteristics, thereby enhancing the network's ability to recognize subtle details of defects.
2. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 1, characterized in that: The detection method comprises the following steps: Step S1, image acquisition and preprocessing, generating a wood surface color defect dataset; Step S2, building the MFE-HRNet structure model; Step S3, training a wood surface color defect detection model; Step S4: Using the trained model for wood surface color defect detection.
3. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 2, characterized in that: Step S1 includes the following steps: Step S1-1, image acquisition: acquiring a wood image through a line array camera; Step S1-2, image cutting: according to the width of the wood image, the wood image is cut into a rectangle with a length-to-width ratio of 2:1; Step S1-3, data set preparation: manually add pixel-level labels to wood images with color defects to prepare a wood surface color defect data set.
4. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 3, characterized in that: In step S2, the MFE-HRNet structural model includes the basic network HRNet and the parallel multi-resolution architecture; The encoder part of the basic network HRNet consists of two consecutive convolutional layers with a stride of 2 and a kernel size of 3×3. Each convolutional layer is followed by batch normalization (BN) and rectified linear unit activation function (ReLU). Thereby reducing the computational cost of the network; the parallel multi-resolution architecture consists of 4 branches, each branch corresponds to a different resolution, and each branch uses multiple 3×3 convolutions, followed by batch normalization BN and rectified linear unit activation function ReLU; the number of feature map channels of each branch increases layer by layer, and feature exchange and fusion are achieved between branches through upsampling and downsampling. The low-resolution feature map is upsampled by bilinear interpolation, and the high-resolution feature map is downsampled by convolution with a kernel size of 3×3 and a step size of 2; features of different resolutions are added pixel by pixel after fusion and activated by ReLU.
5. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 4, characterized in that: The resolutions of the four branches of the parallel multi-resolution architecture are The number of feature map channels of each branch is 64, 128, 256, and 512 respectively.
6. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 3, characterized in that: The multi-branch feature encoding module includes the following steps when working: Step A1: Pass a 7×7 convolutional layer with a stride of 1 to keep the original image resolution unchanged and convert the number of channels from 3-channel RGB to the final output channel number C. The feature map passes through three parallel encoding branches: convolutional encoding branch ConvDown, average pooling encoding branch AvgDown, and slice encoding branch CutDown; Step A2, convolutional coding branch ConvDown: After the feature map is processed by group convolution with a step size of 1 and a convolution kernel of 3×3, it is downsampled using a depthwise separable convolution with a step size of 2 and a convolution kernel of 3×3, followed by a batch normalization BN operation; Step A3, average pooling encoding branch AvgDown: After the feature map is downsampled by the average pooling module, a convolution layer with a convolution kernel of 3×3 is used for feature extraction, followed by a batch normalization BN operation. Step A4, Slice Encoding Branch CutDown: By slicing adjacent pixels and then cascading, the number of feature map channels is Increase to C, the resolution decreases from H×W to Step A5: After the feature maps obtained by the three branches are spliced together along the channel dimension, a convolution operation with a convolution kernel of 1×1 is applied to reduce the dimension at the channel level; Step A6, the downsampled twice feature map is passed through three parallel encoding paths, namely ConvDown branch, CutDown branch and MaxDown branch; The newly added MaxDown branch consists of a maximum pooling downsampling module, a 3×3 convolution kernel, and batch normalization BN.
7. The method for detecting wood surface color defects based on a semantic segmentation network according to claim 3, characterized in that: Step S3 comprises the following steps: Step S3-1. Parameter initialization setting: During the training process, the image size is adjusted to H i ×W i The number of training rounds, initial learning rate and batch size are also set to a, b and c respectively; the cosine annealing learning rate adjustment strategy is used to update the learning rate, and the Adam optimizer is used for parameter optimization. During the training phase, a variety of data augmentation strategies are applied, including random cropping, random brightness adjustment and random rotation; Step S3-2. Start training: randomly select the color defect data set and input it into the MFE-HRNet structure network; Step S3-3. Update parameters: adopt the cross entropy loss function suitable for pixel-level classification tasks as the loss function; during the training process, calculate the loss value between the prediction image and the label image, and then propagate the error layer by layer through back propagation, and gradually update the weight parameters in the MFE-HRNet network to minimize the loss function; the specific loss function formula is as follows: Among them, C represents different categories, x i Represents the i-th element of the true label, y i Represents the probability that the model predicts that x belongs to the i-th category; Step S3-4. Output model: Repeat steps S3-2 and S3-3. When the number of training times reaches the set value, stop training and output the model with the smallest loss value.
