A method for identifying cloth scratch defects
By analyzing the grayscale histogram and texture features of the grayscale image of the cloth, combined with the clustering algorithm to identify cloth scratch defects, the problem of low accuracy of human visual inspection is solved and the accuracy of identification of scratch defects is improved.
Patent Information
- Application Number
- CN202410977792.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-07-22
AI Technical Summary
In the existing technology, the identification of fabric scratch defects relies on human visual inspection, which has low accuracy and is difficult to effectively identify the scratch defects of fabrics during the textile process and after dyeing.
By acquiring the grayscale image of the cloth, constructing the grayscale histogram and grayscale co-occurrence matrix, calculating the abnormality degree and texture direction of the target point, combined with the DBSCAN clustering algorithm to identify suspected defective areas, and then locate the scratched area.
It improves the accuracy of identifying cloth scratch defects, can quantitatively assess the degree of abnormality, effectively identify potential defect areas, and reduce human errors.
Smart Images

Figure CN118521778B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data processing, and in particular to a method for identifying cloth abrasion defects. Background Art
[0002] Fabric abrasion is a defect in which the surface of the fabric is damaged by friction during the textile process or after dyeing, causing local fuzziness and uneven dyeing. During the textile process, due to friction between equipment and machines, the spinning yarn becomes partially fuzzy. In the subsequent dyeing process, the color of the fuzzy parts is different from that of the normal parts, which makes the appearance quality of the fabric unqualified and downgraded; and after dyeing, friction damage will damage the colored parts, causing the fabric quality to be unqualified and downgraded, causing losses to the textile factory. In the textile process, the fabric and the machine are always in relative motion, almost accompanying the life of the fabric from production to delivery, and there are various contacts with the fabric, so the textile process is very easy to cause abrasions.
[0003] Since scratches only affect the dyed color on the surface of the fabric, the extent of the impact of scratches on the overall fabric can only be determined after dyeing. Currently, most of the scratch identification on fabrics is done by human visual inspection, which is limited by human subjectivity and fatigue, making the accuracy of visual inspection unguaranteed, reducing the accuracy of fabric scratch defect identification. Summary of the invention
[0004] The invention provides a cloth abrasion defect recognition method to solve the existing problems.
[0005] A method for identifying cloth scratch defects of the present invention adopts the following technical solution:
[0006] An embodiment of the present invention provides a method for identifying cloth scratch defects, the method comprising the following steps:
[0007] Obtain a grayscale image of the cloth, and record any pixel point in the grayscale image of the cloth as a target point;
[0008] Constructing a grayscale histogram of the grayscale image of the cloth, and obtaining a first abnormality degree of the target point according to the peak value in the grayscale histogram and the grayscale value of the target point;
[0009] Construct a neighborhood window of the target point, and obtain the texture direction according to the gray level co-occurrence matrix corresponding to the neighborhood window in different directions; divide the gray value of the pixel point in the neighborhood window into several gray value sequences of the pixel point according to the texture direction; obtain the defect possibility of the target point according to the first abnormality degree of the target point and the peak and valley values in the gray value sequence of the pixel point;
[0010] According to the defect possibility of the target point, the suspected defect area in the grayscale image of the cloth is identified;
[0011] According to the suspected defective area in the grayscale image of the cloth, the scratched area in the grayscale image of the cloth is identified.
[0012] Furthermore, the step of obtaining the first abnormality degree of the target point according to the peak value in the grayscale histogram and the grayscale value of the target point includes the following specific steps:
[0013] The peak detection algorithm is used to obtain the two gray value peaks with the largest number of pixels in the gray value histogram, and the two gray value peaks are recorded as target peaks;
[0014] The first abnormality degree of the target point is obtained according to the grayscale value of the target point, the grayscale value corresponding to the first target peak value, and the grayscale value corresponding to the second target peak value.
[0015] Furthermore, the first abnormality degree of the target point is obtained according to the gray value of the target point, the gray value corresponding to the first target peak value, and the gray value corresponding to the second target peak value. The corresponding specific calculation formula is:
[0016]
[0017] in, Indicates the first abnormality degree of the target point; Represents the gray value of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; express and The minimum value in ; Represents an exponential function with a natural constant as its base.
[0018] Furthermore, the construction of the neighborhood window of the target point includes the following specific steps:
[0019] Taking the target point in the cloth grayscale image as the center, construct a The neighborhood window of The side length of the preset neighborhood window.
[0020] Furthermore, the texture direction is obtained according to the gray level co-occurrence matrix corresponding to the neighborhood window in different directions, and the specific steps include the following:
[0021] Take the horizontal right direction as 0 degrees, start from the horizontal right direction, rotate clockwise, and determine a direction every 45 degrees to get eight directions;
[0022] Construct the grayscale co-occurrence matrix of the cloth grayscale image in each direction, calculate the angular moment of the grayscale co-occurrence matrix of the cloth grayscale image in each direction, and record the direction corresponding to the minimum value of the angular moment of the grayscale co-occurrence matrix in all directions as the texture direction.
[0023] Furthermore, the grayscale values of pixels in the neighborhood window are divided into a plurality of grayscale value sequences of pixels according to the texture direction, and the specific steps include the following:
[0024] In the neighborhood window of the target point, the grayscale values of all pixels on any straight line corresponding to the normal direction of the texture direction form a grayscale value sequence of pixels, and several grayscale value sequences of non-repeated pixels in the neighborhood window of the target point are obtained.
[0025] Furthermore, the defect possibility of the target point is obtained according to the first abnormality degree of the target point and the peak value and the valley value in the gray value sequence of the pixel point, and the specific steps include the following:
[0026] For the grayscale value sequences of all pixels in the neighborhood window of the target point, all peak values in the grayscale value sequence of each pixel are obtained according to the peak detection algorithm, and all valley values in the grayscale value sequence of each pixel are obtained according to the peak-valley detection algorithm;
[0027] The defect possibility of the target point is obtained according to the first abnormality degree of the target point, the mean of all peak values in the grayscale value sequence of each pixel point in the neighborhood window of the target point, the mean of all valley values in the grayscale value sequence of each pixel point in the neighborhood window of the target point, the grayscale value corresponding to the first target peak and the grayscale value corresponding to the second target peak.
[0028] Furthermore, the defect possibility of the target point is obtained according to the first abnormality degree of the target point, the mean of all peak values in the gray value sequence of each pixel point in the neighborhood window of the target point, the mean of all valley values in the gray value sequence of each pixel point in the neighborhood window of the target point, the gray value corresponding to the first target peak value, and the gray value corresponding to the second target peak value. The corresponding specific calculation formula is:
[0029]
[0030] in, The defect probability of the target point; is the first abnormality degree of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; is the number of gray value sequences of pixels in the neighborhood window where the target point is located; is the first The mean of all peak values in the grayscale value sequence of a pixel; is the first The mean of all valley values in the grayscale value sequence of a pixel; represents an exponential function with a natural constant as base; is the absolute value function.
[0031] Furthermore, the method of identifying the suspected defective area in the grayscale image of the cloth according to the defect possibility of the target point includes the following specific steps:
[0032] The defect probability in the cloth grayscale image is greater than the preset defect threshold All pixels are recorded as defective pixels, and the DBSCAN clustering algorithm is used to cluster all defective pixels to obtain several suspected defective areas in the cloth grayscale image.
[0033] Furthermore, the method of identifying the scratched area in the cloth grayscale image according to the suspected defective area in the cloth grayscale image includes the following specific steps:
[0034] The number of pixels in the suspected defect area in the cloth grayscale image is greater than the preset defect pixel threshold The suspected defect area is recorded as the scratch area in the grayscale image of the cloth.
[0035] The technical solution of the present invention has the following beneficial effects: a cloth grayscale image is obtained, any pixel point in the cloth grayscale image is recorded as a target point, and a grayscale histogram of the cloth grayscale image is constructed, so as to analyze the grayscale distribution in the cloth grayscale image; according to the peak value in the grayscale histogram and the grayscale value of the target point, the characteristics of the first abnormality degree of the target point are extracted, so as to quantitatively evaluate the abnormality degree of the target point; a neighborhood window of the target point is constructed, and a grayscale value sequence of several pixel points in the neighborhood window of the target point is obtained, which is helpful to extract the grayscale information of the area around the target point; according to the first abnormality degree of the target point and the grayscale value sequence of the pixel points, the characteristics of the defect possibility of the target point are extracted, so as to locate the potential defect; according to the defect possibility of the target point, the suspected defect area in the cloth grayscale image is identified, and the target area is provided for subsequent abrasion recognition; according to the suspected defect area in the cloth grayscale image, the abrasion area in the cloth grayscale image is identified, so as to improve the accuracy of cloth abrasion defect recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] 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.
[0037] Figure 1 A flowchart of the steps of a method for identifying a cloth scratch defect according to the present invention;
[0038] Figure 2 It is a grayscale image of cloth. DETAILED DESCRIPTION
[0039] 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 scratch defects proposed by the present invention, its specific implementation method, 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.
[0040] 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.
[0041] The specific scheme of the cloth abrasion defect identification method provided by the present invention is described in detail below with reference to the accompanying drawings.
[0042] See also Figure 1 , which shows a flowchart of a method for identifying a cloth scratch defect provided by an embodiment of the present invention, the method comprising the following steps:
[0043] Step S001: Obtain a grayscale image of the cloth, and record any pixel point in the grayscale image of the cloth as a target point.
[0044] After the cloth is woven, it needs to be sent to the printing and dyeing machine on a conveyor belt. Through multiple superpositions of printing on the conveyor belt, it will eventually present a beautiful pattern. The relative movement between printing and the conveyor belt and the cloth will cause abrasions.
[0045] Therefore, the image capture module is placed at the end of the conveyor belt. Each time the printed product is transmitted along the conveyor belt, the capture module uses the camera to take a picture to capture the cloth image. The captured cloth image is grayed to obtain a cloth grayscale image, such as Figure 2 As shown. Any pixel point in the cloth grayscale image is recorded as the target point. The target point is the first pixel point in the cloth grayscale image. Pixels.
[0046] Step S002: construct a grayscale histogram of the cloth grayscale image, and obtain a first abnormality degree of the target point according to the peak value in the grayscale histogram and the grayscale value of the target point.
[0047] The cloth has texture after weaving, and any kind of abrasion will cause the grayscale value of the abnormal area of the image to change. The grayscale value change of the abraded area will change according to the color depth of the dye, and the deeper the abrasion, the greater the damage to the cloth and the greater the color change.
[0048] In the scratch area, since the fabric is composed of interlaced sinking lines and floating lines, the texture features are formed on the surface of the fabric, so its surface is not uniform in color. When it is scratched, the floating lines first contact the equipment and are scratched. If the sinking lines need to be scratched with greater force, the floating lines will be severely scratched. For normal fabrics, since the grayscales of sinking lines and floating lines are different, there are obvious double peaks in the grayscale histogram. The farther the target point is from the grayscale difference of the double peaks, the more likely the target point is an abnormal pixel.
[0049] Specifically, a grayscale histogram is constructed for the grayscale image of the cloth, the horizontal axis represents the grayscale value of the pixel point, and the vertical axis represents the number of pixels corresponding to the grayscale value. The peak detection algorithm is used to obtain the two grayscale value peaks with the largest number of pixels in the grayscale histogram, and the two grayscale value peaks are recorded as target peaks. The peak detection algorithm is a well-known technology, and the specific method is not introduced here. The calculation formula for the first abnormality degree of the target point is:
[0050]
[0051] in, Indicates the first abnormality degree of the target point; Represents the gray value of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; express and The minimum value in ; represents an exponential function with a natural constant as the base; when the gray value of the target point is different from the gray value of the closest target peak value of the two target peak values, it means that the target point is less likely to belong to the sinking line or floating line, and the location of the target point is more likely to be a scratch defect, and the first abnormality is greater. Therefore, according to the peak value in the gray histogram and the gray value of the target point, the first abnormality feature of the target point is extracted.
[0052] Step S003: construct a neighborhood window of the target point, and obtain the texture direction according to the grayscale co-occurrence matrix corresponding to the neighborhood window in different directions; divide the grayscale values of the pixels in the neighborhood window into several grayscale value sequences of the pixels according to the texture direction; obtain the defect possibility of the target point according to the first abnormality degree of the target point and the peak and valley values in the grayscale value sequence of the pixel points.
[0053] For the scratched area, since it destroys the alternating appearance of the grayscale values of the sunken lines and the floating lines in the normal area, that is, the grayscale distribution difference in the scratched area is reduced, therefore, for the neighborhood range of each target point, the greater the difference between the double peak values in its neighborhood range and the double peak values of the cloth grayscale image, the greater the possibility of being a scratch; it should be further explained that, for normal cloth, the grayscale values of the floating lines and the sunken lines are distributed alternately, that is, the grayscale values show the alternating existence of the double peak values corresponding to the double peak values in the direction of the cloth texture, and due to the scratches, the grayscale values of the floating lines are close to the grayscale values of the sunken lines, then there is an obvious difference between the alternating double peak values of the sunken lines and the peak fluctuation amplitude of the cloth grayscale image, and therefore the target point with obvious difference is more likely to be a defective target point.
[0054] In this embodiment, the horizontal right direction is taken as 0 degrees, starting from the horizontal right direction and rotating clockwise, a direction is determined every 45 degrees to obtain eight directions; a grayscale co-occurrence matrix of the cloth grayscale image in each direction is constructed, and the angular moment of the grayscale co-occurrence matrix of the cloth grayscale image in each direction is calculated; wherein, the grayscale co-occurrence matrix and the angular moment are well-known technologies, and the specific method is not introduced here.
[0055] The smaller the value of the angular moment, the more obvious the difference and uneven distribution of pixels in the grayscale image of the cloth, that is, the more likely it is that there is a directional texture. The direction corresponding to the minimum value of the angular moment of the grayscale co-occurrence matrix in all directions is recorded as the texture direction, thereby extracting the characteristics of the texture direction.
[0056] The side length of the neighborhood window preset in this embodiment is The value is 50, which is described by taking this as an example. Other values may be set in other implementation modes, and this embodiment does not limit this.
[0057] Taking the target point in the cloth grayscale image as the center, construct a In the neighborhood window of the target point, the grayscale values of all pixels on any straight line corresponding to the normal direction of the texture direction form a grayscale value sequence of a pixel point, thereby obtaining a grayscale value sequence of several non-repeated pixels in the neighborhood window of the target point, that is, the characteristics of the grayscale value sequence of the pixel point are extracted. An example is given as follows: , if the normal of the texture direction is horizontal, the grayscale value sequences of the pixels are , and .
[0058] Then the corresponding situation in the grayscale image of the cloth is: the texture is cross-sectioned, and the grayscale value sequence of the pixel points shows that the grayscale value sinking line-floating line-sinking line-floating line appears alternately, that is, the grayscale value will show peak-to-valley fluctuations. Then for the grayscale value sequence of all pixels in the neighborhood window of the target point, all peaks in the grayscale value sequence of the pixel points are obtained according to the peak detection algorithm, and all valleys in the grayscale value sequence of the pixel points are obtained according to the peak-to-valley detection algorithm, and the mean of all peaks and valleys are calculated respectively, among which the peak detection algorithm and the peak-to-valley detection algorithm are well-known technologies, and the specific methods are not introduced here. The calculation formula for the defect possibility of the target point is:
[0059]
[0060] in, The defect probability of the target point; is the first abnormality degree of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; is the number of gray value sequences of pixels in the neighborhood window where the target point is located; is the first The mean of all peak values in the grayscale value sequence of a pixel; is the first The mean of all valley values in the grayscale value sequence of a pixel; represents an exponential function with a natural constant as base; is the absolute value function; The closer the value is to 1, the The closer the fluctuation of the peak and valley values of the gray value sequence of the pixel points is to the overall fluctuation of the gray image of the cloth, the more likely it is that the area in its neighborhood window is a normal area. When the cloth is scratched, the gray value changes, so the fluctuation of the peak and valley values in its neighborhood window is significantly different from the overall fluctuation of the gray image of the cloth, so the possibility of a scratch defect is high. The larger the value; The larger the value of , the more likely it is that the target point is abnormal. Based on the first abnormality degree of the target point and the gray value sequence of the pixel points, the characteristics of the defect possibility of the target point are extracted.
[0061] Step S004: Identify suspected defect areas in the grayscale image of the cloth according to the defect possibility of the target point.
[0062] The defect threshold preset in this embodiment , which is described as an example, and can be set to other values in other implementations, which are not limited in this embodiment. After obtaining the defect possibility of the target point, filter out the defect possibility in the cloth grayscale image greater than the defect threshold All pixels are recorded as defective pixels, and the DBSCAN clustering algorithm is used to cluster all defective pixels. The clustering result is a number of suspected defective areas formed by defective pixels, thereby identifying the suspected defective areas in the grayscale image of the cloth. Among them, the DBSCAN clustering algorithm is a well-known technology, and the specific method is not introduced here. The parameters of the algorithm are neighborhood radius 3 and the minimum sample number threshold is 6, taking this as an example.
[0063] Step S005: Identify the scratched area in the cloth grayscale image based on the suspected defective area in the cloth grayscale image.
[0064] The defective pixel threshold value preset in this embodiment , which is described as an example, and other implementations may be set to other values, which are not limited in this embodiment. When the number of pixels in the suspected defect area is greater than When , it indicates that the suspected defect area is larger and belongs to the scratch area, thus the scratch area is identified from the suspected defect area.
[0065] So far, the present invention is completed.
[0066] To sum up, in the embodiments of the present invention, 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 method for identifying cloth scratch defects, characterized in that: The method comprises the following steps: Obtain a grayscale image of the cloth, and record any pixel point in the grayscale image of the cloth as a target point; Constructing a grayscale histogram of the grayscale image of the cloth, and obtaining a first abnormality degree of the target point according to the peak value in the grayscale histogram and the grayscale value of the target point; Construct a neighborhood window of the target point, and obtain the texture direction according to the gray level co-occurrence matrix corresponding to the neighborhood window in different directions; divide the gray value of the pixel point in the neighborhood window into several gray value sequences of the pixel point according to the texture direction; obtain the defect possibility of the target point according to the first abnormality degree of the target point and the peak and valley values in the gray value sequence of the pixel point; According to the defect possibility of the target point, the suspected defect area in the grayscale image of the cloth is identified; According to the suspected defective area in the grayscale image of the cloth, the scratched area in the grayscale image of the cloth is identified; The method of obtaining the first abnormality degree of the target point according to the peak value in the grayscale histogram and the grayscale value of the target point includes the following specific steps: The peak detection algorithm is used to obtain the two gray value peaks with the largest number of pixels in the gray value histogram, and the two gray value peaks are recorded as target peaks; The first abnormality degree of the target point is obtained according to the gray value of the target point, the gray value corresponding to the first target peak, and the gray value corresponding to the second target peak; The first abnormality degree of the target point is obtained according to the gray value of the target point, the gray value corresponding to the first target peak value, and the gray value corresponding to the second target peak value. The corresponding specific calculation formula is: in, Indicates the first abnormality degree of the target point; Represents the gray value of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; express and The minimum value in ; represents an exponential function with a natural constant as base; The method of obtaining the defect possibility of the target point according to the first abnormality degree of the target point and the peak value and the valley value in the gray value sequence of the pixel point includes the following specific steps: For the grayscale value sequences of all pixels in the neighborhood window of the target point, all peak values in the grayscale value sequence of each pixel are obtained according to the peak detection algorithm, and all valley values in the grayscale value sequence of each pixel are obtained according to the peak-valley detection algorithm; The defect possibility of the target point is obtained according to the first abnormality degree of the target point, the mean of all peak values in the gray value sequence of each pixel point in the neighborhood window of the target point, the mean of all valley values in the gray value sequence of each pixel point in the neighborhood window of the target point, the gray value corresponding to the first target peak value, and the gray value corresponding to the second target peak value; According to the first abnormality degree of the target point, the mean of all peak values in the grayscale value sequence of each pixel point in the neighborhood window of the target point, the mean of all valley values in the grayscale value sequence of each pixel point in the neighborhood window of the target point, the grayscale value corresponding to the first target peak value and the grayscale value corresponding to the second target peak value, the defect possibility of the target point is obtained, and the corresponding specific calculation formula is: in, The defect probability of the target point; is the first abnormality degree of the target point; Indicates the gray value corresponding to the first target peak; Indicates the gray value corresponding to the second target peak; is the number of gray value sequences of pixels in the neighborhood window where the target point is located; is the first The mean of all peak values in the grayscale value sequence of a pixel; is the first The mean of all valley values in the grayscale value sequence of a pixel; represents an exponential function with a natural constant as base; is the absolute value function.
2. A cloth scratch defect identification method according to claim 1, characterized in that: The specific steps of constructing the neighborhood window of the target point are as follows: Taking the target point in the cloth grayscale image as the center, construct a The neighborhood window of The side length of the preset neighborhood window.
3. The method for identifying cloth scratch defects according to claim 1, characterized in that: The specific steps of obtaining the texture direction according to the gray level co-occurrence matrix corresponding to the neighborhood window in different directions are as follows: Take the horizontal right direction as 0 degrees, start from the horizontal right direction, rotate clockwise, and determine a direction every 45 degrees to get eight directions; Construct the grayscale co-occurrence matrix of the cloth grayscale image in each direction, calculate the angular moment of the grayscale co-occurrence matrix of the cloth grayscale image in each direction, and record the direction corresponding to the minimum value of the angular moment of the grayscale co-occurrence matrix in all directions as the texture direction.
4. The method for identifying cloth scratch defects according to claim 1, characterized in that: The method of dividing the grayscale values of pixels in the neighborhood window into a plurality of grayscale value sequences of pixels according to the texture direction includes the following specific steps: In the neighborhood window of the target point, the grayscale values of all pixels on any straight line corresponding to the normal direction of the texture direction form a grayscale value sequence of pixels, and several grayscale value sequences of non-repeated pixels in the neighborhood window of the target point are obtained.
5. The method for identifying cloth scratch defects according to claim 1, characterized in that: The method of identifying the suspected defect area in the grayscale image of the cloth according to the defect possibility of the target point includes the following specific steps: The defect probability in the cloth grayscale image is greater than the preset defect threshold All pixels are recorded as defective pixels, and the DBSCAN clustering algorithm is used to cluster all defective pixels to obtain several suspected defective areas in the cloth grayscale image.
6. The method for identifying cloth scratch defects according to claim 1, characterized in that: The method of identifying the scratched area in the cloth grayscale image according to the suspected defective area in the cloth grayscale image includes the following specific steps: The number of pixels in the suspected defect area in the cloth grayscale image is greater than the preset defect pixel threshold The suspected defect area is recorded as the scratch area in the grayscale image of the cloth.
Citation Information
Patent Citations
Cloth defect detection method based on image processing
CN114723705A
Cloth burr defect detection method
CN115330795A
Geosynthetic fabric quality detection system
CN116309671A
Textile fabrics examination method and the device
KR1020090022419A
