A rapid detection method and system for textile defects based on image processing
By performing color space conversion and fabric structure analysis on the RGB images of textile surfaces, a pixel-by-pixel chromaticity Mahalanobis distance map and symmetry destruction index are generated, solving the problems of insufficient sensitivity and high false detection and false negative rates in textile defect detection in existing technologies, and achieving efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-05
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to comprehensively identify both color differences and structural abnormalities in textile defect detection. They are also susceptible to interference from background noise and environmental factors, resulting in insufficient detection sensitivity and high rates of false positives and false negatives.
An image processing-based approach is adopted to generate a pixel-by-pixel chromaticity Mahalanobis distance map and a fabric structure symmetry disruption index by performing color space conversion on the RGB image of the textile surface. By combining a multi-dimensional feature set and a sliding calculation window, a judgment threshold is set to filter the coordinate set of color difference defects and generate a composite defect location mask.
It improves the sensitivity and accuracy of textile defect detection, reduces the probability of false detection and missed detection, increases detection efficiency, and avoids the subjectivity and inefficiency of manual visual inspection.
Smart Images

Figure CN121053072B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a rapid detection method and system for textile defects based on image processing. Background Technology
[0002] Image processing technology is a comprehensive discipline that uses computer systems or specialized digital signal processing equipment to analyze, enhance, reconstruct, recognize, or understand acquired image information. It involves multiple interdisciplinary fields such as pattern recognition, digital signal processing, artificial intelligence, and machine vision.
[0003] Existing technologies suffer from insufficient detail in practical operation, making it difficult to comprehensively identify both color differences and structural anomalies. This is primarily due to the reliance on traditional image statistics or spatial feature analysis, which is susceptible to interference from background noise and environmental factors, leading to insufficient detection sensitivity. Particularly when detecting slight color differences or localized texture anomalies on fabric surfaces, traditional detection methods struggle to effectively distinguish background information from actual defect features, easily causing false positives or false negatives and reducing detection accuracy. Therefore, improvements are needed. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and to propose a rapid detection method and system for textile defects based on image processing.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a rapid detection method for textile defects based on image processing, comprising the following steps:
[0006] RGB images of the textile surface are acquired, the image data is converted into a pixel matrix, and the RGB values of each pixel are converted into color space to obtain the component values of the L, a, and b channels of each pixel, thus constructing a multidimensional feature set of the image to be inspected.
[0007] Based on the multidimensional feature set of the image to be inspected, a sliding calculation window is set on the textile image to obtain the local background chromaticity result. Then, the Mahalanobis distance between the chromaticity vector of the center pixel of the sliding calculation window and the local background chromaticity result is calculated. After traversing all pixel positions, a pixel-by-pixel chromaticity Mahalanobis distance map is generated.
[0008] Based on the multidimensional feature set of the image to be inspected, the brightness channel data of the image is divided into multiple overlapping fabric structure sub-blocks, and bispectral frequency grid data of the sub-blocks is established. The amplitude value of the bispectral frequency grid data of the sub-blocks is calculated on the entire frequency grid to obtain the fabric structure symmetry destruction index.
[0009] Based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry disruption index, a judgment threshold is set for Mahalanobis distance and symmetry disruption index respectively. The distance value of each pixel in the pixel-by-pixel chromaticity Mahalanobis distance map is compared with the distance judgment threshold, and the pixel coordinates that exceed the threshold are filtered out to obtain the color difference defect coordinate set. The threshold comparison result of the fabric structure symmetry disruption index is combined with the color difference defect coordinate set to generate a composite defect location mask.
[0010] Preferably, the steps for obtaining the multidimensional feature set of the image to be inspected are as follows:
[0011] RGB images of textile surfaces are acquired using optical equipment. The acquired RGB images are then numerically analyzed. The intensity values of the R, G, and B color channels corresponding to each pixel position in the image are extracted pixel by pixel. The RGB values of all pixels are then arranged and combined according to their pixel coordinates to generate a pixel matrix.
[0012] Based on the pixel matrix, the color space is converted one by one for the RGB intensity value corresponding to each pixel position in the pixel matrix, and the RGB values are mapped to the L, a, b color spaces to generate the L channel component value, a channel component value and b channel component value corresponding to each pixel.
[0013] Based on the L-channel, a-channel, and b-channel component values corresponding to each pixel, the component values of the three channels are integrated according to the original pixel position to form a multidimensional feature set of the image to be inspected.
[0014] Preferably, the step of obtaining the local background chromaticity result is as follows:
[0015] A sliding calculation window is set in the multidimensional feature set of the image to be inspected. The window is slid row by row and column by column according to a fixed size and step size. For each sliding position, the L-channel component value, a-channel component value and b-channel component value of all pixels except the center pixel in the sliding calculation window are extracted. They are combined into the chromaticity vector of the corresponding pixel and the spatial position coordinates are marked to generate the local background chromaticity result.
[0016] Preferably, the step of obtaining the pixel-by-pixel chromaticity Mahalanobis distance map is as follows:
[0017] Based on the local background chromaticity results, the Mahalanobis distance of the center pixel of the sliding calculation window is calculated;
[0018] Based on the Mahalanobis distance of the center pixel of the sliding calculation window obtained in each sliding operation, the Mahalanobis distance is written into the two-dimensional image matrix position corresponding to the pixel position in turn. After completing the traversal and filling of all pixel positions, a pixel-by-pixel chromatic Mahalanobis distance map is generated.
[0019] Preferably, the steps for obtaining the sub-block bispectral frequency grid data are as follows:
[0020] Image brightness channel data is extracted from the multidimensional feature set of the image to be inspected. The brightness channel matrix is overlapped and segmented according to a fixed width and height sliding method. For each sliding position, the corresponding two-dimensional brightness channel pixel sub-matrix is extracted to form a set of brightness channel fabric structure sub-blocks.
[0021] Based on the set of fabric structure sub-blocks in the brightness channel, a two-dimensional Fourier transform is performed on each sub-block to calculate the bispectral complex values under the frequency pair combination. The modulus of the bispectral complex values is extracted to construct a bispectral amplitude matrix. The amplitude matrix is normalized so that the sum of the elements is 1, and the bispectral probability distribution of the current sub-block is generated. At the same time, the reference bispectral amplitude matrix calculated from the standard flawless fabric sample is called and normalized to generate the reference bispectral probability distribution. The bispectral frequency grid data of the sub-block are then summarized.
[0022] Preferably, the step of obtaining the fabric structure symmetry destruction index is as follows:
[0023] Based on the bispectral frequency grid data of the sub-block, the fabric structure symmetry disruption index of the sub-block is calculated.
[0024] Preferably, the step of obtaining the color difference defect coordinate set is as follows:
[0025] Based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry destruction index, the distance values of all pixels in the pixel-by-pixel chromaticity Mahalanobis distance map and the bispectral symmetry divergence index values of all fabric structure sub-blocks are statistically analyzed. The 95th percentile of the numerical distribution is calculated and set as the distance judgment threshold and the symmetry judgment threshold, respectively, and the distance judgment threshold and the symmetry judgment threshold are generated.
[0026] Based on the distance judgment threshold, the distance values of all pixels in the pixel-by-pixel chromaticity Mahalanobis distance map are compared with the distance judgment threshold one by one. The coordinates of the pixels whose distance values exceed the distance judgment threshold are extracted, and the corresponding image row and column position values are recorded to form a color difference defect coordinate set.
[0027] Preferably, the step of obtaining the composite defect location mask is as follows:
[0028] Based on the color difference defect coordinate set, the bispectral symmetry divergence index of all fabric structure sub-blocks is compared with the symmetry judgment threshold one by one. The coordinate positions of fabric structure sub-blocks that exceed the symmetry judgment threshold are extracted. The color difference defect coordinate set is then fused with the coordinate positions of the fabric structure sub-blocks to generate a composite defect location mask.
[0029] This invention also provides a rapid detection system for textile defects, comprising:
[0030] The image preprocessing module acquires RGB images of the textile surface, converts the image data into a pixel matrix, performs color space conversion on the RGB values of each pixel, obtains the component values of the L, a, and b channels of each pixel, and constructs a multidimensional feature set of the image to be inspected.
[0031] The color anomaly detection module sets a sliding calculation window on the textile image based on the multi-dimensional feature set of the image to be inspected, obtains the local background color result, and then calculates the Mahalanobis distance between the color vector of the center pixel of the sliding calculation window and the local background color result. After traversing all pixel positions, a pixel-by-pixel color Mahalanobis distance map is generated.
[0032] The structural anomaly detection module, based on the multidimensional feature set of the image to be inspected, divides the brightness channel data of the image into multiple overlapping fabric structure sub-blocks, establishes bispectral frequency grid data of the sub-blocks, and calculates the amplitude value of the bispectral frequency grid data of the sub-blocks on the entire frequency grid to obtain the fabric structure symmetry destruction index.
[0033] The composite defect determination module sets determination thresholds for the Mahalanobis distance and the fabric structure symmetry disruption index based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry disruption index. It compares the distance value of each pixel in the pixel-by-pixel chromaticity Mahalanobis distance map with the distance determination threshold, filters out the pixel coordinates that exceed the threshold, obtains the color difference defect coordinate set, and combines the threshold comparison result of the fabric structure symmetry disruption index with the color difference defect coordinate set to generate a composite defect location mask.
[0034] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0035] This invention acquires image data of textile surfaces, converts it pixel-by-pixel into color space features, and calculates Mahalanobis distance using local pixel statistics. This effectively suppresses background interference using spatial neighborhood statistics, achieving keen detection of color difference defects. Furthermore, the image brightness channel is subdivided into overlapping structural sub-blocks. Through bispectral frequency analysis and the introduction of a symmetry divergence index based on a reference distribution, the degree of local texture structure anomalies is effectively characterized, improving the sensitivity of fabric structural defect detection. Simultaneously, a judgment threshold is set, and a multi-dimensional judgment logic combining color difference coordinates and structural anomaly indices is combined to form a comprehensive composite positioning mask. This reduces the probability of false detection and missed detection while identifying defect locations, improving the reliability and accuracy of textile defect detection. In practical applications, this can improve detection efficiency, avoid the subjectivity and inefficiency of manual visual inspection, and reduce quality risks in the production process. Attached Figure Description
[0036] Figure 1 This is a schematic diagram of the steps of the present invention. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0038] Please see Figure 1 This invention provides a technical solution: a rapid detection method for textile defects based on image processing, comprising the following steps:
[0039] RGB images of the textile surface are acquired, the image data is converted into a pixel matrix, and the RGB values of each pixel are converted into color space to obtain the component values of the L, a, and b channels of each pixel, thus constructing a multidimensional feature set of the image to be inspected.
[0040] Based on the multidimensional feature set of the image to be inspected, a sliding calculation window is set on the textile image to obtain the local background chromaticity result. Then, the Mahalanobis distance between the chromaticity vector of the center pixel of the sliding calculation window and the local background chromaticity result is calculated. After traversing all pixel positions, a pixel-by-pixel chromaticity Mahalanobis distance map is generated.
[0041] Based on the multidimensional feature set of the image to be inspected, the brightness channel data of the image is divided into multiple overlapping fabric structure sub-blocks, and bispectral frequency grid data of the sub-blocks is established. The amplitude value of the bispectral frequency grid data of the sub-blocks is calculated on the entire frequency grid to obtain the fabric structure symmetry destruction index.
[0042] Based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry destruction index, a judgment threshold is set for Mahalanobis distance and symmetry destruction index respectively. The distance value of each pixel in the pixel-by-pixel chromaticity Mahalanobis distance map is compared with the distance judgment threshold. Pixel coordinates that exceed the threshold are filtered out to obtain the color difference defect coordinate set. Combining the threshold comparison result of the fabric structure symmetry destruction index with the color difference defect coordinate set, a composite defect location mask is generated.
[0043] The steps for obtaining the multidimensional feature set of the image to be inspected are as follows:
[0044] RGB images of textile surfaces are acquired using optical equipment. The acquired RGB images are then numerically analyzed. The intensity values of the R, G, and B color channels corresponding to each pixel position in the image are extracted pixel by pixel. The RGB values of all pixels are then arranged and combined according to their pixel coordinates to generate a pixel matrix.
[0045] Based on the pixel matrix, the color space is converted one by one for the RGB intensity value corresponding to each pixel position in the pixel matrix, and the RGB values are mapped to the L, a, b color spaces to generate the L channel component value, a channel component value and b channel component value corresponding to each pixel.
[0046] Based on the L-channel, a-channel, and b-channel component values corresponding to each pixel, the component values of the three channels are integrated according to the original pixel position to form a multidimensional feature set of the image to be inspected.
[0047] Specifically, an industrial-grade high-speed line scan camera mounted above the production line acquires RGB images of the continuously moving textile surface. This camera is configured with a CCD sensor with 4096 photosensitive units and a 50mm telecentric fixed-focus lens with a distortion rate of less than 0.1%. To ensure image uniformity, two flicker-free, high-brightness LED linear light sources, with lengths matching the width of the textile, are symmetrically arranged at a 45-degree angle on both sides of the camera. The color temperature of the light sources is stabilized at 6500K. Before acquisition, a standard Macbeth ColorChecker is used. Color calibration is performed using a 24-color-block color chart. By capturing images of the standard color chart, a 3x3 color correction matrix is calculated between the actual acquired RGB values and the standard sRGB values of the color chart. This matrix is then applied to all subsequent image acquisition processes to achieve color standardization. During acquisition, the textile passes beneath the camera at a constant speed of 0.5 m / s, while the camera synchronously performs line scanning at a rate of 5000 lines per second, ensuring that the physical resolution and lateral resolution of the image are consistent. Each line of analog electrical signal acquired is digitized and analyzed using a 12-bit analog-to-digital converter (ADC), converting the signal of each photosensitive unit... The signal strengths of the R, G, and B channels are converted into integers in the range of 0 to 4095. Subsequently, the system extracts these color-corrected raw digital signals pixel by pixel. The 4096 sets of RGB three-channel intensity values obtained from each scan are organized according to their physical arrangement on the photosensitive unit. As the textile continues to move, the continuously acquired scan lines are stacked row by row in memory and finally arranged and combined according to the preset image height (e.g., 4096 rows) to form a three-dimensional array with dimensions of height x width x number of channels (e.g., 4096 x 4096 x 3). This array is the pixel matrix.
[0048] Based on the pixel matrix generated by the aforementioned steps, the RGB intensity values (R_ij, G_ij, B_ij) corresponding to each pixel position (i,j) in the matrix are processed to initiate a pixel-by-pixel color space conversion process. First, the 12-bit integer values (0-4095) of each channel are normalized to a floating-point number range of 0 to 1. Specifically, this is calculated by dividing the intensity value of each channel by 4095. Next, in order to convert the image data from the device-dependent RGB space to the CIELAB space, which is more consistent with human visual perception, a standard two-stage conversion process is performed. The conversion process involves several stages. The first stage converts the non-linear sRGB values to linear RGB values. This process uses inverse gamma correction. For any normalized channel value C_norm, if it is less than or equal to 0.04045, the linearity is C_norm divided by 12.92; otherwise, the linearity is ((C_norm+0.055) / 1.055)^2.4. After obtaining the linearized R_linear, G_linear, and B_linear values, the process moves to the second stage. A standard 3x3 conversion matrix maps these values to the CIE 1931XYZ color space. This conversion is performed under the D65 standard light source preset, and the conversion formula is as follows:
[0049] Where XYZ are the target tristimulus values, the obtained XYZ values are then converted to CIELAB values. This process requires a reference white point, and the XYZ values of the D65 standard light source are used, namely Xn = 95.047, Yn = 100.000, Zn = 108.883. The conversion function is defined as: L* = 116*f(Y / Yn) - 16, a* = 500*[f(X / Xn) - f(Y / Yn)], b* = 200*[f(Y / Yn) - f(Z / Zn)], where the function f(t) is defined as: if t > 0.008856, then f(t) is the cube root of t, otherwise f(t) = (903.3*t + 16) / 116. By performing the above complete conversion process on each pixel in the pixel matrix, the corresponding L-channel component value, a-channel component value and b-channel component value are finally generated for each pixel in the image.
[0050] Based on the L-channel, a-channel, and b-channel component values calculated for each pixel in the previous step, these three independent numerical streams are structurally integrated. This integration process is performed according to the pixel spatial location of the original image. The system creates a three-dimensional feature vector C_ij = [L_ij, a_ij, b_ij] for each pixel coordinate (i, j) in memory, where L_ij represents the brightness information of the pixel, typically ranging from 0 to 100; a_ij represents its chromaticity information on the red-green axis; and b_ij represents its chromaticity information on the yellow-blue axis, typically ranging from -128 to 127. This operation iterates through all pixels of the original image, from coordinates (0,0) to (H-1,W-1), where H and W are the height and width of the image, respectively. This merges the three previously separate single-channel data matrices (L matrix, a matrix, b matrix) into a unified data structure. Logically, this newly generated data structure is a two-dimensional grid with the same dimensions as the original image. However, each node in the grid is no longer a single color value, but a multi-dimensional feature vector containing L, a, and b components. To ensure efficient processing in subsequent algorithms, this data structure is physically stored as a contiguous block of memory with a total size of H*W*3*.
[0051] The feature vector of pixel (i,j) can be directly accessed by adding the offset (i*W+j)*3*sizeof(float) to the base address. In this way, the L, a, and b component values of all pixels are integrated according to their original pixel positions, and finally a structured, dimensionally regular and easily random-accessable multidimensional feature set of the image to be inspected is formed.
[0052] The steps to obtain the local background chromaticity result are as follows:
[0053] A sliding calculation window is set in the multidimensional feature set of the image to be inspected. The window is slid row by row and column by column according to a fixed size and step size. For each sliding position, the L-channel component value, a-channel component value and b-channel component value of all pixels except the center pixel in the sliding calculation window are extracted. They are combined into the chromaticity vector of the corresponding pixel and the spatial position coordinates are marked to generate the local background chromaticity result.
[0054] Specifically, in the multidimensional feature set of the image to be inspected, a sliding calculation window of a fixed size of 15x15 pixels is used to process the image. The choice of this window size is based on the statistical analysis of the texture periodicity of 100 different types of textile samples. It was found that the size of the basic repeating unit is mostly distributed between 10 and 20 pixels. Therefore, choosing a size of 15x15 can include at least one complete texture unit while avoiding the introduction of too much irrelevant background information. The sliding step size is set to 1 pixel, and the window is opened row by row and column by column, starting from the upper left corner of the image (coordinate (7,7) as the center of the first window). The system begins traversing the window until the bottom right corner (coordinates (W-8, H-8) represent the center of the last window, where W and H are the image width and height). For each sliding calculation window, the system first identifies the center pixel and then extracts the chromaticity features of the remaining 224 neighboring pixels. Specifically, the system sequentially reads the L-channel, a-channel, and b-channel component values of these 224 pixels in the multi-dimensional feature set of the image to be inspected. It then combines the three component values of each neighboring pixel into a three-dimensional chromaticity vector. For example, for neighboring pixel k, its chromaticity vector is C. k =[L k ,a k ,b k ] T Simultaneously, the absolute spatial coordinates (x_k, y_k) of the pixel in the original image are recorded. The chromaticity vectors of all 224 neighboring pixels in the current window and their corresponding spatial coordinates are collected to form a temporary data set associated with the center pixel of the current window. This set is the local background chromaticity result required for this calculation.
[0055] The steps to obtain the pixel-by-pixel chromaticity Mahalanobis distance map are as follows:
[0056] Based on the local background chromaticity results, the Mahalanobis distance of the center pixel of the sliding computation window is calculated using the following formula:
[0057]
[0058] in, To calculate the Mahalanobis distance of the center pixel of the sliding window, C p To calculate the chromaticity vector of the center pixel of the sliding calculation window, μ′ b Let Σ′ be the weighted mean vector of the neighboring pixels excluding the center pixel. b Let w be the weighted covariance matrix of the neighboring pixels. i Let w be the spatial weight of the i-th neighboring pixel, I be a 3D identity matrix, λ be the regularization coefficient, and w be all the weights. i The value μ′ is determined by the Euclidean distance from the spatial location of the center pixel and generated using a Gaussian function. b and Σ′b The specific definitions are as follows:
[0059]
[0060] Among them, W ′ C is the set of all neighboring pixels within the sliding window, excluding the center pixel. i Let be the chromaticity vector of the i-th neighboring pixel;
[0061] Based on the Mahalanobis distance of the center pixel of the sliding calculation window obtained in each sliding operation, the Mahalanobis distance is written into the two-dimensional image matrix position corresponding to the pixel position in turn. After completing the traversal and filling of all pixel positions, a pixel-by-pixel chromatic Mahalanobis distance map is generated.
[0062] Specifically, the formula:
[0063] The advantage of the formula lies in the introduction of Gaussian weights w based on spatial distance. i This makes it possible to calculate the local background chromaticity statistical features (mean vector μ′). b Sum of covariance matrix Σ′ b When the covariance matrix is inverted, neighboring pixels closer to the center pixel contribute more, and vice versa. This design more accurately reflects the true background chromaticity distribution around the center pixel, effectively suppressing interference from distant pixels or noise points, and improving the background model's adaptability to local details. Furthermore, a regularization term λI is added when inverting the covariance matrix, i.e., for the covariance matrix Σ′... b Adding a small positive value λ to the diagonal elements effectively prevents the covariance matrix Σ′ from increasing when neighboring pixels have highly similar colors (e.g., in solid color regions). b The problem of transforming into a singular or near-singular matrix that cannot be inverted enhances the numerical stability of the algorithm and its universality on various textile images.
[0064] C p The chromaticity vector of the center pixel of the sliding calculation window is extracted directly from the multidimensional feature set of the image to be inspected based on the center coordinates (x, y) of the current sliding window. This vector contains the L, a, and b component values of the center pixel. For example, when detecting a pixel suspected of being an oil stain, its chromaticity vector is extracted from the feature set, and its value is C. p =[55.0,4.5,25.0] T The lower L value indicates that the brightness is darker, while the higher b value indicates that the color is more yellow, which is significantly different from the color of normal fabric.
[0065] C iLet C be the chromaticity vector of the i-th neighboring pixel. This vector is also extracted from the multi-dimensional feature set of the image to be tested and represents the color information of the local background around the center pixel. For a 3x3 calculation window, there are 8 neighboring pixels besides the center pixel, and there are 8 corresponding chromaticity vectors C. i For example, in the normal fabric area surrounding the aforementioned center pixel, the chromaticity vector of its eight neighboring pixels might be: C1 = [70.1, 2.1, 10.1]. T C2 = [69.8, 2.0, 9.8] T C3 = [70.2, 1.9, 10.3] T C4 = [70.0, 2.2, 10.0] T C5 =
[0066] [69.9, 1.8, 9.9] T C6 = [70.3, 2.1, 10.2] T C7 = [69.7, 2.0, 9.7] T C8 = [70.4, 1.9, 10.4] T .
[0067] w i The spatial weight of the i-th neighboring pixel is determined by the Euclidean distance between that neighboring pixel and the center pixel, and is generated using a Gaussian function. The calculation formula is as follows: Where d i σ is the Euclidean distance between the coordinates of the i-th neighboring pixel and the coordinates of the center pixel. σ is the standard deviation of the Gaussian function, controlling the rate at which the weights decay with distance. The value of σ is related to the size of the sliding window, and is generally set to one-sixth of the window side length W. For a 15x15 window, σ is set to 15 / 6 = 2.5 to ensure that pixels at the window edges still have a certain weight. For example, in a 3x3 window, σ can be set to 0.5, then the four pixels adjacent to the center pixel (up, down, left, and right, at a distance d) will have a certain weight. i The weight of (=1) is w side =exp(-1 2 / (2·0.5 2 ))=exp(-2)≈0.135, the four pixels on the diagonal (distance) The weight of ) is
[0068] λ is the regularization coefficient, a preset small positive number. Its setting is based on statistical analysis of a large number of flawless sample images. Specifically, from 1000 standard flawless textile images, 50,000 15x15 image patches are randomly selected, and the weighted covariance matrix Σ′ of each image patch is calculated. bThen, the average of the traces (the sum of the diagonal elements) of all these matrices is calculated, and finally, λ is set to one ten-thousandth of this average trace. For example, if the calculated average trace is 0.85, then λ is set to 0.85 × 10⁻⁶. -4 =0.000085. This value is set to minimize the impact on the original covariance structure while ensuring the invertibility of the matrix.
[0069] I is a 3-dimensional identity matrix, i.e. Its function is to adjust the diagonal elements of the covariance matrix in conjunction with the regularization coefficient λ.
[0070] μ′ b It is a weighted mean vector of neighboring pixels excluding the center pixel. It represents the average chromaticity of the local background calculated based on spatial weights and serves as the benchmark for judging whether the center pixel is abnormal.
[0071] Σ′ b It is a weighted covariance matrix of neighboring pixels, which describes the variation of local background chromaticity in the three channels L, a, and b, as well as the correlation between channels, and defines the distribution pattern of the chromaticity space.
[0072] W′ is the set of all neighboring pixels within the sliding window, excluding the center pixel. For a W x W window, this set contains W 2 -1 pixel.
[0073] Calculation process:
[0074] Taking a 3x3 window as an example, the chromaticity vector C of the center pixel... p =[55.0,4.5,25.0] T Using the 8 neighboring pixel vectors C1 to C8 from the previous example and the weight w side =0.135,w corner =0.018.
[0075] Calculate the weighted mean vector μ′ b :
[0076] ∑w i =4·w side +4·w corner =4·0.135+4·0.018=0.54+0.072=0.612.
[0077] ∑w i C i =0.135(C2+C4+C5+C7)+0.018(C1+C3+C6+C8).
[0078] ∑w can be obtained through calculation. i C i≈[42.84,1.22,6.12] T .
[0079]
[0080] ′
[0081] Calculate the weighted covariance matrix Σ b :
[0082] This calculation involves calculating w for each neighboring pixel. i (C i -μ′ b (C) i -μ′ b ) T The process of summing and normalizing is quite cumbersome, but an approximate covariance matrix is obtained through calculation:
[0083] Calculate and inverse the regularized covariance matrix:
[0084] If we set λ = 0.001, then
[0085] Its inverse matrix is:
[0086] Calculate Mahalanobis distance
[0087] First, calculate the difference vector between the center pixel and the mean value of the background:
[0088] C p -μ′ b =[55.0,4.5,25.0] T -[70.0,2.0,10.0] T =[-15.0, 2.5, 15.0] T .
[0089] Finally, calculate the square of the Mahalanobis distance:
[0090]
[0091] The calculated result is approximately 4718.4.
[0092]
[0093] The results indicate that the Mahalanobis distance between the chromaticity vector of the central pixel and the local background chromaticity distribution is 68.69, which is a very high value. In a flawless area, this value would typically be much less than 5. Such a large distance strongly indicates that the color of the central pixel differs significantly from the surrounding background, making it an outlier and possibly a color difference defect.
[0094] Based on the Mahalanobis distance of the center pixel of the sliding calculation window obtained in each sliding operation, the system initiates the pixel-by-pixel chroma Mahalanobis distance generation process. First, a two-dimensional floating-point matrix with the same height and width as the original image to be examined is initialized in memory, with all elements initialized to 0.0. This matrix serves as the carrier for the final pixel-by-pixel chroma Mahalanobis distance map. Next, following the same traversal order as the aforementioned sliding calculation, starting from the first calculable pixel position, the system writes the Mahalanobis distance value calculated in the previous step, for example, 68.69, to the position (x, y) in the two-dimensional matrix that perfectly corresponds to the current center pixel coordinates (x, y). This writing operation is performed across the entire image as the sliding calculation window moves. The process continues as the image moves, processing each pixel and filling its calculated Mahalanobis distance value into the corresponding position in the matrix. For pixel regions where a complete 15x15 calculation window cannot be formed at the image edge (i.e., boundary strips with a width of 7 pixels around the image), the system uses a reflection filling strategy. That is, when calculating these boundary pixels, the image boundary is virtually used as a mirror to reflect the pixel values inside to the outside to construct a complete calculation window. This ensures that every pixel in the image can be calculated with a valid Mahalanobis distance value, avoiding the loss of boundary information. After the sliding calculation window has traversed all pixel positions, this two-dimensional matrix is completely filled, ultimately generating a complete pixel-by-pixel chromatic Mahalanobis distance map.
[0095] The steps for obtaining the bispectral frequency grid data of the sub-block are as follows:
[0096] Image brightness channel data is extracted from the multidimensional feature set of the image to be inspected. The brightness channel matrix is overlapped and segmented according to a fixed width and height sliding method. The corresponding two-dimensional brightness channel pixel sub-matrix is extracted at each sliding position to form a set of brightness channel fabric structure sub-blocks.
[0097] Based on the set of fabric structure sub-blocks in the brightness channel, a two-dimensional Fourier transform is performed on each sub-block to calculate the bispectral complex values under the frequency pair combination. The modulus of the bispectral complex values is extracted to construct a bispectral amplitude matrix. The amplitude matrix is normalized so that the sum of the elements is 1 to generate the bispectral probability distribution of the current sub-block. At the same time, the reference bispectral amplitude matrix calculated from the standard flawless fabric sample is called and normalized to generate the reference bispectral probability distribution. The bispectral frequency grid data of the sub-block are then summarized.
[0098] Specifically, in the multidimensional feature set of the image to be inspected, the system first accurately extracts the L-channel data representing the image brightness information, forming a two-dimensional brightness channel matrix with the same size as the original image. Subsequently, based on the pre-analysis of the texture period of typical plain, twill, and satin fabrics (usually in the range of 32 to 128 pixels), the brightness channel matrix is overlapped and segmented according to a fixed width and height of 64x64 pixels. This size ensures that at least one basic structural unit of the fabric can be completely contained. At the same time, the sliding step size in both the horizontal and vertical directions is set to 32 pixels, i.e., an overlap rate of 50%. This overlap method ensures that even if the defect is located at the boundary of two sub-blocks, it can be detected in at least one sub-block. The complete capture and analysis process begins at the top-left corner (0,0) of the luminance channel matrix. First, a 64x64 pixel two-dimensional luminance channel pixel sub-matrix is extracted. Then, the extraction position is moved 32 pixels to the right, and another sub-matrix is extracted. This process is repeated until the end of the row. Then, the extraction position is moved down 32 pixels to the beginning of the row, and the above horizontal extraction process is repeated until the entire luminance channel matrix is traversed. Each 64x64 two-dimensional luminance channel pixel sub-matrix is treated as an independent analysis unit, and its top-left corner coordinates in the original luminance channel matrix are recorded. Finally, all extracted sub-matrices are managed uniformly to form a set of luminance channel fabric structure sub-blocks.
[0099] Based on the set of luminance channel fabric structure sub-blocks generated in the previous step, the system processes each sub-block in the set one by one. First, a Hamming window function is applied to the sub-block. By multiplying each pixel value in the sub-block matrix by the corresponding window function coefficient, the edges of the sub-block are smoothed, reducing the spectral leakage effect caused by signal truncation during subsequent Fourier transform. The processed sub-block is then fed into a two-dimensional Fast Fourier Transform (FFT) program to calculate a 64x64 complex matrix. This matrix represents the distribution of the sub-blocks in the frequency domain, where each element corresponds to the amplitude and phase of a two-dimensional spatial frequency. Next, the system calculates the bispectrum based on this complex matrix. Specifically, in the predefined non-redundant frequency pair (f k ,f l Within the region, calculate the Fourier transform of the third-order cumulants, that is, for each frequency pair combination, calculate the product of the three Fourier coefficients X(f). k )X(f l )X * (f k +f l ), where X * (f k +f l ) is the frequency f k +f lThe complex conjugate of the Fourier coefficients is used to obtain bispectral complex values. Then, the magnitudes of these bispectral complex values, i.e., their absolute values, are extracted to construct a bispectral amplitude matrix. For subsequent statistical comparisons, this bispectral amplitude matrix needs to be normalized. By calculating the sum of all elements in the matrix and then dividing each element by the sum, the bispectral probability distribution of the current sub-block is obtained. At the same time, the system retrieves a reference bispectral amplitude matrix of a standard flawless fabric sample from a preset database. This reference matrix is generated by performing the same processing procedure on sub-blocks of more than 1,000 flawless fabric samples of the same type and averaging the resulting bispectral amplitude matrices element-wise. Similarly, this reference bispectral amplitude matrix is normalized to generate a reference bispectral probability distribution. Finally, the bispectral probability distribution of the current sub-block is paired with the reference bispectral probability distribution to obtain the bispectral frequency grid data of the sub-block.
[0100] The steps for obtaining the fabric structure symmetry destruction index are as follows:
[0101] Based on the bispectral frequency grid data of the sub-blocks, the fabric structure symmetry disruption index of the sub-blocks is calculated using the following formula:
[0102]
[0103] in, p is the fabric structure symmetry disruption index of the s-th brightness channel fabric structure sub-block. s (f k ,f l Let p be the normalized bispectral probability distribution of the s-th sub-block. ref (f k ,f l () represents the average bispectral probability distribution of the corresponding frequency pairs of the standard flawless fabric sub-pieces. Let R and S be the average distribution values at corresponding locations of these two distributions, and let F be the frequency index. k with f l The maximum number of possible values.
[0104] Specifically, the formula:
[0105] The advantage of the formula lies in its ability to calculate the bispectral probability distribution p of the sub-block under test. s The reference bispectral probability distribution p of the standard flawless sub-block refThe JSD between the two can quantify the degree of deviation between the fabric structure of the tested sub-block and the standard structure. Normal fabric texture has a high degree of periodicity and symmetry, and its bispectral distribution shows clear and concentrated peaks. However, any structural defects, such as broken yarns, sparse weft, or holes, will disrupt this periodicity, causing the bispectral energy to disperse or exhibit abnormal peaks in the frequency domain, thus making p s Significantly different from p ref Calculated The value also increases accordingly;
[0106] p s (f k ,f l ) represents the normalized bispectral probability distribution of the s-th sub-block. This parameter is directly derived from the bispectral analysis and normalization results of the current brightness channel fabric structure sub-block under test in the previous steps. It is a two-dimensional matrix, and each element p in the matrix... s (f k ,f l ) indicates that at the corresponding frequency pair (f k ,f l The probability density of bispectral energy, where the sum of all elements is 1. For example, for a sub-block that detects a broken yarn defect, its bispectral energy will diffuse from the normal texture dominant frequency to other frequencies, and its distribution will be as follows: The probability value of areas that originally had lower energy (such as the upper left corner) becomes higher.
[0107] p ref (f k ,f l The parameter p represents the average bispectral probability distribution of the standard flawless fabric sub-blocks corresponding to the frequency pairs. This parameter was obtained through offline learning before system deployment. The acquisition process is as follows: at least 500 images of standard flawless fabrics of a specified type were collected from the current production line. Each image was segmented according to the same settings as online detection (64x64 sub-blocks, 32-pixel overlap), generating tens of thousands of standard sub-blocks. The bispectral amplitude matrix of each standard sub-block was calculated. Then, the bispectral amplitude matrices of all standard sub-blocks were accumulated element-wise at the corresponding frequency pairs and averaged to obtain an overall reference bispectral amplitude matrix. Finally, this reference matrix was normalized (so that the sum of all its elements is 1), thus obtaining the reference bispectral probability distribution p of this type of fabric. ref For example, the reference distribution of a plain weave fabric is highly concentrated on a few dominant frequencies representing the warp and weft yarn cycles:
[0108] m(f k ,f l ) is p s (f k ,fl ) and p ref (f k ,f l The calculation method for the average distribution values of these two locations has already been expanded and reflected in the original formula, that is... It serves as an intermediate quantity in the JSD calculation process, used to construct a mixed distribution as a reference benchmark for KL divergence.
[0109] R and S are frequency indices f, respectively. k with f l The maximum number of values is determined by the size of the sub-block. For a 64x64 pixel sub-block, after a two-dimensional Fourier transform, the resulting frequency grid is also 64x64. Therefore, R = 64 and S = 64. In the example, we take R = 2 and S = 2.
[0110] Calculation process:
[0111] Substitute the aforementioned parameter p s and p ref The numerical values for the example are calculated on a 2x2 frequency grid (R=2, S=2).
[0112] Calculate the mean distribution m(f) of the two distributions. k ,f l ):
[0113] The first part of the calculation formula, namely p s Half of the KL divergence relative to m:
[0114]
[0115] The second part of the calculation formula, namely p ref Half of the KL divergence relative to m:
[0116]
[0117]
[0118] Adding the two parts together yields the final fabric structure symmetry disruption index.
[0119]
[0120] The results show that the fabric structure symmetry disruption index of the s-th brightness channel fabric structure sub-block is 0.2195. This value quantifies the degree of difference between the bispectral distribution of the sub-block under test and the bispectral distribution of the ideal flawless sample. The value is between 0 and 1, where 0 indicates that the two distributions are completely identical, that is, the sub-block has no structural defects. The larger the value, the greater the difference, and the higher the probability and severity of defects. In this example, 0.2195 is a value that deviates significantly from 0, indicating that the fabric structure of this sub-block has obvious symmetry disruption and is very likely to contain structural defects such as broken yarns and holes.
[0121] The steps to obtain the coordinate set of color difference defects are as follows:
[0122] Based on the pixel-wise chromaticity Mahalanobis distance map and the fabric structure symmetry destruction index, the distance values of all pixels in the pixel-wise chromaticity Mahalanobis distance map and the bispectral symmetry divergence index values of all fabric structure sub-blocks are statistically analyzed. The 95th percentile of the numerical distribution is calculated and set as the distance judgment threshold and symmetry judgment threshold, respectively, and the distance judgment threshold and symmetry judgment threshold are generated.
[0123] Based on the distance judgment threshold, the distance values of all pixels in the pixel-by-pixel chromaticity Mahalanobis distance map are compared with the distance judgment threshold one by one. The coordinates of the pixels whose distance values exceed the distance judgment threshold are extracted and the corresponding image row and column position values are recorded to form a color difference defect coordinate set.
[0124] Specifically, based on the pixel-wise chromatic Mahalanobis distance map and the fabric structure symmetry disruption index, the system first performs independent statistical analysis on these two sets of data to adaptively determine the judgment threshold. For generating the distance judgment threshold, the system extracts the distance values of all pixels in the two-dimensional pixel-wise chromatic Mahalanobis distance map (e.g., a 4096x4096 pixel image containing 16,777,216 distance values) and flattens it into a one-dimensional floating-point array. Then, using an efficient quicksort algorithm, such as introspection sort, it sorts this array containing over 16 million values in ascending order. After sorting, it calculates the index of the 95th percentile of the array by multiplying the total array length by 0.95 and rounding down. For example, for 16,777,216 values, the index is 15,938,355. The system then reads the Mahalanobis distance value at this index and sets it as the distance judgment threshold for the current image. For example, if this value is 8.75... The distance threshold is 8.75. Similarly, for the generation of the symmetry threshold, the system collects the fabric structure symmetry destruction index of all fabric structure sub-blocks (for example, for a 4096x4096 image, if it is divided according to a size of 64x64 and an overlap step of 32 pixels, it will generate ((4096-64) / 32+1)^2=127^2=16129 sub-blocks, that is, 16129 index values). These index values are formed into a one-dimensional array and sorted in ascending order. Then the 95th percentile of this array is calculated. For example, for 16129 index values, the index position of the 95th percentile is floor(16129*0.95)=15322. The system reads the value at the 15322nd position in the sorted array, for example, 0.213, and sets it as the symmetry threshold. By setting the threshold using this percentile method based on the current image data distribution, the distance threshold and the symmetry threshold are generated.
[0125] Based on the distance threshold generated in the previous step, the system initiates binarization segmentation processing of the pixel-by-pixel chroma Mahalanobis distance map. First, an empty dynamic array or list is initialized to store the coordinates of subsequently selected defective pixels; this is the initial form of the color difference defect coordinate set. Then, the system executes a nested loop to traverse the entire pixel-by-pixel chroma Mahalanobis distance map pixel by pixel. The outer loop variable i iterates from 0 to the image height minus 1, and the inner loop variable j iterates from 0 to the image width minus 1. In each loop iteration, the system reads the corresponding Mahalanobis distance value D_i from the pixel-by-pixel chroma Mahalanobis distance map based on the current row and column index (i,j). The system then compares the value of D_ij with a predetermined distance threshold (e.g., 8.75). The condition for comparison is whether D_ij is greater than 8.75. If the comparison result is true, that is, the Mahalanobis distance of the current pixel exceeds the threshold, the system adds the two-dimensional coordinates (i,j) of the pixel as a data pair to the color difference defect coordinate set. If the comparison result is false, no operation is performed, and the system directly enters the next loop. This process will continue until every pixel in the image has been accessed and compared. Finally, the previously initialized dynamic array will contain the precise row and column position information of all pixels that have been judged as color difference abnormalities, forming the color difference defect coordinate set.
[0126] The steps to obtain the composite defect location mask are as follows:
[0127] Based on the color difference defect coordinate set, the bispectral symmetry divergence index of all fabric structure sub-blocks is compared with the symmetry judgment threshold one by one. The coordinate positions of fabric structure sub-blocks that exceed the symmetry judgment threshold are extracted. The color difference defect coordinate set is then fused with the coordinate positions of the fabric structure sub-blocks to generate a composite defect location mask.
[0128] Specifically, based on the color difference defect coordinate set, the system first creates a two-dimensional Boolean or integer matrix with the same size as the image to be inspected, and initializes all its elements to 0 or false. This matrix will serve as the final composite defect localization mask. Next, the system performs a threshold comparison on the fabric structure symmetry destruction index of all fabric structure sub-blocks. It traverses each sub-block, reads its symmetry index, and compares it with the previously calculated symmetry judgment threshold (e.g., 0.213). If the symmetry index of a sub-block is greater than 0.213, the system records the coverage area of that sub-block in the original image, i.e., its upper left corner coordinates (block_row, block_col) and its 64x64 size. Subsequently, the system begins to fuse the two detection results to fill the composite defect localization mask. The fusion process is performed in two steps. The first step... The system iterates through each pixel coordinate (i,j) in the color difference defect coordinate set and modifies the value from 0 to 1 at the corresponding position (i,j) in the composite defect location mask, marking all color difference defect points. The second step involves the system iterating through all fabric structure sub-blocks identified as structurally abnormal. For each such sub-block, the system uses its recorded upper-left corner coordinates and dimensions to set all pixel values in the composite defect location mask corresponding to that entire 64x64 area to 1. This operation is equivalent to printing a 64x64 "defect" label on the mask. The logical relationship between these two steps is "OR," meaning that if a pixel position is marked in color difference detection or its sub-block is marked in structure detection, its value in the final mask will be 1. After marking all coordinates and sub-block areas, the composite defect location mask is generated.
[0129] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A rapid detection method for textile defects based on image processing, characterized in that, Includes the following steps: RGB images of the textile surface are acquired, the image data is converted into a pixel matrix, and the RGB values of each pixel are converted into color space to obtain the component values of the L, a, and b channels of each pixel, thus constructing a multidimensional feature set of the image to be inspected. Based on the multidimensional feature set of the image to be inspected, a sliding calculation window is set on the textile image to obtain the local background chromaticity result. Then, the Mahalanobis distance between the chromaticity vector of the center pixel of the sliding calculation window and the local background chromaticity result is calculated. After traversing all pixel positions, a pixel-by-pixel chromaticity Mahalanobis distance map is generated. Based on the multidimensional feature set of the image to be inspected, the brightness channel data of the image is divided into multiple overlapping fabric structure sub-blocks, and bispectral frequency grid data of the sub-blocks is established. The amplitude value of the bispectral frequency grid data of the sub-blocks is calculated on the entire frequency grid to obtain the fabric structure symmetry destruction index. Based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry disruption index, a judgment threshold is set for Mahalanobis distance and symmetry disruption index respectively. The distance value of each pixel in the pixel-by-pixel chromaticity Mahalanobis distance map is compared with the distance judgment threshold, and the pixel coordinates that exceed the threshold are filtered out to obtain the color difference defect coordinate set. The threshold comparison result of the fabric structure symmetry disruption index is combined with the color difference defect coordinate set to generate a composite defect location mask.
2. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the multidimensional feature set of the image to be inspected are as follows: RGB images of textile surfaces are acquired using optical equipment. The acquired RGB images are then numerically analyzed. The intensity values of the R, G, and B color channels corresponding to each pixel position in the image are extracted pixel by pixel. The RGB values of all pixels are then arranged and combined according to their pixel coordinates to generate a pixel matrix. Based on the pixel matrix, the color space is converted one by one for the RGB intensity value corresponding to each pixel position in the pixel matrix, and the RGB values are mapped to the L, a, b color spaces to generate the L channel component value, a channel component value and b channel component value corresponding to each pixel. Based on the L-channel, a-channel, and b-channel component values corresponding to each pixel, the component values of the three channels are integrated according to the original pixel position to form a multidimensional feature set of the image to be inspected.
3. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the local background chromaticity result are as follows: A sliding calculation window is set in the multidimensional feature set of the image to be inspected. The window is slid row by row and column by column according to a fixed size and step size. For each sliding position, the L-channel component value, a-channel component value and b-channel component value of all pixels except the center pixel in the sliding calculation window are extracted. They are combined into the chromaticity vector of the corresponding pixel and the spatial position coordinates are marked to generate the local background chromaticity result.
4. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the pixel-by-pixel chromaticity Mahalanobis distance map are as follows: Based on the local background chromaticity results, the Mahalanobis distance of the center pixel of the sliding calculation window is calculated; Based on the Mahalanobis distance of the center pixel of the sliding calculation window obtained in each sliding operation, the Mahalanobis distance is written into the two-dimensional image matrix position corresponding to the pixel position in turn. After completing the traversal and filling of all pixel positions, a pixel-by-pixel chromatic Mahalanobis distance map is generated.
5. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the sub-block bispectral frequency grid data are as follows: Image brightness channel data is extracted from the multidimensional feature set of the image to be inspected. The brightness channel matrix is overlapped and segmented according to a fixed width and height sliding method. For each sliding position, the corresponding two-dimensional brightness channel pixel sub-matrix is extracted to form a set of brightness channel fabric structure sub-blocks. Based on the set of fabric structure sub-blocks in the brightness channel, a two-dimensional Fourier transform is performed on each sub-block to calculate the bispectral complex values under the frequency pair combination. The modulus of the bispectral complex values is extracted to construct a bispectral amplitude matrix. The amplitude matrix is normalized so that the sum of the elements is 1, and the bispectral probability distribution of the current sub-block is generated. At the same time, the reference bispectral amplitude matrix calculated from the standard flawless fabric sample is called and normalized to generate the reference bispectral probability distribution. The bispectral frequency grid data of the sub-block are then summarized.
6. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the fabric structure symmetry disruption index are as follows: Based on the bispectral frequency grid data of the sub-block, the fabric structure symmetry disruption index of the sub-block is calculated.
7. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the coordinate set of color difference defects are as follows: Based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry destruction index, the distance values of all pixels in the pixel-by-pixel chromaticity Mahalanobis distance map and the bispectral symmetry divergence index values of all fabric structure sub-blocks are statistically analyzed. The 95th percentile of the numerical distribution is calculated and set as the distance judgment threshold and the symmetry judgment threshold, respectively, and the distance judgment threshold and the symmetry judgment threshold are generated. Based on the distance judgment threshold, the distance values of all pixels in the pixel-by-pixel chromaticity Mahalanobis distance map are compared with the distance judgment threshold one by one. The coordinates of the pixels whose distance values exceed the distance judgment threshold are extracted, and the corresponding image row and column position values are recorded to form a color difference defect coordinate set.
8. The rapid textile defect detection method based on image processing according to claim 1, characterized in that, The steps for obtaining the composite defect location mask are as follows: Based on the color difference defect coordinate set, the bispectral symmetry divergence index of all fabric structure sub-blocks is compared with the symmetry judgment threshold one by one. The coordinate positions of fabric structure sub-blocks that exceed the symmetry judgment threshold are extracted. The color difference defect coordinate set is then fused with the coordinate positions of the fabric structure sub-blocks to generate a composite defect location mask.
9. The rapid textile defect detection system according to the image processing-based rapid textile defect detection method as described in any one of claims 1-8, characterized in that, include: The image preprocessing module acquires RGB images of the textile surface, converts the image data into a pixel matrix, performs color space conversion on the RGB values of each pixel, obtains the component values of the L, a, and b channels of each pixel, and constructs a multidimensional feature set of the image to be inspected. The color anomaly detection module sets a sliding calculation window on the textile image based on the multi-dimensional feature set of the image to be inspected, obtains the local background color result, and then calculates the Mahalanobis distance between the color vector of the center pixel of the sliding calculation window and the local background color result. After traversing all pixel positions, a pixel-by-pixel color Mahalanobis distance map is generated. The structural anomaly detection module, based on the multidimensional feature set of the image to be inspected, divides the brightness channel data of the image into multiple overlapping fabric structure sub-blocks, establishes bispectral frequency grid data of the sub-blocks, and calculates the amplitude value of the bispectral frequency grid data of the sub-blocks on the entire frequency grid to obtain the fabric structure symmetry destruction index. The composite defect determination module sets determination thresholds for the Mahalanobis distance and the fabric structure symmetry disruption index based on the pixel-by-pixel chromaticity Mahalanobis distance map and the fabric structure symmetry disruption index. It compares the distance value of each pixel in the pixel-by-pixel chromaticity Mahalanobis distance map with the distance determination threshold, filters out the pixel coordinates that exceed the threshold, obtains the color difference defect coordinate set, and combines the threshold comparison result of the fabric structure symmetry disruption index with the color difference defect coordinate set to generate a composite defect location mask.
Citation Information
Patent Citations
A fabric defect detection method based on self-adaptive segmentation and template correction
CN109949287A
Sock flaw detection method and system based on machine vision
CN119067975A