A computer vision-based sawn timber processing defect image recognition method
Patent Information
- Application Number
- CN202611209504.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-10-09
AI Technical Summary
[0010]本发明要解决的技术问题是:现有基于卷积神经网络的锯材表面缺陷检测方法,无法有效区分木材天然高频纹理与微细裂纹等隐蔽性缺陷所呈现的高频边缘特征,导致在实际工业流水线检测中同时出现天然木纹被误判为裂纹缺陷、误检率偏高,以及仅具有一至二像素宽度的微细裂纹被木纹背景噪声淹没而无法检出、漏检率偏高的问题,同时现有方案对大规模标注数据依赖程度高,在小样本条件下鲁棒性不足
[0019]1.本发明通过在网络浅层显式构建描述木材天然纹理连续走向的方向张量场,使网络具备区分正常纹理走向与局部拓扑异常的先验能力,能够降低天然木纹被误判为裂纹的概率,缓解误检问题。
Smart Images

Figure CN122887893A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and wood processing automation technology, specifically to a method for identifying defective images in sawn timber processing based on computer vision. Background Technology
[0002] Automatic identification of surface defects in sawn timber is one of the key technologies in the field of wood processing automation. The identification results directly affect the efficiency of wood grading and the utilization rate of downstream materials. A typical sawn timber surface visual inspection system consists of an industrial camera, a strobe light source, an image acquisition card and an industrial control computer. The acquired images are preprocessed and then sent to a deep learning model for defect classification and localization.
[0003] The closest existing technical solution to this invention is a deep learning detection method based on a target detection framework, the typical process of which is: acquiring images of the sawn timber surface through an industrial camera;
[0004] Image preprocessing includes normalization and noise reduction;
[0005] The preprocessed image is input into the backbone network of a convolutional neural network, and multi-scale feature maps are extracted layer by layer.
[0006] By fusing features of different scales in a feature pyramid structure, a fused feature map is obtained.
[0007] The bounding box coordinates and category confidence of defects are regressed on the fused feature map using the detection head;
[0008] Then, through the non-maximum suppression method, the final defect detection box and category label are output. The backbone network of this type of scheme mainly relies on pixel-level edge and gradient intensity information to extract features, without distinguishing the differences in physical properties between the natural texture of wood and defect features.
[0009] Since both natural wood grain and microcracks exhibit high-frequency edge features in images, existing methods struggle to statistically distinguish their physical properties during training. This leads to a high false positive rate, with many natural wood grains being misclassified as cracks. Furthermore, existing network structures typically employ multi-level downsampling to expand the receptive field and reduce computational cost. However, microcracks are usually only one to two pixels wide and are easily submerged by strong background noise during repeated downsampling. This results in over-smoothing or even loss of features in deep networks, leading to a high false negative rate. In addition, existing methods are essentially pure data-driven end-to-end learning paradigms that do not explicitly incorporate physical priors about wood grain into the network structure. The model's generalization ability highly depends on large-scale, class-balanced labeled data. However, crack defect samples are naturally scarce and labeling is costly, resulting in insufficient robustness and generalization performance of the model under small sample conditions. Summary of the Invention
[0010] The technical problem this invention aims to solve is that existing methods for detecting surface defects in sawn timber based on convolutional neural networks cannot effectively distinguish between the high-frequency edge features of natural wood grain and hidden defects such as microcracks. This leads to problems in actual industrial production line inspections, where natural wood grain is misjudged as crack defects, resulting in a high false detection rate, and microcracks with a width of only one to two pixels are drowned out by the wood grain background noise and cannot be detected, resulting in a high false negative rate. In addition, existing solutions are highly dependent on large-scale labeled data and lack robustness under small sample conditions.
[0011] To address the aforementioned technical problems, this invention provides a computer vision-based method for identifying defects in sawn timber processing images, comprising: acquiring a standardized image of the sawn timber surface;
[0012] Gradient calculation and local structure tensor construction are performed on the standardized image, and eigenvalue decomposition is performed on the structure tensor to obtain the orientation tensor field corresponding to the standardized image. The orientation tensor field includes the principal orientation angle of the texture and the orientation consistency coefficient for each pixel.
[0013] The standardized image is subjected to shallow convolution feature extraction to obtain a shallow feature map, and the shallow feature map is input into a learnable wavelet decomposition operator for frequency domain decomposition to obtain a low-frequency sub-band feature map and a high-frequency sub-band feature map.
[0014] The low-frequency subband feature map and the orientation tensor field are input into the background flow field branch network to obtain the reconstructed background orientation map.
[0015] Calculate the actual gradient direction angle of the standardized image, and obtain the gradient anomaly response value based on the relative angle difference between the actual gradient direction angle and the reconstructed background orientation pattern, combined with the gradient magnitude.
[0016] The gradient anomaly response value and the high-frequency subband feature map are input into the defect gradient anomaly branch network to obtain the defect confidence map. The background flow field branch network and the defect gradient anomaly branch network share the network structure of the pre-shallow convolution feature extraction, while the network structures in the middle and later stages are independent of each other.
[0017] Based on the defect confidence map, threshold determination and connected component analysis are performed to output the location and category information of defects on the sawn timber surface. This invention also provides a corresponding system for implementing the above method.
[0018] Compared with the prior art, the beneficial effects of the present invention by adopting the above technical solution are as follows:
[0019] 1. This invention explicitly constructs a directional tensor field describing the continuous direction of the natural wood grain in the shallow layer of the network, enabling the network to have the prior ability to distinguish between normal grain direction and local topological anomalies, thereby reducing the probability of natural wood grain being misjudged as cracks and alleviating the problem of false detection.
[0020] 2. This invention separates periodic high-frequency textures and non-periodic high-frequency abrupt changes in the frequency domain through learnable wavelet decomposition, and decouples high-frequency sub-band features by combining directional consistency coefficients, thereby improving the signal-to-noise ratio of defect features relative to the texture background. This allows weak crack responses to be highlighted before feature fusion, reducing the risk of defect features being submerged during network downsampling and alleviating the problem of missed detection.
[0021] 3. This invention explicitly decouples background texture fitting and defect anomaly detection into a dual-branch structure that shares front features and has independent middle and rear sections. This allows the defect detection branch to focus on learning subtle gradient anomaly patterns, reducing the model's dependence on large-scale labeled data and maintaining good detection performance even with small sample conditions. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of the overall architecture of the system in an embodiment of the present invention;
[0023] Figure 2 This is a flowchart illustrating the construction of the direction tensor field in an embodiment of the present invention.
[0024] Figure 3 This is a flowchart of frequency-space domain joint decoupling + dual-branch network inference in an embodiment of the present invention. Detailed Implementation
[0025] The following is in conjunction with the appendix Figure 1-3 The specific embodiments of the present invention will be further described below. It should be noted that the description of these embodiments is for the purpose of helping to understand the present invention, but does not constitute a limitation of the present invention.
[0026] The technical solution of the present invention will be further described in detail below with reference to specific embodiments. The implementation of the present invention relies on the existing visual inspection hardware of the sawing production line. Only a high-speed line scan camera and a uniform stroboscopic light source are needed to obtain images that meet the algorithm requirements, without the need to add three-dimensional scanning or multispectral equipment.
[0027] The system consists of an image acquisition module, an image preprocessing module, a directional tensor field construction module, a frequency-spatial domain joint decoupling module, a dual-branch detection network module, and a defect judgment and output module. These modules are connected sequentially according to the data flow, forming an end-to-end defect identification and processing link. The high-speed line scan camera in the image acquisition module, in conjunction with a uniform stroboscopic light source, performs line-by-line scanning imaging on the surface of the sawn timber moving at a constant speed on the production line, and stitches together a complete two-dimensional image of the sawn timber surface. The image preprocessing module performs grayscale normalization, geometric distortion correction, and noise reduction on the acquired raw images sequentially to obtain a standardized image, which serves as the common input for subsequent modules.
[0028] Regarding the orientation tensor field construction module, its core principle is to estimate the principal orientation and reliability of the natural texture at each pixel by using the gradient distribution statistics within the local window of the image. This explicitly introduces the physical prior of wood texture into the shallow layers of the network. Specifically, for the standardized image... The gradient components are obtained by taking the first-order partial derivatives along the horizontal and vertical directions respectively. and ;
[0029] Construct a second-order structure tensor matrix centered on the pixel to be processed within a locally Gaussian weighted window:
[0030] ;
[0031] in, Represents pixels The second-order structure tensor matrix at the location;
[0032] This represents a Gaussian weighted window function centered on the pixel, used to assign weights to pixels within the window that decrease with distance;
[0033] The summation symbol represents the summation of the corresponding product terms of all pixels within the window.
[0034] For matrix Eigenvalue decomposition yields two non-negative eigenvalues. , ( Not less than ),Pick The orientation angle of the corresponding feature vector is used as the principal orientation angle of the texture at that point. The specific calculation formula is as follows:
[0035] ;
[0036] Simultaneously calculate the directional consistency coefficient:
[0037] ;
[0038] The range of values is The larger the value, the more unidirectional and reliable the texture direction of the local area at that point, and it can be used as a basis for judging normal wood grain areas;
[0039] A smaller value indicates local directional disorder at that point, which may correspond to a defect area or a texture boundary area. This is obtained pixel by pixel. and The combined tensors form a two-dimensional directional tensor field with the same resolution as the normalized image, which serves as one of the prior inputs for the subsequent dual-branch network.
[0040] Regarding the frequency-spatial domain joint decoupling module, this invention utilizes the feature map output from the shallow layer of the convolutional backbone network. A learnable wavelet transform module is introduced to decompose the features from the frequency domain perspective, thereby achieving forced separation between naturally periodic high-frequency textures and non-periodic high-frequency abrupt changes. The decomposition process is represented as follows:
[0041] ;
[0042] in, This indicates that the filter parameters can be automatically learned through backpropagation using a wavelet decomposition operator. The filter parameters are automatically optimized through network training;
[0043] The low-frequency sub-band feature map obtained by decomposition corresponds to the natural texture background of wood with periodic continuity;
[0044] The high-frequency subband feature map obtained by decomposition contains both crack defect response and may also contain a small amount of high-frequency noise.
[0045] To further distinguish between periodic high-frequency components and aperiodic high-frequency abrupt changes within high-frequency subbands, this invention incorporates a directional consistency coefficient. Modulate the high-frequency subband to construct a decoupling constraint loss:
[0046] ;
[0047] in, This represents the normalized response amplitude of the high-frequency subband feature map at this pixel, with a value range of [value range missing]. ;
[0048] As a balance coefficient, this loss function constrains the high-frequency response amplitude to approach zero in regions with high directional consistency, thus suppressing the misjudgment of natural wood grain as high-frequency abrupt changes.
[0049] In regions of low directional consistency, the high-frequency response amplitude is constrained to approach one, encouraging the model to retain and amplify potential crack signals in such regions. This loss is applied to the filter parameters through backpropagation during the training phase. Optimize.
[0050] Regarding the dual-branch detection network, this invention designs a background flow field branch and a defect gradient anomaly branch. The two branches share the pre-built shallow feature extraction network, but are completely decoupled in the middle and later stages, each independently learning different objective functions. The background flow field branch receives low-frequency sub-band features. With direction tensor field The background texture flow field is reconstructed through several convolutional layers, and the reconstructed orientation map is output. The training loss for this branch is the angle difference loss between the reconstructed orientation pattern and the true orientation tensor field:
[0051] ;
[0052] in, Used to apply greater weight to high-confidence regions;
[0053] Because the direction angle has To maintain periodic symmetry, we adopt The cosine form measures the angle difference, avoiding errors caused by angle wrapping.
[0054] Defect gradient anomaly branch receiver high frequency subband characteristics Using the orientation tensor field information, calculate the actual image gradient orientation angle at each pixel. Combined with the principal direction angle predicted by the background branch Define the relative angle difference:
[0055] ;
[0056] Then, the gradient anomaly response value is calculated:
[0057] ;
[0058] in, This represents the gradient magnitude at that point. The physical meaning of this response value is: when the actual gradient direction is neither parallel nor orthogonal to the main direction of the background texture, i.e., the relative angle difference is close to 45 degrees, A large value indicates that the local structure deviates from the regular orientation of the texture field and belongs to a potential topological anomaly region.
[0059] In contrast, the gradient direction of normal wood grain is parallel to the main direction, with a relative angle difference close to 0 degrees, and the response value approaches zero.
[0060] When the relative angle difference is close to 90 degrees, the relationship is also close to parallel or orthogonal, and the response value also approaches zero. The defect branch will... High-frequency subband characteristics Several convolutional layers and nonlinear activations are input together, and the final defect confidence map is output. Its training employs weighted binary cross-entropy loss:
[0061] ;
[0062] in, This indicates the actual defect label marked at this pixel, with a value of 1 for defects and 0 for background.
[0063] The positive sample weighting coefficient is used to alleviate the class imbalance problem caused by the number of crack pixels being much smaller than the number of background pixels. In this embodiment... Take an empirical value of 10; the specific value can be adjusted according to the ratio of positive to negative samples in the training set.
[0064] During the model training phase, the total training loss of the two branches and the decoupled module is the weighted sum of the losses of each component:
[0065] ;
[0066] in, , To balance the hyperparameter weighting coefficients contributing to each loss term, these coefficients are determined through validation set tuning. In this embodiment, they are set to 0.5 and 0.3 respectively. Based on the labeled data, the weights are calculated according to the aforementioned loss functions. , and The weighted sum is obtained The parameters of each layer of the network, including the filter parameters of the learnable wavelet decomposition operator, are updated through the backpropagation algorithm. The process is repeated until the model's performance metrics on the validation set converge.
[0067] After the model completes training, it enters the online inference stage, where the defect confidence map output by the model after training convergence is analyzed. A judgment threshold is set; in this embodiment, the threshold is set to 0.5. Pixels that exceed the threshold are marked as defective pixels.
[0068] Connectivity analysis is performed on the marked pixels to merge neighboring pixels into a complete defect region. The coordinates, area, and average confidence of the bounding rectangle of each region are calculated as the location and confidence information of the defect.
[0069] Combining the morphology and response characteristics of the defect area, the system outputs information on categories such as cracks and dead knots. These results are then linked with the upper-level control system to guide downstream automated processing actions such as sawn timber grading, rejection, or marking. This includes image acquisition, image preprocessing, directional tensor field calculation, shallow feature extraction and frequency domain decomposition, forward calculation of background flow field branches, forward calculation of defect gradient anomaly branches, loss calculation and parameter update during the training phase, defect determination and post-processing during the inference phase, as well as result output and linkage control.
[0070] Corresponding to the above method, the present invention also provides a computer vision-based image recognition system for defects in lumber processing. The system includes an image acquisition module, an image preprocessing module, a directional tensor field construction module, a frequency-spatial domain joint decoupling module, a dual-branch detection network module, and a defect judgment and output module. The specific functions of each module correspond one-to-one with the steps of the aforementioned method, and will not be repeated here.
[0071] It should be noted that the embodiments of the present invention are not limited to the specific examples described above. In the construction of the directional tensor field, instead of using the method based on structure tensor eigenvalue decomposition, a Gabor filter bank can be used to perform multi-directional, multi-scale filtering on the image. By comparing the intensity distribution of the filtering responses in each direction, the principal direction of the local texture and its confidence level can be estimated, thus obtaining a similar result. and The directional prior information is used by the subsequent dual-branch network. In the frequency domain decoupling module, instead of using learnable wavelet transform, learnable Fourier transform or discrete cosine transform modules can be used to decompose the feature map in the frequency domain. By applying consistency constraints similar to the aforementioned decoupling constraint loss to the energy distribution of different frequency bands, the separation of periodic textures and non-periodic abrupt changes can also be achieved. The above alternative methods are different from this embodiment in terms of computational principle, but they can all achieve the same technical purpose and are within the protection scope of this invention.
[0072] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present invention. Therefore, any modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the protection scope defined by the claims of the present invention.
Claims
1. A method for image recognition of defects in lumber processing based on computer vision, characterized in that, include: Obtain standardized images of the sawn timber surface; Gradient calculation and local structure tensor construction are performed on the standardized image, and eigenvalue decomposition is performed on the structure tensor to obtain the orientation tensor field corresponding to the standardized image. The orientation tensor field includes the principal orientation angle of the texture and the orientation consistency coefficient for each pixel. The standardized image is subjected to shallow convolution feature extraction to obtain a shallow feature map, and the shallow feature map is input into a learnable wavelet decomposition operator for frequency domain decomposition to obtain a low-frequency sub-band feature map and a high-frequency sub-band feature map. The low-frequency subband feature map and the orientation tensor field are input into the background flow field branch network to obtain the reconstructed background orientation map. The actual gradient direction angle of the standardized image is calculated. Based on the relative angle difference between the actual gradient direction angle and the reconstructed background orientation pattern, and combined with the gradient magnitude, the gradient anomaly response value is obtained. The gradient anomaly response value increases when the relative angle difference approaches 45 degrees, and decreases when the relative angle difference approaches 0 degrees and 90 degrees. The gradient anomaly response value and the high-frequency subband feature map are input into the defect gradient anomaly branch network to obtain the defect confidence map. The background flow field branch network and the defect gradient anomaly branch network share the network structure of the aforementioned shallow convolution feature extraction, while the network structures in the middle and later stages are independent of each other. Based on the defect confidence map, threshold determination and connected component analysis are performed to output the location and category information of defects on the sawn timber surface.
2. The method as described in claim 1, characterized in that, The step of obtaining the orientation tensor field corresponding to the normalized image includes: The first-order partial derivatives of the standardized image are calculated along the horizontal and vertical directions to obtain the horizontal gradient component and the vertical gradient component. Centered on the pixel to be processed, within a local Gaussian weighted window, a second-order structure tensor matrix is constructed based on the horizontal gradient component and the vertical gradient component. The second-order structure tensor matrix is decomposed into eigenvalues to obtain a first eigenvalue and a second eigenvalue, wherein the first eigenvalue is not less than the second eigenvalue. The feature vector direction angle corresponding to the first feature value is taken as the main texture direction angle of the pixel to be processed; The directional consistency coefficient of the pixel to be processed is obtained based on the difference between the first feature value and the second feature value and the ratio of the sum of the first feature value and the second feature value.
3. The method as described in claim 1, characterized in that, Also includes: The high-frequency sub-band feature map is decoupled based on the directional consistency coefficient. The decoupling constraint is used to reduce the response amplitude of the high-frequency sub-band feature map in the region where the directional consistency coefficient increases, and to increase the response amplitude of the high-frequency sub-band feature map in the region where the directional consistency coefficient decreases. The decoupling constraint participates in network training in the form of a loss function.
4. The method as described in claim 1, characterized in that, The training loss of the background flow field branch network is constructed based on the angle difference between the reconstructed background orientation map and the texture principal orientation angle in the orientation tensor field, and the measurement result of the angle difference is weighted according to the orientation consistency coefficient.
5. The method as described in claim 1, characterized in that, The training loss of the defect gradient anomaly branch network is a weighted binary cross-entropy loss. The weights are used to increase the contribution of defect pixels in the loss calculation, so as to alleviate the class imbalance problem caused by the number of defect pixels being less than the number of background pixels.
6. The method according to any one of claims 3 to 5, characterized in that, The total training loss of the network is a weighted sum of the training loss of the defect gradient anomaly branch network, the training loss of the background flow field branch network, and the loss function corresponding to the decoupling constraint. The weight coefficients of each loss term are determined by parameter tuning through the validation set.
7. The method as described in claim 1, characterized in that, The step of acquiring a standardized image of the sawn timber surface includes: using a line scan camera in conjunction with a stroboscopic light source to perform line-by-line scanning imaging on the sawn timber surface moving at a uniform speed along the conveying direction to obtain the original image; The original image is subjected to grayscale normalization, geometric distortion correction and denoising processing in sequence to obtain the standardized image.
8. The method as described in claim 1, characterized in that, The step of performing threshold determination and connected component analysis based on the defect confidence map, and outputting the location and category information of defects on the sawn timber surface, includes: marking pixels in the defect confidence map whose confidence values exceed a preset threshold as defect pixels; Perform connected component analysis on the marked defect pixels and merge adjacent defect pixels to form defect regions; Calculate the coordinates, area, and average confidence level of the circumscribed rectangle of the defect region, and output them as part of the location information.
9. A computer vision-based image recognition system for defects in lumber processing, characterized in that, It includes an image acquisition module, an image preprocessing module, a direction tensor field construction module, a frequency-spatial domain joint decoupling module, a dual-branch detection network module, and a defect judgment and output module; The image acquisition module is used to acquire raw images of the sawn timber surface; The image preprocessing module is used to process the original image to obtain a standardized image; The orientation tensor field construction module is used to perform gradient calculation and local structure tensor construction on the standardized image, and to perform eigenvalue decomposition on the structure tensor to obtain the orientation tensor field, which includes the pixel-wise texture principal orientation angle and orientation consistency coefficient. The frequency-spatial domain joint decoupling module is used to perform shallow convolution feature extraction on the standardized image to obtain a shallow feature map, and decompose the shallow feature map into a low-frequency sub-band feature map and a high-frequency sub-band feature map; The dual-branch detection network module includes a background flow field branch network and a defect gradient anomaly branch network. The background flow field branch network is used to obtain a reconstructed background orientation map based on the low-frequency sub-band feature map and the orientation tensor field. The defect gradient anomaly branch network is used to obtain a defect confidence map based on the relative angle difference between the reconstructed background orientation map and the actual gradient orientation angle, the gradient magnitude, and the high-frequency sub-band feature map. The defect determination and output module is used to perform threshold determination and connected component analysis based on the defect confidence map, and output the location information and category information of defects on the sawn timber surface.