Cloth image defect detection method based on polymorphic data augmentation and block recognition
Through polymorphic data amplification and block recognition algorithms, new defect images are generated and block detected, which solves the problem of low defect detection accuracy in cloth images and achieves high-precision detection of images with larger sizes and complex backgrounds.
Patent Information
- Application Number
- CN202210384892.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-13
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-04-13
AI Technical Summary
Existing cloth image defect detection methods are difficult to achieve high accuracy when the size is large and the background is complex, and cannot meet industrial needs.
The polymorphic data amplification algorithm is used to generate new defect images, and combined with the block recognition algorithm and the detection frame fusion algorithm, the detection accuracy is improved by detecting block by block and merging the detection results.
It improves the accuracy of defect detection in cloth images with large size and complex background, solves the problem of low defect detection accuracy in high-resolution images, and has reference significance for similar target detection.
Smart Images

Figure CN114782346B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image processing and is a cloth image defect detection method based on polymorphic data amplification and block recognition. Background Art
[0002] my country is the world's largest cloth producer and exporter, and a large number of defects will be generated during the cloth production process. Cloth defect detection is crucial to cloth quality. However, most factories still rely on workers to detect cloth defects. This defect detection method has low accuracy, difficult to unify detection standards, and consumes a lot of manpower. Therefore, the automated detection of cloth defects has great research significance.
[0003] With the rapid development of computer technology, traditional image processing technology and deep learning-based target detection algorithms are gradually applied to defect detection in cloth images. For defect detection of cloth images with simple backgrounds, traditional image processing technology has achieved good results; for defect detection of cloth images with small size and simple backgrounds, deep learning-based target detection algorithms have basically met industrial needs. However, most of the cloth produced by factories has the characteristics of large size and complex background. For cloth images with large size, complex background and a large number of small defects, the existing detection methods are difficult to obtain high detection accuracy and cannot meet actual production needs. Summary of the invention
[0004] In view of the above problems, the present invention proposes a cloth image defect detection method based on polymorphic data amplification and block recognition, which is a detection method for cloth images with large size and complex background, so as to solve the problem of low accuracy of high-resolution image defect detection.
[0005] The present invention utilizes a multi-morphological data augmentation algorithm to extract defect features, adopts a traditional image processing method to change the defect morphology, fuses the defects after morphological transformation with the original cloth image, and generates new defect images in batches; utilizes a block recognition algorithm and a detection frame fusion algorithm, crops images, uses small-size images to train the model, inputs large-size images during reasoning, adopts block-by-block detection, and merges the detection results to complete the detection of cloth images with large size and complex background, thereby improving the detection accuracy of defects in cloth images with large size and complex background.
[0006] The technical solution of the present invention:
[0007] A cloth image defect detection method based on polymorphic data amplification and block recognition, the steps are as follows:
[0008] Step (1), collect defective cloth images, filter out pixels whose RGB three-channel values are within a certain range according to the color space, thereby extracting cloth defects in a fixed color range, and set the image background to white or black to obtain defect features that are independent of the background.
[0009] Step (2), randomly changing the shape of the defect of the object through commonly used data enhancement methods such as scaling, mirroring, cropping, rotation, morphological processing, etc., to obtain a new defect image.
[0010] Step (3), randomly batch-fusing the new defect images obtained in step (2) into the cloth images, removing the white or black background, and performing polymorphic amplification on the original data set, thereby constructing a cloth data set with polymorphic defects, effectively reducing the amplification similarity, and realizing cross-color cloth amplification.
[0011] Step (4): During the training process, the image segmentation method is used to crop the large-size image into small-size images, and the model is trained using the small-size images. During the inference process, the input large-size image is segmented into small-size images and put into the network, and the images are detected one by one. The relevant parameters about image segmentation can be obtained through formulas (1) to (4):
[0012]
[0013]
[0014]
[0015]
[0016] Among them, h_times and w_times represent the number of recognitions in the height direction and width direction respectively, H and W represent the height and width of the large image respectively, h and w represent the height and width of the cropped small image respectively, bias_h and bias_w represent the length of the cross area in the height direction and width direction respectively.
[0017] Step (5): After the reasoning process of step (4), the detection results of each small-size image are obtained, and then the image merging algorithm is used to merge the block detection results. The image merging algorithm maps the detection results of the small-size image to the large-size image according to the relative position relationship between the defect and the large-size image. Because the position of the small-size image relative to the large-size image is determined, the position of the defect relative to the large-size image is determined. According to formulas (5) to (10), the position of the defect in the large-size image can be obtained:
[0018] x1=(w-bias_w)*i(i≥0) (5)
[0019] y1=(h-bias_h)*j(j≥0) (6)
[0020] x2=w+x1 (7)
[0021] y2=h+y1 (8)
[0022] X=x1+x (9)
[0023] Y=y1+y (10)
[0024] Among them, i and j are the sequence numbers of the cropped image in the width and height directions respectively (the sequence number starts from 0), (x1, y1) are the coordinates of the upper left corner of the cropped image, (x2, y2) are the coordinates of the lower right corner of the cropped image, (x, y) are the position of the cloth defect in the cropped image, and (X, Y) are the coordinates of the defect relative to the entire image.
[0025] Step (6): If there are repeated detection results in the overlapping areas of the image block detection results, assuming that the two repeated detection results are the same type of defects and their IoU (intersection over union) is greater than the set threshold, a non-maximum suppression algorithm (suppressing elements that are not maximum values) is used to delete the detection frames with lower confidence and retain the detection frames with higher confidence.
[0026] Step (7), there are overlapping areas in adjacent cropped images, and the detection results of the two images are incomplete. In the process of merging intersecting detection frames, when the IoU (intersection over union) of the two detection frames is greater than the set threshold, the two detection frames are merged into a large detection frame, the maximum circumscribed rectangle of the two small detection frames is taken as the new detection frame, and the maximum value of the two confidences is set as the new confidence; the position coordinates of the new detection frame are obtained according to formulas (11) to (14):
[0027] X1=min(x1,x3) (11)
[0028] Y1=min(y1,y3) (12)
[0029] X2=Max(x2,x4) (13)
[0030] Y2=Max(y2,y4) (14)
[0031] Among them, (X1, Y1X2, Y2) are the new detection box coordinates, (x1, y1, x2, y2) and (x3, y3, x4, y4) are the two detection box coordinates in the small image.
[0032] Step (8), Cascade R-CNN is a popular target detection algorithm with high accuracy and stability. The Cascade R-CNN target detection algorithm is used to detect defects in small-size images in blocks to obtain defect detection results of small-size images. Then, the defect detection results of small-size images are merged through steps (5), (6), and (7), that is, the defect positions detected on each small-size image are mapped to the large-size image, and finally the detection results of the large-size image are obtained.
[0033] Beneficial effects of the present invention: The present invention proposes a polymorphic data amplification method and a block recognition algorithm. Compared with the traditional data amplification method, the polymorphic data amplification method can batch generate defects with polymorphic characteristics, solve the problem of insufficient sample size of some defect categories, and improve the detection accuracy of defects in small sample size categories. The block recognition algorithm converts high-resolution cloth image defect detection into multiple low-resolution image defect detections, solves the problem that high-resolution small-size defects are difficult to detect, and improves the detection accuracy of small-size defects. The present invention solves the problem of high-resolution, complex background cloth image defect detection through polymorphic data amplification and block recognition algorithms, which has reference significance for the same type of target detection problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is the extracted cloth defect image;
[0035] Figure 2 To change the original shape of the cloth defect image;
[0036] Figure 3 It is the cloth image after polymorphic amplification;
[0037] Figure 4 Divide the cloth image into block images;
[0038] Figure 5 This is the image merged using the non-maximum suppression algorithm;
[0039] Figure 6 The image after executing the maximum bounding rectangle merging algorithm;
[0040] Figure 7 This is the result of high-resolution cloth image defect detection. Specific implementation methods
[0041] In order to make the purpose, technical scheme and advantages of the present invention more clearly described, the common defects in cloth defects will be taken as an example below, combined with the accompanying drawings in the present invention, to fully describe the technical scheme in the present invention.
[0042] (1) Collect defective cloth images with a resolution of 4096 × 1680. Extract the defective parts in the cloth images to obtain images with the cloth defects as the main body and a white or black background, such as Figure 1 As shown;
[0043] (2) The defect image of the cloth is randomly scaled, mirrored, cropped, rotated and processed by common morphological processing methods to change the shape of the defect and generate a new defect image, such as Figure 2 As shown;
[0044] (3) Then, the defect image after the morphological change is fused with the cloth image, and the white or black background of the defect image is removed to obtain the amplified cloth image, such as Figure 3 As shown;
[0045] (4) Taking into account the detection time and detection accuracy, the cloth image with a resolution of 4096×1680 is cropped into 6 cloth images with a resolution of 1680×960 for model training; in the inference process, the image segmentation algorithm is used to detect each block one by one. The image segmentation process is as follows: Figure 4 As shown, using formula (1) and formula (2):
[0046]
[0047]
[0048] The number of recognition times in the height direction h_times=2 and the number of recognition times in the width direction w_times=3 are obtained.
[0049] (5) The detection results of 6 small-size images are obtained by block detection using an image segmentation algorithm. The position of each defect in the large-size image is obtained based on the relative position of the small-size image and the large-size image, thereby mapping the defects detected in the small-size image to the large-size image, completing the merging of the small-size image detection results.
[0050] (6) There are repeated detection results of cloth defects in the overlapping area of the image block detection results, and the two defects belong to the same category. Here, the IoU (intersection over union) threshold is taken as 0.7. Since the IoU (intersection over union) of the two detection frames is greater than 0.7, the non-maximum suppression algorithm is used to delete the detection frames with confidence levels of 0.49 and 0.58, and retain the detection frames with confidence levels of 0.68 and 0.89. The merged image is as follows: Figure 5 As shown;
[0051] (7) In the process of merging the two intersecting detection frames of the cloth defect, the IoU (intersection over union) threshold is set to 0.3. Since the IoU (intersection over union) of the two detection frames is greater than 0.3, the two detection frames are merged, and the maximum bounding rectangle of the two detection frames is taken as the new detection frame. At the same time, 0.58 is set as the new confidence level. The image after executing the maximum bounding rectangle merging algorithm is as follows: Figure 6 As shown;
[0052] (8) After block detection by the Cascade R-CNN target detection algorithm and subsequent merging algorithm processing, the detection results of defects in the high-resolution cloth image are obtained, such as Figure 7 As shown, the problem of cloth image defect detection with high resolution and complex background is effectively solved.
Claims
1. A cloth image defect detection method based on polymorphic data amplification and block recognition, characterized in that: Here are the steps: Step (1), collecting defective cloth images, filtering out pixels whose RGB three-channel values are within a certain range according to the color space, thereby extracting cloth defects within a fixed color range, setting the image background to white or black, and obtaining defect features that are independent of the background; Step (2), randomly changing the shape of the defect of the object by a data enhancement method on the defect image obtained in step (1) to obtain a new defect image; Step (3), randomly batch-merge the new defect images obtained in step (2) into the cloth images, remove the white or black background, perform polymorphic amplification on the original data set, and thus construct a cloth data set with polymorphic defects; Step (4): During the training process, the image segmentation method is used to crop the large-size image into small-size images, and the model is trained using the small-size images. During the inference process, the input large-size image is segmented into small-size images and put into the network, and the images are detected one by one. The relevant parameters about image segmentation are obtained through formulas (1) to (4): Among them, h_times and w_times represent the number of recognitions in the height direction and width direction respectively, H and W represent the height and width of the large image respectively, h and w represent the height and width of the cropped small image respectively, bias_h and bias_w represent the length of the cross area in the height direction and width direction respectively; Step (5): After the reasoning process of step (4), the detection result of each small-size image is obtained, and then the image merging algorithm is used to merge the block detection results; the image merging algorithm maps the detection result of the small-size image to the large-size image according to the relative position relationship between the defect and the large-size image. Because the position of the small-size image relative to the large-size image is determined, the position of the defect relative to the large-size image is determined. According to formulas (5) to (10), the position of the defect in the large-size image is obtained: x1=(w-bias_w)*i,i≥0 (5) y1=(h-bias_h)*j,j≥0 (6) x2=w+x1 (7) y2=h+y1(8) X=x1+x (9) Y=y1+y (10) Where i and j are the order numbers of the cropped image in the width and height directions respectively, (x1, y1) are the coordinates of the upper left corner of the cropped image, (x2, y2) are the coordinates of the lower right corner of the cropped image, (x, y) are the position of the fabric defect in the cropped image, and (X, Y) are the coordinates of the defect relative to the entire image; Step (6), if there are repeated detection results in the overlapping area of the image block detection results, assuming that the two repeated detection results are the same type of defects and the intersection-over-union ratio is greater than the set threshold, a non-maximum suppression algorithm is used to delete the detection frame with lower confidence and retain the detection frame with higher confidence; Step (7), there are overlapping areas in adjacent cropped images, and the detection results of the two images are incomplete. In the process of merging intersecting detection frames, when the intersection-and-union ratio of the two detection frames is greater than the set threshold, the two detection frames are merged into a large detection frame, the maximum circumscribed rectangle of the two small detection frames is taken as the new detection frame, and the maximum value of the two confidences is set as the new confidence; the position coordinates of the new detection frame are obtained according to formulas (11) to (14): X1=min(x1,x3) (11) Y1=min(y1,y3) (12) X2=Max(x2,x4) (13) Y2=Max(y2,y4) (14) Among them, (X1, Y1X2, Y2) are the coordinates of the new detection box, (x1, y1, x2, y2), (x3, y3, x4, y4) are the coordinates of the two detection boxes in the small image; Step (8), using the Cascade R-CNN target detection algorithm to detect defects in the small-size image in blocks to obtain the defect detection results of the small-size image, and then merging the defect detection results of the small-size image through steps (5), (6), and (7), that is, mapping the defect positions detected on each small-size image to the large-size image, and finally obtaining the detection results of the large-size image.
Citation Information
Patent Citations
Remote sensing image ship detection method based on block extraction
CN111027511A
Composite ultrasonic image defect detection method based on deep learning and superpixel segmentation
CN113298809A
Method for identifying and positioning photovoltaic string in map
CN113505726A
Fabric defect detection method based on deep convolutional neural network and visual saliency
WO2019104767A1
Target detection method and device
WO2021077868A1
