Fabric defect detection method, device, computer equipment and readable storage medium

Using computer vision technology to detect fabric defects, using grid division and redundant gray level co-occurrence matrices to extract texture features, combined with neural network classification, it solves the objectivity and efficiency problems of traditional manual detection and achieves high accuracy and efficiency. Fabric defect detection.

CN114419004BActive Publication Date: 2024-09-06FOSHAN JIYAN ZHILIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210072590.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-21
Publication Date
2024-09-06
Estimated Expiration
2042-01-21

AI Technical Summary

Technical Problem

Traditional manual methods for fabric defect detection are difficult to guarantee objectivity and consistency, which affects product quality and production efficiency. In addition, inspectors work long hours, resulting in low credibility.

Method used

Using computer vision technology, fabric images are collected through camera equipment, pre-processed and then meshed according to the texture cycle. The redundant gray level co-occurrence matrix is ​​used to extract the mesh texture features, and the pre-trained fabric defect detection neural network is used for classification. Mark the location of defects.

Benefits of technology

It improves the accuracy and efficiency of fabric defect detection, reduces the influence of human factors, and enhances the reliability and real-time nature of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114419004B
    Figure CN114419004B
Patent Text Reader

Abstract

The present application relates to a method, device, computer equipment and readable storage medium for detecting fabric defects, and relates to the field of textiles. The method obtains a fabric image to be detected acquired by a camera, pre-processes the fabric image to be detected to obtain a pre-processed fabric image, meshes the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a gridded fabric image, and uses a redundant grayscale co-occurrence matrix to extract the grid texture features of the gridded fabric image, classifies the grid texture features through a pre-trained fabric defect detection neural network, and determines whether the grid texture features are defect features based on the classification results; if the grid texture features are determined to be defect features, the defect position is marked in the grid texture features corresponding to the fabric image to be detected. The above technical solution can improve the detection accuracy and efficiency of fabric defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of textiles, and in particular to a method, device, computer equipment and readable storage medium for detecting fabric defects. Background Art

[0002] At present, the fabric surface quality inspection of most domestic textile enterprises is still completed by quality inspectors through traditional manual methods. This traditional method of relying on manual inspection for fabric defect inspection first requires professional skills training for inspectors and requires inspectors to have rich experience; secondly, due to the inclusion of human subjective factors, the objectivity and consistency of the inspection results are difficult to guarantee. In addition, due to the long working hours during the inspection process, it is difficult for quality inspectors to maintain a good mental and physical state for a long time, which also leads to low credibility of the inspection results. It can be seen that the traditional manual fabric defect inspection affects the product quality and production efficiency in the textile production process. In recent years, computer vision technology has made great progress. Using machine vision to replace manual inspection for surface defect inspection of objects has become a focus issue in industrial production. The use of machine vision to detect fabric surface defects has practical significance for promoting the intelligent and efficient development of enterprises. Summary of the invention

[0003] Based on this, it is necessary to provide a method, device, computer equipment and readable storage medium for detecting fabric defects that can improve the accuracy and efficiency of fabric defect detection in order to address the above technical problems.

[0004] In a first aspect, the present application provides a method for detecting fabric defects, the method comprising:

[0005] Acquire a fabric image to be detected acquired by a camera device, and pre-process the fabric image to be detected to obtain a pre-processed fabric image;

[0006] The pre-processed fabric image is meshed according to the texture period of the pre-processed fabric image to obtain a plurality of meshed fabric images, and the mesh texture features of each meshed fabric image are extracted using a redundant gray-level co-occurrence matrix;

[0007] The mesh texture features are classified by using a pre-trained fabric defect detection neural network, and whether the mesh texture features are defect features is determined according to the classification results;

[0008] If the grid texture feature is determined to be a defect feature, the defect position is marked in the grid texture feature corresponding to the fabric image to be detected.

[0009] In one embodiment, the method for detecting fabric defects further comprises:

[0010] Acquire a fabric sample image that has been marked in advance; the fabric sample image includes a defective fabric sample image and a flawless fabric sample image;

[0011] The sample fabric texture features of the fabric sample image are extracted, and the sample fabric texture features are input into the classifier for training to construct a fabric defect detection neural network.

[0012] In one embodiment, the step of preprocessing the fabric image to be detected to obtain a preprocessed fabric image includes:

[0013] According to the proximity of each pixel point in the fabric image to be detected and the neighboring pixel points around the pixel point in the geometric space or the similarity in the gray space, the gray value weight corresponding to the neighboring pixel point is adjusted;

[0014] The target gray value of the pixel is obtained by weighted averaging the gray values ​​of each neighboring pixel according to the gray value weight;

[0015] According to the target gray value of each pixel in the fabric image to be detected, a preprocessed fabric image is obtained.

[0016] In one embodiment, the step of gridding the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a plurality of gridded fabric images comprises:

[0017] determining a homogenization parameter of the preprocessed fabric image according to a gray value difference between each pixel pair in the preprocessed fabric image;

[0018] Measuring the texture period of the pre-processed fabric image according to the homogenization parameter and determining the grid size for meshing the pre-processed fabric image;

[0019] The pre-processed fabric image is gridded based on the grid size to obtain a number of gridded fabric images.

[0020] In one embodiment, the step of determining the homogenization parameter of the pre-processed fabric image according to the gray value difference between each pixel pair in the pre-processed fabric image comprises:

[0021] Determine the relative position relationship of each pixel pair in the preprocessed fabric image, and determine the gray value difference of the pixel pair based on the relative position relationship;

[0022] The probability distribution of each gray value difference is calculated to calculate the statistical probability that the gray value difference is a preset difference, and the homogenization parameter of the pre-processed fabric image is determined according to the probability distribution result.

[0023] In one embodiment, the step of extracting the grid texture features of each gridded fabric image using the redundant gray level co-occurrence matrix includes:

[0024] Each gridded fabric image is decomposed at multiple scales by using a pre-established generalized Gaussian filter to obtain multiple redundant images of different scales corresponding to the gridded fabric image;

[0025] Generate a gray level co-occurrence matrix corresponding to each redundant image to obtain a redundant gray level co-occurrence matrix of the gridded fabric image;

[0026] The corresponding feature quantities are obtained according to the redundant gray-level co-occurrence matrix to obtain the grid texture features of the gridded fabric image.

[0027] In one embodiment, the step of obtaining corresponding feature quantities according to the redundant gray-level co-occurrence matrix to obtain the grid texture features of the gridded fabric image includes:

[0028] The feature parameters of the redundant image are calculated based on the redundant gray-level co-occurrence matrix, and the feature parameters include angular second-order moment, contrast, correlation, inverse difference moment and entropy;

[0029] Feature extraction is performed on the gridded fabric image according to the feature parameters to obtain the grid texture features corresponding to the gridded fabric image.

[0030] In a second aspect, the present application also provides a device for detecting fabric defects, the device comprising:

[0031] A fabric image acquisition module is used to acquire the fabric image to be detected acquired by a camera device, and pre-process the fabric image to be detected to obtain a pre-processed fabric image;

[0032] A texture feature extraction module is used to grid the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a plurality of gridded fabric images, and to extract the grid texture features of each gridded fabric image using a redundant gray-level co-occurrence matrix;

[0033] A defect feature determination module is used to classify the mesh texture features through a pre-trained fabric defect detection neural network, and determine whether the mesh texture features are defect features according to the classification results;

[0034] The defect position marking module is used to mark the defect position in the grid texture feature corresponding to the fabric image to be detected if the grid texture feature is determined to be a defect feature.

[0035] In a third aspect, the present application further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for detecting fabric defects mentioned in the first aspect when executing the computer program.

[0036] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method for detecting fabric defects mentioned in the first aspect are implemented.

[0037] The above-mentioned fabric defect detection method, device, computer equipment and readable storage medium obtain the fabric image to be detected acquired by a camera, pre-process the fabric image to be detected to obtain a pre-processed fabric image, grid the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a gridded fabric image, and use a redundant grayscale co-occurrence matrix to extract the grid texture features of the gridded fabric image, classify the grid texture features through a pre-trained fabric defect detection neural network, and determine whether the grid texture features are defect features based on the classification results; if the grid texture features are determined to be defect features, the defect position is marked in the grid texture features corresponding to the fabric image to be detected, thereby improving the detection accuracy and efficiency of fabric defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 Schematic diagram of an application scenario of a method for detecting fabric defects in an embodiment;

[0039] Figure 2 is a flow chart of a method for detecting fabric defects in one embodiment;

[0040] Figure 3 is a flow chart of a method for constructing a neural network for fabric defect detection in one embodiment;

[0041] Figure 4 is a decomposition principle diagram of a gridded fabric image in one embodiment;

[0042] Figure 5 yes Figure 4 Corresponding image decomposition instance reference image;

[0043] Figure 6 is a schematic diagram of the positional relationship between two pixels in a pixel pair in an embodiment;

[0044] Figure 7 is a schematic structural diagram of a fabric defect detection device in one embodiment;

[0045] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0047] The technical solution of the present application is to realize accurate detection of fabric defects based on computer vision. In order to facilitate understanding of the present application solution, the application environment to which the embodiments of the present application are applicable is first introduced.

[0048] Figure 1 FIG. 1 is a schematic diagram of an application scenario of a method for detecting fabric defects in an embodiment. Figure 1 As shown, the camera device 101 is connected to the terminal 102 by wired communication. The camera device 101 is set at a fixed position. When the fabric to be detected moves to a preset position range, the camera device 101 continuously shoots the fabric to be detected to obtain the fabric image to be detected. The camera device 101 transmits the captured fabric image to the terminal 102. The terminal 102 obtains the fabric image to be detected and detects defects in the fabric image to be detected. First, after pre-processing the fabric image to be detected, it is grid-divided according to the texture period of the fabric to obtain a number of gridded fabric images, and the grid texture features of each gridded fabric image are extracted using a redundant gray-level co-occurrence matrix. The grid texture features are classified by a pre-trained fabric defect detection neural network to determine whether the grid texture features are defect features. If the grid texture features are determined to be defect features, the defect position is marked in the grid texture features corresponding to the fabric image to be detected. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, industrial computers, etc.

[0049] Optionally, the application environment may further include a display device 103, such as a display screen, which may be provided by the terminal 102 or may be an independent external device that is communicatively connected to the terminal 102. The terminal 102 sends the detection result of the fabric defect to the display device 103, so as to display the detection result to the user through the display device.

[0050] In one embodiment, the application environment may further include a marking mechanism 104, and the terminal 102 is connected to the marking mechanism 104. When the terminal 102 detects the defect position corresponding to the defect feature, the marking mechanism 104 is controlled to mark the defect position corresponding to the fabric to be detected. In this technical solution, the camera device 101 collects the fabric image corresponding to the fabric to be detected and transmits it to the terminal 102 for fabric defect detection operation. After determining the fabric defect position, the marking mechanism is controlled to mark the fabric defect position corresponding to the fabric to be detected, thereby improving the marking real-time performance of fabric defect detection and the defect detection efficiency.

[0051] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0052] The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0053] Figure 2 The flowchart of a method for detecting fabric defects in one embodiment is shown. The method for detecting fabric defects can be executed in a terminal.

[0054] Specifically, Figure 2 As shown, the method for detecting fabric defects may include the following steps:

[0055] S210, acquiring a fabric image to be detected acquired by a camera device, and preprocessing the fabric image to be detected to obtain a preprocessed fabric image.

[0056] The camera device is a device with image acquisition function. The following is an explanation using a camera as an example. The camera is installed in a fixed position. When the fabric to be detected is detected to be within the preset position range, the camera is triggered by the encoder to shoot the fabric to be detected to obtain an image of the fabric to be detected. Optionally, the fabric to be detected can be photographed by a linear array camera. The fabric to be detected moves at a constant speed. When the fabric to be detected moves within the preset position range, one or more linear array cameras are used to continuously scan the fabric to be detected line by line to achieve uniform detection of the entire surface of the fabric to be detected. The linear array camera accurately captures images with micron-level accuracy, thereby improving the accuracy of defect detection.

[0057] Optionally, the fabric image to be detected can be a grayscale fabric image. When the collected fabric image to be detected is a color fabric image, grayscale processing can be used to convert the color fabric image into a grayscale fabric image. Optionally, the resolution of the image to be detected is 8192×3000. The high-resolution fabric image to be detected can improve the detection accuracy of fabric defects.

[0058] In this embodiment, the image of the fabric to be detected is acquired by the camera, and the image of the fabric to be detected is transmitted to the computer device by using the image acquisition card, so that the fabric to be detected is detected by the computer device. Optionally, the computer device obtains the image of the fabric to be detected acquired by the camera, and performs pre-processing such as tilt correction, smoothing denoising and contrast enhancement on the image of the fabric to be detected, so as to eliminate the noise of the fabric image to be detected while maintaining the texture characteristics, thereby improving the detection accuracy of fabric defects.

[0059] S220, gridding the preprocessed fabric image according to the texture period of the preprocessed fabric image to obtain a plurality of gridded fabric images, and extracting grid texture features of the gridded fabric images using a redundant gray-level co-occurrence matrix.

[0060] Fabric pattern and texture are important parameter indicators that reflect fabric surface information. Most fabric textures and patterns are periodic. As the yarn interlacing rules and pattern distribution change, the periodicity will also show certain simple or complex changes accordingly. Errors in the weaving and printing and dyeing process may directly affect the surface quality of the fabric. This technical solution can detect fabric defects based on the texture period in the pre-processed fabric image.

[0061] In one embodiment, a pre-processed fabric image is divided into a plurality of grid blocks by gridding the pre-processed fabric image, and a plurality of gridded fabric images are obtained. Optionally, the pre-processed fabric image is gridded according to the texture period in the horizontal and vertical directions of the pre-processed fabric image to obtain the plurality of gridded fabric images.

[0062] Since texture is formed by the repeated appearance of grayscale distribution in spatial position, there will be a certain grayscale relationship between two pixels separated by a certain distance in the image space, that is, the spatial correlation characteristics of grayscale in the image. Gray-level Co-occurrence Matrix (GLCM) refers to a method of describing texture features by studying the spatial correlation characteristics of grayscale.

[0063] In one embodiment, the grid texture features corresponding to each gridded fabric image can be extracted through multiple gray level co-occurrence matrices. Optionally, the gray level co-occurrence matrices corresponding to each gridded fabric image are calculated to obtain a redundant gray level co-occurrence matrix, and the grid texture features of the gridded fabric image are extracted using the redundant gray level co-occurrence matrix.

[0064] S230, classifying the grid texture features through a pre-trained fabric defect detection neural network, and determining whether the grid texture features are defect features according to the classification results.

[0065] In order to design a neural network model structure suitable for fabric defect detection, the neural network model needs to be trained to determine the appropriate number of hidden layers, input layer, output layer, number of nodes in the hidden layer, and transfer function of the neural network model.

[0066] Figure 3 FIG. 1 is a flow chart of a method for constructing a neural network for fabric defect detection in an embodiment. Figure 3 As shown, in one embodiment, the fabric defect detection neural network can be obtained in the following manner, which may include the following implementation steps:

[0067] S110: Acquire a pre-labeled fabric sample image.

[0068] The fabric sample images include defective fabric sample images and non-defective fabric sample images.

[0069] A number of fabric images are randomly selected as fabric sample images, and the fabric sample images are labeled. If they are defective fabric sample images, the defective fabric sample images are labeled "1", and if they are flawless fabric sample images, the flawless fabric sample images are labeled "0".

[0070] S120, extracting sample fabric texture features from the fabric sample image, inputting the sample fabric texture features into a classifier for training, and constructing a fabric defect detection neural network.

[0071] In one embodiment, fabric texture features of each fabric sample image can be extracted by means of a grayscale co-occurrence matrix to obtain sample fabric texture features. Optionally, each fabric sample image is multi-scale decomposed by a pre-established generalized Gaussian filter to obtain multiple sample redundant images of different scales corresponding to the fabric sample image, and a grayscale co-occurrence matrix corresponding to each sample redundant image is generated to obtain a redundant grayscale co-occurrence matrix of the fabric sample image, and the redundant grayscale co-occurrence matrix of the fabric sample image is used to obtain corresponding feature quantities to obtain sample grid texture features corresponding to the fabric sample image.

[0072] The sample fabric texture features are input into the classifier for training and learning, and the model parameters of the classifier are continuously optimized to obtain the fabric defect detection neural network.

[0073] In this embodiment, the mesh texture features extracted based on the redundant gray co-occurrence matrix method determine that the fabric defect detection neural network adopts a BP neural network structure, the number of nodes in the input layer is 30, the hidden layer is 2 layers, and the number of nodes in each layer is 128. The recognition accuracy and recognition speed of fabric defects are optimal. In addition, the ELU function is selected as the activation function of the hidden layer of the neural network to make the neural network converge faster and the image classification effect better, and the softmax function is added to the output layer so that the sum of all output values ​​is 1, and each output value can be regarded as the probability of discriminating the mesh texture feature as a defect feature category or a normal feature category. At the same time, the approval operation is added before the activation function of each layer, and the cross entropy loss function is used as the loss function of the training process to improve the robustness of the fabric defect detection neural network.

[0074] S240: If it is determined that the grid texture feature is a defect feature, the defect position is marked in the grid texture feature corresponding to the fabric image to be detected.

[0075] The grid texture features of a normal image, i.e., a flawless image, are significantly different from those of a defective image. Grid texture features refer to the coarseness, density, and other characteristics of the texture in each grid after the image is gridded. Generally speaking, grid texture features can be represented by characteristic parameters such as Angular second moment (Asm), Contrast (Con), Correlation (Cor), Inverse different moment (Idm), and Entropy (Ent). Among them, the Asm value can be used to describe the uniformity of grayscale distribution and the coarseness of texture in the image, the Cor value can be used to describe the correlation of matrix elements in the row or column direction, the Con value can be used to characterize the clarity of the image by the depth of the texture grooves, the Idm value can be used to characterize the homogeneity of the image texture, and measure the uniformity of the local changes in the image texture, and the Ent value can be used to characterize the complexity of the image texture.

[0076] The mesh texture features input to the fabric defect detection neural network are classified into normal features and defect features according to the output values ​​of each feature parameter of the mesh texture features. Since the feature parameters of the mesh texture features of the normal image and the mesh texture features of the defect image are obviously different, it is determined whether the input mesh texture feature is a defect feature according to the output values ​​of each feature parameter. If the mesh texture feature is determined to be a defect feature, the defect position is marked at the position corresponding to the mesh texture feature corresponding to the fabric image to be detected.

[0077] The fabric defect detection method provided in the present embodiment obtains a fabric image to be detected acquired by a camera, pre-processes the fabric image to be detected to obtain a pre-processed fabric image, grids the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a gridded fabric image, extracts grid texture features of the gridded fabric image using a redundant grayscale co-occurrence matrix, classifies the grid texture features using a pre-trained fabric defect detection neural network, and determines whether the grid texture features are defect features based on the classification results; if the grid texture features are determined to be defect features, the defect position is marked in the grid texture features corresponding to the fabric image to be detected, thereby improving the detection accuracy and efficiency of fabric defects.

[0078] In order to more clearly illustrate the technical solution of the present application, the implementation of multiple steps of the method for detecting fabric defects is further described below.

[0079] In one embodiment, preprocessing the fabric image to be detected to obtain the preprocessed fabric image in step S210 may include the following steps:

[0080] S2101, adjusting the gray value weights of the neighborhood pixels according to the proximity of each pixel in the fabric image to be detected and the neighborhood pixels around the pixel in the geometric space or the similarity in the gray space.

[0081] In one embodiment, the fabric image to be detected can be preprocessed by a filter. Optionally, a nonlinear filter such as a bilateral filter and a median filter can be used for preprocessing, and a linear filter such as a Gaussian filter, a mean filter and a box filter can also be used for preprocessing. Optionally, the present embodiment uses a bilateral filter to perform smoothing on the fabric image to be detected, which can maintain the edge information of the image, thereby improving the detection accuracy.

[0082] By setting different grayscale value weights for different pixels, the noise of each pixel of the fabric image to be detected can be reduced. There are several neighboring pixels around a certain pixel. According to the proximity of the pixel to its neighboring pixels in the geometric space and the similarity in the grayscale space, the corresponding grayscale value weight is set for the corresponding neighboring pixel.

[0083] In this embodiment, the parameter c(ξ,x) is set to represent the degree of proximity between the pixel point x and its neighboring pixel point ξ in the geometric space, and s(f(ξ),f(x)) represents the degree of similarity between the pixel point x and its neighboring pixel point ξ in the gray space. Optionally, in one embodiment, in a local area where the gray values ​​are relatively close on the fabric image to be detected, since the gray value difference near the pixel point x is small, the function s(f(ξ),f(x)) acting on the gray space has almost no effect on the filtering result, and focuses on the filtering effect of the parameter c(ξ,x). At this time, the gray value weights of the neighboring pixels are adjusted, the gray value weights of the neighboring pixels far away from the pixel point x are increased, and the gray value weights of the neighboring pixels close to the pixel point x are reduced, so as to smooth the image to be detected in the geometric space and reduce noise.

[0084] Optionally, in another embodiment, in a local area where the grayscale value difference on the fabric image to be detected is large, such as in the edge area of ​​the fabric image to be detected, when the pixel point x is on the darker side of the edge, the function s(f(ξ), f(x)) acting in the grayscale space will participate in filtering, and adjust the weights of the neighboring pixel points corresponding to the pixel point x, and the grayscale value weights of the neighboring pixel points on the same side as the pixel point x (located in the dark part) are increased, and the grayscale value weights of the neighboring pixel points on the opposite side of the pixel point x (located in the bright part) are lowered. Take the bilateral filter as an example to illustrate, at this time, the grayscale value of the pixel point x is the result of weighted averaging of the grayscale values ​​of the neighboring pixel points on the same side (i.e., the dark part) of the filtering template of the bilateral filter, and the pixels in the bright part have almost no effect on it, and vice versa.

[0085] S2102, performing weighted averaging of the grayscale values ​​of each neighborhood pixel according to the grayscale value weight to obtain a target grayscale value of the pixel.

[0086] The target grayscale value is obtained by weighted averaging the proximity of the neighboring pixels near a pixel in the geometric space and the similarity in the chromaticity space. The target grayscale value is the result of filtering the pixel. The mathematical model expression can be:

[0087]

[0088] Its normalized coefficient is:

[0089]

[0090] Among them, c(ξ,x) represents the closeness between a certain pixel point x (i.e., the center point of the filter) and its neighboring pixel point ξ in the geometric space, and s(f(ξ),f(x)) represents the similarity between the pixel point x and its neighboring pixel point ξ in the grayscale space.

[0091] In this embodiment, gray value information is added to spatial filtering through bilateral filtering, and the gray value weights of the neighborhood pixels corresponding to each pixel are adjusted through the gray value information to achieve a filtering effect that maintains the edge information of the image, thereby improving the detection accuracy of fabric defects.

[0092] S2103, obtaining a preprocessed fabric image according to the target grayscale value of each pixel in the fabric image to be detected.

[0093] Each pixel in the fabric image to be detected is filtered by a filter, and the calculated target grayscale value is used as the grayscale value of the pixel after filtering, so as to realize preprocessing such as smoothing and denoising of the fabric image to be detected, and obtain a preprocessed fabric image, thereby achieving the goal of reducing the detection noise of the fabric to be detected without affecting the texture characteristics of the fabric to be detected.

[0094] In the related art, when smoothing and filtering an image to reduce noise, the edge information of the image will become blurred, thereby affecting the detection accuracy of fabric defects. This embodiment adjusts the grayscale value weights corresponding to the neighboring pixels according to the proximity of each pixel of the fabric image to be detected and its neighboring pixels in the geometric space or the similarity in the grayscale space, and performs weighted averaging on the grayscale values ​​of the neighboring pixels, thereby preprocessing the fabric image to be detected. While smoothing and removing noise from the fabric image to be detected, the edge information of the image is maintained, thereby improving the detection accuracy of fabric defects.

[0095] In one embodiment, the step S220 of gridding the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a plurality of gridded fabric images may include the following steps:

[0096] S2201. Determine a homogenization parameter of the preprocessed fabric image according to the gray value difference between each pixel pair in the preprocessed fabric image.

[0097] In the same texture period, the texture properties of the fabric are the same or similar. In one embodiment, the texture period is determined by finding the minimum cycle unit of the fabric pattern. Optionally, the minimum cycle unit of the fabric pattern is determined by preprocessing the gray value difference between each pixel pair of the fabric image, and the degree of similarity of the texture of the fabric pattern is measured by setting a homogenization parameter.

[0098] Optionally, in one embodiment, determining the homogenization parameter of the preprocessed fabric image by the gray value difference between each pixel pair may be implemented in the following manner, which may specifically include the following steps:

[0099] S301, determining the relative position relationship of each pixel pair in the preprocessed fabric image, and determining the gray value difference of the pixel pair based on the relative position relationship.

[0100] In this embodiment, the relative position relationship may refer to the relative position relationship between any two pixel points (i.e., a pixel pair) in the horizontal or vertical direction. A displacement vector v = (v1, v2) may be defined to represent the relative position of a pixel pair in the preprocessed fabric image. The relative angle and direction of the pixel pair may be determined by the displacement vector.

[0101] Set the size of the pre-processed fabric image I to L y ×L x , the grayscale value class of the image is K. Preprocessing Any pixel point p=(x,y)∈I,I={0,1,...,L y -1}×{0,1,...,L x -1}, the grayscale value at the pixel point p is expressed as I(p)∈{0,1,...,K-1}, and the grayscale value difference parameter a of the pixel pair is defined. The grayscale value difference a=I(p)-I(p+v) represents the grayscale value difference of the pixel pair with a certain relative position.

[0102] S302: Calculate the probability distribution of the gray value difference, and determine the homogenization parameter of the pre-processed fabric image according to the statistical result of the probability distribution.

[0103] In this embodiment, the distribution of each gray value difference in the preprocessed fabric image is determined by statistically analyzing the probability distribution of the gray value difference of the pixel pair. Optionally, for each determined displacement vector v, a gray value difference distribution histogram about the gray value difference a and the displacement vector v is statistically analyzed, and the corresponding frequency distribution parameter P is obtained after the gray value difference distribution histogram is normalized. v (a)

[0104] According to the frequency distribution parameter P v (a) Obtain the homogenization parameter of a pixel pair whose relative position relationship is vector v according to the following formula:

[0105]

[0106] Where v represents the displacement vector of the pixel pair, a represents the gray value difference of the pixel pair, and P v (a) represents the frequency distribution parameters of the pixel pair.

[0107] S2202: Measure the texture period of the pre-processed fabric image according to the homogenization parameter, and determine the grid size for grid division of the pre-processed fabric image.

[0108] From the above formula of homogenization parameter, it can be known that when the gray value difference a of the pixel pair is 0, the homogenization value G(I,v) reaches the maximum value of 1. In the same texture period, the homogenization value G(I,v) reaches the maximum value, that is, the texture period of the pre-processed fabric image can be determined by calculating the maximum value of the homogenization value G(I,v). When the vector v is an integer multiple of the texture period of the pre-processed fabric image, the homogenization value G(I,v) can also reach the maximum value. Therefore, it is necessary to select a minimum displacement vector v from multiple displacement vectors v that meet the requirements, that is The texture period is calculated according to the minimum displacement vector v. Optionally, by defining different displacement vectors v, a minimum displacement vector v is determined in the horizontal and vertical directions respectively, and the texture period in the horizontal and vertical directions is obtained. The grid size for dividing the pre-processed fabric image is determined based on the texture period.

[0109] S2203, gridding the pre-processed fabric image based on the grid size to obtain a plurality of gridded fabric images.

[0110] For the same pre-processed fabric image, several grids of different sizes can be determined according to different texture periods. According to the determined grid sizes, the pre-processed fabric image is gridded to obtain several gridded fabric images.

[0111] In this embodiment, the grayscale value difference of a pixel pair is determined according to the relative position relationship of any pixel pair in the preprocessed fabric image, the probability distribution of the grayscale value difference is statistically calculated, and the homogenization parameter of the pixel pair is determined according to the statistical result of the probability distribution to measure the fabric texture period, thereby improving the measurement efficiency and measurement accuracy of the texture period, thereby accurately gridding the preprocessed fabric.

[0112] In one embodiment, extracting the grid texture features of the gridded fabric image by using the redundant gray-level co-occurrence matrix in step S220 may include the following steps:

[0113] S2204, performing multi-scale decomposition on each gridded fabric image by using a pre-established generalized Gaussian filter to obtain a plurality of redundant images of different scales corresponding to the gridded fabric image.

[0114] Since fabric defects vary in size, in order to accurately detect fabric defects of varying sizes, the present technical solution performs multi-scale decomposition on the gridded fabric to obtain multiple redundant images of different scales. For example, generally speaking, the scale of the gridded fabric image is 256*256, and the present embodiment extracts each pixel of the gridded fabric image at intervals of a preset number of pixels to obtain redundant images of various scales such as 126*126, 64*64, etc.

[0115] In one embodiment, each gridded fabric image is decomposed at multiple scales by a pre-established generalized Gaussian filter to obtain multiple redundant images of different scales corresponding to the gridded fabric image. Optionally, a generalized Gaussian filter is pre-established. In one embodiment, a generalized Gaussian filter is established by using a Gaussian filter as a filter kernel of the generalized Gaussian filter, and its expression is as follows:

[0116]

[0117]

[0118]

[0119] Among them, (x, y) represents the coordinates of the point relative to the template center (0, 0), p(x, y) represents the gray value weight at the pixel point (x, y) in the generalized Gaussian filter template that is away from the template center (0, 0), and Γ(.) represents the gamma function. The parameters σ and β jointly control the shape of the generalized Gaussian filter model. The regulating effect of σ on the generalized Gaussian filter model is consistent with the standard Gaussian model. By selecting different β parameter values, different generalized Gaussian filter models are obtained. These generalized Gaussian filter models are used as low-pass filter kernel functions to perform image filtering in the image decomposition process, thereby performing multi-scale decomposition of the gridded fabric image and obtaining multiple redundant images of different scales.

[0120] See also Figure 4 and Figure 5 , Figure 4 is a decomposition principle diagram of a gridded fabric image in one embodiment, Figure 5 yes Figure 4 Corresponding image decomposition example reference figure. In one embodiment, the process of multi-scale decomposition of the gridded fabric image using a generalized Gaussian low-pass filter with Gaussian properties can be as follows: first, the first-level decomposition original image is low-pass filtered by a generalized Gaussian low-pass filter to obtain a first-level low-pass image L1, and then the residual between the original image and the low-pass image is used as its high-frequency part H1; then, the second-level original image is filtered by a generalized Gaussian low-pass filter after parameter adjustment to obtain a low-pass image L2, and then the residual between the low-pass image L1 and the low-pass image L2 is used as the high-frequency part H2 of the second-level decomposition; finally, the third level uses the same method to obtain low-pass images L3 and H3. Through the above operations, the generation of redundant images is completed.

[0121] S2205 , generating gray-level co-occurrence matrices corresponding to each redundant image, and obtaining a redundant gray-level co-occurrence matrix of the gridded fabric image.

[0122] The gray-level co-occurrence matrix is ​​a statistical method for describing the texture characteristics of an image by counting the specific gray-level value combinations of pixel pairs with specific relative position relationships in the image. The size of the gray-level co-occurrence matrix is ​​determined by the order of the gray-level values ​​in the image. Usually, an L y ×L x An eight-bit grayscale image has 256 levels, so the corresponding gray-level co-occurrence matrix size is 256×256. Figure 6 As shown, Figure 6 This is a schematic diagram of the positional relationship between two pixels in a pixel pair in an embodiment. First, a pixel is selected as a reference point. The positional relationship between the other pixel and the reference point is (θ, d), where θ represents the direction of the vector formed by the other pixel and the reference point. The size of θ can be selected from {0°, 45°, 90°, 135°}, and d represents the number of pixels between the two points.

[0123] If we use an ordered pair of real numbers (m,n), (m,n=0,1,2,...,255) to represent the grayscale values ​​of two points, let the coordinates of the reference point be (x0,y0) and the coordinates of the other pixel be (x1,y1), then the statistical result N θ,d (m,n) can be expressed as the following formula.

[0124] N 0°,d (m, n)=#{((x0, y0), (x1, y1))∈(L y ×L x)×(L y ×L x )|

[0125] y0-y1=0, |x0-x1|=d,

[0126] I(x0, y0)=m, I(x1, y1)=n}

[0127] N 45°,d (m, n)=#{((x0, y0), (x1, y1))∈(L y ×L x )×(L y ×L x )|

[0128] (y0-y1=d, |x0-x1|=-d)or (y0-y1=-d, |x0-x1|=d),

[0129] I(x0, y0)=m, I(x1, y1)=n}

[0130] N 90°,d (m, n)=#{((x0, y0), (x1, y1))∈(L y ×L x )×(L y ×L x )|

[0131] |y0-y1|=d, x0-x1=0,

[0132] I(x0, y0)=m, I(x1, y1)=n}

[0133] N 135°,d (m, n)=#{((x0, y0), (x1, y1))∈(L y ×L x )×(L y ×L x )|

[0134] (y0-y1=-d, |x0-x1|=-d)or (y0-y1=d, |x0-x1|=d),

[0135] I( x0 , y0)=m, I(x1,y1)=n}

[0136] The number of times the gray value combination (m, n) of the pixel point pair with direction θ and distance d appears in the entire image is N. θ,d (m, n), the number of times all combinations of direction θ and distance d appear is N θ,d , then you can use P θ,d(m, n) represents the probability of the combination appearing in direction θ and distance d:

[0137]

[0138] Gray-level co-occurrence matrix P θ,d It can be expressed as:

[0139]

[0140] S2206. Obtain corresponding feature quantities according to the redundant gray-level co-occurrence matrix to obtain grid texture features of the gridded fabric image.

[0141] In this embodiment, the feature quantity is obtained by performing corresponding formula calculation based on the redundant gray-level co-occurrence matrix to obtain different feature parameters, and these feature parameters are used to characterize different attributes of the grid texture feature.

[0142] In one embodiment, the step S2206 of obtaining corresponding feature quantities according to the redundant gray-level co-occurrence matrix to obtain the grid texture features of the gridded fabric image may include the following steps:

[0143] S401. Calculate feature parameters of the redundant image based on the redundant gray-level co-occurrence matrix, where the feature parameters include angular second-order moment, contrast, correlation, inverse difference moment, and entropy.

[0144] Feature calculation based on gray-level co-occurrence matrix:

[0145] Angular second moment (ASM):

[0146]

[0147] Contrast:

[0148]

[0149] Correlation:

[0150]

[0151] Where μ x , μ y , σ x , σ y The calculation is as follows:

[0152]

[0153]

[0154]

[0155]

[0156] Inverse difference moment (IDM):

[0157]

[0158] Entropy:

[0159]

[0160] S402: extracting features of the gridded fabric image according to the feature parameters to obtain grid texture features corresponding to the gridded fabric image.

[0161] The feature parameters corresponding to multiple redundant images, that is, the first-level low-pass redundant image obtained after decomposition, and its corresponding grid texture features can be expressed as:

[0162] F L1 ={Asm L1 ,Con L1 ,Cor L1 ,Idm L1 ,Ent L1}

[0163] Among them, Asm L1 Con represents the angular second-order moment value of the primary low-pass redundant image. L1 Represents the contrast value of the primary low-pass redundant image, Cor L1 Indicates the correlation value of the first-level low-pass redundant image, Idm L1 Represents the inverse moment value of the first-level low-pass redundant image, Ent L1 Represents the entropy value of the first-level low-pass redundant image.

[0164] For the first-level high-pass redundant image after decomposition, its corresponding grid texture feature can be expressed as:

[0165] F H1 ={Asm H1 ,Con H1 ,Cor H1 ,Idm H1 ,Ent H1}

[0166] Among them, Asm H1 Con represents the angular second-order moment value of the first-level high-pass redundant image. H1 Indicates the contrast value of the primary high-pass redundant image, Cor H1 Indicates the correlation value of the first-level high-pass redundant image, Idm H1 Represents the inverse moment value of the first-level high-pass redundant image, Ent H1Represents the entropy value of the first-level high-pass redundant image.

[0167] By analogy, the eigenvalues ​​corresponding to each redundant image are obtained. Since the gridded fabric image is decomposed into multiple different redundant images, the grid texture features corresponding to the gridded fabric image can be obtained according to the eigenvalues ​​of each different redundant image.

[0168] The grid texture image is determined to be a defective image or a normal image (i.e., a defect-free image) by various characteristic parameters in the grid texture image. For example, Asm can be used to describe the uniformity of the grayscale distribution in the image and the coarseness of the texture. If the value of each element in the grayscale co-occurrence matrix does not fluctuate much, the Asm value will be relatively small, otherwise it will be relatively large. If the Asm value is large, the texture is relatively coarse, otherwise it is relatively fine. Cor can be used to describe the correlation of matrix elements in the row or column direction. If the image has texture in a certain direction, the Cor value of the matrix in that direction will be relatively large. When the texture grooves are deep, the larger the Con value, the clearer the image is. Conversely, when the texture grooves are shallow, the smaller the Con value, the more blurred the image is. The larger the Ent entropy value, the more dispersed the element values ​​in the matrix are. If there is no texture in the image, the Ent entropy value is small. If the texture in the image is complex, the Ent entropy value is large.

[0169] Based on this, there are obvious differences in the eigenvalues ​​corresponding to the characteristic parameters of defective images and normal images: the Asm value shows that the defective image is smaller than the normal image; the Con value shows that the defective image is higher than the normal image as a whole and the fluctuation is more obvious; the Cor value shows that the correlation of the defective image is higher than that of the normal image, and the two are clearly distinguished; the Idm value shows that the normal image is higher overall and has a smaller overall fluctuation, and this characteristic is related to the contrast; the Ent value shows that the defective image has a larger entropy value because the defects in the defective image destroy the original regularity of the fabric image and the image becomes disordered.

[0170] The above examples are only used to assist in explaining the technical solution of the present disclosure, and the illustrated contents and specific processes involved do not constitute a limitation on the usage scenarios of the technical solution of the present disclosure.

[0171] The following is a detailed description of the relevant embodiments of the device for detecting fabric defects.

[0172] Figure 7 Schematic diagram of the structure of a fabric defect detection device in an embodiment, which can be executed on a terminal.

[0173] like Figure 7 As shown, the fabric defect detection device 200 may include: a fabric image acquisition module 210, a texture feature extraction module 220, a defect feature determination module 230 and a defect position marking module 240;

[0174] The fabric image acquisition module 210 is used to acquire the fabric image to be detected acquired by a camera device, and pre-process the fabric image to be detected to obtain a pre-processed fabric image;

[0175] The texture feature extraction module 220 is used to grid the pre-processed fabric image according to the texture period of the pre-processed fabric image to obtain a plurality of gridded fabric images, and to extract the grid texture features of each gridded fabric image using a redundant gray level co-occurrence matrix;

[0176] A defect feature determination module 230 is used to classify the mesh texture feature through a pre-trained fabric defect detection neural network, and determine whether the mesh texture feature is a defect feature according to the classification result;

[0177] The defect position marking module 240 is used to mark the defect position in the grid texture feature corresponding to the fabric image to be detected if it is determined that the grid texture feature is a defect feature.

[0178] The fabric defect detection device provided by the present application obtains the fabric image to be detected and preprocesses it through the fabric image acquisition module 210, the texture feature extraction module 220 grids the preprocessed fabric image to be detected according to the texture period, and extracts the grid texture features using the redundant grayscale co-occurrence matrix, the defect feature determination module 230 classifies the grid texture features through a pre-trained fabric defect detection neural network to determine whether the grid texture features are defect features, and the defect position marking module 240 marks the defect position in the grid texture features corresponding to the fabric image to be detected, thereby improving the detection accuracy and efficiency of fabric defects.

[0179] In one of the embodiments, the fabric defect detection device also includes: a neural network construction module, including a sample image acquisition unit and a neural network training unit; wherein the sample image acquisition unit is used to acquire a pre-labeled fabric sample image; the fabric sample image includes a defective fabric sample image and a flawless fabric sample image; the neural network training unit is used to extract sample fabric texture features of the fabric sample image, input the sample fabric texture features into a classifier for training, and construct a fabric defect detection neural network.

[0180] In one embodiment, the fabric image acquisition module 210 includes: a weight adjustment unit, a gray value calculation unit and a pre-processed fabric image acquisition unit; wherein the weight adjustment unit is used to adjust the gray value weights corresponding to the neighborhood pixels according to the proximity of each pixel in the fabric image to be detected and the neighborhood pixels around the pixel in the geometric space or the similarity in the gray space; the gray value calculation unit is used to perform weighted averaging of the gray values ​​of each neighborhood pixel according to the gray value weights to obtain the target gray value of the pixel; the pre-processed fabric image acquisition unit is used to obtain the pre-processed fabric image according to the target gray value of each pixel in the fabric image to be detected.

[0181] In one embodiment, the texture feature extraction module 220 includes: a homogenization parameter determination unit, a grid size determination unit and a gridded fabric image acquisition unit; wherein the homogenization parameter determination unit is used to determine the homogenization parameter of the preprocessed fabric image according to the gray value difference between each pixel pair in the preprocessed fabric image; the grid size determination unit is used to measure the texture period of the preprocessed fabric image according to the homogenization parameter and determine the grid size for gridding the preprocessed fabric image; the gridded fabric image acquisition unit is used to grid the preprocessed fabric image based on the grid size to obtain a plurality of gridded fabric images.

[0182] In one embodiment, the homogenization parameter determination unit includes: a grayscale value difference determination subunit and a homogenization parameter determination subunit; wherein the grayscale value difference determination subunit is used to determine the relative position relationship of each pixel pair in the preprocessed fabric image, and determine the grayscale value difference of the pixel pair based on the relative position relationship; the homogenization parameter determination subunit is used to calculate the statistical probability that the grayscale value difference is a preset difference by statistically analyzing the probability distribution of each different grayscale value difference, and determine the homogenization parameter of the preprocessed fabric image according to the probability distribution result.

[0183] In one embodiment, the texture feature extraction module 220 includes: a redundant image generation unit, a redundant grayscale co-occurrence matrix acquisition unit and a grid texture feature acquisition unit; wherein the redundant image generation unit is used to perform multi-scale decomposition on each gridded fabric image through a pre-established generalized Gaussian filter to obtain a plurality of redundant images of different scales corresponding to the gridded fabric image; the redundant grayscale co-occurrence matrix acquisition unit is used to generate a grayscale co-occurrence matrix corresponding to each redundant image to obtain a redundant grayscale co-occurrence matrix of the gridded fabric image; the grid texture feature acquisition unit is used to obtain corresponding feature quantities according to the redundant grayscale co-occurrence matrix to obtain grid texture features of the gridded fabric image.

[0184] In one of the embodiments, the grid texture feature obtaining unit includes: a feature parameter calculation subunit and a grid texture feature obtaining subunit; wherein the feature parameter calculation subunit is used to calculate the feature parameters of the redundant image based on the redundant grayscale co-occurrence matrix, and the feature parameters include angular second-order moment, contrast, correlation, inverse moment and entropy; the grid texture feature obtaining subunit is used to extract features of the gridded fabric image according to the feature parameters to obtain the grid texture features corresponding to the gridded fabric image.

[0185] The fabric defect detection device of this embodiment can execute the fabric defect detection method shown in the previous embodiment of the present application, and its implementation principle is similar, which will not be repeated here.

[0186] Each module in the above-mentioned fabric defect detection device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0187] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure is shown in FIG. Figure 8 As shown. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with other external devices through a network connection. When the computer program is executed by the processor, a method for detecting fabric defects is implemented.

[0188] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0189] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0190] Acquire a fabric image to be detected acquired by a camera device, and pre-process the fabric image to be detected to obtain a pre-processed fabric image;

[0191] The pre-processed fabric image is meshed according to the texture period of the pre-processed fabric image to obtain a plurality of meshed fabric images, and the mesh texture features of each meshed fabric image are extracted using a redundant gray-level co-occurrence matrix;

[0192] The mesh texture features are classified by using a pre-trained fabric defect detection neural network, and whether the mesh texture features are defect features is determined according to the classification results;

[0193] If the grid texture feature is determined to be a defect feature, the defect position is marked in the grid texture feature corresponding to the fabric image to be detected.

[0194] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0195] A fabric sample image that has been annotated in advance is obtained; the fabric sample image includes a defective fabric sample image and a flawless fabric sample image; sample fabric texture features of the fabric sample image are extracted, the sample fabric texture features are input into a classifier for training, and a fabric defect detection neural network is constructed.

[0196] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0197] According to the proximity of each pixel point in the fabric image to be detected and the neighboring pixel points around the pixel point in the geometric space or the similarity in the grayscale space, the grayscale value weight corresponding to the neighboring pixel point is adjusted; the grayscale value of each neighboring pixel point is weighted averaged according to the grayscale value weight to obtain the target grayscale value of the pixel point; according to the target grayscale value of each pixel point in the fabric image to be detected, a preprocessed fabric image is obtained.

[0198] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0199] The homogenization parameter of the pre-processed fabric image is determined according to the gray value difference between each pixel pair in the pre-processed fabric image; the texture period of the pre-processed fabric image is measured according to the homogenization parameter to determine the grid size for gridding the pre-processed fabric image; the pre-processed fabric image is gridded based on the grid size to obtain a plurality of gridded fabric images.

[0200] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0201] The relative position relationship of each pixel pair in the pre-processed fabric image is determined, and the gray value difference of the pixel pair is determined based on the relative position relationship; the probability distribution of the gray value difference is statistically calculated, and the homogenization parameter of the pre-processed fabric image is determined according to the statistical result of the probability distribution.

[0202] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0203] Through the pre-established generalized Gaussian filter, each gridded fabric image is decomposed at multiple scales to obtain a plurality of redundant images of different scales corresponding to the gridded fabric image; the grayscale co-occurrence matrix corresponding to each redundant image is generated to obtain the redundant grayscale co-occurrence matrix of the gridded fabric image; the corresponding feature quantity is obtained according to the redundant grayscale co-occurrence matrix to obtain the grid texture feature of the gridded fabric image.

[0204] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0205] The feature parameters of the redundant image are calculated based on the redundant gray-level co-occurrence matrix. The feature parameters include angular second-order moment, contrast, correlation, inverse difference moment and entropy. The gridded fabric image is feature extracted according to the feature parameters to obtain the grid texture features corresponding to the gridded fabric image.

[0206] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0207] Acquire a fabric image to be detected acquired by a camera device, and pre-process the fabric image to be detected to obtain a pre-processed fabric image;

[0208] The pre-processed fabric image is meshed according to the texture period of the pre-processed fabric image to obtain a plurality of meshed fabric images, and the mesh texture features of each meshed fabric image are extracted using a redundant gray-level co-occurrence matrix;

[0209] The mesh texture features are classified by using a pre-trained fabric defect detection neural network, and whether the mesh texture features are defect features is determined according to the classification results;

[0210] If the grid texture feature is determined to be a defect feature, the defect position is marked in the grid texture feature corresponding to the fabric image to be detected.

[0211] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0212] A fabric sample image that has been annotated in advance is obtained; the fabric sample image includes a defective fabric sample image and a flawless fabric sample image; sample fabric texture features of the fabric sample image are extracted, the sample fabric texture features are input into a classifier for training, and a fabric defect detection neural network is constructed.

[0213] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0214] According to the proximity of each pixel point in the fabric image to be detected and the neighboring pixel points around the pixel point in the geometric space or the similarity in the grayscale space, the grayscale value weight corresponding to the neighboring pixel point is adjusted; the grayscale value of each neighboring pixel point is weighted averaged according to the grayscale value weight to obtain the target grayscale value of the pixel point; according to the target grayscale value of each pixel point in the fabric image to be detected, a preprocessed fabric image is obtained.

[0215] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0216] The homogenization parameter of the pre-processed fabric image is determined according to the gray value difference between each pixel pair in the pre-processed fabric image; the texture period of the pre-processed fabric image is measured according to the homogenization parameter to determine the grid size for gridding the pre-processed fabric image; the pre-processed fabric image is gridded based on the grid size to obtain a plurality of gridded fabric images.

[0217] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0218] The relative position relationship of each pixel pair in the pre-processed fabric image is determined, and the gray value difference of the pixel pair is determined based on the relative position relationship; the probability distribution of the gray value difference is statistically calculated, and the homogenization parameter of the pre-processed fabric image is determined according to the statistical result of the probability distribution.

[0219] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0220] Through the pre-established generalized Gaussian filter, each gridded fabric image is decomposed at multiple scales to obtain a plurality of redundant images of different scales corresponding to the gridded fabric image; the grayscale co-occurrence matrix corresponding to each redundant image is generated to obtain the redundant grayscale co-occurrence matrix of the gridded fabric image; the corresponding feature quantity is obtained according to the redundant grayscale co-occurrence matrix to obtain the grid texture feature of the gridded fabric image.

[0221] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0222] The feature parameters of the redundant image are calculated based on the redundant gray-level co-occurrence matrix. The feature parameters include angular second-order moment, contrast, correlation, inverse difference moment and entropy. The gridded fabric image is feature extracted according to the feature parameters to obtain the grid texture features corresponding to the gridded fabric image.

[0223] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0224] It should be understood that, although the various steps in the above-mentioned flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned figure may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0225] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0226] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for detecting fabric defects, characterized in that: The method comprises: Acquire a fabric image to be detected acquired by a camera device, and preprocess the fabric image to be detected to obtain a preprocessed fabric image; Determine the relative position relationship of each pixel pair in the preprocessed fabric image, and determine the grayscale value difference of the pixel pair based on the relative position relationship, wherein the grayscale value difference is a=I(p)-I(p+v), where I(p) is the grayscale value at the pixel point p, and I(p+v) is the grayscale value of the displacement vector of the pixel point p; The probability distribution of the gray value difference is calculated, and the homogenization parameter of the pre-processed fabric image is determined according to the statistical result of the probability distribution, wherein the homogenization parameter is Where v represents the displacement vector of the pixel pair, a represents the gray value difference of the pixel pair, and P v (a) represents the frequency distribution parameter of the pixel pair, wherein the frequency distribution parameter is obtained by normalizing the gray value difference distribution histogram of the gray value difference a and the displacement vector v; The texture period of the pre-processed fabric image is measured according to the homogenization parameter, and the texture period is measured according to the minimum displacement vector v * Determine that the minimum displacement vector determining a grid size for gridding the preprocessed fabric image; Gridding the preprocessed fabric image based on the grid size to obtain a plurality of gridded fabric images, and extracting grid texture features of each of the gridded fabric images using a redundant gray-level co-occurrence matrix; Classifying the grid texture feature by using a pre-trained fabric defect detection neural network, and determining whether the grid texture feature is a defect feature according to the classification result; If it is determined that the grid texture feature is a defect feature, the defect position is marked in the grid texture feature corresponding to the fabric image to be detected.

2. The method according to claim 1, characterized in that Also includes: Acquire a fabric sample image that is pre-marked; the fabric sample image includes a fabric sample image with defects and a fabric sample image without defects; Sample fabric texture features are extracted from the fabric sample image, and the sample fabric texture features are input into a classifier for training to construct a fabric defect detection neural network.

3. The method according to claim 1, characterized in that: The step of preprocessing the fabric image to be detected to obtain a preprocessed fabric image comprises: According to the proximity of each pixel point in the fabric image to be detected and the neighboring pixel points around the pixel point in the geometric space or the similarity in the gray space, adjusting the gray value weight corresponding to the neighboring pixel point; Performing weighted averaging of the grayscale values ​​of each of the neighborhood pixels according to the grayscale value weights to obtain a target grayscale value of the pixel; A preprocessed fabric image is obtained according to the target grayscale value of each pixel in the fabric image to be detected.

4. The method according to claim 1, characterized in that: The step of extracting the grid texture features of each of the gridded fabric images by using the redundant gray-level co-occurrence matrix comprises: Performing multi-scale decomposition on each of the gridded fabric images by using a pre-established generalized Gaussian filter to obtain a plurality of redundant images of different scales corresponding to the gridded fabric image; Generate a gray level co-occurrence matrix corresponding to each of the redundant images to obtain a redundant gray level co-occurrence matrix of the gridded fabric image; Corresponding feature quantities are obtained according to the redundant gray-level co-occurrence matrix to obtain grid texture features of the gridded fabric image.

5. The method according to claim 4, characterized in that The step of obtaining corresponding feature quantities according to the redundant gray-level co-occurrence matrix to obtain the grid texture features of the gridded fabric image comprises: Calculate characteristic parameters of the redundant image based on the redundant gray-level co-occurrence matrix, wherein the characteristic parameters include angular second-order moment, contrast, correlation, inverse difference moment and entropy; Feature extraction is performed on the gridded fabric image according to the feature parameters to obtain grid texture features corresponding to the gridded fabric image.

6. A fabric defect detection device, characterized in that: The device comprises: A fabric image acquisition module is used to acquire the fabric image to be detected acquired by a camera device, and preprocess the fabric image to be detected to obtain a preprocessed fabric image; The texture feature extraction module determines the relative position relationship of each pixel pair in the pre-processed fabric image, determines the gray value difference of the pixel pair based on the relative position relationship, and the gray value difference is a=I(p)-I(p+v), where I(p) is the gray value at the pixel point p, and I(p+v) is the gray value of the displacement vector of the pixel point p; calculates the probability distribution of the gray value difference, and determines the homogenization parameter of the pre-processed fabric image according to the statistical result of the probability distribution, and the homogenization parameter is Where v represents the displacement vector of the pixel pair, a represents the gray value difference of the pixel pair, and P v (a) represents the frequency distribution parameter of the pixel pair, wherein the frequency distribution parameter is obtained by normalizing the gray value difference a and the gray value difference distribution histogram of the displacement vector v; the texture period of the pre-processed fabric image is measured according to the homogenization parameter, and the texture period is measured according to the minimum displacement vector v * Determine that the minimum displacement vector Determining a grid size for gridding the pre-processed fabric image, gridding the pre-processed fabric image based on the grid size to obtain a plurality of gridded fabric images, and extracting grid texture features of each of the gridded fabric images using a redundant gray-level co-occurrence matrix; A defect feature determination module is used to classify the grid texture feature through a pre-trained fabric defect detection neural network, and determine whether the grid texture feature is a defect feature according to the classification result; The defect position marking module is used to mark the defect position in the grid texture feature corresponding to the fabric image to be detected if the grid texture feature is determined to be a defect feature.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.