A method for identifying cloth defects
By segmenting and density clustering of the grayscale image on the surface of the cloth, combining the grayscale difference sequence calculation, the fabric defect area is identified, which solves the problem of texture edge interference and improves the accuracy and efficiency of defect recognition.
Patent Information
- Application Number
- CN202411124558.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2044-08-16
AI Technical Summary
In fabric production, due to interference with the fabric texture edge during the machine automation process, it is difficult to identify defects such as rolling shuttle marks.
By obtaining the grayscale image of the cloth surface, segmenting it into small areas, using density clustering and grayscale difference sequences to calculate the defect probability of each area, and combining aggregation and discreteness, the defect area is identified.
Improve the accuracy of defect recognition, avoid texture edge interference, accurately identify cloth defect areas, and reduce calculation amount.
Smart Images

Figure CN118644490B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of pattern recognition, and in particular to a method for identifying cloth defects. Background Art
[0002] With the rapid development of the textile industry, the degree of mechanical automation is getting higher and higher, and the demand for cloth is also increasing. However, in the process of machine automation production, it is necessary to monitor and identify the quality of the cloth in real time to ensure that the produced cloth is free of defects. Shuttle mark is a common defect in cloth production. The reason for its formation is that the shuttle is rolled in the shuttle channel without punching out the yarn layer, and the warp yarn is pulled or broken, forming a wave-like uneven cloth surface.
[0003] The method of identifying defects in cloth is usually to obtain the defect contour based on the edge of the image to identify the defect area. However, this method cannot identify the specific cloth defects because of the interference of the cloth texture edge in addition to the defect contour edge. Summary of the invention
[0004] The present invention provides a cloth defect recognition method to solve the problem that the specific cloth defect cannot be recognized due to interference from the cloth texture edge in addition to the defect contour edge.
[0005] A cloth defect recognition method of the present invention adopts the following technical solution:
[0006] An embodiment of the present invention provides a method for identifying cloth defects, the method comprising the following steps:
[0007] Obtaining a grayscale image of the cloth surface image;
[0008] Obtaining block regions of the grayscale image, segmenting each block region using a preset segmentation threshold, and obtaining a suspected defect region of each block region;
[0009] Obtaining the edge line of the suspected defect area, performing density clustering on the edge pixel points on the edge line of the suspected defect area, and obtaining cluster blocks with different densities; obtaining the edge area of the edge line, and obtaining the degree of disorder of the pixel points in the edge area according to the grayscale values of the pixel points in the edge area of the edge line;
[0010] According to the number of cluster blocks inside and outside the edge area of the edge line, the density of each cluster block and the degree of disorder of the pixels in the edge area, the aggregation of the edge line is obtained; the grayscale sequence of the pixels around each circle of the edge line is obtained, the grayscale difference sequence is obtained according to the grayscale sequence, and the discreteness of each circle around the edge line is calculated according to the grayscale difference sequence;
[0011] The defect probability of each circle around the edge line is obtained according to the aggregation of the edge line and the discreteness of each circle around the edge line, and the probability that the suspected defect area belongs to the defect area is obtained according to the defect probability of all circles around the edge line;
[0012] When the probability that the suspected defect region belongs to the defect region is greater than a preset probability threshold, the suspected defect region is marked as a defect region.
[0013] Furthermore, the step of obtaining the grayscale image block regions, segmenting each block region using a preset segmentation threshold, and obtaining the suspected defect region of each block region includes the following specific steps:
[0014] The grayscale image is segmented into N*N block areas, and the area in the block area that is smaller than a preset segmentation threshold is regarded as a suspected defect area.
[0015] Furthermore, the step of obtaining the edge area of the edge line includes the following specific steps:
[0016] A width of five pixels is extended to the inside and the outside of the suspected defect area respectively, and the area of the pixels of the width is recorded as the edge area of the edge line.
[0017] Furthermore, the degree of disorder of the pixels in the edge area is obtained according to the grayscale values of the pixels in the edge area of the edge line, and the specific calculation formula included is as follows:
[0018]
[0019] In the formula, Indicates the degree of confusion of pixels in the edge area of the edge line. The grayscale set of pixels in the edge area representing the edge line, The gray value of the pixel point in the edge area representing the edge line is The number of pixels, .
[0020] Furthermore, the aggregation of the edge line is obtained according to the number of cluster blocks inside and outside the edge area of the edge line, the density of each cluster block, and the degree of disorder of the pixels in the edge area, and the specific steps include the following:
[0021] The clustering features are obtained according to the number of cluster blocks inside and outside the edge area of the edge line. , the formula for obtaining the clustering of edge lines based on clustering features is as follows:
[0022]
[0023] In the formula, Indicates the aggregation of edge lines, Indicates The density of cluster blocks, Indicates the degree of confusion of pixels in the edge area of the edge line. Indicates the number of cluster blocks within the edge region of the edge line.
[0024] Furthermore, the clustering feature is obtained according to the number of cluster blocks inside and outside the edge area of the edge line. , including the following specific formulas:
[0025]
[0026] In the formula, represents the number of cluster blocks within the edge area excluding the edge line, Indicates the number of cluster blocks excluding the edge area of the edge line.
[0027] Furthermore, the discreteness of each circle around the edge line is calculated according to the grayscale difference sequence, and the specific formula included is as follows:
[0028]
[0029] In the formula, represents the discreteness of the ith circle around the edge line, represents the mean of the grayscale difference sequence of pixels around the i-th circle of the edge line, Around the edge line The number of pixels in the circle, Represents the nth element in the grayscale difference sequence.
[0030] Furthermore, the step of obtaining the grayscale difference sequence according to the grayscale sequence includes the following specific steps:
[0031] The nth element in the grayscale difference sequence is recorded as ,in, , Indicates the edge line The gray value of the nth pixel in the gray sequence of the circle, represents the gray value of the n+1th pixel in the gray sequence, then the gray difference sequence , m represents the number of The number of pixels in the circle.
[0032] Furthermore, the defect probability of each circle around the edge line is obtained according to the aggregation of the edge line and the discreteness of each circle around the edge line, and the specific calculation formula included is as follows:
[0033]
[0034] In the formula, Indicates the edge line The defect probability of the circle, It is expressed as the clustering of edge lines, represents the discreteness of the i-th circle of pixels of the edge line, and e represents a natural constant.
[0035] Furthermore, the method of obtaining the probability that the suspected defect area belongs to the defect area according to the defect probabilities of all circles around the edge line includes the following specific steps:
[0036] The mean of the defect probabilities of all circles on the edge line of the suspected defect area is recorded as the probability that the suspected defect area belongs to the defect area.
[0037] The beneficial effects of the technical solution of the present invention are:
[0038] The grayscale image and suspected defect area of the cloth surface image are obtained to improve the accuracy of defect recognition. The edge pixels on the edge line of the suspected defect area are density clustered to obtain cluster blocks of different densities. The edge area of the edge line is obtained, thereby obtaining the degree of confusion of the pixels in the edge area, which reflects the characteristics of the defect area. The aggregation of the edge line is obtained by combining the number of cluster blocks inside and outside the edge area of the edge line. At the same time, the discreteness of each circle around the edge line is calculated, which further improves the accuracy of defect recognition. The probability that the suspected defect area belongs to the defect area is obtained based on the discreteness and aggregation, avoiding the interference of other texture edges of the cloth, accurately identifying the defect area of the cloth, and reducing the amount of calculation. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 The present invention is a flowchart of the steps of a cloth defect identification method. DETAILED DESCRIPTION
[0041] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a method for identifying cloth defects proposed by the present invention, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0042] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0043] The specific scheme of a cloth defect recognition method provided by the present invention is described in detail below with reference to the accompanying drawings.
[0044] See also Figure 1 , which shows a flow chart of a method for identifying cloth defects provided by an embodiment of the present invention, the method comprising the following steps:
[0045] Step S001: Obtain a grayscale image of the cloth surface image.
[0046] The present invention is to identify texture defects on the surface of cloth, and needs to collect images of the surface of cloth. Since the texture features and grayscale features of the surface of cloth need to be analyzed, a clear and flat image is required.
[0047] An industrial electronic recognition device is used to capture an RGB image of the cloth surface. An industrial camera is arranged in the industrial electronic recognition device for collecting images. The industrial electronic recognition device also includes a detection platform for placing cloth. In addition, it also includes a light source for vertically irradiating the cloth surface. In this embodiment, the size of the RGB image is 1024×1024. Other values can be set in other embodiments, and this embodiment does not specifically limit it. The flatness of the texture on the surface of the cloth is processed to obtain a clear and flat image. In order to prevent the judgment of the regularity of the texture from being affected by factors of the image itself, the collected image is grayed to obtain a corresponding grayscale image.
[0048] Step S002: Obtain block regions of the grayscale image, and segment each block region using a preset segmentation threshold to obtain a suspected defect region of each block region.
[0049] It should be noted that when the shuttle mark defect appears on the surface of the cloth, a wavy area will appear on the surface and its grayscale value will change. Pixels with small grayscale indicate that the wrinkles are more obvious and the pixels are more concentrated. Pixels with smaller edge grayscale values are arranged around the edge of the defect, and an affected area with smaller grayscale values will also be formed around the defect.
[0050] The main purpose of the present invention is to identify the shuttle mark defect on the surface of the cloth. In order to reduce the amount of calculation in defect identification, the obtained image can be partitioned. Because the size of the collected image is regular, it is directly partitioned into equal parts, and the image is equally divided into N*N block areas. This embodiment takes N=64 as an example for description. Other values can be set in other embodiments, and this embodiment does not make specific limitations. The shuttle mark defect on the surface of the cloth will have a change in grayscale, and its grayscale value is smaller than that of the cloth surface. Therefore, a preliminary screening can be performed based on the change in grayscale. If the grayscale changes in the block area, it needs to be identified; if the grayscale does not change in the block area, it does not need to be identified again, and only the block area with grayscale changes needs to be identified.
[0051] A fixed segmentation threshold T is set for the N*N block areas according to the performance under different thresholds. This embodiment is described by taking T=50 as an example. Other values may be set in other embodiments, and this embodiment does not specifically limit it. Because the grayscale value of the shuttle mark defect is smaller than the grayscale of the normal cloth surface, the two areas formed after segmentation using the segmentation threshold T, the area smaller than the threshold is the suspected shuttle mark defect area, and the other area is the normal cloth area. The suspected shuttle mark defect area smaller than the threshold is regarded as the suspected defect area.
[0052] At this point, the suspected defect area of each block area is obtained.
[0053] Step S003: Obtain the edge line of the suspected defect area, density cluster the edge pixels on the edge line of the suspected defect area, and obtain cluster blocks of different densities; obtain the edge area of the edge line, and obtain the degree of confusion of the pixels in the edge area according to the grayscale values of the pixels in the edge area of the edge line.
[0054] The edge line of the suspected defect area is obtained, and the edge line is the outline of the suspected defect area. Because the gray value of the defective pixel is small, and the defect is formed because the shuttle is rolled in the shuttle channel without punching out the yarn layer, the warp yarn is pulled or broken, the fabric structure is damaged or there are wrinkles locally, forming a wavy shuttle rolling mark defect, so the arrangement of the edge pixels will change, and the pixels with small gray values indicate that the wrinkles formed are more obvious, and the pixel points are more concentrated. The pixels with small edge gray values are arranged around the edge of the defect, and an affected area with a small gray value will also be formed around the defect, which needs to be distinguished according to the changes in the pixels.
[0055] The pixels in the suspected defect area are clustered at the edge of the defect, but are evenly distributed elsewhere. Due to the stacking of pixels in the suspected defect area, a shadow-like pixel cluster is generated in the image. The clustering is manifested by a smaller grayscale value of the pixels; and because the edge pixels diffuse outward to a small extent, a sudden change in grayscale occurs. Based on these characteristics, it is believed that the edge pixels of the rolling shuttle mark defect are more clustered.
[0056] In order to calculate the clustering characteristics of pixels, firstly, the edge line pixels are density clustered according to the distribution of edge pixels of each suspected defect area to obtain cluster blocks of different densities. Because the grayscale values of the pixels inside the edge line are uniform and the density of the pixels is large, the grayscale values of the pixels on the edge line have changed greatly, forming multiple cluster blocks, while the grayscale changes of the pixels outside the edge line are slightly smoother, and the density is large compared to the edge pixels. It should be noted here that the edge line is regarded as an area with a certain width, rather than a single edge line, so that when calculating the clustering of edge pixels, it can be calculated in a certain area. According to the edge detected by the above edge, the width of five pixels is extended to the inside and outside of the suspected defect area respectively, and the area of pixels of this width is recorded as the edge area of the edge line. Since the edge line is the outline of the suspected defect area, the edge line is closed, so the edge area has two inner and outer contour lines.
[0057] According to the grayscale distribution of edge pixels, the degree of discreteness of edge pixels is expressed. The greater the degree of discreteness, the lower the aggregation of pixels. First, the degree of disorder of edge pixels is calculated. The greater the degree of disorder of edge pixels, the greater the degree of change of pixels.
[0058] For the edge area of the edge line, the chaos degree feature of the pixel points in the edge area of the edge line is extracted, and the calculation formula is as follows:
[0059]
[0060] In the formula, Indicates the degree of confusion of pixels in the edge area of the edge line. The grayscale set of pixels in the edge area representing the edge line, The gray value of the pixel point in the edge area representing the edge line is The number of pixels, , The gray value of the pixel point in the edge area representing the edge line is The percentage of pixels in the entire edge area is It represents the entropy value, which is used to indicate the overall disorder of the edge area. The more gray values are distributed, the greater the disorder.
[0061] Step S004: Obtain the aggregation of the edge line according to the number of cluster blocks inside and outside the edge area of the edge line, the density of each cluster block, and the degree of disorder of the pixels in the edge area; obtain the grayscale sequence of the pixels around each circle of the edge line, obtain the grayscale difference sequence according to the grayscale sequence, and calculate the discreteness of each circle around the edge line according to the grayscale difference sequence.
[0062] The distribution of pixels is represented by the distribution entropy of the pixels in the edge area of the edge line, and then the aggregation of edge pixels on the edge line is calculated. According to the cluster blocks obtained above, the density of different cluster blocks and the number of cluster blocks change to obtain the degree of aggregation of edge pixels on the edge line. The degree of aggregation of pixels is reflected by the number of edge cluster blocks and the density of pixels in the cluster blocks. The fewer the number of cluster blocks in the edge area, the greater the density of pixels of the same grayscale, indicating greater aggregation. The aggregation characteristics of edge pixels in the edge area of the edge line are extracted, and the specific calculation formula is as follows:
[0063]
[0064] In the formula, It represents the aggregation of edge pixels in the edge area of the edge line, which is simply referred to as the aggregation of the edge line. represents the number of cluster blocks in the edge region of the edge line, Indicates the number of cluster blocks within the edge area except the edge line, that is, the number of cluster blocks inside the contour line in the edge area. Indicates the number of cluster blocks outside the edge area of the edge line, that is, the number of cluster blocks outside the outer contour line of the edge area. Indicates the first The density of cluster blocks is calculated based on the average distance between two pixels. It represents the average density of cluster blocks in the edge area. The greater the density of pixels in the cluster blocks, the greater the aggregation. It is a clustering feature, which represents the sum of the differences in the number of cluster blocks. If the number of cluster blocks in the edge area of the edge line is greater, the grayscale change is greater. If the number of cluster blocks is smaller, the grayscale change is smaller, and the dispersion of the pixels is smaller.
[0065] Since the greater the clustering of edge lines, the smaller the grayscale difference of the pixels in the area, the more likely it is a defect area, and the pixels in the edge area of the edge line can be defined as having a greater discreteness to the area, the discreteness of the edge pixels is obtained based on the distribution of the edge pixels.
[0066] First, obtain the grayscale sequence of pixels around the edge of the i-th circle , where Indicates the edge around The grayscale sequence of the circle's pixels, Indicates The gray value of the nth pixel in the circle, Indicates the edge line The smaller the grayscale difference of the pixel points, the smaller the discreteness of the suspected defect area is, and the more likely it is a defect area. The nth element in the grayscale difference sequence is recorded as ,in, , Indicates the edge line The gray value of the nth pixel in the gray sequence of the circle, represents the gray value of the n+1th pixel in the gray sequence, then the gray difference sequence , extract the discrete features of the grayscale difference sequence, and the calculation formula is as follows:
[0067]
[0068] In the formula, Indicates the edge line The discreteness of the grayscale difference sequence of the pixel points of the circle is simply recorded as the discreteness of the pixel points of the i-th circle of the edge line. represents the mean of the grayscale difference sequence of pixels around the i-th circle of the edge line, Around the edge line The number of pixels in the circle, the ratio is This formula is a variance formula and no logical explanation is given.
[0069] So far, the aggregation of edge lines and the first The discreteness of the circle pixels.
[0070] Step S005: Obtain the defect probability of each circle around the edge line based on the clustering of the edge line and the discreteness of each circle around the edge line, and obtain the probability that the suspected defect area belongs to the defect area based on the defect probabilities of all circles around the edge line; when the probability that the suspected defect area belongs to the defect area is greater than the preset probability threshold, mark the suspected defect area as a defect area.
[0071] According to the above method, the aggregation and the first The discreteness of the circle pixels, if the edge line aggregation and the edge line The larger the discreteness of the circle pixel points, the more likely it is that the area is a defect area. The discreteness of the circle pixel points can be used to obtain the probability of defective pixels, which is calculated as follows:
[0072]
[0073] In the formula, Indicates the edge line The probability that the circled pixel belongs to the defect area is simply called the defect probability, and e represents a natural constant. Represents the normalization process.
[0074] In this embodiment, there are 5 circles of pixels around the edge line, and the average of the probabilities that all the circle pixels on the edge line of the suspected defect area belong to the defect area is recorded as the probability that the suspected defect area belongs to the defect area. When the probability is greater than the preset probability threshold P, it means that the suspected defect area is a defect area. This embodiment takes P=0.62 as an example for description. Other embodiments can set other values. This embodiment does not specifically limit it. Then mark the obtained defects for manual verification.
[0075] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A cloth defect recognition method, characterized in that: The method comprises the following steps: Obtaining a grayscale image of the cloth surface image; Obtaining block regions of the grayscale image, segmenting each block region using a preset segmentation threshold, and obtaining a suspected defect region of each block region; Obtaining the edge line of the suspected defect area, performing density clustering on the edge pixel points on the edge line of the suspected defect area, and obtaining cluster blocks with different densities; obtaining the edge area of the edge line, and obtaining the degree of disorder of the pixel points in the edge area according to the grayscale values of the pixel points in the edge area of the edge line; According to the number of cluster blocks inside and outside the edge area of the edge line, the density of each cluster block and the degree of disorder of the pixels in the edge area, the aggregation of the edge line is obtained; the grayscale sequence of the pixels around each circle of the edge line is obtained, the grayscale difference sequence is obtained according to the grayscale sequence, and the discreteness of each circle around the edge line is calculated according to the grayscale difference sequence; The defect probability of each circle around the edge line is obtained according to the aggregation of the edge line and the discreteness of each circle around the edge line, and the probability that the suspected defect area belongs to the defect area is obtained according to the defect probability of all circles around the edge line; When the probability that the suspected defective area belongs to the defective area is greater than a preset probability threshold, marking the suspected defective area as a defective area; The specific steps of obtaining the probability that the suspected defect area belongs to the defect area according to the defect probabilities of all circles around the edge line are as follows: The mean of the defect probabilities of all circles on the edge line of the suspected defect area is recorded as the probability that the suspected defect area belongs to the defect area.
2. A cloth defect identification method according to claim 1, characterized in that: The step of obtaining the grayscale image block regions, segmenting each block region using a preset segmentation threshold, and obtaining the suspected defect region of each block region includes the following specific steps: The grayscale image is segmented and the image is equally divided into N*N block areas. The area in the block area that is smaller than a preset segmentation threshold is regarded as a suspected defect area, where N is a preset value.
3. A cloth defect identification method according to claim 1, characterized in that: The step of obtaining the edge area of the edge line includes the following specific steps: A width of five pixels is extended to the inside and the outside of the suspected defect area respectively, and the area of the pixels of the width is recorded as the edge area of the edge line.
4. A cloth defect identification method according to claim 1, characterized in that: The specific calculation formula for obtaining the disorder degree of the pixel points in the edge area according to the grayscale value of the pixel points in the edge area of the edge line is as follows: In the formula, Indicates the degree of confusion of pixels in the edge area of the edge line. The grayscale set of pixels in the edge area representing the edge line, The gray value of the pixel point in the edge area representing the edge line is The number of pixels, .
5. A cloth defect identification method according to claim 1, characterized in that: The method of obtaining the aggregation of edge lines according to the number of cluster blocks inside and outside the edge area of the edge line, the density of each cluster block, and the degree of disorder of pixels in the edge area includes the following specific steps: The clustering features are obtained according to the number of cluster blocks inside and outside the edge area of the edge line. , the formula for obtaining the clustering of edge lines based on clustering features is as follows: In the formula, Indicates the aggregation of edge lines, Indicates The density of cluster blocks, Indicates the degree of confusion of pixels in the edge area of the edge line. Indicates the number of cluster blocks within the edge region of the edge line.
6. A cloth defect identification method according to claim 5, characterized in that: The clustering feature is obtained according to the number of cluster blocks inside and outside the edge area of the edge line , including the following specific formulas: In the formula, represents the number of cluster blocks within the edge area excluding the edge line, Indicates the number of cluster blocks excluding the edge area of the edge line.
7. A cloth defect identification method according to claim 1, characterized in that: The discreteness of each circle around the edge line is calculated according to the grayscale difference sequence, and the specific formula included is as follows: In the formula, represents the discreteness of the ith circle around the edge line, represents the mean of the grayscale difference sequence of pixels around the i-th circle of the edge line, Around the edge line The number of pixels in the circle, Represents the nth element in the grayscale difference sequence.
8. A cloth defect identification method according to claim 1, characterized in that: The step of obtaining the grayscale difference sequence according to the grayscale sequence includes the following specific steps: The nth element in the grayscale difference sequence is recorded as ,in, , Indicates the edge line The gray value of the nth pixel in the gray sequence of the circle, represents the gray value of the n+1th pixel in the gray sequence, then the gray difference sequence , m represents the number of The number of pixels in the circle.
9. A cloth defect identification method according to claim 1, characterized in that: The defect probability of each circle around the edge line is obtained according to the aggregation of the edge line and the discreteness of each circle around the edge line, and the specific calculation formula included is as follows: In the formula, Indicates the edge line The defect probability of the circle, It is expressed as the clustering of edge lines, represents the discreteness of the i-th circle of pixels of the edge line, and e represents a natural constant.
