A method of textile defect detection

By constructing YOLO and U-Net models and combining them with texture gradient analysis, the problem of decreased detection accuracy caused by stretching deformation of printing and dyeing patterns was solved, achieving high-precision textile defect detection and enabling accurate location and classification of defect types.

CN120876494BActive Publication Date: 2025-12-09BAOJI DADI TEXTILE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511397548.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-28
Publication Date
2025-12-09
Estimated Expiration
2045-09-28

AI Technical Summary

Technical Problem

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.

Method used

通过构建基于YOLO算法的目标检测模型和U-Net模型,提取印染图案的边缘图像数据,结合纹理梯度分析计算拉伸程度值,并与标准印染图案对比,判断印染图像数据的合格性。

Benefits of technology

It improves the accuracy of textile defect detection, can accurately locate defect locations and distinguish defect types, reduces the influence of factors such as color changes and ambient lighting, and provides tensile percentage values ​​in each direction, thus improving the accuracy and detail of the detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876494B_ABST
    Figure CN120876494B_ABST
Patent Text Reader

Abstract

The present application relates to the field of textile defect detection, and particularly to a textile defect detection method, comprising the following steps: S1, obtaining first image data of a textile; S2, extracting second image data containing printing and dyeing patterns from the first image data; S3, constructing printing and dyeing image data and edge image data according to the second image data; S4, calculating the stretching degree value of the textile in each stretching direction according to the edge image data; in the present application, when calculating the stretching degree of the textile in each direction, since the texture of the textile is analyzed instead of the foreground pattern, the method is not sensitive to interference factors such as color change, pattern content and slight stains, and compared with common detection methods, the method provides accurate stretching percentage values in each direction instead of simple pass or fail judgment, thereby improving the calculation accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of textile defect detection, and particularly to a textile defect detection method. BACKGROUND

[0002] Printing and dyeing is the general term for "dyeing" and "printing", which refers to the process of coloring textiles (fibers, yarns, fabrics) through physical, chemical or physical-chemical methods to obtain uniform and fast colors. The printing and dyeing pattern of textiles is a key link to ensure product quality, which directly affects brand image, customer satisfaction and production cost.

[0003] The common printing and dyeing pattern defect detection method only analyzes whether each pixel belongs to the printing and dyeing pattern according to the similarity between the target printing and dyeing pattern and the standard printing and dyeing pattern or uses a deep learning model, ignoring the deformation of the printing and dyeing pattern caused by internal stretching, which affects the detection accuracy. SUMMARY

[0004] In view of the deficiencies of the prior art, the present application provides a textile defect detection method, which solves the technical problems in the background art.

[0005] To achieve the above object, the present application provides the following technical scheme:

[0006] A textile defect detection method, comprising the following steps:

[0007] S1, acquiring first image data of a textile product;

[0008] S2, extracting second image data containing a printing and dyeing pattern from the first image data;

[0009] S3, constructing printing and dyeing image data and edge image data according to the second image data;

[0010] S4, calculating the stretching degree value of the textile product in each stretching direction according to the edge image data ;

[0011] S5, acquiring a standard printing and dyeing pattern, comparing the differences between the standard printing and dyeing pattern and the printing and dyeing image data, and combining the stretching degree value to determine whether the printing and dyeing image data is qualified;

[0012] If yes, the process ends;

[0013] If not, feedback to the control end to mark the textile product.

[0014] Further, in step S2, the following steps are included:

[0015] S21, acquire first historical image data of a plurality of textiles, and take the first historical image data as first training samples;

[0016] S22, mark the position of the printing and dyeing pattern of each training sample to obtain a first sample label of the first training sample;

[0017] S23, train a target detection model using the first training sample and the first sample label to obtain a first target model;

[0018] S24, input the first image data into the first target model to generate second image data.

[0019] Further, in step S23, the first target model is constructed based on the YOLO algorithm.

[0020] Further, in step S3, the following steps are specifically included:

[0021] S31, acquire a plurality of second historical image data;

[0022] S32, pre-process the second historical image data to generate third historical image data;

[0023] S33, manually outline the contour of the printing and dyeing pattern in each third historical image data, and generate a first mask image according to it;

[0024] S34, take the third historical image data as second training samples, and take the first mask image as second sample labels to train a U-Net model to generate a second target model;

[0025] S35, pre-process the second image data and input it into the second target model to generate a 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 is consistent with the second image data, and 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, then copy the pixel values of the corresponding positions in the second image data to the same positions in the first all-zero image to generate printing and dyeing image data; extract all black pixel positions in the second mask image, then copy the pixel values of the corresponding positions in the second image data to the same positions in the second all-zero image to generate edge image data.

[0028] Further, in step S4, the following steps are specifically included:

[0029] S41, taking the upper left corner point of the second image data as the origin 0, constructing a plane coordinate system with the upper frame and the left frame of the gray-scale edge image as the x-axis and the y-axis respectively, and converting the edge image data into a gray-scale edge image;

[0030] S42, calculating a gradient parameter set of each pixel point in the gray-scale edge image, the gradient parameter set including a gradient amplitude and an unsigned gradient direction ;

[0031] S43, dividing the gray-scale edge image into a plurality of cell units with a size of Cx C, and calculating a gradient histogram of each cell unit;

[0032] S44, setting a sliding window with a length of M and a width of N in the gray-scale edge image, the step length of the sliding window being 1, the sliding window generating a block each time, and connecting the histogram vectors of all cell units in each block to generate a block feature vector , the expression of which being:

[0033]

[0034] In the formula, denotes a transposition operation of a vector; denotes the histogram vector of the i-th cell unit;

[0035] S45, normalizing each block feature vector to obtain a normalized block feature vector , the expression of which being:

[0036]

[0037] In the formula, denotes the Euclidean length of ; denotes a first smoothing term;

[0038] S46, connecting all the normalized block feature vectors in sequence to generate a feature description vector of the gray-scale edge image;

[0039] S47, extracting the histogram vector mean value of each stretch direction in the feature description vector, and calculating a stretch degree value according to the histogram vector mean value.

[0040] Further, in step S42, the following steps are specifically included:

[0041] ​​S421, calculate the horizontal gradient of each pixel and the vertical gradient of each pixel The calculation formula is respectively:

[0042]

[0043] In the formula, Indicates the gray scale edge image;

[0044]

[0045] S422, according to the horizontal gradient and the vertical gradient of each pixel Calculate the gradient amplitude The calculation formula is:

[0046]

[0047] S423, according to the horizontal gradient and the vertical gradient of each pixel Calculate the gradient direction The calculation formula is:

[0048]

[0049] In the formula, Indicates the Function;

[0050] S424, convert the gradient direction To the range of Generate unsigned gradient direction The expression is:

[0051]

[0052] In the formula, Indicates the direction of the edge of the pixel .

[0053] Further, in step S43, specifically includes the following steps:

[0054] S431, divide the gradient histogram into B intervals, each interval The range is , Where ;

[0055] S432, for each pixel in any cell unit, find the interval To which the unsigned gradient direction Belongs;

[0056] S433, according to the unsigned gradient direction The normalized weight factor is calculated The calculation formula is as follows:

[0057]

[0058] In the formula, represents the minimum value of the corresponding interval responsible for the angle range;

[0059] S434, according to the normalized weight factor The histogram vectors of the pixel to two adjacent intervals and interval are calculated and The calculation formula is as follows:

[0060]

[0061]

[0062] In the formula, and respectively represent the histogram vectors of the pixel to interval and interval and ;

[0063] S435, repeat steps S432-S434 until the gradient histogram of each cell unit is obtained.

[0064] Further, in step S47, the calculation formula of the stretching degree value is as follows:

[0065]

[0066] In the formula, represents the mean value of the standard histogram vector; represents the second smoothing term.

[0067] Further, in step S5, it specifically includes the following steps:

[0068] S51, superimpose the standard printing pattern and the printing image data to obtain the overstretching area and the missing area;

[0069] S52, construct overstretching binary map and missing binary map according to the overstretching area and the missing area, and calculate the overstretching area and the missing area according to them, the calculation formula is as follows: ​

[0070]

[0071]

[0072] wherein, W2 and H2 represent the width and height of the second image data respectively; and respectively represent the width and height of the second image data;

[0073] S53, constructing the overhang region covariance matrix and the missing region covariance matrix , whose expressions are respectively:

[0074]

[0075]

[0076] wherein, represents the pixel point coordinate of ; represents the mean value of all pixel point coordinates of ; represents the pixel point coordinate of ; represents the mean value of all pixel point coordinates of ;

[0077] S54, calculating the overhang region orientation angle and the missing region orientation angle according to the overhang region covariance matrix and the missing region covariance matrix ;

[0078] S55, extracting the overhang stretch degree value and the missing stretch degree value according to the overhang region orientation angle and the missing region orientation angle respectively, and calculating the overhang exemption factor and the missing exemption factor according to them, whose calculation formulas are respectively:

[0079]

[0080]

[0081] wherein, represents the proportional coefficient; represents the total number of pixel points of the standard printing and dyeing pattern;

[0082] S56, calculating the overhang exemption factor and the missing exemption factor Effective overhang area and effective missing area The calculation formula is respectively:

[0083]

[0084]

[0085] In the formula, Total number of pixel points in the overhang area is represented by; Total number of pixel points in the missing area is represented by;

[0086] S57, preset maximum allowed effective overhang area and maximum allowed effective missing area, judge whether effective overhang area does not exceed the maximum allowed effective overhang area and effective missing area does not exceed the maximum allowed effective missing area are all established;

[0087] If yes, it means that the printing and dyeing image data is qualified;

[0088] If no, it means that the printing and dyeing image data is unqualified.

[0089] Compared with the prior art, the present application provides a textile defect detection method, which has the following beneficial effects:

[0090] 1. In the present application, when calculating the stretching degree of the textile in each direction, since the texture of the textile is analyzed instead of the foreground pattern, the interference factors such as color change, pattern content and slight stains are not sensitive, and compared with the common detection method, accurate stretching percentage value in each direction is provided instead of simple qualified or unqualified judgment, which improves the calculation accuracy.

[0091] 2. In the present application, when judging whether the printing and dyeing image data is qualified, the deformation is calculated according to the texture gradient of the textile, and then the printing and dyeing image data is compared with the pattern content, which can reduce the influence of factors such as uneven color and environmental light change, in addition, the pixel level position where the defect occurs can be accurately positioned, which not only helps to judge whether the product is qualified, but also helps to distinguish the defect type, and provides more accurate basis for quality control and classification processing. BRIEF DESCRIPTION OF DRAWINGS

[0092] The drawings described herein are used to provide further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute improper limitation on the present application. In the drawings:

[0093] Figure 1 It is a flow chart of a textile defect detection method of the present application. DETAILED DESCRIPTION

[0094] In order to make the above objectives, characteristics and advantages of the present application more obvious and easy to understand, the present application will be further described in detail below with reference to the drawings and specific embodiments. By this, the implementation process of how to apply technical means to solve technical problems and achieve technical effects of the present application can be fully understood and implemented.

[0095] Those of ordinary skill in the art can understand that all or part of the steps of the following embodiment methods can be completed by programs instructing relevant hardware, therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment in the form of combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program codes.

[0096] Printing and dyeing is the general term of "dyeing" and "printing", which refers to the process of coloring textile (fiber, yarn, fabric) through physical, chemical or physical-chemical combined methods, so as to make it obtain uniform and fast color. The printing and dyeing process is complex and prone to defects, common ones including color difference, color flower / dyeing unevenness, color stain, missing printing and printing inaccuracy. After the completion of printing and dyeing operation of the textile, the above problems need to be detected to ensure that the printing and dyeing of the textile meets the needs. For this purpose, please refer to Figure 1 The present application proposes a textile defect detection method, which comprises the following steps:

[0097] S1, acquiring first image data of the textile; specifically, a high-definition camera is used to shoot the printing position of the textile, which can be set on the flow line. When the printing and dyeing of the textile is completed, the high-definition camera is used to complete the shooting of the textile. In order to ensure that the complete printing and dyeing pattern and the surrounding textile texture information are shot, the complete textile needs to be shot.

[0098] S2, extracting second image data containing the printing and dyeing pattern from the first image data; specifically, since the texture of the textile is relatively soft, when the high-definition camera shoots it, there may be non-linear stretching or contraction, which leads to misjudgment of the common visual detection model during detection. Therefore, in addition to detecting the printing and dyeing pattern, the surrounding texture also needs to be detected. Therefore, in step S2, the following steps are specifically included:

[0099] S21, acquiring first historical image data of a plurality of textiles, and taking the first historical image data as first training samples; specifically, the first historical image data represents the first image data of other textiles that have been shot in the past;

[0100] S22, mark the printing and dyeing pattern position of each training sample to obtain a first sample label of the first training sample; specifically, mark a box in the first historical image data using manual work to frame the printing and dyeing pattern and the surrounding part position, so as to analyze the printing and dyeing pattern and the texture around it in the later stage; it should be noted that the high-definition camera is arranged at a fixed height and a fixed angle (preferably directly above the textile, and the lens thereof is perpendicular to the plane where the textile is located), so the size of the first historical image data obtained each time is the same, and therefore the size of the printing and dyeing pattern marked is also basically the same, which can make the size of the second image data output by the first target model consistent.

[0101] S23, train the target detection model using the first training sample and the first sample label to obtain a 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 network; it should be noted that both the YOLO algorithm and the convolutional neural network belong to common prior art, and the working principle thereof will not be described here;

[0102] S24, input the first image data into the first target model to generate second image data.

[0103] S3, construct printing and dyeing image data and edge image data according to the second image data; specifically, in step S3, the following steps are specifically included:

[0104] S31, obtain a plurality of second historical image data; specifically, the second historical image data represents the output result of the processing of the first historical image data by the target model;

[0105] S32, pre-process the second historical image data to generate third historical image data; specifically, the pre-processing of the second historical image data includes: (1) normalizing the pixel value from the range of 0 to 255 to the range of 0 to 1 to accelerate the convergence of the model; (2) scaling the second historical image data to a fixed size (self-defined);

[0106] S33, manually outline the contour of the printing and dyeing pattern in each third historical image data, and generate a first mask image according to the same; specifically, the first mask image is pixel-level labeled according to a labeling tool (such as LabelMe, CVAT, and EISeg); it should be noted that the first mask image is a black and white image with the same size as the third historical image data, wherein the pixel value of the background is 0 (i.e. black), and the pixel value of the printing and dyeing 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 the gray-scale edge image; specifically, is used to measure the intensity change rate of the pixel point in the horizontal direction, a positive value indicates that it changes from dark to light from left to right, and a negative value indicates that it changes from light to dark; the greater the absolute value, the more likely there is a vertical edge at this point;

[0117]

[0118] Specifically, is used to measure the intensity change rate of the pixel point in the vertical direction; the greater the value, the more likely there is a horizontal edge at this point;

[0119] S422, according to the horizontal gradient and the vertical gradient of calculate the gradient amplitude , the calculation formula is:

[0120]

[0121] Specifically, is used to integrate the changes in the horizontal and vertical directions to represent the overall intensity or significance of the edge of the point; the greater the value, the more likely this point is part of the edge;

[0122] S423, according to the horizontal gradient and the vertical gradient of calculate the gradient direction , the calculation formula is:

[0123]

[0124] In the formula, represents function;

[0125] S424, convert the gradient direction to range to generate an unsigned gradient direction , the expression is:

[0126]

[0127] In the formula, represents the direction of the edge of the pixel point .

[0128] S43, divide the gray-scale edge image into a plurality of cell units with a size of CxC, and calculate the gradient histogram of each cell unit; specifically, in step S43, it specifically includes the following steps:

[0129] S431, divide the gradient histogram into B bins, each bin ranges from to ; it is to be noted that each bin covers an angle range of ;

[0130] S432, for each pixel in any cell, find its unsigned gradient direction belongs to ;

[0131] S433, according to the unsigned gradient direction calculate the normalized weight factor , whose formula is:

[0132]

[0133] wherein represents the minimum value of the angle range responsible by the corresponding bin ;

[0134] S434, according to the normalized weight factor calculate the histogram vectors and of the pixel to the two adjacent bins and , whose formulas are respectively:

[0135]

[0136]

[0137] wherein and respectively represent the histogram vectors and of the pixel to the bin and the bin ; it is to be noted that if the bin is the last bin, then is the first bin, forming a ring; represents the accumulation operation;

[0138] S435, repeat steps S432-S434 until the gradient histogram of each cell is obtained.

[0139] S44, set a sliding window with length and width of M and N respectively in the gray-scale edge image, the step length of the sliding window is 1, and the sliding window generates a block each time, for the histogram vectors of all cells in each block Connect to generate a block feature vector , the expression is:

[0140]

[0141] In the formula, Indicates the transposition operation of the vector; Indicates the histogram vector of the i-th cell unit; ; Indicates the sum of the gradient amplitude contributions of all pixels in the i-th cell unit falling in the b-th interval; it should be noted that M and N are self-defined parameters;

[0142] S45, normalize each block feature vector To obtain the normalized block feature vector , the expression is:

[0143]

[0144] In the formula, Indicates the Euclidean length of ; Indicates the first smoothing term; it should be noted that is a very small constant, which is in the present application to prevent the calculation formula of the normalized block feature vector from being meaningless;

[0145] S46, connect all normalized block feature vectors in order to generate a feature description vector of the gray edge image;

[0146] S47, extract the histogram vector mean value of each stretch direction in the feature description vector, and calculate the stretch degree value ; specifically, in step S47, the calculation formula of the stretch degree value is:

[0147]

[0148] In the formula, Indicates the standard histogram vector mean value; Indicates the second smoothing term; specifically, a large number of normal textiles without stretch and defects are used, and the histogram vector mean value of each stretch direction in the feature description vector is obtained, that is, ; it should be noted that ​The degree of deformation of the texture of the textile in each direction relative to the normal state is quantified; The closer to 0, the more normal the direction is; .

[0149] In the present application, when calculating the degree of stretching of the textile in each direction, since the texture of the textile is analyzed instead of the foreground pattern, the interference factors such as color change, pattern content and slight stains are not sensitive, and compared with the common detection method, the percentage value of the stretching in each direction is provided instead of the simple pass or fail judgment, and the calculation accuracy is improved.

[0150] S5, obtaining a standard printing and dyeing pattern, comparing the difference between the standard printing and dyeing pattern and the printing and dyeing image data, and combining the stretching degree value determining whether the printing and dyeing image data is qualified;

[0151] if yes, ending;

[0152] if no, feeding back to the control end to mark the textile; specifically, in step S5, the following steps are specifically included:

[0153] S51, superimposing the standard printing and dyeing pattern and the printing and dyeing image data to obtain the over-stretching area and the missing area; specifically, a standard printing and dyeing pattern is pre-shooted, that is, the standard printing and dyeing pattern, since the distance between the high-definition camera and the textile is always kept consistent, the distance between each two pixel points in the standard printing and dyeing pattern and the printing and dyeing image data corresponds to the actual space point, so the proportion of the printing and dyeing pattern in the standard printing and dyeing pattern and the actual printing and dyeing pattern is consistent, that is, the size is basically consistent; in addition, the overlapping position with the most coincident pixel points is taken as the overlapping position of the standard printing and dyeing pattern and the printing and dyeing image data to improve the accuracy of the overlapping; it should be noted that the over-stretching area represents the pixel point area that the printing and dyeing image data has more than the standard printing and dyeing pattern; the missing area represents the pixel point area that the printing and dyeing image data is missing compared with the standard printing and dyeing pattern;

[0154] S52, constructing an over-stretching binary image according to the over-stretching area and the missing area and a missing binary image and calculating the over-stretching area and the missing area according to the same, and the calculation formula is respectively:

[0155]

[0156]

[0157] In the formula, and respectively represent the width and height of the second image data; specifically, using the planar coordinate system constructed in step S41 to determine the coordinate position of each pixel point, wherein, at coordinate , if the pixel point belongs to the overhanging region, then is 1; otherwise, it is 0. At coordinate , if the pixel point belongs to the missing region, then is 1; otherwise, it is 0.

[0158] S53, constructing an overhanging region covariance matrix and a missing region covariance matrix , whose expressions are respectively:

[0159]

[0160]

[0161] In the formula, x i represents the pixel point coordinate of the i-th pixel point in the overhanging region; represents the mean value of all pixel point coordinates of the overhanging region; represents the pixel point coordinate of the i-th pixel point in the missing region; represents the mean value of all pixel point coordinates of the missing region;

[0162] S54, calculating the overhanging region orientation angle and the missing region orientation angle according to the overhanging region covariance matrix and the missing region covariance matrix ; specifically, the calculation formula of the overhanging region orientation angle is:

[0163]

[0164]

[0165] S55, extracting the overhanging stretching degree value and the missing stretching degree value according to the overhanging region orientation angle and the missing region orientation angle respectively, and calculating the overhanging exemption factor and the missing exemption factor according to them, whose calculation formulas are respectively:

[0166]

[0167] ​​​​​

[0168] In the formula, represents a proportional coefficient; represents the total number of pixel points of the standard printing and dyeing pattern; in the present application, is 0.8;

[0169] S56, according to the overstretching exemption factor and the missing exemption factor calculate the effective overstretching area and the effective missing area The calculation formula is respectively:

[0170]

[0171]

[0172] In the formula, represents the total number of pixel points of the overstretching area; represents the total number of pixel points of the missing area;

[0173] S57, preset the maximum allowed effective overstretching area and the maximum allowed effective missing area, judge whether the effective overstretching area does not exceed the maximum allowed effective overstretching area and the effective missing area does not exceed the maximum allowed effective missing area;

[0174] If yes, it means that the printing and dyeing image data is qualified;

[0175] If not, it means that the printing and dyeing image data is unqualified.

[0176] In the present application, when judging whether the printing and dyeing image data is qualified, the deformation is calculated according to the texture gradient of the textile, and then the content of the printing and dyeing image data is compared, which can reduce the influence of factors such as uneven color and environmental light change, in addition, it can accurately locate the pixel level position where the defect occurs, not only helps to judge whether the product is qualified, but also helps to distinguish the defect type, provides more accurate basis for quality control and classification processing.

[0177] The above embodiments have introduced the present application in detail, and the principles and embodiments of the present application have been described by applying specific examples; the above embodiment description is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific embodiments and application scope will be changed; in view of the above, the content of the specification should not be understood as a limitation of the present application.

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; 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. 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. 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 allowable effective over-stretch area and the maximum allowable 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.

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 object detection model using the first training sample and the first sample label to obtain the first object 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 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 .

5. The textile defect detection method according to claim 4, 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.

6. The textile defect detection method according to claim 4, 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.

7. The textile defect detection method according to claim 4, 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.

Citation Information

Patent Citations

  • Visual inspection method for textile quality

    CN116843688A

  • Program, and data processing device

    WO2025150325A1