Extraction and Detection of Surface Defects in Particleboards by Tracking Moving Targets

Considering the linear motion of particleboards in the production line, the detection of surface defects in particleboards is a major challenge. In this paper, a method based on moving target tracking is proposed for the detection of surface defects in particleboards. To achieve this, the kernel correlation filter (KCF) target tracking algorithm was modified with the median flow algorithm and used to capture the moving targets of surface defects. The defect images were extracted by a Sobel operator, and the defect number, the defect area, and the degree of damage were calculated. The level of surface defect in particleboards was evaluated by fuzzy pattern recognition. Experiments were then carried out to prove the effectiveness and accuracy of the proposed method.


Introduction
As one of the three artificial boards, particleboards can be made of chipped broken wood or wheat stalk, rice straw, bamboo, etc.The basic material used for particleboards is very small and can come from different sources.Particleboards are widely used in many fields due to their advantages of low production cost, high hardness, and wide market availability.Since the 21st century, energy conservation has become an important indicator of the technical level of industrial production.The problem of poor forest resources and low forest coverage has meant the industrial production of particleboards has become an important method to make up for this situation.
At present, in the field of surface defect detection of particleboards, most production lines are technologically backward, with some even relying on artificial, visual inspection.This method is not only inefficient but also costs a lot of manpower, and the results are not exact enough.
In recent years, many scholars have made contributions to improve the technology of particleboard production line, including those involving technical fields such as impact resistance and internal bonding strength [1][2][3][4][5][6][7][8][9].In Reference [1], samples of high-density homogeneous particleboards of sugarcane bagasse and castor oil polyurethane resin were manufactured and subjected to low-velocity impacts using an instrumented drop weight impact tower and four different energy levels.Reference [3] evaluated the physical and mechanical properties of particleboards manufactured from a mixture of sycamore leaves and wood particles.In Reference [6], the effects of grit sizes of sand belt, feeding speed, and the feed power of the heads of the sander on surface roughness of the particleboard panels were investigated.Reference [7] evaluated the physical, mechanical, and durable properties of sorghum bagasse particleboards (SBP), which are layered by several materials.Despite these numerous studies, the detection of surface defects has seldom been reported.In the field of automatic detection of surface defects, some scholars have studied detection methods for the characteristics of steel, glass, and other materials [10][11][12][13][14][15][16][17][18][19], but few have studied the surface defect detection technology on particleboards.In Reference [10], classical convolutional neural networks (CNNs) trained in pure supervised manner was used to detect defects on steel surfaces.The defects were identified by the reflection of light on the steel surface owing to the good reflectance of steel materials.Although this method can effectively identify steel surface defects, it takes a long time to calculate.Moreover, it is not suitable for rough surface materials, such as particleboards, as it cannot detect defects by reflective characteristics.A detection algorithm for the recognition and segmentation of defects in mobile phone screen glass (MPSG) was proposed in Reference [12].The combination of subtraction and projection (CSP) was used to identify defects on the MPSG image, which could eliminate the influence of fluctuation in ambient illumination.Reference [17] proposed an efficient similarity measure for the detection of surface defects in printed circuit boards (PCB).The method could measure the similarity between the scene image and the reference image of PCB surface without the need to compute image features such as eigenvalues and eigenvectors.The method proposed in Reference [18] was aimed at improving quality control in the ceramic tile industry.An automated inspection system for ceramic tile based on image processing techniques was used to detect edge damages and middle cracks on the surface of the tile.Reference [19] proposed a method for detecting defect on air-bearing surfaces (ABS), which has variance luminance intensity.The co-occurrence matrix was used to avoid the variance intensity of ABS images.However, these methods are only suitable for the detection of small defects.When applied to the detection of surface defects in particleboards, a large number of small wood chips on the surface of the board may cause serious false detection.Reference [15] proposed a method based on thresholding segmentation to detect surface defects in a glass substrate.A straight-line intercept histogram was established directly from the two-dimensional information of an image, and the Otsu criterion was then used to find the best intercept threshold from the one-dimensional histogram.However, this method can only detect the surface of the glass substrate by taking photos under the static state, and it cannot realize dynamic detection on the production line.
Through the study of existing technologies, the aim of this paper is to examine the problem of detecting surface defects in particleboards.
In the whole production process of particleboards, the board is always in motion in the production line, and the surface defects are mostly exposed shaving defects.In view of this situation, we adopted the moving target tracking technology and the image segmentation technology to achieve image capture, extraction, and detection of surface defects in particleboards, including defects of different sizes and shaving defects with different depths.The main contributions of this study can be summarized as follows: (1) The KCF moving target tracking algorithm was used to track surface defects in particleboards in the production line, and the forward-backward error was introduced to reduce the tracking error using the median flow method.
(2) The motion targets of each frame in video sequence were extracted using the edge detection method to obtain more complete and accurate characteristic data of the moving target.
(3) According to the extracted defect images, various defect characteristic parameters were calculated, and the surface defect level of the particleboard was evaluated using the fuzzy pattern recognition method.
The rest of the paper is organized as follows.Section 2 introduces the KCF target tracking algorithm, which was used to capture the surface defects in the particleboard.Section 3 introduces the samples and equipment used in the experiment.In Section 4, the tracking and detection results of the surface defects are given.Section 5 gives the calculation of the defect characteristic parameters according to the extracted defect images.The defects are also analyzed using fuzzy pattern recognition.Finally, the conclusions of the work are drawn in Section 6.

The KCF Target Tracking Algorithm
The kernel correlation filter has been widely used in the field of moving target detection and tracking since it was first proposed in 2014 [20].KCF is a discriminative tracking method that mainly uses the given samples to train a discriminative classifier, which can distinguish between targets and backgrounds.Circulant matrices are used to translate and scale the samples, and the discrete Fourier transform (DFT) is used to accelerate the algorithm.
Considering an n × 1 vector and x representing a line of the target area image as the base sample, in order to get more samples to train the classifier, we can use a cyclic shift operator P to perform one-dimensional translations of x.P is a n × n matrix.
Due to its cyclic property, all samples obtained after transformation can be expressed by the following equation: Equation ( 2) can be written in matrix form as follows: Equation (3) represents the form of circulant matrices [21].The elements in X depend on vector x, while DFT makes the matrices diagonal [22].Equation (3) can be expressed as follows: where F is the DFT constant matrix, and x denotes the DFT of x, i.e., x = F(x).
Circulant matrices combined with DFT can generate a large number of samples for classifier training in a stable and effective way, thus ensuring the accuracy of tracking results.
The "kernel trick" can be used to turn a linear mapping problem to a nonlinear kernel space and turn the calculation of low-dimensional space mapping to high-dimensional kernel space.The inseparable problem in low-dimensional space will become linearly separable in high-dimensional space, and we can realize an efficient training of the classifier [23].
We can define the n × n kernel matrix as follows: where k xz is the kernel correlation of the base sample x and base patch z.
According to the regression function, f (z) can be given as follows: where α is the regression coefficient; the value range of i is [1, n]; and k(z, x i ) is the element of a n × n matrix K, which denotes the dot products between x and z.
We can compute the regression function for all candidate patches with the following equation: Diagonalizing Equation ( 7), we obtain the following: It is obvious that f (z) is a linear combination of the neighboring kernel values from k xz , weighted by the learned coefficients α.As this is a filtering process, it can be better expressed in the Fourier domain.
When the kernel function training is complete, the new sample will map to the kernel space directly.Using the trained function to calculate the value for all positions, the location of the target can then be quickly detected.
Although KCF can perform well in both tracking effect and tracking speed, it also has a limitation in that it is not free to change the size of the target tracking boxes; this means tracking can be easily disturbed when the target is covered.However, for the detection of surface defects in particleboards, it is almost impossible that the defect targets will be deformed or covered, thus the imperfection of the algorithm will not have a negative impact the final tracking effect.Moreover, the advantage of fast tracking speed of the algorithm can fully meet the requirements of the running speed of a normal production line, ensuring real-time performance.

The Median Flow
The median flow is derived from the tracking module in the tracking-learning-detection (TLD) algorithm [24][25][26][27].According to the principle that a good tracking algorithm should have forward-backward consistency, i.e., in a chronological or antichronological order, the tracking results should be the same.We can define the forward-backward (FB) error of an arbitrary tracker as follows: where, S = (I t , I t+1 , . . ., I t+k ) denotes the processed image sequence; X i is the position of the feature point P at time t; T k f = (X t , X t+1 , . . ., X t+k ) and T k b = ( Xt , Xt+1 , . . ., Xt+k ) denote the chronological order and the antichronological order tracking results, respectively; and k is the number of the current image frame.
Equation (9) shows that the FB error of a tracker is essentially the Euclidean distance between the initial position X i and the predicted position Xt of the feature point P. The calculation diagram of FB error is shown in Figure 1.In the process of tracking, the FB errors of each feature point are calculated, and the point whose FB error is less than the median value of the sum of the total FB errors is taken as the effective tracking feature point.Finally, according to the coordinate changes of these points, the position of the target boundary box in the image at time 1 t + can be calculated.
where i r denotes the change rate of the distance between point t i X and point t j X in the two adjacent frames; R denotes the average change rate of i r ; and t S denotes the size of the target boundary box in image t I , which is the number t frame image in the video sequence.
In this study, the median flow algorithm was used to amend the tracking results of the KCF to make the tracking results more accurate and ensure the reliability of subsequent calculation results of the target defect parameters.

Sobel Edge Operator
After the defect targets are captured by the tracking algorithm, their images will be extracted by edge detection.In this study, the defect targets were separated from the background by the Sobel edge operator.
The Sobel edge operator has two 3 3 × templates.Considering A as the original image, then image x G , which is detected vertically, and image y G , which is detected horizontally, can be expressed as follows: In the process of tracking, the FB errors of each feature point are calculated, and the point whose FB error is less than the median value of the sum of the total FB errors is taken as the effective tracking feature point.Finally, according to the coordinate changes of these points, the position of the target boundary box in the image at time t + 1 can be calculated.
where r i denotes the change rate of the distance between point X t i and point X t j in the two adjacent frames; R denotes the average change rate of r i ; and S t denotes the size of the target boundary box in image I t , which is the number t frame image in the video sequence.
In this study, the median flow algorithm was used to amend the tracking results of the KCF to make the tracking results more accurate and ensure the reliability of subsequent calculation results of the target defect parameters.

Sobel Edge Operator
After the defect targets are captured by the tracking algorithm, their images will be extracted by edge detection.In this study, the defect targets were separated from the background by the Sobel edge operator.
The Sobel edge operator has two 3 × 3 templates.Considering A as the original image, then image G x , which is detected vertically, and image G y , which is detected horizontally, can be expressed as follows: The value of gradient can be expressed as follows: The direction of gradient can be expressed as follows: The Sobel edge operator can make a further weighted adjustment to the undesirable segmentation results according to the pixel position.This process can alleviate the edge blurring and improve the quality of the segmentation results.

Experiment Equipment
In this study, a transmission device with photoelectric switch installed at the input end, an industry camera (CCD camera), and a computer system that can support the required software performance were used for the experiments.A structural diagram of the system is shown in Figure 2.
The value of gradient can be expressed as follows: The direction of gradient can be expressed as follows: tan( ) The Sobel edge operator can make a further weighted adjustment to the undesirable segmentation results according to the pixel position.This process can alleviate the edge blurring and improve the quality of the segmentation results.

Experiment Equipment
In this study, a transmission device with photoelectric switch installed at the input end, an industry camera (CCD camera), and a computer system that can support the required software performance were used for the experiments.A structural diagram of the system is shown in Figure 2. A motor was used to drive a flat transmission in the transmission device.The photoelectric switch was used to detect whether the current particleboard had fully passed through the transmission device, providing a start and stop signal for the test program.The system adopted DFK 23GP031 GigE chromatic industry camera from ImagingSource as the image acquisition equipment.The camera uses line-by-line scanning to obtain image information, with an effective pixel of up to 2592 × 1944.Images captured by the camera are transmitted to the computer in real time.In terms of software, IC Capture 2.4 was selected as the image display software, and MATLAB was used to implement all tracking and detection algorithms.

Sample Acquisition
The most common surface defects on the particleboard production line are exposed wood shaving defects, and the shape, size, and depth of the defects can vary.Figure 3 shows images of different surface defects.A motor was used to drive a flat transmission in the transmission device.The photoelectric switch was used to detect whether the current particleboard had fully passed through the transmission device, providing a start and stop signal for the test program.The system adopted DFK 23GP031 GigE chromatic industry camera from ImagingSource as the image acquisition equipment.The camera uses line-by-line scanning to obtain image information, with an effective pixel of up to 2592 × 1944.Images captured by the camera are transmitted to the computer in real time.In terms of software, IC Capture 2.4 was selected as the image display software, and MATLAB was used to implement all tracking and detection algorithms.

Sample Acquisition
The most common surface defects on the particleboard production line are exposed wood shaving defects, and the shape, size, and depth of the defects can vary.Figure 3 shows images of different surface defects.When the KCF target tracking algorithm is used to track the surface defects in the particleboard, a large number of sample images are used to train the classifier of the algorithm.The circulant matrix introduced in Section 2.1 is an effective method to obtain a large number of sample images.The sample images obtained by the circulant matrix are shown in Figure 4.In reality, the number of samples obtained is much larger than that shown in the figure.

Tracking and Detection Experiment
In this study, three particleboards with different degrees of surface defects were selected experimental objects, and a total of five exposed wood shaving defects on their surfaces were track

Tracking and Detection Experiment
In this study, three particleboards with different degrees of surface defects were selected as experimental objects, and a total of five exposed wood shaving defects on their surfaces were tracked.The experimental particleboards were numbered A-C.The surface defects, shown in Figure 3 A comparison between the tracking results of the improved KCF algorithm with the median flow correction and the TLD algorithm is shown in Figure 5. (e)

Tracking and Detection Experiment
In this study, three particleboards with different degrees of surface defects were selected as experimental objects, and a total of five exposed wood shaving defects on their surfaces were tracked.In Figure 5, the red target tracking box denotes the tracking results of KCF, and the yellow target tracking box denotes the tracking results of TLD.The "x" in the upper right corner denotes the loss of the tracking target of the corresponding algorithm.
The edge detection results of defect images in the target tracking box using Sobel operator is In Figure 5, the red target tracking box denotes the tracking results of KCF, and the yellow target tracking box denotes the tracking results of TLD.The "x" in the upper right corner denotes the loss of the tracking target of the corresponding algorithm.
The edge detection results of defect images in the target tracking box using Sobel operator is shown in Figure 6.The result vacancy represents the loss of target in the tracking process.
(e) In Figure 5, the red target tracking box denotes the tracking results of KCF, and the yellow target tracking box denotes the tracking results of TLD.The "x" in the upper right corner denotes the loss of the tracking target of the corresponding algorithm.
The edge detection results of defect images in the target tracking box using Sobel operator is shown in Figure 6.The result vacancy represents the loss of target in the tracking process.It can be seen from the tracking and detection results that the TLD lost several targets in the process of tracking, while the KCF hardly lost any of the targets.
The computation time of each defect target tracked by KCF was less than 0.1 s, which can fully meet the real-time requirements of the particleboard production line.

The Area of Defect Targets
By calculating the number of pixels inside the edge, we can obtain the area of the defect target detected in the current frame image.The larger the area, the more serious is the defect damage.In the tracking and detection process of a single defect, a defect area value is obtained for each frame of It can be seen from the tracking and detection results that the TLD lost several targets in the process of tracking, while the KCF hardly lost any of the targets.
The computation time of each defect target tracked by KCF was less than 0.1 s, which can fully meet the real-time requirements of the particleboard production line.

The Area of Defect Targets
By calculating the number of pixels inside the edge, we can obtain the area of the defect target detected in the current frame image.The larger the area, the more serious is the defect damage.In the tracking and detection process of a single defect, a defect area value is obtained for each frame of image, and the average value A r is taken as the final defect area.Table 1 shows the results of defect area calculation of surface defect targets.

The Depth of Defect Targets
The depth of defect targets d can be defined as the gray average difference of the target image area and the background image area.It can be calculated as follows: where G t and G b denote the gray average of defect target area and background area, respectively; G ij is the gray value of pixel (i, j); L denotes the entire target area; A 0 denotes the total number of pixels in the image; and A r denotes the number of pixels in the target area.
In the tracking and detection process of the defect, we can get a value of defect depth in each frame of image, and their average is also taken as the final value of d.The greater the value of defect depth d, the more serious is the defect damage.Table 2 shows the results of defect depth calculation of surface defect targets.

The Number of Surface Defects
When the particleboard is transported on the transmission, the photoelectric switch can give the start or end signals when the board enters or leaves the camera view.The program counts the number of defects detected during each group of start-end signals and takes it as the number of defects on each particleboard.According to this, there were two defects in board A, one defect in board B, and two defects in board C.

The Analysis of Surface Defects
Fuzzy pattern recognition is used to analyze surface defects in particleboards according to the obtained defect characteristic parameters [28][29][30][31].Considering the feature of the characteristic parameters, the method of group identification was adopted in this study to solve the problem, while the Hamming distance, Euclid distance, and dose-approximation value were selected as the evaluation indexes.
Considering M and N are the fuzzy subsets on the domain U = {u 1 , u 2 , . . . ,u n }, the Hamming distance between the fuzzy sets M and N can be expressed as follows: The Euclid distance between fuzzy sets M and N can be expressed as follows: M and N are essentially 1 × n vectors.The inner product of M and N can be expressed as follows: The outer product can be expressed as follows: The dose-approximation value of M and N can be expressed as follows: It can also be written as follows: The final pattern recognition result is obtained according to the principle of proximity selection.Considering M 1 , . . ., M i , M i+1 , . . ., M n are the fuzzy models on domain U, and N is the object to be identified, if there is σ(M i , N) = max{σ(M 1 , N), σ(M 2 , N), . . ., σ(M n , N)}, N will be considered to belong to fuzzy model M i .
In this study, the surface defects of the particleboard were divided into P 1 , P 2 , and P 3 grades.The required indexes are shown in Table 3. From Table 3, we can obtain that the standard fuzzy sets of the first-class, second-class, and third-class boards were M 1 = [0.6,0.5, 0.6] T , M 2 = [0.3,0.4, 0.3] T , and The surface quality indexes of the experimental particleboards are shown in Table 4.The Hamming distance, Euclid distance, and dose-approximation values between the experimental boards and standard boards are shown in Tables 5-7, respectively.According to the principle of proximity selection, the following conclusions can be drawn from the three evaluation indexes of fuzzy pattern recognition: Particleboard A was the second-class board, board B was the first-class board, and board C was the third-class board.
As can be seen from the above experimental results, the artificial detection not only had undetected errors but also failed to accurately give the characteristic parameters of the defects.In the experiment conducted with TLD, a defect in board D was undetected, and the calculation error of the defect damage degree was large, leading to reduced accuracy of the final analysis results.In comparison, the KCF-based detection algorithm proposed in this paper could accurately capture the defect targets on the surface of the particleboards.The calculation results of the defect characteristic parameters had a high accuracy, and the analysis result was in line with the actual situation.
The process of the detection of surface defects in particleboards and surface quality evaluation is shown in Figure 7.

Figure 2 .
Photoelectric switchComputer and peripherals Chromatic industry camera

Figure 2 .
Figure 2. Structural diagram of the particleboard surface defect detection system.

Figure 3 .
Figure 3. Images of different surface defects: (a) subcircular defect; (b) subrectangular defect; (c) slender defect; (d) large defect; (e) adjacent defect.When the KCF target tracking algorithm is used to track the surface defects in the particleboard, a large number of sample images are used to train the classifier of the algorithm.The circulant matrix introduced in Section 2.1 is an effective method to obtain a large number of sample images.The sample images obtained by the circulant matrix are shown in Figure4.In reality, the number of samples obtained is much larger than that shown in the figure.

Figure 4 .
Figure 4. Sample images obtained by circulant matrices: (a) image reduced by 40 pixels; (b) image reduced by 20 pixels; (c) base image; (d) image increased by 20 pixels; (e) image increased by 40 pixels.

Figure 4 .
Figure 4. Sample images obtained by circulant matrices: (a) image reduced by 40 pixels; (b) image reduced by 20 pixels; (c) base image; (d) image increased by 20 pixels; (e) image increased by 40 pixels.
, were numbered a-e.Among them, defect a and b were in board A, defect c was in board B, defect d and e were in board C. The surface quality grade on the production line was first-class for board B, second-class for board A, and third-class for board C. (Boards of class 1 are excellent, class 2 are medium, and class 3 are inferior.)

Figure 4 .
Figure 4. Sample images obtained by circulant matrices: (a) image reduced by 40 pixels; (b) image reduced by 20 pixels; (c) base image; (d) image increased by 20 pixels; (e) image increased by 40 pixels.

Figure 6 .
Figure 6.The results of the Sobel operator detection of partial surface defects.The result vacancy represents the loss of target in the tracking process.(a) Detection according to the tracking results of the improved kernel correlation filter (KCF) algorithm; (b) detection according to the tracking results of the tracking-learning-detection (TLD) algorithm.

Figure 6 .
Figure 6.The results of the Sobel operator detection of partial surface defects.The result vacancy represents the loss of target in the tracking process.(a) Detection according to the tracking results of the improved kernel correlation filter (KCF) algorithm; (b) detection according to the tracking results of the tracking-learning-detection (TLD) algorithm.

Figure 7 .
Figure 7. Flowchart of the detection of surface defects in particleboards and surface quality evaluation.Figure 7. Flowchart of the detection of surface defects in particleboards and surface quality evaluation.

Figure 7 .
Figure 7. Flowchart of the detection of surface defects in particleboards and surface quality evaluation.Figure 7. Flowchart of the detection of surface defects in particleboards and surface quality evaluation.

Table 1 .
The results of area calculation of surface defect targets.

Table 2 .
The results of defect depth calculation of surface defect targets.

Table 3 .
Surface quality indexes of the standard particleboard.

Table 4 .
Surface quality indexes of the experimental particleboards.

Table 5 .
The Hamming distance between the experimental boards and standard boards.

Table 6 .
The Euclid distance between the experimental boards and standard boards.

Table 7 .
The dose-approximation values between the experimental boards and standard boards.