Textile fabric defect detection method
By constructing YOLO and U-Net models to extract edge image data of textiles and combining texture gradient analysis to calculate the degree of stretching, the problem of decreased detection accuracy caused by deformation of printed patterns during stretching was solved, and high-precision textile defect detection was achieved.
Patent Information
- Application Number
- CN202511397548.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-09-28
AI Technical Summary
Existing methods for detecting defects in textiles fail to effectively account for the deformation caused by the stretching of printed patterns, resulting in decreased detection accuracy.
By constructing a target detection model based on the YOLO algorithm and a U-Net model, edge image data of the printed and dyed patterns are extracted. The degree of stretching is calculated by combining textile texture gradient analysis and compared with standard printed and dyed patterns to determine the qualification of the printed and dyed image data.
It improves the accuracy of textile defect detection, can accurately locate defect positions, reduce the impact of color changes and ambient light changes, provides tensile percentage values in all directions, and supports quality control and classification.
Smart Images

Figure CN120876494A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of textile defect detection, specifically a method for detecting textile defects. Background Technology
[0002] Dyeing and printing is a general term encompassing both "dyeing" and "printing." It refers to the process of coloring textiles (fibers, yarns, fabrics) using physical, chemical, or combined physical-chemical methods to achieve uniform and durable colors. The printed patterns on textiles are a crucial element in ensuring product quality, directly impacting brand image, customer satisfaction, and production costs.
[0003] Common methods for detecting defects in printed patterns rely solely on the similarity between the target printed pattern and the standard printed pattern, or use deep learning models to analyze whether each pixel belongs to the printed pattern. These methods ignore the deformation of the printed pattern caused by internal stretching, which affects the detection accuracy. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention provides a method for detecting defects in textiles, which solves the technical problems mentioned in the background section.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] A method for detecting defects in textiles includes the following steps:
[0007] S1. Acquire the first image data of the textile;
[0008] S2. Extract the second image data containing the printing and dyeing pattern from the first image data;
[0009] S3. Construct printing and dyeing image data and edge image data based on the second image data;
[0010] S4. Calculate the textile in each stretching direction based on the edge image data. stretching value ;
[0011] S5. Obtain the standard printing and dyeing pattern, compare the differences between the standard printing and dyeing pattern and the printing and dyeing image data, and combine the stretching value. Determine whether the printing and dyeing image data is qualified;
[0012] If so, then the process ends;
[0013] If not, feedback is sent to the control unit to mark the textile.
[0014] Furthermore, step S2 specifically includes the following steps:
[0015] S21. Obtain first historical image data of several textiles, and use the first historical image data as the first training sample.
[0016] S22. Mark the position of the printing pattern for each training sample to obtain the first sample label of the first training sample;
[0017] S23. Train the target detection model using the first training sample and the first sample label to obtain the first target model;
[0018] S24. Input the first image data into the first target model to generate the second image data.
[0019] Furthermore, in step S23, the first target model is constructed based on the YOLO algorithm.
[0020] Furthermore, step S3 specifically includes the following steps:
[0021] S31. Obtain several second historical image data;
[0022] S32. Preprocess the second historical image data to generate the third historical image data;
[0023] S33. Manually outline the contour of the printing pattern in each third historical image data, and generate the first mask image based on it;
[0024] S34. Using the third historical image data as the second training sample and the first mask image as the second sample label, train the U-Net model to generate the second target model;
[0025] S35. Preprocess the second image data and input it into the second target model to generate the second mask image;
[0026] S36. Create a first all-zero image and a second all-zero image. The size of the first all-zero image and the second all-zero image are the same as the data of the second image. The pixel value of each pixel in the first all-zero image and the second all-zero image is 0.
[0027] S37. Extract all white pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the first all-zero image to generate dyed image data; extract all black pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the second all-zero image to generate edge image data.
[0028] Furthermore, step S4 specifically includes the following steps:
[0029] S41. Using the top left corner of the second image data as the origin 0, construct a planar coordinate system with the top and left borders of the grayscale edge image as the x and y axes respectively, and convert the edge image data into a grayscale edge image.
[0030] S42. Calculate the gradient parameter set for each pixel in the grayscale edge image. The gradient parameter set includes the gradient magnitude. and unsigned gradient direction ;
[0031] S43. Divide the grayscale edge image into several cell units of size C×C, and calculate the gradient histogram of each cell unit.
[0032] S44. In a grayscale edge image, set a sliding window with length M and width N, respectively. The step size of the sliding window is 1. The sliding window generates a block each time it slides. For the histogram vector of all cell units in each block... Connect them to generate a block feature vector. Its expression is:
[0033]
[0034] In the formula, This represents the transpose operation of a vector; Indicates the first Histogram vector of each cell unit;
[0035] S45. For each block feature vector Normalization is performed to obtain the normalized block feature vector. Its expression is:
[0036]
[0037] In the formula, express Euclidean length; Indicates the first smoothing term;
[0038] S46. Normalize all block feature vectors Connect them sequentially to generate a feature description vector for the grayscale edge image;
[0039] S47. Extract each stretching direction from the feature description vector. histogram vector mean And based on the calculated stretch value .
[0040] Furthermore, step S42 specifically includes the following steps:
[0041] S421. Calculate the horizontal gradient of each pixel. vertical gradient of and The calculation formulas are as follows:
[0042]
[0043] In the formula, Represents a grayscale edge image;
[0044]
[0045] S422, Based on the horizontal gradient vertical gradient of and Calculate gradient magnitude The calculation formula is as follows:
[0046]
[0047] S423, Based on the horizontal gradient vertical gradient of and Calculate gradient direction The calculation formula is as follows:
[0048]
[0049] In the formula, express function;
[0050] S424, Gradient direction Switch to Range generates unsigned gradient directions Its expression is:
[0051]
[0052] In the formula, Represents pixels The orientation of the edge.
[0053] Furthermore, step S43 specifically includes the following steps:
[0054] S431. Divide the gradient histogram into B intervals, each interval The range is ,in ;
[0055] S432. For each pixel within any cell unit, find its unsigned gradient direction. The interval to which it belongs ;
[0056] S433, Based on the unsigned gradient direction Calculate the normalized weighting factor The calculation formula is as follows:
[0057]
[0058] In the formula, Indicates the corresponding interval The minimum value of the angle range it is responsible for;
[0059] S434, Based on the normalized weighting factor Calculate the pixel pair between two adjacent intervals. and interval histogram vector and The calculation formulas are as follows:
[0060]
[0061]
[0062] In the formula, and These represent the pixel pairs in the interval. and interval histogram vector and ;
[0063] S435. Repeat steps S432-S434 until the gradient histogram of each cell unit is obtained.
[0064] Further, in step S47, the stretching degree value The calculation formula is:
[0065]
[0066] In the formula, This represents the mean of the standard histogram vector; This indicates the second smoothing term.
[0067] Furthermore, step S5 specifically includes the following steps:
[0068] S51. Overlay the standard printing and dyeing pattern and printing and dyeing image data to obtain the overstretched area and the missing area.
[0069] S52. Construct a binary hyperextension map based on the hyperextension region and the missing region. and missing binary map And calculate the area of the overstretched region based on it. and the area of the missing region The calculation formulas are as follows:
[0070]
[0071]
[0072] In the formula, and These represent the width and height of the second image data, respectively.
[0073] S53. Constructing the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Their expressions are as follows:
[0074]
[0075]
[0076] In the formula, express The pixel coordinates; express The mean of the coordinates of all pixels; express The pixel coordinates; express The mean of the coordinates of all pixels;
[0077] S54. Based on the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Calculate the orientation angle of the overstretched region and the orientation angle of the missing area ;
[0078] S55, Based on the orientation angle of the overstretched area and the orientation angle of the missing area Extract the overstretch value separately and missing stretch value And calculate the overstretch exemption factor based on it. and missing exemption factors The calculation formulas are as follows:
[0079]
[0080]
[0081] In the formula, Indicates the proportionality coefficient; This represents the total number of pixels in a standard printed pattern.
[0082] S56. Based on the overextension exemption factor and missing exemption factors Calculate the effective overstretch area and effective missing area The calculation formulas are as follows:
[0083]
[0084]
[0085] In the formula, This represents the total number of pixels in the overextended region. Indicates the total number of pixels in the missing region;
[0086] S57. Preset the maximum permissible effective over-stretch area and the maximum permissible effective missing area, and determine the effective over-stretch area. Not exceeding the maximum permissible effective overstretch area and effective missing area Does the condition of not exceeding the maximum permissible valid missing area hold true?
[0087] If so, it means the printing and dyeing image data is qualified;
[0088] If not, it means the printing image data is unqualified.
[0089] Compared with the prior art, the present invention provides a method for detecting defects in textiles, which has the following beneficial effects:
[0090] 1. In this invention, when calculating the degree of stretching of textiles in each direction, since the texture of the textile is analyzed rather than the foreground pattern, it is not sensitive to interfering factors such as color changes, pattern content and minor stains. Moreover, compared with common detection methods, it provides accurate percentage values of stretching in each direction, rather than a simple pass or fail judgment, thus improving the calculation accuracy.
[0091] 2. In this invention, when judging whether the printing and dyeing image data is qualified, the deformation is calculated based on the texture gradient of the textile. Then, by comparing the printing and dyeing image data with the pattern content, the influence of factors such as uneven color and changes in ambient light can be reduced. In addition, the pixel-level location of the defect can be accurately located, which not only helps to judge whether the product is qualified, but also helps to distinguish the defect type, providing a more refined basis for quality control and classification. Attached Figure Description
[0092] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0093] Figure 1 This is a flowchart of a textile defect detection method according to the present invention. Detailed Implementation
[0094] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. This will allow for a full understanding of how the present application uses technical means to solve technical problems and achieve technical effects, and to facilitate its implementation.
[0095] Those skilled in the art will understand that all or part of the steps in the methods of the following embodiments can be implemented by a program instructing related hardware. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0096] Dyeing and printing is a general term encompassing both "dyeing" and "printing." It refers to the process of coloring textiles (fibers, yarns, fabrics) using physical, chemical, or combined physical-chemical methods to achieve uniform and durable colors. The dyeing and printing process is complex and prone to defects, commonly including: color difference, uneven coloring / spotting, color stains, missed prints, and inaccurate printing. After the dyeing and printing process is completed, these issues need to be inspected to ensure the textile meets the required standards. For more information, please refer to [link / reference needed]. Figure 1 As shown, this invention proposes a method for detecting defects in textiles, comprising the following steps:
[0097] S1. Acquire the first image data of the textile; specifically, use a high-definition camera to photograph the printing position of the textile. It can be set on the production line. When the textile printing and dyeing is completed, the high-definition camera will photograph the textile. In order to ensure that the complete printing and dyeing pattern and the surrounding textile texture information are captured, it is necessary to photograph the complete textile.
[0098] S2. Extract the second image data containing the printed pattern from the first image data; specifically, because textiles are relatively soft, they may experience non-linear stretching or shrinkage when photographed by a high-definition camera, causing common visual detection models to misjudge during detection. Therefore, in addition to detecting the printed pattern, it is also necessary to detect the surrounding texture. Thus, step S2 specifically includes the following steps:
[0099] S21. Acquire first historical image data of several textiles, and use the first historical image data as the first training sample; specifically, the first historical image data refers to the first image data of other textiles that were photographed in the past.
[0100] S22. Mark the position of the printing pattern for each training sample to obtain the first sample label for the first training sample. Specifically, manually mark boxes in the first historical image data to enclose the printing pattern and surrounding parts within them, so as to facilitate the analysis of the printing pattern and its surrounding texture later. It should be noted that the high-definition camera is set at a fixed height and fixed angle (preferably directly above the textile, with its lens pointing perpendicular to the plane where the textile is located), so the size of the first historical image data acquired each time is the same, and the size of the printing pattern marking is also basically the same, which can make the size of the second image data output by the first target model consistent.
[0101] S23. The target detection model is trained using the first training sample and the first sample label to obtain the first target model. Specifically, in step S23, the first target model is constructed based on the YOLO algorithm. In addition, the first target model can also be constructed based on other algorithms such as convolutional neural networks. It should be noted that both the YOLO algorithm and convolutional neural networks are common existing technologies, and their working principles will not be elaborated here.
[0102] S24. Input the first image data into the first target model to generate the second image data.
[0103] S3. Construct printing and dyeing image data and edge image data based on the second image data; specifically, step S3 includes the following steps:
[0104] S31. Obtain several second historical image data; specifically, the second historical image data represents the output result of the first historical image data after processing by the target model;
[0105] S32. Preprocess the second historical image data to generate the third historical image data; specifically, the preprocessing of the second historical image data includes: (1) changing the pixel values from Range normalization to (2) Scale the second historical image data to a fixed size (custom);
[0106] S33. Manually outline the contour of the printing pattern in each third historical image data, and generate a first mask image based on it; specifically, the first mask image is annotated at the pixel level using annotation tools (such as LabelMe, CVAT, EISeg); it should be noted that the first mask image is a black and white image of the same size as the third historical image data, in which the pixel value of the background is 0 (i.e., black), and the pixel value of the printing pattern is 1 (i.e., white).
[0107] S34. Using the third historical image data as the second training sample and the first mask image as the second sample label, train the U-Net model to generate the second target model; specifically, for each pixel, the second target model will output a value between... The value between 0.5 and 0.5 represents the probability that the pixel belongs to the printing pattern. If it is greater than or equal to 0.5, it means that the pixel belongs to the printing pattern; if it is less than 0.5, it means that the pixel does not belong to the printing pattern. It should be noted that the U-Net model is a common existing technology, which will not be elaborated here.
[0108] S35. Preprocess the second image data and input it into the second target model to generate the second mask image; specifically, the preprocessing of the second image data is the same as step S32.
[0109] S36. Create a first all-zero image and a second all-zero image. The size of the first all-zero image and the second all-zero image are the same as the data of the second image. The pixel value of each pixel in the first all-zero image and the second all-zero image is 0.
[0110] S37. Extract all white pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the first all-zero image to generate dyed image data; extract all black pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the second all-zero image to generate edge image data.
[0111] S4. Calculate the textile in each stretching direction based on the edge image data. stretching value Specifically, due to the characteristics of textiles, even when placed on a flat surface, they are likely to experience internal stretching, leading to deformation of the printed pattern. This can affect the detection results of the visual inspection model to some extent. Therefore, step S4 specifically includes the following steps:
[0112] S41. Using the top left corner of the second image data as the origin 0, construct a planar coordinate system with the top and left borders of the grayscale edge image as the x and y axes respectively, and convert the edge image data into a grayscale edge image.
[0113] S42. Calculate the gradient parameter set for each pixel in the grayscale edge image. The gradient parameter set includes the gradient magnitude. and unsigned gradient direction Specifically, step S42 includes the following steps:
[0114] S421. Calculate the horizontal gradient of each pixel. vertical gradient of and The calculation formulas are as follows:
[0115]
[0116] In the formula, Represents a grayscale edge image; specifically, This measure measures the rate of change of intensity of a pixel in the horizontal direction. A positive value indicates that the pixel changes from dark to light from left to right, and a negative value indicates that the pixel changes from light to dark. The larger the absolute value, the more likely there is a vertical edge at that location.
[0117]
[0118] Specifically, It is used to measure the rate of change of intensity of a pixel in its vertical direction; the larger the value, the more likely there is a horizontal edge at that location.
[0119] S422, Based on the horizontal gradient vertical gradient of and Calculate gradient magnitude The calculation formula is as follows:
[0120]
[0121] Specifically, Used to synthesize changes in both horizontal and vertical directions to represent the overall intensity or salience of the edge at that point; the larger the value, the more likely the point is to be part of an edge.
[0122] S423, Based on the horizontal gradient vertical gradient of and Calculate gradient direction The calculation formula is as follows:
[0123]
[0124] In the formula, express function;
[0125] S424, Gradient direction Switch to Range generates unsigned gradient directions Its expression is:
[0126]
[0127] In the formula, Represents pixels The orientation of the edge.
[0128] S43. Divide the grayscale edge image into several cell units of size C×C, and calculate the gradient histogram of each cell unit; specifically, step S43 includes the following steps:
[0129] S431. Divide the gradient histogram into B intervals, each interval The range is ,in It should be noted that the angular range covered by each interval is... ;
[0130] S432. For each pixel within any cell unit, find its unsigned gradient direction. The interval to which it belongs ;
[0131] S433, Based on the unsigned gradient direction Calculate the normalized weighting factor The calculation formula is as follows:
[0132]
[0133] In the formula, Indicates the corresponding interval The minimum value of the range of angles it is responsible for;
[0134] S434, Based on the normalized weighting factor Calculate the pixel pair between two adjacent intervals. and interval histogram vector and The calculation formulas are as follows:
[0135]
[0136]
[0137] In the formula, and These represent the pixel pairs in the interval. and interval histogram vector and It should be noted that if the interval If it is the last interval, then It is the first interval, forming a ring; Indicates an accumulation operation;
[0138] S435. Repeat steps S432-S434 until the gradient histogram of each cell unit is obtained.
[0139] S44. In a grayscale edge image, set a sliding window with length M and width N, respectively. The step size of the sliding window is 1. The sliding window generates a block each time it slides. For the histogram vector of all cell units in each block... Connect them to generate a block feature vector. Its expression is:
[0140]
[0141] In the formula, This represents the transpose operation of a vector; Indicates the first Histogram vector of each cell unit; ; This represents the sum of gradient magnitude contributions from all pixels whose gradient direction falls within the b-th interval in the i-th cell unit; it should be noted that M and N are both user-defined parameters.
[0142] S45. For each block feature vector Normalization is performed to obtain the normalized block feature vector. Its expression is:
[0143]
[0144] In the formula, express Euclidean length; This represents the first smoothing term; it should be noted that... It is an extremely small constant, which takes the value of in this invention. To prevent the normalization of block feature vectors The calculation formula is meaningless;
[0145] S46. Normalize all block feature vectors Connect them sequentially to generate a feature description vector for the grayscale edge image;
[0146] S47. Extract each stretching direction from the feature description vector. histogram vector mean And based on the calculated stretch value Specifically, in step S47, the stretching degree value... The calculation formula is:
[0147]
[0148] In the formula, This represents the mean of the standard histogram vector; This represents the second smoothing term; specifically, it involves using a large number of normal textiles without stretching or defects, and obtaining the stretching direction in each of their feature description vectors. The mean of the histogram vector, i.e. It should be noted that, It quantifies the degree of deformation of textile texture in each direction relative to its normal state; The closer it is to 0, the more normal the direction is; .
[0149] In this invention, when calculating the stretch of textiles in each direction, the analysis of the textile texture rather than the foreground pattern makes it insensitive to interfering factors such as color changes, pattern content, and minor stains. Compared to common testing methods, it provides accurate percentage stretch values in each direction, rather than a simple pass or fail judgment, thus improving calculation accuracy.
[0150] S5. Obtain the standard printing and dyeing pattern, compare the differences between the standard printing and dyeing pattern and the printing and dyeing image data, and combine the stretching value. Determine whether the printing and dyeing image data is qualified;
[0151] If so, then the process ends;
[0152] If not, feedback is sent to the control terminal to mark the textile; specifically, step S5 includes the following steps:
[0153] S51. Overlay the standard printing and dyeing pattern and the printing and dyeing image data to obtain the over-stretched area and the missing area. Specifically, a standard printing and dyeing pattern is pre-shot. Since the distance between the high-definition camera and the textile remains constant, the distance between any two pixels in the standard printing and dyeing pattern and the actual spatial point is equal. Therefore, the proportions of the printing and dyeing pattern in the standard printing and dyeing pattern and the actual printing and dyeing pattern are consistent, meaning their sizes are basically the same. In addition, the overlapping position with the most overlapping pixels is used as the overlapping position of the standard printing and dyeing pattern and the printing and dyeing image data to improve the accuracy of the overlap. It should be noted that the over-stretched area refers to the area of extra pixels in the printing and dyeing image data compared to the standard printing and dyeing pattern; the missing area refers to the area of missing pixels in the printing and dyeing image data compared to the standard printing and dyeing pattern.
[0154] S52. Construct a binary hyperextension map based on the hyperextension region and the missing region. and missing binary map And calculate the area of the overstretched region based on it. and the area of the missing region The calculation formulas are as follows:
[0155]
[0156]
[0157] In the formula, and These represent the width and height of the second image data, respectively; specifically, the planar coordinate system constructed in step S41 is used to determine the coordinate position of each pixel, wherein, in the coordinate... If the pixel belongs to the overextended region, then The value is 1 if it is set to 1, otherwise 0. (In coordinates...) If the pixel belongs to the missing region, then The value is 1 if it is positive and 0 otherwise.
[0158] S53. Constructing the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Their expressions are as follows:
[0159]
[0160]
[0161] In the formula, express The pixel coordinates; express The mean of the coordinates of all pixels; express The pixel coordinates; express The mean of the coordinates of all pixels;
[0162] S54. Based on the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Calculate the orientation angle of the overstretched region and the orientation angle of the missing area Specifically, the overstretched area faces the angle. The calculation formula is:
[0163]
[0164]
[0165] S55, Based on the orientation angle of the overstretched area and the orientation angle of the missing area Extract the overstretch value separately and missing stretch value And calculate the overstretch exemption factor based on it. and missing exemption factors The calculation formulas are as follows:
[0166]
[0167]
[0168] In the formula, Indicates the proportionality coefficient; This represents the total number of pixels in a standard printed pattern; in this invention, It is 0.8;
[0169] S56. Based on the overextension exemption factor and missing exemption factors Calculate the effective overstretch area and effective missing area The calculation formulas are as follows:
[0170]
[0171]
[0172] In the formula, This represents the total number of pixels in the overextended region. Indicates the total number of pixels in the missing region;
[0173] S57. Preset the maximum permissible effective over-stretch area and the maximum permissible effective missing area, and determine the effective over-stretch area. Not exceeding the maximum permissible effective overstretch area and effective missing area Does the condition of not exceeding the maximum permissible valid missing area hold true?
[0174] If so, it means the printing and dyeing image data is qualified;
[0175] If not, it means the printing image data is unqualified.
[0176] In this invention, when judging whether the dyeing and printing image data is qualified, the deformation is calculated based on the texture gradient of the textile. Then, by comparing the dyeing and printing image data with the pattern content, the influence of factors such as uneven color and changes in ambient light can be reduced. In addition, the pixel-level location of the defect can be accurately located, which not only helps to judge whether the product is qualified, but also helps to distinguish the defect type, providing a more refined basis for quality control and classification.
[0177] The above embodiments provide a detailed description of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for detecting defects in textiles, characterized in that, Includes the following steps: S1. Acquire the first image data of the textile; S2. Extract the second image data containing the printing and dyeing pattern from the first image data; S3. Construct printing and dyeing image data and edge image data based on the second image data; S4. Calculate the textile in each stretching direction based on the edge image data. stretching value ; S5. Obtain the standard printing and dyeing pattern, compare the differences between the standard printing and dyeing pattern and the printing and dyeing image data, and combine the stretching value. Determine whether the printing and dyeing image data is qualified; If so, then the process ends; If not, feedback is sent to the control unit to mark the textile.
2. The textile defect detection method according to claim 1, characterized in that, Step S2 specifically includes the following steps: S21. Obtain first historical image data of several textiles, and use the first historical image data as the first training sample. S22. Mark the position of the printing pattern for each training sample to obtain the first sample label of the first training sample; S23. Train the target detection model using the first training sample and the first sample label to obtain the first target model; S24. Input the first image data into the first target model to generate the second image data.
3. The textile defect detection method according to claim 2, characterized in that, In step S23, the first target model is constructed based on the YOLO algorithm.
4. The textile defect detection method according to claim 1, characterized in that, Step S3 specifically includes the following steps: S31. Obtain several second historical image data; S32. Preprocess the second historical image data to generate the third historical image data; S33. Manually outline the contour of the printing pattern in each third historical image data, and generate the first mask image based on it; S34. Using the third historical image data as the second training sample and the first mask image as the second sample label, train the U-Net model to generate the second target model; S35. Preprocess the second image data and input it into the second target model to generate the second mask image; S36. Create a first all-zero image and a second all-zero image. The size of the first all-zero image and the second all-zero image are the same as the data of the second image. The pixel value of each pixel in the first all-zero image and the second all-zero image is 0. S37. Extract all white pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the first all-zero image to generate dyed image data; extract all black pixel positions in the second mask image, and then copy the corresponding pixel values in the second image data to the same position in the second all-zero image to generate edge image data.
5. The textile defect detection method according to claim 1, characterized in that, Step S4 specifically includes the following steps: S41. Using the top left corner of the second image data as the origin 0, construct a planar coordinate system with the top and left borders of the grayscale edge image as the x and y axes respectively, and convert the edge image data into a grayscale edge image. S42. Calculate the gradient parameter set for each pixel in the grayscale edge image. The gradient parameter set includes the gradient magnitude. and unsigned gradient direction ; S43. Divide the grayscale edge image into several cell units of size C×C, and calculate the gradient histogram of each cell unit. S44. In a grayscale edge image, set a sliding window with length M and width N, respectively. The step size of the sliding window is 1. The sliding window generates a block each time it slides. For the histogram vector of all cell units in each block... Connect them to generate a block feature vector. Its expression is: In the formula, This represents the transpose operation of a vector; Indicates the first Histogram vector of each cell unit; S45. For each block feature vector Normalization is performed to obtain the normalized block feature vector. Its expression is: In the formula, express Euclidean length; Indicates the first smoothing term; S46. Normalize all block feature vectors Connect them sequentially to generate a feature description vector for the grayscale edge image; S47. Extract each stretching direction from the feature description vector. histogram vector mean And based on the calculated stretch value .
6. The textile defect detection method according to claim 5, characterized in that, Step S42 specifically includes the following steps: S421. Calculate the horizontal gradient of each pixel. vertical gradient of and The calculation formulas are as follows: In the formula, Represents a grayscale edge image; S422, Based on the horizontal gradient vertical gradient of and Calculate gradient magnitude The calculation formula is as follows: S423, Based on the horizontal gradient vertical gradient of and Calculate gradient direction The calculation formula is as follows: In the formula, express function; S424, Gradient direction Switch to Range generates unsigned gradient directions Its expression is: In the formula, Represents pixels The orientation of the edge.
7. The textile defect detection method according to claim 5, characterized in that, Step S43 specifically includes the following steps: S431. Divide the gradient histogram into B intervals, each interval The range is ,in ; S432. For each pixel within any cell unit, find its unsigned gradient direction. The interval to which it belongs ; S433, Based on the unsigned gradient direction Calculate the normalized weighting factor The calculation formula is as follows: In the formula, Indicates the corresponding interval The minimum value of the angle range it is responsible for; S434, Based on the normalized weighting factor Calculate the pixel pair between two adjacent intervals. and interval histogram vector and The calculation formulas are as follows: In the formula, and These represent the pixel pairs in the interval. and interval histogram vector and ; S435. Repeat steps S432-S434 until the gradient histogram of each cell unit is obtained.
8. The textile defect detection method according to claim 5, characterized in that, In step S47, the stretching degree value The calculation formula is: In the formula, This represents the mean of the standard histogram vector; This indicates the second smoothing term.
9. The textile defect detection method according to claim 1, characterized in that, Step S5 specifically includes the following steps: S51. Overlay the standard printing and dyeing pattern and printing and dyeing image data to obtain the overstretched area and the missing area. S52. Construct a binary hyperextension map based on the hyperextension region and the missing region. and missing binary map And calculate the area of the overstretched region based on it. and the area of the missing region The calculation formulas are as follows: In the formula, and These represent the width and height of the second image data, respectively. S53. Constructing the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Their expressions are as follows: In the formula, express The pixel coordinates; express The mean of the coordinates of all pixels; express The pixel coordinates; express The mean of the coordinates of all pixels; S54. Based on the covariance matrix of the hyperextension region and the covariance matrix of the missing regions Calculate the orientation angle of the overstretched region and the orientation angle of the missing area ; S55, Based on the orientation angle of the overstretched area and the orientation angle of the missing area Extract the overstretch value separately and missing stretch value And calculate the overextension exemption factor based on it. and missing exemption factors The calculation formulas are as follows: In the formula, Indicates the proportionality coefficient; This represents the total number of pixels in a standard printed pattern. S56. Based on the overextension exemption factor and missing exemption factors Calculate the effective overstretch area and effective missing area The calculation formulas are as follows: In the formula, This represents the total number of pixels in the overextended region. Indicates the total number of pixels in the missing region; S57. Preset the maximum permissible effective over-stretch area and the maximum permissible effective missing area, and determine the effective over-stretch area. Not exceeding the maximum permissible effective overstretch area and effective missing area Does the condition of not exceeding the maximum permissible valid missing area hold true? If so, it means the printing and dyeing image data is qualified; If not, it means the printing image data is unqualified.
Citation Information
Patent Citations
Garment fabric tensile strength detection method
CN115205295A
Visual inspection method for textile quality
CN116843688A
Method of object recognition in image data using combined edge magnitude and edge direction analysis techniques
US20090226033A1
Fabric defect detection method based on deep convolutional neural network and visual saliency
WO2019104767A1
Program, and data processing device
WO2025150325A1
Cited By
Textile color difference detection method based on image detection
CN121453792A
