Wood surface defect online detection method and system based on machine vision
By eliminating texture interference through adaptive median filtering and curve fitting, combined with the improved ResNet-18 network and YOLOv8s model, fast and accurate classification and positioning of wood surface defects are achieved, solving the problems of insufficient detection accuracy and efficiency in existing technologies and improving the detection capabilities of wood processing production lines.
Patent Information
- Application Number
- CN202510933362.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-07-08
AI Technical Summary
Existing machine vision inspection technology cannot fully capture the texture, color and material difference characteristics of the wood surface, resulting in insufficient recognition ability. In addition, traditional methods are insufficient in detection speed, accuracy and model generalization ability, making it difficult to meet the real-time, efficient and accurate detection requirements of wood processing production lines.
Adaptive median filtering and curve fitting methods are used to eliminate texture interference. The improved ResNet-18 network is used for multi-scale feature extraction and weighted fusion of multi-spectral channels is used to construct a three-dimensional feature matrix. The Canny operator and morphological operations are combined for segmentation. The YOLOv8s model is used for defect classification and location. The servo motor drives the sorting device for automatic grading and removal.
It achieves rapid and accurate classification and positioning of wood surface defects, improves detection efficiency and accuracy, reduces labor costs, reduces product quality instability, and can be seamlessly connected to existing production lines.
Smart Images

Figure CN120765611A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a method and system for online detection of wood surface defects based on machine vision. Background Art
[0002] Existing machine vision inspection technologies still face numerous challenges. Most methods rely solely on single-spectrum imaging, failing to fully capture the texture, color, and material variations of wood surfaces, resulting in insufficient recognition of some defects. During image processing, commonly used filtering and segmentation algorithms struggle to effectively eliminate the interference of complex wood surface textures, impacting defect detection accuracy. Furthermore, traditional deep learning models suffer from slow detection speeds and weak generalization capabilities in feature extraction and defect classification and location, making them unable to meet the real-time, efficient, and accurate inspection requirements of wood processing production lines. Summary of the Invention
[0003] The purpose of the present invention is to solve the above problems and to design a method and system for online detection of wood surface defects based on machine vision.
[0004] To achieve the above object, the technical solution of the present invention is that, further, in the above-mentioned online detection method for wood surface defects based on machine vision, the online detection method for wood surface defects comprises the following steps: Obtain wood surface image data, use adaptive median filtering to reduce noise on the data, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; Using an improved ResNet-18 network to perform multi-scale feature extraction on the initial wood surface image data; and extracting differential features of the wood surface through weighted fusion of multi-spectral channels to construct a three-dimensional feature matrix; Based on the grayscale mean and standard deviation of the initial wood surface image data, an adaptive threshold is calculated to segment the defect area, and the segmented image data is obtained by optimizing the Canny operator and morphological operations; Using the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classify and locate the defects, and obtain defect detection results; The defect detection results are transmitted to the production line control system in real time, and the defective wood is automatically graded and removed by a servo motor-driven sorting device.
[0005] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the process of obtaining wood surface image data, reducing noise on the data using adaptive median filtering, and eliminating surface texture interference based on curve fitting to obtain initial wood surface image data includes: Calculate the grayscale variance within the 3×3 neighborhood of each pixel in the surface image data. If the variance is greater than the set noise threshold, the pixel is determined to be a noise point. The median value in the noise point window is calculated using an adaptive median filtering method, and it is determined whether the median value is equal to the center pixel value of the window to obtain denoised surface image data.
[0006] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the step of obtaining wood surface image data, reducing noise on the data using adaptive median filtering, eliminating surface texture interference based on curve fitting, and obtaining initial wood surface image data further includes: Perform a two-dimensional Fourier transform on the de-noised surface image data to convert the image from the spatial domain to the frequency domain, and extract the periodic texture frequency components of the wood surface through a bandpass filter to obtain a texture feature image; A cubic polynomial curve fitting method is used to fit each row of pixels in the texture feature image, and the texture curve image obtained by fitting is subtracted from the original image to obtain initial wood surface image data.
[0007] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the improved ResNet-18 network is used to perform multi-scale feature extraction on the initial wood surface image data; and the differential features of the wood surface are extracted through weighted fusion of multi-spectral channels to construct a three-dimensional feature matrix, including: In each convolutional layer of the ResNet-18 network, the traditional convolution kernel is replaced with the Daubechies wavelet convolution kernel to obtain an improved ResNet-18 network; The improved ResNet-18 network is used to perform wavelet decomposition on the input image to obtain high-frequency and low-frequency sub-bands of different scales. Convolution operations are performed on each sub-band separately, and the results are reconstructed by wavelet to obtain the feature map after wavelet convolution.
[0008] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the adaptive threshold value is calculated based on the grayscale mean and standard deviation of the initial wood surface image data to segment the defect area, and the segmented image data is obtained by optimization using the Canny operator and morphological operations, including: Perform Gaussian filtering on the segmented image to remove high-frequency noise in the image, calculate the gradient amplitude and gradient direction of the image, and obtain a preliminary defect edge image through double threshold detection and edge connection; Morphological opening and closing operations are performed on the Canny edge detection results. The opening operation uses rectangular structure elements to remove small burrs and isolated noise points on the edge; the closing operation uses circular structure elements to connect the broken parts on the edge to obtain segmented image data.
[0009] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the YOLOv8s model is used to identify the segmented image data and the three-dimensional feature matrix, classify and locate the defects, and obtain the defect detection results, including: Adjust the segmented image data and perform channel splicing on the three-dimensional feature matrix to form the input tensor; The input tensor is input into the trained YOLOv8s model. Through multi-layer convolution and pooling operations, the defect features are extracted and predicted, and the defect detection results containing defect category, confidence level, and bounding box coordinates are output.
[0010] Furthermore, in the above-mentioned online detection method for wood surface defects based on machine vision, the defect detection results are transmitted to the production line control system in real time, and the defective wood is automatically graded and removed by a sorting device driven by a servo motor, including: The production line control system calculates the position of the defective wood on the conveyor belt and the time it arrives at the sorting device based on the received defect detection results; When the defective wood reaches the sorting position, the control system sends a control signal to the servo motor to drive the sorting device to sort the defective wood out of the production line.
[0011] Furthermore, in the online detection system for wood surface defects based on machine vision, the online detection system for wood surface defects includes the following modules: The wood image acquisition module is used to obtain wood surface image data, reduce noise on the data using adaptive median filtering, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; A feature matrix construction module is used to perform multi-scale feature extraction on the initial wood surface image data using an improved ResNet-18 network; and to extract differential features of the wood surface through weighted fusion of multi-spectral channels to construct a three-dimensional feature matrix; A wood image segmentation module is used to calculate an adaptive threshold value to segment defect areas based on the grayscale mean and standard deviation of the initial wood surface image data, and optimize the data using the Canny operator and morphological operations to obtain segmented image data; A wood defect detection module is used to use the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classify and locate defects, and obtain defect detection results; The defective wood rejection module is used to transmit the defect detection results to the production line control system in real time, and automatically classify and reject the defective wood by driving the sorting device through a servo motor.
[0012] Furthermore, in the wood surface defect online detection system based on machine vision, the wood image acquisition module includes the following submodules: The calculation submodule is used to calculate the grayscale variance within the 3×3 neighborhood of each pixel in the surface image data. If the variance is greater than the set noise threshold, the pixel is determined to be a noise point; The judgment submodule is used to calculate the median value in the noise point window by using the adaptive median filtering method, and to judge whether the median value is equal to the center pixel value of the window, so as to obtain the denoised surface image data.
[0013] Furthermore, in the wood surface defect online detection system based on machine vision, the wood defect detection module includes the following submodules: The adjustment submodule is used to adjust the segmented image data and perform channel splicing with the three-dimensional feature matrix to form an input tensor; The extraction submodule is used to input the input tensor into the trained YOLOv8s model, extract and predict defects through multi-layer convolution and pooling operations, and output defect detection results including defect category, confidence level, and bounding box coordinates.
[0014] Its beneficial effects are as follows: by acquiring wood surface image data, using adaptive median filtering to reduce noise on the data, and eliminating surface texture interference based on curve fitting, initial wood surface image data is obtained; using an improved ResNet-18 network to extract multi-scale features from the initial wood surface image data; and through weighted fusion of multispectral channels, extracting differential features of the wood surface and constructing a three-dimensional feature matrix; based on the grayscale mean and standard deviation of the initial wood surface image data, calculating an adaptive threshold to segment the defect area, and optimizing it using the Canny operator and morphological operations to obtain segmented image data; using the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classifying and locating defects, and obtaining defect detection results; the defect detection results are transmitted to the production line control system in real time, and the servo motor drives the sorting device to automatically grade and remove defective wood. 1. The characteristics of different types of defects can be presented more clearly. At the same time, the preprocessing method of adaptive median filtering and curve fitting can effectively remove noise and eliminate wood texture interference, making subsequent defect detection more accurate. 2. By calculating the average gradient amplitude and information entropy to determine channel weights, the system effectively integrates the texture, color, and material differences of the wood surface. The constructed three-dimensional feature matrix provides rich information for defect identification, significantly improving the expressiveness of defect features compared to traditional single feature extraction methods. 3. It achieves rapid and accurate classification and location of various wood defects, improving detection efficiency and accuracy compared to traditional detection methods. 4. It can seamlessly integrate with existing wood processing production lines, effectively improving production efficiency, reducing labor costs, and reducing product quality instability caused by manual intervention. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Various other advantages and benefits will become apparent to those skilled in the art by reading the following detailed description of the preferred embodiment.The accompanying drawings are only for the purpose of illustrating the preferred embodiment and are not to be considered as limiting the present invention.
[0016] Figure 1 Schematic diagram of a first embodiment of a method for online detection of wood surface defects based on machine vision in an embodiment of the present invention; Figure 2 Schematic diagram of a second embodiment of a method for online detection of wood surface defects based on machine vision in an embodiment of the present invention; Figure 3 Schematic diagram of the first embodiment of the online detection system for wood surface defects based on machine vision in an embodiment of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0018] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a," "an," "said," and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0019] The present invention will be described in detail below with reference to the accompanying drawings. Figure 1 As shown, the online detection method for wood surface defects based on machine vision includes the following steps: Step 101: Acquire wood surface image data, reduce noise on the data using adaptive median filtering, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; Specifically, in this embodiment, the grayscale variance within a 3×3 neighborhood of each pixel in the surface image data is calculated. If the variance is greater than a set noise threshold, the pixel is determined to be a noise point. The adaptive median filtering method is used to calculate the median value in the noise point window, and it is judged whether the median value is equal to the center pixel value of the window to obtain the denoised surface image data.
[0020] Perform a two-dimensional Fourier transform on the de-noised surface image data to convert the image from the spatial domain to the frequency domain, and extract the periodic texture frequency components of the wood surface through a bandpass filter to obtain a texture feature image; The cubic polynomial curve fitting method is used to fit each row of pixels in the texture feature image. The texture curve image obtained by fitting is subtracted from the original image to obtain the initial wood surface image data.
[0021] Specifically, (1) Construction of multispectral imaging system Hardware Configuration: A multispectral imaging system is employed, consisting of a linear array of LEDs emitting light in five different wavelengths (red, green, blue, near-infrared, and short-wave infrared) and five high-resolution CCD cameras. The light sources are evenly distributed at a 45-degree angle on both sides of the wood conveyor belt, ensuring uniform illumination of the wood surface and avoiding shadows. The cameras are mounted directly above the conveyor belt, perpendicular to the wood surface at a distance of 1.5 meters. The captured images maintain a resolution of 2048 × 1536 pixels, with each pixel corresponding to a 0.1 mm × 0.1 mm area on the wood surface.
[0022] Image acquisition control: Through the synchronous trigger device, the camera synchronously acquires images at a frequency of 500Hz when the wood passes at a constant speed of 0.5m / s, ensuring that the surface of each piece of wood can be completely covered without missing any area.
[0023] (2) Adaptive median filtering noise reduction Noise detection: In the image preprocessing stage, the grayscale variance within the 3×3 neighborhood of each pixel is first calculated. If the variance is greater than the set noise threshold (set to 20 based on experience), the pixel is determined to be a noise point.
[0024] Dynamic Filter Window Adjustment: For noise points, an adaptive median filter is used. The filter window size starts at 3×3 and gradually increases to 7×7. Each time the window is increased, the median value within the window is calculated and a check is performed to see if it equals the center pixel value. If so, the window expansion stops and the center pixel value is replaced with the median value. If not, the window expansion continues until it reaches the maximum size or meets the required criteria. This method effectively removes salt and pepper noise while preserving image edges and details to the greatest extent possible.
[0025] (3) Curve fitting to eliminate texture interference Texture feature extraction: A two-dimensional Fourier transform is performed on the preprocessed image to convert the image from the spatial domain to the frequency domain. In the frequency domain, a bandpass filter is set to extract the periodic texture frequency components of the wood surface and obtain a texture feature image.
[0026] Curve Fitting Model: A cubic polynomial curve fitting method is used to fit each row of pixels in the texture feature image. Let the grayscale value of each row of pixels be yi, and the corresponding column coordinates be xi (i=1,2,...,n). The fitting curve equation is y=ax³+bx²+cx+d. The coefficients a, b, c, and d are solved using the least squares method to minimize the sum of squared errors between the fitted curve and the actual pixel values.
[0027] Texture elimination: Subtract the fitted texture curve image from the original image to obtain the initial wood surface image data after removing texture interference, highlighting the defect features of the wood surface.
[0028] Step 102: Use the improved ResNet-18 network to perform multi-scale feature extraction on the initial wood surface image data; and extract the difference features of the wood surface through weighted fusion of multi-spectral channels to construct a three-dimensional feature matrix; Specifically, in this embodiment, in each convolutional layer of the ResNet-18 network, the traditional convolution kernel is replaced with the Daubechies wavelet convolution kernel to obtain an improved ResNet-18 network; The improved ResNet-18 network is used to perform wavelet decomposition on the input image to obtain high-frequency and low-frequency sub-bands of different scales. Convolution operations are performed on each sub-band separately, and the results are reconstructed by wavelet to obtain the feature map after wavelet convolution.
[0029] Specifically, (1) Improving ResNet-18 network design Wavelet convolution (WTConv) is introduced: In each convolutional layer of the ResNet-18 network, the traditional 3×3 convolution kernel is replaced with a wavelet convolution kernel. The wavelet convolution kernel uses the Daubechies wavelet (db4) and performs a wavelet transform on the image in the horizontal, vertical, and diagonal directions to achieve multi-scale feature extraction. The specific operation of wavelet convolution involves first performing wavelet decomposition on the input image to obtain high-frequency and low-frequency subbands of different scales; then performing a convolution operation on each subband; and finally, performing wavelet reconstruction on the result to obtain the feature map after wavelet convolution.
[0030] Network structure adjustment: In the residual block of ResNet-18, the original skip connection structure is retained, but a wavelet convolution layer is added after each convolution layer to form a new residual unit. This improved network structure can better capture details and edge information in the image, and improve the ability to express the characteristics of wood surface defects.
[0031] (2) Weighted fusion of multispectral features Channel weight calculation: For each feature map extracted from a multispectral channel (red, green, blue, near-infrared, and short-wave infrared), we first calculate the average gradient magnitude and information entropy of each channel as indicators of channel importance. The average gradient magnitude reflects the richness of edges and details in the image within the channel, while the information entropy reflects the richness of information in the image within the channel.
[0032] 3D feature matrix construction: The feature maps of each channel are weighted and fused to produce a fused feature map. The fused feature maps of the three visible light channels (red, green, and blue) are then concatenated with the fused feature maps of the two infrared channels (near infrared and shortwave infrared) to form a 3D feature matrix of dimensions H × W × D (where H is the image height, W is the image width, and D is the feature dimension, D = 1024 in this example). This matrix captures the texture, color, and material differences of the wood surface.
[0033] Step 103: Based on the grayscale mean and standard deviation of the initial wood surface image data, calculate the adaptive threshold value to segment the defect area, and use the Canny operator and morphological operation to optimize and obtain segmented image data; Specifically, in this embodiment, Gaussian filtering is performed on the segmented image to remove high-frequency noise in the image, the gradient amplitude and gradient direction of the image are calculated, and a preliminary defect edge image is obtained by double-threshold detection and edge connection. Morphological opening and closing operations are performed on the Canny edge detection results. The opening operation uses rectangular structure elements to remove small burrs and isolated noise points on the edge; the closing operation uses circular structure elements to connect the broken parts on the edge to obtain segmented image data.
[0034] Specifically, (1) Adaptive threshold segmentation Grayscale statistical parameter calculation: The initial wood surface image data is divided into 8×8 sub-blocks, and the grayscale mean and standard deviation of each sub-block are calculated. The grayscale mean reflects the average grayscale level of the sub-block, and the standard deviation reflects the degree of grayscale distribution dispersion within the sub-block.
[0035] Adaptive threshold determination: For each sub-block, adaptive threshold calculation can automatically adjust the threshold according to the grayscale characteristics of different areas and accurately segment the defect area.
[0036] (2) Defect edge optimization Edge detection using the Canny operator: First, the segmented image is Gaussian filtered with a kernel size of 5×5 and a standard deviation of 1.0 to remove high-frequency noise. The image's gradient magnitude and direction are then calculated, and the non-maximum suppression algorithm is used to refine edges. Finally, edges are detected and connected using a dual threshold (high threshold of 0.3 and low threshold of 0.1) to obtain a preliminary defect edge image.
[0037] Morphological operations: Perform morphological opening and closing operations on the Canny edge detection results. The opening operation uses a 3×3 rectangular structuring element to remove small burrs and isolated noise points on the edge. The closing operation uses a 5×5 circular structuring element to connect broken parts on the edge and fill small holes, obtaining clear, continuous defect edges and eliminating small area noise to obtain segmented image data.
[0038] Step 104: Use the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classify and locate the defects, and obtain defect detection results; Specifically, in this embodiment, the segmented image data is adjusted and channel-joined with the three-dimensional feature matrix to form an input tensor; The input tensor is input into the trained YOLOv8s model. Through multi-layer convolution and pooling operations, the defect features are extracted and predicted, and the defect detection results containing defect category, confidence level, and bounding box coordinates are output.
[0039] Specifically, (1) YOLOv8s model training Dataset Preparation: We collected 10,000 images of various wood defects (knots, cracks, wormholes, discoloration, etc.). We split the dataset into a training set and a validation set in an 8:2 ratio. We annotated each image for each defect, including its type, location coordinates, and bounding box dimensions.
[0040] Data augmentation: To improve the generalization ability of the model, the training set was augmented with data, including random rotation (-15 degrees to 15 degrees), horizontal flipping, brightness adjustment (±20%), and contrast adjustment (±20%), expanding the training set to 20,000 images.
[0041] Model parameter settings: The YOLOv8s model uses an input image size of 640×640, the LeakyReLU activation function, the Adam optimizer, an initial learning rate of 0.001, a batch size of 32, and a training period of 100 epochs. During training, a cosine annealing learning rate decay strategy is used to gradually reduce the learning rate to improve the model's convergence speed and accuracy.
[0042] (2) Defect detection process Input data processing: The segmented image data is resized to 640×640 and channel-wise concatenated with the three-dimensional feature matrix to form an input tensor of size 640×640×(3+D) (where 3 is the RGB channel of the segmented image and D is the feature dimension of the three-dimensional feature matrix).
[0043] Model inference: The input tensor is fed into the trained YOLOv8s model. The model extracts and predicts defects through multi-layer convolution and pooling operations, and outputs detection results including defect category, confidence level, and bounding box coordinates.
[0044] Result post-processing: The non-maximum suppression (NMS) algorithm is used to process the prediction results, remove overlapping bounding boxes, retain high-confidence and unique defect detection results, and achieve accurate classification and positioning of wood surface defects.
[0045] Step 105: The defect detection results are transmitted to the production line control system in real time, and the servo motor drives the sorting device to automatically classify and remove the defective wood.
[0046] Specifically, in this embodiment, the production line control system calculates the position of the defective wood on the conveyor belt and the time it arrives at the sorting device based on the received defect detection results; When the defective wood reaches the sorting position, the control system sends a control signal to the servo motor to drive the sorting device to sort the defective wood out of the production line.
[0047] Specifically, (1) Real-time transmission of test results Communication Protocol: TCP / IP communication protocol is used to establish a stable network connection between the inspection system and the production line control system. The inspection system packages defect detection results (including information such as defect location, type, and severity) into JSON-formatted data frames and transmits them to the production line control system in real time via Ethernet at a transmission rate of 100Mbps, ensuring real-time and reliable data transmission.
[0048] Data synchronization: During the transmission process, a timestamp synchronization mechanism is used to ensure that the detection results correspond to the position of the wood on the production line, avoiding sorting errors caused by transmission delays.
[0049] (2) Sorting device control Servo motor drive: Based on the defect detection results, the production line control system calculates the position of defective wood on the conveyor belt and the time it will reach the sorting device. When a defective wood reaches the sorting location, the control system sends a control signal to the servo motor, driving the sorting device (push plate, robotic arm, etc.) to sort the defective wood from the production line. The servo motor uses closed-loop control, with a position accuracy of ±0.5mm and a response time of less than 50ms, ensuring accurate and timely sorting.
[0050] Grading strategies: Different grading strategies are developed based on the type and severity of defects. Severe defects (such as large cracks and dense areas of wormholes) are directly removed from the production line. Minor defects (such as small knots and localized discoloration) are automatically graded and transported to the appropriate processing area for further processing. The modular design of the sorting device allows for rapid adjustment and replacement based on varying wood sizes and sorting requirements.
[0051] Its beneficial effects are as follows: by acquiring wood surface image data, using adaptive median filtering to reduce noise on the data, and eliminating surface texture interference based on curve fitting, the initial wood surface image data is obtained; the initial wood surface image data is extracted at multiple scales using an improved ResNet-18 network; and through weighted fusion of multispectral channels, the differential features of the wood surface are extracted to construct a three-dimensional feature matrix; based on the grayscale mean and standard deviation of the initial wood surface image data, an adaptive threshold is calculated to segment the defect area, and the Canny operator and morphological operations are used for optimization to obtain segmented image data; the segmented image data and the three-dimensional feature matrix are identified using the YOLOv8s model, defects are classified and located, and defect detection results are obtained; the defect detection results are transmitted to the production line control system in real time, and the defective wood is automatically graded and removed by a servo motor-driven sorting device. 1. The characteristics of different types of defects can be presented more clearly. At the same time, the preprocessing method of adaptive median filtering and curve fitting can effectively remove noise and eliminate wood texture interference, making subsequent defect detection more accurate. 2. By calculating the average gradient amplitude and information entropy to determine channel weights, the system effectively integrates the texture, color, and material differences of the wood surface. The constructed three-dimensional feature matrix provides rich information for defect identification, significantly improving the expressiveness of defect features compared to traditional single feature extraction methods. 3. It achieves rapid and accurate classification and location of various wood defects, improving detection efficiency and accuracy compared to traditional detection methods. 4. It can seamlessly integrate with existing wood processing production lines, effectively improving production efficiency, reducing labor costs, and reducing product quality instability caused by manual intervention.
[0052] See also Figure 2 In the online detection method of wood surface defects based on machine vision, the following steps are involved in obtaining wood surface image data, reducing noise on the data using adaptive median filtering, eliminating surface texture interference based on curve fitting, and obtaining initial wood surface image data: Step 201: Perform a two-dimensional Fourier transform on the de-noised surface image data to convert the image from the spatial domain to the frequency domain, and extract the periodic texture frequency components of the wood surface through a bandpass filter to obtain a texture feature image; Step 202: Fit each row of pixels in the texture feature image using a cubic polynomial curve fitting method, and subtract the texture curve image obtained by fitting from the original image to obtain initial wood surface image data.
[0053] Specific (1) Construction of multispectral imaging system Hardware Configuration: A multispectral imaging system is employed, consisting of a linear array of LEDs emitting light in five different wavelengths (red, green, blue, near-infrared, and short-wave infrared) and five high-resolution CCD cameras. The light sources are evenly distributed at a 45-degree angle on both sides of the wood conveyor belt, ensuring uniform illumination of the wood surface and avoiding shadows. The cameras are mounted directly above the conveyor belt, perpendicular to the wood surface at a distance of 1.5 meters. The captured images maintain a resolution of 2048 × 1536 pixels, with each pixel corresponding to a 0.1 mm × 0.1 mm area on the wood surface. Image acquisition control: Through the synchronous trigger device, the camera synchronously acquires images at a frequency of 500Hz when the wood passes at a constant speed of 0.5m / s, ensuring that the surface of each piece of wood can be completely covered without missing any area. (2) Adaptive median filtering noise reduction Noise detection: In the image preprocessing stage, the grayscale variance within the 3×3 neighborhood of each pixel is first calculated. If the variance is greater than the set noise threshold (set to 20 based on experience), the pixel is determined to be a noise point. Dynamic Filter Window Adjustment: For noise points, an adaptive median filter is used. The filter window size starts at 3×3 and gradually increases to 7×7. Each time the window is increased, the median value within the window is calculated and a check is performed to see if it equals the center pixel value. If so, the window expansion stops and the center pixel value is replaced with the median value. If not, the window expansion continues until it reaches the maximum size or meets the required criteria. This method effectively removes salt and pepper noise while preserving image edges and details to the greatest extent possible. (3) Curve fitting to eliminate texture interference Texture feature extraction: A two-dimensional Fourier transform is performed on the preprocessed image to convert the image from the spatial domain to the frequency domain. In the frequency domain, a bandpass filter is set to extract the periodic texture frequency components of the wood surface and obtain a texture feature image. Curve Fitting Model: A cubic polynomial curve fitting method is used to fit each row of pixels in the texture feature image. Let the grayscale value of each row of pixels be yi, and the corresponding column coordinates be xi (i=1,2,...,n). The fitting curve equation is y=ax³+bx²+cx+d. The coefficients a, b, c, and d are solved using the least squares method to minimize the sum of squared errors between the fitted curve and the actual pixel values. Texture elimination: Subtract the fitted texture curve image from the original image to obtain the initial wood surface image data after removing texture interference, highlighting the defect features of the wood surface.
[0054] The above is an introduction to the embodiment of the online detection method of wood surface defects based on machine vision of the present invention. Figure 3In the wood surface defect online detection system based on machine vision, the wood surface defect online detection system includes the following modules: The wood image acquisition module is used to obtain wood surface image data, reduce noise on the data using adaptive median filtering, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; The feature matrix construction module is used to extract multi-scale features from the initial wood surface image data using an improved ResNet-18 network. It also extracts differential features of the wood surface through weighted fusion of multispectral channels to construct a three-dimensional feature matrix. The wood image segmentation module is used to calculate the adaptive threshold value to segment the defect area based on the grayscale mean and standard deviation of the initial wood surface image data, and optimize it using the Canny operator and morphological operations to obtain segmented image data; The wood defect detection module is used to use the YOLOv8s model to identify segmented image data and three-dimensional feature matrices, classify and locate defects, and obtain defect detection results; The defective wood rejection module is used to transmit the defect detection results to the production line control system in real time, and automatically classify and reject defective wood by driving the sorting device through a servo motor.
[0055] The above shows and describes the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely preferred examples of the present invention and are not intended to limit the present invention. Various changes and improvements may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and improvements fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. A wood surface defect online detection method based on machine vision, characterized in that: The method for online detection of wood surface defects comprises the following steps: Obtain wood surface image data, use adaptive median filtering to reduce noise on the data, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; Using an improved ResNet-18 network to perform multi-scale feature extraction on the initial wood surface image data; and extracting differential features of the wood surface through weighted fusion of multi-spectral channels to construct a three-dimensional feature matrix; Based on the grayscale mean and standard deviation of the initial wood surface image data, an adaptive threshold is calculated to segment the defect area, and the segmented image data is obtained by optimizing the Canny operator and morphological operations; Using the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classify and locate the defects, and obtain defect detection results; The defect detection results are transmitted to the production line control system in real time, and the defective wood is automatically graded and removed by a servo motor-driven sorting device.
2. The method for online detection of wood surface defects based on machine vision according to claim 1, characterized in that: The method of obtaining wood surface image data, reducing noise on the data using adaptive median filtering, and eliminating surface texture interference based on curve fitting to obtain initial wood surface image data includes: Calculate the grayscale variance within the 3×3 neighborhood of each pixel in the surface image data. If the variance is greater than the set noise threshold, the pixel is determined to be a noise point. The median value in the noise point window is calculated using an adaptive median filtering method, and it is determined whether the median value is equal to the center pixel value of the window to obtain denoised surface image data.
3. The method for online detection of wood surface defects based on machine vision according to claim 2, wherein: The method further includes: obtaining wood surface image data, reducing noise on the data using adaptive median filtering, eliminating surface texture interference based on curve fitting, and obtaining initial wood surface image data; Perform a two-dimensional Fourier transform on the de-noised surface image data to convert the image from the spatial domain to the frequency domain, and extract the periodic texture frequency components of the wood surface through a bandpass filter to obtain a texture feature image; A cubic polynomial curve fitting method is used to fit each row of pixels in the texture feature image, and the texture curve image obtained by fitting is subtracted from the original image to obtain initial wood surface image data.
4. The method for online detection of wood surface defects based on machine vision according to claim 2, wherein: The improved ResNet-18 network is used to perform multi-scale feature extraction on the initial wood surface image data; And through the weighted fusion of multi-spectral channels, the difference characteristics of the wood surface are extracted and a three-dimensional feature matrix is constructed, including: In each convolutional layer of the ResNet-18 network, the traditional convolution kernel is replaced with the Daubechies wavelet convolution kernel to obtain an improved ResNet-18 network; The improved ResNet-18 network is used to perform wavelet decomposition on the input image to obtain high-frequency and low-frequency sub-bands of different scales. Convolution operations are performed on each sub-band separately, and the results are reconstructed by wavelet to obtain the feature map after wavelet convolution.
5. The method for online detection of wood surface defects based on machine vision according to claim 2, wherein: The method of calculating the adaptive threshold value for segmenting the defective area based on the grayscale mean and standard deviation of the initial wood surface image data, and optimizing the segmented image data using the Canny operator and morphological operations includes: Perform Gaussian filtering on the segmented image to remove high-frequency noise in the image, calculate the gradient amplitude and gradient direction of the image, and obtain a preliminary defect edge image through double threshold detection and edge connection; Morphological opening and closing operations are performed on the Canny edge detection results. The opening operation uses rectangular structure elements to remove small burrs and isolated noise points on the edge; the closing operation uses circular structure elements to connect the broken parts on the edge to obtain segmented image data.
6. The method for online detection of wood surface defects based on machine vision according to claim 2, wherein: The YOLOv8s model is used to identify the segmented image data and the three-dimensional feature matrix, classify and locate defects, and obtain defect detection results, including: Adjust the segmented image data and perform channel splicing on the three-dimensional feature matrix to form the input tensor; The input tensor is input into the trained YOLOv8s model. Through multi-layer convolution and pooling operations, the defect features are extracted and predicted, and the defect detection results containing defect category, confidence level, and bounding box coordinates are output.
7. The method for online detection of wood surface defects based on machine vision according to claim 2, wherein: The defect detection results are transmitted to the production line control system in real time, and the defective wood is automatically graded and removed by the sorting device driven by a servo motor, including: The production line control system calculates the position of the defective wood on the conveyor belt and the time it arrives at the sorting device based on the received defect detection results; When the defective wood reaches the sorting position, the control system sends a control signal to the servo motor to drive the sorting device to sort the defective wood out of the production line.
8. The online detection system for wood surface defects based on machine vision is characterized by: The wood surface defect online detection system includes the following modules: The wood image acquisition module is used to obtain wood surface image data, reduce noise on the data using adaptive median filtering, eliminate surface texture interference based on curve fitting, and obtain initial wood surface image data; A feature matrix construction module is used to perform multi-scale feature extraction on the initial wood surface image data using an improved ResNet-18 network; And through the weighted fusion of multi-spectral channels, the difference characteristics of the wood surface are extracted and a three-dimensional feature matrix is constructed; A wood image segmentation module is used to calculate an adaptive threshold value to segment defect areas based on the grayscale mean and standard deviation of the initial wood surface image data, and optimize the data using the Canny operator and morphological operations to obtain segmented image data; A wood defect detection module is used to use the YOLOv8s model to identify the segmented image data and the three-dimensional feature matrix, classify and locate defects, and obtain defect detection results; The defective wood rejection module is used to transmit the defect detection results to the production line control system in real time, and automatically classify and reject the defective wood by driving the sorting device through a servo motor.
9. The machine vision-based online detection system for wood surface defects according to claim 8, characterized in that: The wood image acquisition module includes the following submodules: The calculation submodule is used to calculate the grayscale variance within the 3×3 neighborhood of each pixel in the surface image data. If the variance is greater than the set noise threshold, the pixel is determined to be a noise point; The judgment submodule is used to calculate the median value in the noise point window by using the adaptive median filtering method, and to judge whether the median value is equal to the center pixel value of the window, so as to obtain the denoised surface image data.
10. The machine vision-based online detection system for wood surface defects according to claim 8, characterized in that: The wood defect detection module includes the following submodules: The adjustment submodule is used to adjust the segmented image data and perform channel splicing with the three-dimensional feature matrix to form an input tensor; The extraction submodule is used to input the input tensor into the trained YOLOv8s model, extract and predict defects through multi-layer convolution and pooling operations, and output defect detection results including defect category, confidence level, and bounding box coordinates.
Citation Information
Patent Citations
Method and system for detecting knurs on surface of wood board based on computer vision
CN114881969A
Lead screw module surface defect online detection method and device based on machine vision
CN119090862A
Automatic optical detection method and system based on gasket surface defects
CN119643448A
Stainless steel surface defect detection method based on machine vision
CN119810080A
Wood water paint surface defect detection method based on computer vision
CN119831958A
Cited By
Intelligent sorting control system for preparing crushed chilies
CN121372903A
Intelligent sorting control system for chili powder preparation
CN121372903B
Bearing gland machining surface micro-defect three-dimensional shape reconstruction and analysis method based on multispectral image fusion
CN121437523A
Three-dimensional morphology reconstruction and analysis method for bearing gland machining surface micro-defects based on multispectral image fusion
CN121437523B