Fabric surface defect detection method based on local binary pattern
Through the detection method based on local binary mode, using the ILBP method to process fabric images, extract features and calculate similarity coefficients, the problems of high complexity and low accuracy of existing fabric surface defect detection methods are solved, and efficient and accurate Fabric surface defect detection.
Patent Information
- Application Number
- CN202411574916.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-14
AI Technical Summary
The existing fabric surface defect detection methods have problems such as high computational complexity, low accuracy or require a large number of training images.
Using a detection method based on the local binary mode, the grayscale image is processed through the local binary mode ILBP method, the feature vector is extracted and the similarity coefficient is calculated, and whether each pixel point is a defective pixel point is realized to realize the defect detection of fabric surface.
The detection process is simplified, the accuracy and efficiency of defect detection are improved, and the preparation time is reduced. Only a standard defect-free picture is needed as the detection template.
Smart Images

Figure CN119444723A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a computer vision image processing method, and in particular to a fabric surface defect detection method based on a local binary pattern. Background Art
[0002] Automatic fabric surface defect detection is a quality control process used to identify and locate defects on the fabric surface. Automatic fabric surface defect detection is particularly important for textile manufacturers to improve product quality and maintain market competitiveness. Compared with manual visual inspection process, it has high inspection accuracy and can detect multiple types of defects, reducing the time and cost of product quality inspection process.
[0003] After searching the existing technologies, we found that the methods can be divided into three categories:
[0004] 1) Fabric defect detection method based on improved gray level co-occurrence matrix (MGLCM). MGLCM is a statistical texture descriptor. In the training stage, four statistical features including energy, homogeneity, contrast and correlation are calculated from the MGLCM of defect-free samples. Zhu et al. (2015) used autocorrelation function and gray level co-occurrence matrix (GLCM) for defect detection of colored fabrics. In the training stage, the autocorrelation function is first applied to the defect-free image to calculate the size of the repeated pattern. Based on this size, a template image is obtained and the defect-free image is segmented into blocks of the same size. Then, a GLCM with specified parameters is calculated for the template image and each block. Finally, the defect-free blocks are detected based on the Euclidean distance between the block and the template image.
[0005] 2) Spectrum-based processing methods, such as Li and Zhang et al. (2015) proposed a fabric surface defect detection method based on multi-scale wavelet transform and Gaussian mixture model. First, the sample image is decomposed into four levels using the pyramid wavelet decomposition algorithm. Then the image is reconstructed based on the wavelet coefficients. Finally, the reconstructed image is divided into defect-free parts and defective parts using the Gaussian mixture model based on the expectation maximization algorithm.
[0006] 3) Detection methods based on deep learning. For example, Jun-Feng et al. (2019) proposed a fabric textile defect detection method based on deep convolutional neural network (CNN). The method proposed three main steps (Jun-Feng et al., 2019). First, the image is decomposed into local blocks to consider the periodic pattern of the fabric and use the features of the distance matching function (DMF). Next, the local blocks are manually labeled. Then, these local blocks are transferred to the convolutional neural network (CNN) to extract discriminative features. Finally, in the detection stage, the entire image is slid and scanned using the trained model to detect defects, and finally the category and location of each defect are obtained. Some disadvantages can be considered here (Jun-Feng et al., 2019). For example, the computational complexity of the DMF method is higher than that of related methods. The overlap between local blocks is not considered, so the localization of the final result is not sufficient in many practical situations. In addition, in order to train CNN, a sufficient number of training images is required.
[0007] Existing algorithms have problems such as high complexity or low accuracy or too many training images. For example, the computational complexity of the DMF method is higher than that of related methods. The overlap between local blocks is not considered, so the localization of the final result is not sufficient in many practical situations. In addition, in order to train CNN, a sufficient number of training images is required. However, our proposed method only requires one image in the training stage, which effectively reduces the preparation time. Summary of the invention
[0008] The purpose of the present invention is to provide a fabric defect detection method based on local binary patterns. Compared with the background technology, the recognition method is simpler, the surface defect detection effect is better, and the object practicability is wider.
[0009] The steps of the technical solution adopted by the present invention to solve its technical problem are as follows:
[0010] A fabric surface defect detection method based on local binary patterns of the present invention comprises the following steps:
[0011] 1) A camera is used to capture several grayscale images of the fabric surface.
[0012] 2) Select a defect-free grayscale image from several grayscale images, and obtain the feature vector WF of the defect-free image window by processing it using the local binary pattern ILBP method and performing feature extraction K and the feature vector MF of the initial grayscale image, thereby calculating the similarity coefficient threshold T like .
[0013] 3) Select the grayscale image to be detected from several grayscale images, and obtain the feature vector wf of the detection image window by processing it using the local binary pattern ILBP method and performing feature extraction k , calculate the similarity coefficient l k .
[0014] 4) Then according to the similarity coefficient l obtained in step 3) k and the similarity coefficient threshold T obtained in step 2) like Determine whether each pixel is a defective pixel.
[0015] 5) The white connected domain formed by all defective pixels determined in step 4) is the defect of the fabric image, thus realizing fabric surface defect detection.
[0016] The step 2) is specifically as follows:
[0017] 2.1) Select a defect-free grayscale image from the several grayscale images obtained in step 1) as the initial grayscale image.
[0018] 2.2) Use a camera to observe and determine the sizes Rx and Ry of the repeated texture in the selected initial grayscale image.
[0019] The sizes Rx and Ry of the repeating texture are determined empirically.
[0020] 2.3) Taking each pixel as the center and Rx and Ry as the size of an image window, the initial grayscale image is segmented by sliding to obtain K defect-free image windows. The step size can be set according to the specific situation.
[0021] 2.4) Each defect-free image window is processed by the local binary pattern (ILBP) method to obtain the ILBP histogram of each defect-free image window.
[0022] 2.5) Perform feature extraction on the ILBP histogram of each defect-free image window to obtain the feature vector WF of each defect-free image window K .
[0023] 2.6) Each pixel of the initial grayscale image selected in step 2.1) is processed using an improved local binary pattern (ILBP) method to obtain an ILBP histogram of the initial grayscale image.
[0024] 2.7) Perform feature extraction on the ILBP histogram of the initial grayscale image obtained in step 2.6) to obtain a feature vector MF of the initial grayscale image.
[0025] 2.8) The feature vectors WF of the K defect-free image windows obtained in step 2.5) are KThe similarity is calculated with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain K similarity coefficients L K .
[0026] 2.9) Select the similarity coefficient with the largest value from the K similarity coefficients obtained in step 2.8) as the similarity coefficient threshold T like .
[0027] The step 3) is specifically as follows:
[0028] 3.1) Select a grayscale image from the several grayscale images obtained in step 1) as the detection grayscale image.
[0029] 3.2) Taking Rx and Ry in step 2.2) as the size of an image window and performing image segmentation on the detection grayscale image, k detection image windows are obtained.
[0030] 3.3) Each detected image window is processed by the improved local binary pattern (ILBP) method to obtain the ILBP histogram of each detected image window.
[0031] 3.4) Perform feature extraction on the ILBP histogram of each detected image window to obtain the feature vector wf of each detected image window k .
[0032] 3.5) The feature vectors wf of the k detection image windows obtained in step 3.4) are k The similarity calculation is performed with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain the similarity coefficient l of the k detection image windows k .
[0033] The step 4) is specifically as follows:
[0034] 4.1) The similarity coefficient l of the k detection image windows obtained in step 3.5) is k Respectively and step 2.9) obtained similarity coefficient threshold T like By comparison, it is determined whether each detected image window is a defective window.
[0035] 4.2) Create a mask image with the same size as the detection grayscale image, and set the position count of each pixel in the mask image to zero. Traverse all detection image windows. Whenever a detection image window is judged to be a defect window, the corresponding position count of each pixel in the defect window in the mask image is increased by one. Finally, the mask image of the detection grayscale image after all detection image windows are processed is obtained.
[0036] 4.3) Compare the position counts corresponding to each pixel in the mask image obtained in step 4.2) with the position count threshold T num Compare and determine whether each pixel is a defective pixel.
[0037] The improved local binary pattern ILBP method in step 2.4), step 2.6) or step 3.3) is specifically:
[0038] S1. In the image window, the image window range obtained with the center point c as the center and R as the radius includes a total of P neighboring points centered on the center point c. Four partial maps of each image window are calculated, namely, the positive binary partial map, the negative binary partial map, the amplitude binary partial map and the global contrast two-part map.
[0039] S2. Calculate the number of changes in the binary changes of adjacent neighboring points in each partial image of each image window.
[0040] S3, the change number and change number threshold U of the adjacent neighboring points binarized in each partial graph obtained in step S2 T , calculate the count value N of each partial image of each image window c .
[0041] S4, the different count values N obtained in step S3 c As the x-axis of the histogram, count the different count values N c The number of partial images corresponding to the image window and the different count values N obtained by counting c The number of partial images corresponding to the image window is used as the y-axis of the histogram, thereby establishing a histogram of ILBP.
[0042] The positive binary part map, negative binary part map, amplitude binary part map and global contrast binary part map of each image window in step S1 are set according to the following formula:
[0043]
[0044] In the formula, is a positive binary partial graph, is the negative binary part graph, M j is the amplitude binary part map, C j is the global contrast binary part map, S() is the binary part, j is the neighbor index, P is the number of neighbors, g j is the gray value of the neighboring point, g c is the gray value of the center point c, t noise is the noise immunity threshold, m is the amplitude threshold, g is average is the grayscale average of the image window, and x is the independent variable of the binary part S().
[0045] The number of changes in the binary changes of the adjacent neighboring points in each partial image of each image in step S2 is set according to the following formula:
[0046]
[0047] Where U c is the number of changes in the binary value of adjacent neighboring points in the partial graph, f p-1 is the binary value of the last neighbor point, f 0 is the binary value of the first neighbor point, j is the neighbor point index, P is the number of neighbor points, and f j is the binary value of the neighboring point, f j-1 f j The binary value of the previous neighboring point.
[0048] The count value N of each partial image of each image window in step S3 c Set it according to the following formula:
[0049]
[0050] Where N c is the count value of the partial image in the image window, j is the neighbor index, P is the number of neighbor points, and f j is the binary value of the neighboring point, U c is the number of changes in the binary value of the adjacent neighboring points in the partial graph, U T is the change quantity threshold.
[0051] The method for feature extraction in step 2.5), step 2.7) or step 3.4) is specifically as follows:
[0052] The histogram of ILBP obtained in step 2.4), step 2.6) or step 3.3) is normalized, and features are extracted from the normalized histogram. Finally, a feature vector is formed based on the features of the extracted histogram.
[0053] The normalization method includes but is not limited to L1 norm normalization and L2 norm normalization.
[0054] The feature extraction includes but is not limited to statistical features, distribution features and shape features.
[0055] The K similarity coefficients L in step 2.8) K The calculation formula is:
[0056]
[0057] Where, L Kis the similarity coefficient of the defect-free image window, K is the number of segmented image windows, 4P+8 is the total number of four feature vectors of length P+2, I is the feature vector index, is the feature vector of the defect-free image window indexed as I, MF I is the feature vector of the initial grayscale image with index I.
[0058] The k similarity coefficients l in step 3.5) k The calculation formula is:
[0059]
[0060] In the formula, l k is the similarity coefficient of the detected image window, k is the number of segmented image windows, 4P+8 is the total number of feature vectors of length P+2, i is the feature vector index, is the feature vector of the detection image window with index i, MF i is the feature vector of the initial grayscale image with index i.
[0061] In step 4.1), whether each detection image window is a defective window is determined specifically according to the following formula:
[0062]
[0063] In the formula, To detect whether the image window is a defective window, l k To detect the similarity coefficient of the image window, T like is the similarity coefficient threshold.
[0064] The mask position count of each pixel corresponding to the position of the mask image in step 4.2) is specifically processed according to the following formula:
[0065]
[0066] In the formula, To detect whether the image window is a defect window, mask (x,y) To determine the completion k Count the mask positions after detecting whether the image window is a defect window, Mask (x,y) To determine w k The mask position count before detecting whether the image window is a defect window, w k is the detection image window, (x, y) is the position of the pixel in the detection image window.
[0067] In step 4.3), whether each pixel is a defective pixel is determined according to the following formula:
[0068]
[0069] In the formula, mask (x,y) To determine the completion k Detect whether the image window is a defect window after the mask position count, flag (x,y) is the defect pixel mark, T num is the position count threshold.
[0070] The present invention has the following beneficial effects:
[0071] The present invention utilizes the gray discontinuity characteristics of the fabric surface defect image area, and locates defects by improving the local binary mode to complete image feature extraction and image similarity coefficient comparison. No manual debugging and setting are required, and only a standard defect-free picture is needed as a comparison template for detecting surface defects. The method algorithm is simple to implement in program engineering, and has great application potential in the online computer vision detection of fabric and cloth quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 is a flow chart of the method of the present invention.
[0073] Figure 2 This is an image of a fabric without defects in Example 2 of the present invention.
[0074] Figure 3 It is the defect-free image window segmented in Embodiment 2 of the present invention.
[0075] Figure 4 This is the process of calculating using the local binary pattern (ILBP) method with one pixel as the center point in Embodiment 2 of the present invention.
[0076] Figure 5 This is an example diagram of defect window mask position counting in embodiment 2 of the present invention.
[0077] Figure 6 This is an example diagram of the detection results in Example 2 of the present invention.
[0078] Figure 7 This is an example diagram of the detection results in Example 3 of the present invention. DETAILED DESCRIPTION
[0079] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0080] like Figure 1 As shown, the embodiments of the present invention and their implementation process are as follows:
[0081] 1) A camera is used to capture several grayscale images of the fabric surface.
[0082] 2) Select a defect-free grayscale image from several grayscale images, and obtain the feature vector WF of the defect-free image window by processing it using the local binary pattern ILBP method and performing feature extraction K and the feature vector MF of the initial grayscale image, thereby calculating the similarity coefficient threshold T like .
[0083] Step 2) is specifically as follows:
[0084] 2.1) Select a defect-free grayscale image from the several grayscale images obtained in step 1) as the initial grayscale image.
[0085] 2.2) Use a camera to observe and determine the sizes Rx and Ry of the repeated texture in the selected initial grayscale image.
[0086] The sizes Rx and Ry of the repeating texture are determined empirically.
[0087] 2.3) Taking each pixel as the center and Rx and Ry as the size of an image window, the initial grayscale image is segmented by sliding to obtain K defect-free image windows. The step size can be set according to the specific situation.
[0088] 2.4) Each defect-free image window is processed by the local binary pattern (ILBP) method to obtain the ILBP histogram of each defect-free image window.
[0089] 2.5) Perform feature extraction on the ILBP histogram of each defect-free image window to obtain the feature vector WF of each defect-free image window K .
[0090] 2.6) Each pixel of the initial grayscale image selected in step 2.1) is processed using an improved local binary pattern (ILBP) method to obtain an ILBP histogram of the initial grayscale image.
[0091] 2.7) Perform feature extraction on the ILBP histogram of the initial grayscale image obtained in step 2.6) to obtain a feature vector MF of the initial grayscale image.
[0092] 2.8) The feature vectors WF of the K defect-free image windows obtained in step 2.5) are K The similarity is calculated with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain K similarity coefficients L K .
[0093] K similarity coefficients L in step 2.8) K The calculation formula is:
[0094]
[0095] Where, L K is the similarity coefficient of the defect-free image window, K is the number of segmented image windows, 4P+8 is the total number of four feature vectors of length P+2, I is the feature vector index, WF KI is the feature vector of the defect-free image window indexed as I, MF I is the feature vector of the initial grayscale image with index I.
[0096] 2.9) Select the similarity coefficient with the largest value from the K similarity coefficients obtained in step 2.8) as the similarity coefficient threshold T like .
[0097] The similarity coefficient threshold T in step 2.9) like The following formula is used to set:
[0098] T like =max(L K ),K=1,2,……,N
[0099] Where, T like is the similarity coefficient threshold, L K is the similarity coefficient of the defect-free image window, and K is the number of segmented image windows.
[0100] 3) Select the grayscale image to be detected from several grayscale images, and obtain the feature vector wf of the detection image window by processing it using the local binary pattern ILBP method and performing feature extraction k , calculate the similarity coefficient l k .
[0101] Step 3) is specifically:
[0102] 3.1) Select a grayscale image from the several grayscale images obtained in step 1) as the detection grayscale image.
[0103] 3.2) Taking Rx and Ry in step 2.2) as the size of an image window and performing image segmentation on the detection grayscale image, k detection image windows are obtained.
[0104] 3.3) Each detected image window is processed by the improved local binary pattern (ILBP) method to obtain the ILBP histogram of each detected image window.
[0105] The improved local binary pattern ILBP method in step 2.4), step 2.6) or step 3.3) is specifically:
[0106] S1. In the image window, the image window range obtained with the center point c as the center and R as the radius includes a total of P neighboring points centered on the center point c. Four partial maps of each image window are calculated, namely, the positive binary partial map, the negative binary partial map, the amplitude binary partial map and the global contrast two-part map.
[0107] The positive binary part map, negative binary part map, amplitude binary part map and global contrast binary part map of each image window in step S1 are set according to the following formula:
[0108]
[0109] In the formula, is a positive binary partial graph, is the negative binary part graph, M j is the amplitude binary part map, C j is the global contrast binary part map, S() is the binary part, j is the neighbor index, P is the number of neighbors, g j is the gray value of the neighboring point, g c is the gray value of the center point c, t noise is the noise immunity threshold, m is the amplitude threshold, g is average is the grayscale average of the image window, x is the independent variable of the binary part S(), t noise It is set manually according to the imaging effect, and m is usually the amplitude average of the image window.
[0110] S2. Calculate the number of changes in the binary changes of adjacent neighboring points in each partial image of each image window.
[0111] The number of changes in the binary changes of the adjacent neighboring points in each partial image of each image in step S2 is set according to the following formula:
[0112]
[0113] Where U c is the number of changes in the binary value of adjacent neighboring points in the partial graph, f p-1 is the binary value of the last neighbor point, f 0 is the binary value of the first neighbor point, j is the neighbor point index, P is the number of neighbor points, and f j is the binary value of the neighboring point, f j-1 f j The binary value of the previous neighboring point.
[0114] S3, the change number and change number threshold U of the adjacent neighboring points binarized in each partial graph obtained in step S2 T , calculate the count value N of each partial image of each image window c.
[0115] The count value N of each partial image of each image window in step S3 c Set it according to the following formula:
[0116]
[0117] Where N c is the count value of the partial image in the image window, j is the neighbor index, P is the number of neighbor points, and f j is the binary value of the neighboring point, U c is the number of changes in the binary value of the adjacent neighboring points in the partial graph, U T is the change quantity threshold.
[0118] S4, the different count values N obtained in step S3 c As the x-axis of the histogram, count the different count values N c The number of partial images corresponding to the image window and the different count values N obtained by counting c The number of partial images corresponding to the image window is used as the y-axis of the histogram, thereby establishing a histogram of ILBP.
[0119] 3.4) Perform feature extraction on the ILBP histogram of each detected image window to obtain the feature vector wf of each detected image window k .
[0120] The method for feature extraction in step 2.5), step 2.7) or step 3.4) is specifically as follows:
[0121] The histogram of ILBP obtained in step 2.4), step 2.6) or step 3.3) is normalized, and features are extracted from the normalized histogram. Finally, feature vectors are combined according to the features of the extracted histograms, that is, feature vectors WF of K defect-free image windows are obtained. K , the feature vector MF of the initial grayscale image and the feature vector wf of the k detection image windows k .
[0122] 3.5) The feature vectors wf of the k detection image windows obtained in step 3.4) are k The similarity calculation is performed with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain the similarity coefficient l of the k detection image windows k .
[0123] The k similarity coefficients l in step 3.5) k The calculation formula is:
[0124]
[0125] In the formula, l k is the similarity coefficient of the detected image window, k is the number of segmented image windows, 4P+8 is the total number of feature vectors of length P+2, i is the feature vector index, is the feature vector of the detection image window with index i, MF i is the feature vector of the initial grayscale image with index i.
[0126] 4) Then according to the similarity coefficient l obtained in step 3) k and the similarity coefficient threshold T obtained in step 2) like Determine whether each pixel is a defective pixel.
[0127] Step 4) is specifically as follows:
[0128] 4.1) The similarity coefficient l of the k detection image windows obtained in step 3.5) is k Respectively and step 2.9) obtained similarity coefficient threshold T like By comparison, it is determined whether each detected image window is a defective window.
[0129] In step 4.1), whether each detection image window is a defective window is determined according to the following formula:
[0130]
[0131] In the formula, To detect whether the image window is a defective window, l k To detect the similarity coefficient of the image window, T like is the similarity coefficient threshold.
[0132] 4.2) Create a mask image with the same size as the detection grayscale image, and set the position count of each pixel in the mask image to zero. Traverse all detection image windows. Whenever a detection image window is judged to be a defect window, the corresponding position count of each pixel in the defect window in the mask image is increased by one. The corresponding position in the mask image refers to the same position. Finally, the mask image of the detection grayscale image after processing all detection image windows is obtained.
[0133] The mask position count of each pixel corresponding to the position of the mask image in step 4.2) is specifically processed according to the following formula:
[0134]
[0135] In the formula, To detect whether the image window is a defect window, mask (x,y) To determine the completion kCount the mask positions after detecting whether the image window is a defect window, Mask (x,y) To determine w k The mask position count before detecting whether the image window is a defect window, w k is the detection image window, (x, y) is the position of the pixel in the detection image window.
[0136] 4.3) Compare the position counts corresponding to each pixel in the mask image obtained in step 4.2) with the position count threshold T num Compare and determine whether each pixel is a defective pixel.
[0137] In step 4.3), whether each pixel is a defective pixel is determined according to the following formula:
[0138]
[0139] In the formula, mask (x,y) To determine the completion k Detect whether the image window is a defect window after the mask position count, flag (x,y) is the defect pixel mark, T num is the position count threshold.
[0140] 5) The white connected domain formed by all defective pixels determined in step 4) is the defect of the fabric image, thus realizing fabric surface defect detection.
[0141] Example 2
[0142] 1) Take a gray image of a fabric without defects, such as Figure 2 shown.
[0143] 2) Select pixel sizes Rx and Ry according to the image repeating texture.
[0144] 3) Use Rx and Ry to split the image and get Figure 3 K small windows are shown.
[0145] 4) Apply ILBP operation to the K small windows obtained in step 3). Substitute each pixel point of the small window into the formula, Figure 4 This is the process where one pixel is calculated as the center point, and the result of the four parts is U c It is 2, 4, 5, 4.
[0146] 5) R = 1, P = 8, take U T =P / 4=2.
[0147] 2=U T , N c The number of "1" is 4;
[0148] 4>U T , N c P+1=9;
[0149] 5>U T , N c P+1=9;
[0150] Each pixel is calculated in the same way to get N c There are 4 histograms on the x-axis and the same number on the y-axis.
[0151] 6) Create 4 window feature vectors WF with a length of P+2 K , the values correspond to the y values of the histogram from left to right.
[0152] 7) Execute step 4) on the entire image to obtain the ILBP histograms of K image windows.
[0153] 8) Extract features from the ILBP histogram obtained in step 6) to obtain four main feature vectors MF with a length of P+2.
[0154] 9) Step 6) The window feature vector WF K The main feature vector MF obtained in step 8) is substituted into the corresponding formula to obtain the similarity coefficient L K .
[0155] 10) After all small windows have obtained similarity coefficients, substitute them into the corresponding formula and take the maximum value as the similarity coefficient threshold T like .
[0156] 11) According to the sizes Rx, Ry obtained in step 2), the detected grayscale image is divided into k image windows.
[0157] 12) Execute step 4) on k detection image windows to obtain ILBP histograms of the k image windows.
[0158] 13) Extract features from the k histograms obtained in step 12) to obtain feature vectors wf of k detection image windows k .
[0159] 14) For the k detection window feature vectors wf obtained in step 13) k The main feature vector MF obtained in step 8) is substituted into the corresponding formula to obtain k similarity coefficients l k .
[0160] 15) These k similarity coefficients l k and similarity coefficient threshold T like For comparison, substitute the corresponding formula, similarity coefficient l kWindows smaller than the threshold are judged as non-defective windows, and windows larger than the threshold are judged as defective windows.
[0161] 16) Create a Figure 1 The size of the mask map is as follows: all pixels in the defect window correspond to the defect mask position count + 1, and the mask position count mask is obtained by substituting it into the corresponding formula (x,y) .
[0162] 17) After all windows are counted, the pixels at all positions of the detected image are substituted into the corresponding formula to obtain the defective pixel flag. (x,y) , the position of the defective pixel (x, y) is the position corresponding to the defect.
[0163] like Figure 5 As shown, T num Take P / 4=2. The pixel counts at the four corners of the four small windows are 1, the pixel counts at the top, bottom, left and right are 2, and the pixel count of the overlapping black pixel in the middle is 4. Only the black pixel count in the middle is greater than 2, and this point is the pixel to which the defect belongs.
[0164] 18) All defective pixels on the mask map indicate the location of the defect, such as Figure 6 shown.
[0165] Example 3
[0166] The results after being treated in the same manner as Example 1 and Example 2 are as follows Figure 7 shown.
[0167] After multiple implementations of multiple embodiments of the present invention, the accuracy of the method of the present invention reached 95%.
[0168] The above specific implementation modes are used to explain the present invention rather than to limit the present invention. Any modification and change made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A fabric surface defect detection method based on local binary pattern, characterized in that: The method comprises the following steps: 1) Using a camera to obtain several grayscale images of the fabric surface; 2) Select a defect-free grayscale image from several grayscale images, and obtain the feature vector WF of the defect-free image window by processing it using the local binary pattern ILBP method and performing feature extraction K and the feature vector MF of the initial grayscale image, thereby calculating the similarity coefficient threshold T like ; 3) Select the grayscale image to be detected from several grayscale images, and obtain the feature vector wf of the detection image window by processing it using the local binary pattern ILBP method and performing feature extraction k , calculate the similarity coefficient l k ; 4) Then according to the similarity coefficient l obtained in step 3) k and the similarity coefficient threshold T obtained in step 2) like Determine whether each pixel is a defective pixel; 5) The white connected domain formed by all defective pixels determined in step 4) is the defect of the fabric image, thus realizing fabric surface defect detection.
2. The method for detecting fabric surface defects based on local binary patterns according to claim 1, characterized in that: The step 2) is specifically as follows: 2.1) Selecting a defect-free grayscale image from the plurality of grayscale images obtained in step 1) as an initial grayscale image; 2.2) using a camera to observe and determine the sizes Rx and Ry of the repeated texture in the selected initial grayscale image; 2.3) Taking each pixel as the center and Rx and Ry as the size of an image window, the initial grayscale image is segmented by sliding to obtain K defect-free image windows; 2.4) Processing each defect-free image window obtained by using the local binary pattern (ILBP) method to obtain an ILBP histogram of each defect-free image window; 2.5) Perform feature extraction on the ILBP histogram of each defect-free image window to obtain the feature vector WF of each defect-free image window K ; 2.6) processing each pixel of the initial grayscale image selected in step 2.1) by using an improved local binary pattern (ILBP) method to obtain an ILBP histogram of the initial grayscale image; 2.7) performing feature extraction on the ILBP histogram of the initial grayscale image obtained in step 2.6) to obtain a feature vector MF of the initial grayscale image; 2.8) The feature vectors WF of the K defect-free image windows obtained in step 2.5) are K The similarity is calculated with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain K similarity coefficients L K ; 2.9) Select the similarity coefficient with the largest value from the K similarity coefficients obtained in step 2.8) as the similarity coefficient threshold T like .
3. The method for detecting fabric surface defects based on local binary patterns according to claim 2, characterized in that: The step 3) is specifically as follows: 3.1) Selecting a grayscale image from the plurality of grayscale images obtained in step 1) as a detection grayscale image; 3.2) Taking Rx and Ry in step 2.2) as the size of an image window and performing image segmentation on the detection grayscale image to obtain k detection image windows; 3.3) Each detected image window is processed by an improved local binary pattern (ILBP) method to obtain an ILBP histogram of each detected image window; 3.4) Perform feature extraction on the ILBP histogram of each detected image window to obtain the feature vector wf of each detected image window k ; 3.5) The feature vectors wf of the k detection image windows obtained in step 3.4) are k The similarity is calculated with the feature vector MF of the initial grayscale image obtained in step 2.7) to obtain the similarity coefficient l of the k detection image windows k .
4. The method for detecting fabric surface defects based on local binary patterns according to claim 3, characterized in that: The step 4) is specifically as follows: 4.1) The similarity coefficient l of the k detection image windows obtained in step 3.5) is k Respectively and step 2.9) obtained similarity coefficient threshold T like Comparison is performed to determine whether each detected image window is a defective window; 4.2) Create a mask image of the same size as the grayscale image to be detected, and set the position count of each pixel in the mask image to zero. Traverse all the detection image windows. Whenever a detection image window is determined to be a defect window, the position count of each pixel in the defect window in the mask image is increased by one. Finally, the mask image of the grayscale image after all the detection image windows are processed is obtained. 4.3) Compare the position counts corresponding to each pixel in the mask image obtained in step 4.2) with the position count threshold T num Compare and determine whether each pixel is a defective pixel.
5. The fabric surface defect detection method based on local binary pattern according to claim 1 or 2, characterized in that: The improved local binary pattern ILBP method in step 2.4), step 2.6) or step 3.3) is specifically: S1. In the image window, the image window range obtained with the center point c as the center and R as the radius includes a total of P neighboring points centered on the center point c, and four partial maps of each image window are calculated, namely, a positive binary partial map, a negative binary partial map, an amplitude binary partial map and a global contrast two-part map; S2, calculating the number of changes in the binary changes of the adjacent neighboring points in each partial image of each image window; S3, the change number and change number threshold U of the adjacent neighboring points binarized in each partial graph obtained in step S2 T , calculate the count value N of each partial image of each image window c ; S4, the different count values N obtained in step S3 c As the x-axis of the histogram, count the different count values N c The number of partial images corresponding to the image window and the different count values N obtained by counting c The number of partial images corresponding to the image window is used as the y-axis of the histogram, thereby establishing a histogram of ILBP.
6. The method for detecting fabric surface defects based on local binary patterns according to claim 5, characterized in that: The positive binary part map, negative binary part map, amplitude binary part map and global contrast binary part map of each image window in step S1 are set according to the following formula: In the formula, is a positive binary partial graph, is the negative binary part graph, M j is the amplitude binary part map, C j is the global contrast binary part map, S() is the binary part, j is the neighbor index, P is the number of neighbors, g j is the gray value of the neighboring point, g c is the gray value of the center point c, t noise is the noise immunity threshold, m is the amplitude threshold, g is average is the grayscale average of the image window, and x is the independent variable of the binary part S(); The number of changes in the binary changes of the adjacent neighboring points in each partial image of each image in step S2 is set according to the following formula: Where U c is the number of changes in the binary value of adjacent neighboring points in the partial graph, f p-1 is the binary value of the last neighbor point, f0 is the binary value of the first neighbor point, j is the neighbor point index, P is the number of neighbor points, and f j is the binary value of the neighboring point, f j-1 f j The binary value of the previous neighboring point; The count value N of each partial image of each image window in step S3 c Set it according to the following formula: Where N c is the count value of the partial image in the image window, j is the neighbor index, P is the number of neighbor points, and f j is the binary value of the neighboring point, U c is the number of changes in the binary value of the adjacent neighboring points in the partial graph, U T is the change quantity threshold.
7. The method for detecting fabric surface defects based on local binary patterns according to claim 5, characterized in that: The method for feature extraction in step 2.5), step 2.7) or step 3.4) is specifically as follows: The histogram of ILBP obtained in step 2.4), step 2.6) or step 3.3) is normalized, and features are extracted from the normalized histogram. Finally, a feature vector is formed based on the features of the extracted histogram.
8. The method for detecting fabric surface defects based on local binary patterns according to claim 2, characterized in that: The K similarity coefficients L in step 2.8) K The calculation formula is: Where, L K is the similarity coefficient of the defect-free image window, K is the number of segmented image windows, 4P+8 is the total number of four feature vectors of length P+2, I is the feature vector index, WF KI is the feature vector of the defect-free image window indexed as I, MF I is the feature vector of the initial grayscale image with index I.
9. The method for detecting fabric surface defects based on local binary patterns according to claim 3, characterized in that: The k similarity coefficients l in step 3.5) k The calculation formula is: In the formula, l k is the similarity coefficient of the detected image window, k is the number of segmented image windows, 4P+8 is the total number of four feature vectors of length P+2, i is the feature vector index, is the feature vector of the detection image window with index i, MF i is the feature vector of the initial grayscale image with index i.
10. The method for detecting fabric surface defects based on local binary patterns according to claim 3, characterized in that: In step 4.1), whether each detection image window is a defective window is determined specifically according to the following formula: In the formula, To detect whether the image window is a defective window, l k To detect the similarity coefficient of the image window, T like is the similarity coefficient threshold; The mask position count of each pixel corresponding to the position of the mask image in step 4.2) is specifically processed according to the following formula: In the formula, To detect whether the image window is a defect window, mask (x,y) To determine the completion k Count the mask positions after detecting whether the image window is a defect window, Mask (x,y) To determine w k The mask position count before detecting whether the image window is a defect window, w k is the detection image window, (x, y) is the position of the pixel in the detection image window; In step 4.3), whether each pixel is a defective pixel is determined according to the following formula: In the formula, mask (x,y) To determine the completion k Detect whether the image window is a defect window after the mask position count, flag (x,y) is the defect pixel mark, T num is the position count threshold.