Textile defect detection method based on image processing
Through image processing-based methods, using autocorrelation function and spectrum diagram analysis, the problem of inaccurate textile defect detection results is solved, and the accurate detection and positioning of textile defects is achieved, and the accuracy and efficiency of detection are improved.
Patent Information
- Application Number
- CN202510685218.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-06-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The results of textile defect detection are inaccurate and are affected by environmental factors, lighting changes, imaging angle, fabric softness and tensile properties.
Using an image-based processing method, by acquiring historical fabric images for preprocessing, the autocorrelation function is calculated to determine the grid size, the fabric images are divided and spectral map analysis are analyzed, and the spectrum difference between real-time fabric map and defect map is calculated to achieve defect detection.
It realizes accurate detection and positioning of textile defects, and can analyze new fabric images in real time, with high accuracy and reliability, improves detection sensitivity and accuracy, and reduces labor costs.
Smart Images

Figure CN120198435A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of textile defect detection. More specifically, the present invention relates to a textile defect detection method based on image processing. Background Art
[0002] Textiles are one of the basic materials commonly used in modern industry and daily life, and are applied in multiple fields such as clothing, household items, industrial equipment, medical and health, etc. With the rapid development of the textile industry, how to improve production efficiency, reduce costs, and ensure product quality has become an important issue in the industry. Traditional textile quality inspection mostly relies on manual inspection, which not only increases production costs, but also is prone to missed inspections or misinspections due to human negligence, fatigue, etc., seriously affecting the stability of product quality and the competitiveness of enterprises.
[0003] In recent years, with the continuous progress of artificial intelligence, computer vision technology, and deep learning algorithms, automated detection methods based on image processing have gradually become a research hotspot in the field of textile defect detection. Image processing technology can capture detailed information of textiles through a camera device, and then use computer algorithms to analyze the images to accurately identify and classify various defects, such as fabric breakage, stains, color differences, pattern misalignment, etc. Compared with traditional manual inspection methods, the defect detection system based on image processing has the advantages of high speed, high accuracy, and high automation.
[0004] However, different types of textiles have differences in material, texture, color, etc., resulting in different defect manifestations. In addition, environmental factors, light changes, camera angles, the softness and stretchability of fabrics, etc. will all affect the image quality and the accuracy of defect detection, resulting in inaccurate textile defect detection results. Summary of the Invention
[0005] To solve the technical problem of inaccurate textile defect detection results, the present invention provides a textile defect detection method based on image processing. The method includes: obtaining preprocessed fabric images in history and marking the defect types of the fabric images; for any fabric image, using the autocorrelation function to calculate the period to determine the grid size; dividing the fabric images of different defect types in history according to the grid size, extracting the grids at the defect positions as defect grids, and obtaining the spectrogram of the defect grids; dividing the real-time fabric image obtained in real time according to the grid size to obtain real-time grids, and obtaining the spectrogram of each real-time grid, and respectively calculating the spectral difference between the spectrogram of any real-time grid and the spectrogram of any defect grid to complete defect detection.
[0006] Preferably, the preprocessing includes: graying the fabric RGB images obtained in history and performing filtering denoising to complete the preprocessing.
[0007] Preferably, the determining the grid size includes: taking the time interval as the period in response to the maximum of the autocorrelation function; traversing to obtain the periods of each row of pixel value sequences, taking the period with the highest occurrence frequency as the grid length, and obtaining the calculation of the grid width in the same way according to the calculation of the grid length, so as to obtain the grid size.
[0008] Preferably, the spectral difference satisfies the relational expression: , represents the real-time grid and the defective grid of the spectral difference, represents the real-time grid in the spectrogram of the row and the column value of the defective grid in the spectrogram of the represents the two-norm.
[0009] Preferably, the completing the defect detection includes: traversing to obtain the spectral differences between any real-time grid and each defective grid, and the one with the minimum spectral difference is the defect of the real-time grid.
[0010] Preferably, it further includes: taking any defect type as the target defect, taking other defect types except the target defect as the control defects, and taking the fabric map of the target defect as the target map; respectively calculating the spectral difference maps between the spectrogram of the target map and the spectrograms of a number of normal fabric maps, counting the number of non-zero positions at each location to obtain a difference matrix; calculating the importance of each position in the spectrogram for identifying the target defect according to the difference matrix, taking the normalized importance as the weight, and weighted summing the spectral differences to obtain the defect degree of the target defect existing in the real-time fabric map; in response to the defect degree being greater than the preset defect threshold, there is a target defect in the real-time fabric map.
[0011] Preferably, the importance satisfies the relational expression: , represents the importance of the position in the spectrogram for identifying the target defect , represents the target defect in the difference matrix between the spectrogram of the position of the and the spectrogram of the normal fabric map, the element value of the position,
[0012] Preferably, the defect degree satisfies the relational expression: , indicates the presence of target defects in the real-time fabric image and the degree of the defect, indicates in the spectrogram the importance of the position for the recognition of the target defect and, indicates the spectral difference between the real-time fabric image and the normal fabric image at the position.
[0013] Advantages of the present invention: Through preprocessing, grid division, and spectrogram analysis, the present invention can accurately extract the defect features in the fabric and achieve matching with different defect types through spectral difference analysis. In this way, defects in the fabric can be detected in real time and their severity can be quantified, thereby providing an efficient solution for the quality control of textiles.
[0014] It can not only process historical image data but also analyze new fabric images in real time, with high accuracy and reliability. At the same time, by calculating the importance of each position for defect recognition and performing weighted processing, the sensitivity and accuracy of the detection are further improved, so that the detection efficiency of the production line can be greatly increased, the labor cost can be reduced, and the quality stability of textiles can be ensured in practical applications. Description of the drawings
[0015] Figure 1 is a flowchart of a method for detecting textile defects based on image processing according to an embodiment of the present invention. Specific embodiments
[0016] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention.
[0017] Next, the specific embodiments of the present invention will be described in detail in conjunction with the drawings.
[0018] Referring to Figure 1 , a method for detecting textile defects based on image processing includes steps S1 - S4, specifically as follows: S1: Obtain the preprocessed fabric images in history and mark the defect types for the fabric images.
[0019] In one embodiment, when using an industrial camera to capture textile images, it is necessary to grayscale the captured RGB images, converting the color images into single-channel grayscale images, thereby simplifying the subsequent image processing process. After grayscaling, filtering and denoising is a necessary step to remove the noise in the images and improve the quality and clarity of the images. Exemplarily, the filtering methods include mean filtering, Gaussian filtering or median filtering.
[0020] After filtering and denoising, a preprocessed fabric image is obtained. Defect detection and marking are performed on the fabric image. For example, defect types such as cracks, stains, damages, foreign objects, etc. on the fabric are marked.
[0021] S2: For any fabric image, use the autocorrelation function to calculate the period to determine the grid size.
[0022] It should be noted that the texture of textiles usually has obvious periodicity, which is a common feature in textile design and manufacturing. When detecting textile defects, the periodicity of the texture can be utilized to assist in identifying abnormalities. Generally, the texture of textiles should maintain a certain regularity and consistency, and any change that does not conform to this periodic pattern may indicate potential defects. For example, when there are alternating textures with different periods on the fabric surface, or when the arrangement of the texture is disordered, uneven, etc., it indicates that the textile may have problems such as weaving defects, uneven dyeing, or fabric surface damage. By monitoring and analyzing the periodic changes of the texture, these problems can be discovered and located in a timely manner, thereby improving the quality control level and production efficiency of textiles.
[0023] In one embodiment, for any fabric image, the periodicity of its texture can be calculated through the autocorrelation function.
[0024] The autocorrelation function is a method for measuring the repeatability of a sequence of image pixel values in space or time.
[0025] By calculating the autocorrelation function of the image, find the point with the largest autocorrelation function value. The time interval corresponding to this point is the period of the image, reflecting the regularity of the texture. Then, traverse each row of the pixel value sequence of the image and calculate the autocorrelation function for each row, thereby obtaining the period of each row. By statistically analyzing the occurrence frequencies of all row periods, a most common period can be determined, and this period can be regarded as the grid length of the fabric image.
[0026] Using a similar method, calculate the period along each column of the pixel value sequence, and obtain the most common period from it as the width of the grid.
[0027] Finally, through the calculation of the grid length and grid width, the grid size of the fabric is obtained. In this way, through periodic analysis, the structural characteristics of the fabric pattern can be accurately identified, providing a basis for defect detection and quality control.
[0028] In another embodiment, in order to reduce the computational amount, the texture period can be calculated by randomly selecting the gray value sequences of several rows instead of calculating the period of each row. This is because in the image, the change of gray values usually has a certain regularity, and different rows have great similarity in the overall texture characteristics. By only selecting the gray value sequences of some rows for period calculation, the computational resources and time consumption can be effectively reduced, while ensuring the representativeness and accuracy of the calculation results. By randomly selecting the number of rows, both over - calculation can be avoided and the periodic characteristics of the texture can be better captured.
[0029] S3: Divide the fabric images of different defect types in history according to the grid size, extract the grids at the defect positions as defect grids, and obtain the spectrogram of the defect grids.
[0030] It should be noted that when the textile has no defects, the spectrograms of each grid should show consistency because the normal fabric texture has regularity. In the spectrogram, the normal texture structure usually forms obvious energy peaks at specific frequency positions, and these peaks reflect the characteristics of the fabric such as periodicity, directionality, and uniformity. By observing the peak positions, intensities, and distributions in the spectrogram, the structural information of the fabric can be extracted, such as the repetition period of the texture, the dominant direction of the texture, and the overall uniformity of the fabric. However, when the textile has defects, the original regular texture structure will be damaged, thus affecting the energy distribution of the spectrogram. For example, textile scratches usually cause the missing or weakening of the corresponding texture period characteristic peaks, manifested as a significant reduction in the energy values of certain frequencies in the spectrogram. Changes in the spinning density will also cause the destruction of the periodic characteristic peaks, and the original regular energy distribution is distorted. There may be irregular abnormal peaks or uneven energy distribution in the spectrogram. These abnormal changes in the spectrogram can be used as indicators of defects to help detect and locate quality problems in textiles.
[0031] S4: Divide the real - time fabric image obtained in real - time according to the grid size to obtain real - time grids, and obtain the spectrogram of each real - time grid. Calculate the spectral differences between the spectrogram of any real - time grid and the spectrogram of any defect grid respectively to complete defect detection.
[0032] In one embodiment, the spectral difference satisfies the relational expression: , represents the real - time grid and the defect grid of the spectral difference, represents the real - time grid In the spectrogram, the value at the th row and the th column, represents the spectrogram of the defective cell In the spectrogram, the value at the th row and the th column, represents the two-norm.
[0033] Traverse to obtain the spectral differences between any real-time cell and each defective cell. The real-time cell with the smallest spectral difference is the defect of the real-time cell.
[0034] It should be noted that the spectral differences between the spectrograms of normal grids and defective cells are the same. Therefore, the positions of the grids with defects in the real-time fabric diagram can be determined based on the spectral differences.
[0035] In another embodiment, the analysis of spectral differences usually focuses on the overall energy distribution, but does not fully consider the variation differences in the positions of different defects in the spectrogram. In fact, different types of defects will have different effects on the spectrogram of textiles. For example, when scratches appear on the surface of textiles, the continuity of the texture is damaged, and the original periodic characteristic peaks may be weakened or lost. At this time, the energy peak at the specific frequency position corresponding to the scratch in the spectrogram will be significantly reduced, showing local energy loss. When the spinning density changes, the overall texture structure of the fabric will also change, resulting in a large change in the overall energy distribution of the spectrogram, which may be manifested as irregular changes in the peaks at multiple frequency positions or uneven energy distribution. Therefore, in addition to analyzing the energy changes in the spectrogram, it is also necessary to consider the influence of the different positions where the defects occur on the spectrogram. By comprehensively analyzing the local and overall differences in the spectrogram, different defect types can be more accurately identified, and the location and diagnosis of defects can be effectively carried out.
[0036] Take any defect type as the target defect, take the other defect types except the target defect as the control defects, and take the fabric diagram of the target defect as the target diagram.
[0037] Calculate the spectral difference diagrams between the spectrogram of the target diagram and the spectrograms of a number of normal fabric diagrams respectively, count the number of non-zero positions at each location, and obtain the difference matrix. Among them, the positions where the difference is 0 indicate that there is no difference between the defect and the normal textile, and they are not significant for defect identification, so they are not counted.
[0038] Calculate the importance of each position in the spectrogram for identifying the target defect according to the difference matrix. The importance satisfies the relational expression: , represents the importance of the position in the spectrogram for identifying the target defect , Indicates the target defect In the difference matrix between the spectrogram of The element value at the position, Indicates the control defect In the difference matrix between the spectrogram of The element value at the position.
[0039] Taking the normalized importance as the weight, the weighted sum of the spectral differences is obtained to get the defect degree of the target defect existing in the real-time fabric image. The defect degree satisfies the relational expression: , Indicates that there is a target defect in the real-time fabric image The defect degree of, Indicates in the spectrogram The position for the target defect The importance of recognition, Indicates the spectral difference between the real-time fabric image and the normal fabric image at The position.
[0040] In response to the defect degree being greater than the preset defect threshold, there is a target defect in the real-time fabric image.
[0041] It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of this invention patent shall be subject to the appended claims.
Claims
1. A textile defect detection method based on image processing, characterized in that Including: Obtain the preprocessed fabric images in history, and label the defect types of the fabric images; For any fabric image, use the autocorrelation function to calculate the period to determine the grid size; Divide the fabric images of different defect types in history according to the grid size, extract the grids at the defect positions as defect grids, and obtain the spectrograms of the defect grids; Divide the real-time fabric images obtained in real time according to the grid size to obtain real-time grids, and obtain the spectrograms of each real-time grid. Calculate the spectral differences between the spectrogram of any real-time grid and the spectrogram of any defect grid respectively to complete defect detection.
2. The textile defect detection method based on image processing according to claim 1, wherein The preprocessing includes: Grayscale the fabric RGB images obtained in history, and perform filtering and denoising to complete the preprocessing.
3. A textile defect detection method based on image processing according to claim 1, characterized in that, The determining the grid size includes: In response to the maximum of the autocorrelation function, take the time interval as the period; Traverse to obtain the periods of the pixel value sequences of each row, take the period with the highest occurrence frequency as the grid length, and obtain the calculation of the grid width in the same way according to the calculation of the grid length to obtain the grid size.
4. A method for detecting textile defects based on image processing according to claim 1, characterized in that, The spectral difference satisfies the relational expression: , represents the real-time cell and the defective cell in terms of spectral difference, represents the value at the th row and th column in the spectrogram of the real-time cell , represents the value at the th row and th column in the spectrogram of the defective cell , represents the two-norm.
5. A method for detecting textile defects based on image processing according to claim 1, characterized in that, The completing defect detection includes: Traverse to obtain the spectral differences between any real-time grid and each defect grid, and the one with the smallest spectral difference is the defect of the real-time grid.
6. The method for detecting textile defects based on image processing according to claim 1, wherein Also included: Take any defect type as the target defect, take the other defect types except the target defect as the control defects, and take the fabric image of the target defect as the target image; Calculate the spectral difference maps between the spectrogram of the target image and the spectrograms of a number of normal fabric images respectively, count the number of non-zero positions at each location, and obtain the difference matrix; Calculate the importance of each position in the spectrogram for identifying the target defect according to the difference matrix, take the normalized importance as the weight, and perform weighted summation on the spectral differences to obtain the defect degree of the target defect existing in the real-time fabric image; In response to the defect degree being greater than the preset defect threshold, there is a target defect in the real-time fabric image.
7. The method for detecting textile defects based on image processing according to claim 6, characterized in that, The importance satisfies the relational expression: , represents the importance of the position in the spectrogram for the identification of target defects, and represents the element value at the position in the difference matrix between the spectrogram of the target defect and the normal fabric pattern. It represents the element value at the position in the difference matrix between the spectrogram of the control defect and the normal fabric pattern. 8. The method for detecting textile defects based on image processing according to claim 6, wherein The defect degree satisfies the relational expression: , indicates the degree of target defects in the real-time fabric image ; indicates the importance of the position in the spectrogram for identifying the target defects ; indicates the spectral difference between the real-time fabric image and the normal fabric image at the position
Citation Information
Patent Citations
Broadband spectrum detection method based on multi-scale window sliding
CN112751633A
Textile surface defect detection method
CN118196095A
Method of detecting yarn unevenness
US5910187A
Cited By
Defect mode detection method, device, equipment, medium and product
CN120894298A