A mattress fabric defect image recognition method based on mattress fabric quality inspection

By constructing a dual-path collaborative sensing structure, combining frequency domain and spatial feature pathways, the periodic texture interference in complex mattress fabrics is suppressed, and the defect feature response is enhanced. This solves the problems of over-segmentation and missed detection in the quality inspection of complex fabrics, and achieves high-precision and automated defect detection.

CN122134685APending Publication Date: 2026-06-02HANGZHOU BITAO FABRIC CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU BITAO FABRIC CO LTD
Filing Date
2026-02-28
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies struggle to distinguish between normal textures and defects in the quality inspection of complex mattress fabrics such as high-precision jacquard and 3D weaving, leading to problems of over-segmentation and missed detection.

Method used

A dual-path collaborative sensing structure is adopted, combining frequency domain prior paths and spatial feature paths. Spatial modulation weights are generated through cross-domain fusion units to suppress periodic texture responses and enhance abnormal feature responses, thereby achieving defect localization.

Benefits of technology

It effectively reduces oversegmentation and false alarm rates, improves the accuracy and robustness of quality inspection, and achieves efficient and automated defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134685A_ABST
    Figure CN122134685A_ABST
Patent Text Reader

Abstract

This invention relates to the field of image recognition technology, specifically disclosing a method for identifying fabric defects based on mattress fabric quality inspection. The method involves acquiring fabric surface images and performing dual-domain feature representation processing to obtain spatial domain image data and frequency domain spectral data representing the periodicity of texture. A dual-path collaborative perception structure is then constructed, comprising a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. This structure extracts multi-level spatial features and global periodic prior features. The cross-domain fusion unit generates spatial modulation weights based on the periodic prior features, applying weighted modulation to suppress background and enhance anomalies in the spatial features, outputting defect location information. Through adaptive segmentation, texture feature extraction, and template matching of the defect location information, a structured quality inspection result containing defect category and location is generated. This invention effectively overcomes the feature confusion problem under complex texture backgrounds, improving the accuracy and automation level of defect identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, specifically to a method for identifying fabric defects based on mattress fabric quality inspection. Background Technology

[0002] With the development of machine vision technology, automated defect detection methods based on image processing are gradually being applied. In the mattress fabric production process, rapid and accurate detection of surface defects (such as stains, broken yarns, holes, color differences, etc.) is a key step in ensuring product quality. Traditional quality inspection mainly relies on manual visual inspection, which suffers from problems such as low efficiency, high labor intensity, strong subjectivity, susceptibility to fatigue and missed detections, and high costs, making it difficult to meet the quality control requirements of modern high-speed production lines.

[0003] The existing technology has the following shortcomings: When inspecting mattress fabrics with highly periodic and complex textures such as high-precision jacquard and 3D weaving, the normal texture patterns, shadows caused by the weaving structure, and light reflection points on the surface are highly similar to the features of real defects such as tiny stains and broken yarns in the pixel-level feature space. While existing semantic segmentation networks can detect local anomalies, they lack the ability to explicitly understand the global periodicity of the image. Therefore, they cannot fundamentally distinguish between "meaningful background textures" and "meaningless defects," leading to the missegmentation of a large number of normal textures as defects, resulting in severe oversegmentation and a massive number of false positives. Simply increasing the judgment threshold to improve efficiency will cause real defects to be submerged in the textured background and missed. Summary of the Invention

[0004] The purpose of this invention is to provide a method for identifying fabric defects based on mattress fabric quality inspection, so as to solve the problems mentioned above.

[0005] The objective of this invention can be achieved through the following technical solutions: A method for identifying fabric defects based on mattress fabric quality inspection includes the following steps: S1: Acquire images of the fabric surface to obtain raw image data; S2: Perform dual-domain feature representation processing on the original image data to generate corresponding spatial domain image data and frequency domain spectral data. The frequency domain spectral data is used to characterize the periodicity of the fabric surface texture. S3: Construct a dual-path collaborative sensing structure, which includes a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. The spatial feature path is used to receive and process spatial domain image data and output multi-level spatial features. The frequency domain prior path is used to receive and process frequency domain spectrogram data and output global periodic prior features. S4: Based on the dual-path collaborative sensing structure, defect feature extraction and localization are performed. The cross-domain fusion unit generates spatial modulation weights for multi-level spatial features according to global periodic prior features, so as to suppress the texture feature response that conforms to the periodic pattern and enhance the non-periodic abnormal feature response, thereby outputting defect localization information. S5: Based on the defect location information, generate fabric quality inspection results that include the defect category and location.

[0006] As a further aspect of the present invention: S2 specifically includes: Convert the original image data into grayscale image data; Perform a two-dimensional Fourier transform on the grayscale image data to obtain the corresponding initial spectrum data, and calculate the amplitude information of the initial spectrum data to generate a spectrum amplitude diagram; Logarithmic operations are performed on the spectral amplitude plot to obtain a logarithmic spectrum plot. The logarithmic spectrum plot is then normalized to finally generate frequency domain spectrum data that characterizes the periodicity of the fabric surface texture.

[0007] As a further aspect of the present invention: the generation of the spectral amplitude map specifically includes: Windowing smoothing is performed on the grayscale image data to reduce spectral leakage, resulting in preprocessed grayscale image data; The preprocessed grayscale image data is input into a preset two-dimensional fast Fourier transform process to obtain initial spectral data containing complex numbers; Based on the initial spectrum data, calculate the squared real part and squared imaginary part of each frequency component corresponding to the initial spectrum data. The sum of the squared real part and the squared imaginary part is then taken as a square root to generate the spectral amplitude diagram.

[0008] As a further aspect of the present invention: S3 specifically includes: A frequency domain prior pathway is constructed. Through a first processing sequence consisting of multiple cascaded convolutional and pooling layers, features are extracted and compressed from the input frequency domain spectrogram data, and global periodic prior features are output. A spatial feature pathway is constructed, and a second processing sequence containing parallel high-resolution and low-resolution processing streams is used to extract multi-scale features from the input spatial domain image data and output multi-level spatial features. A cross-domain fusion unit is constructed. The cross-domain fusion unit first maps the global periodic prior features into a spatial weight map. Then, the spatial weight map is used to perform weighted modulation on selected level features in the multi-level spatial features, and the fused enhanced features are output as the basis for defect localization information.

[0009] As a further aspect of the present invention: the output multi-level spatial features specifically include: The input spatial domain image data is simultaneously input into both the high-resolution branch and the low-resolution branch; the high-resolution branch maintains the original spatial scale of the input data and processes it through the first convolution sequence; the low-resolution branch first reduces the spatial scale of the data through a convolution operation with a stride greater than one, and then processes it through the second convolution sequence. Upsample the feature data output from the low-resolution branch to the same spatial scale as the feature data from the high-resolution branch; The upsampled low-resolution feature data and the feature data output by the high-resolution branch are concatenated and fused by channel splicing to generate and output one layer of features in the multi-level spatial features.

[0010] As a further aspect of the present invention: S4 specifically includes: The global periodic prior features are input into a first mapping module consisting of a convolutional layer and a normalization layer to generate an initial spatial modulation weight map. The initial spatial modulation weight map is numerically inverted to generate a defect enhancement weight map. The defect enhancement weight map is multiplied element-wise with the preset intermediate level features in the multi-level spatial features to obtain the modulated candidate defect features. Convolution and nonlinear activation are performed on the candidate defect features to output defect location information that represents the probability distribution of the defect region.

[0011] As a further aspect of the present invention: the step of performing numerical inversion processing on the initial spatial modulation weight map to generate a defect enhancement weight map specifically includes: The initial spatial modulation weight map is subjected to maximum and minimum value normalization to obtain a normalized weight map with values ​​ranging from 0 to 1. Subtract a constant from each numerical element in the normalized weighted graph to obtain the intermediate weighted graph; A nonlinear mapping based on a preset power exponent is performed on the intermediate weight map to further amplify the weight difference between defective and non-defective regions, ultimately generating a defect-enhanced weight map.

[0012] As a further aspect of the present invention: S5 specifically includes: Perform adaptive threshold-based binarization segmentation and connected component analysis on the defect location information to obtain a preliminary set of defect region contours; For each contour in the preliminary set of defect region contours, the corresponding image patch is extracted from the spatial domain image data, and the local texture direction consistency and contrast features of the gray-level co-occurrence matrix of the image patch are calculated. The local texture direction consistency and contrast features are concatenated to form a defect description vector; The defect description vector is matched with a predefined defect feature template library to determine the final category of each defect region, and a structured fabric quality inspection result is generated by combining its contour coordinates.

[0013] The beneficial effects of this invention are: (1) This invention innovatively introduces frequency domain analysis into the defect detection process by constructing a dual-path collaborative perception structure. The frequency domain prior path specifically learns the global periodicity of fabric texture and generates spatial modulation weights through cross-domain fusion units, thereby dynamically suppressing the interference response generated by regular textures (such as jacquard patterns and woven shadows) in the spatial feature path, while enhancing the salience of non-periodic abnormal features. This method enables the model to essentially distinguish between "background texture" and "real defects", thus significantly reducing oversegmentation and false alarms caused by feature confusion when facing complex fabrics such as high-precision jacquard and three-dimensional weaving, while avoiding tiny defects being submerged by the background, achieving high-precision and highly robust pixel-level defect localization.

[0014] (2) This invention provides a complete solution from image acquisition to structured report generation. This method, through adaptive threshold segmentation and dual-feature (orientation consistency, contrast) template matching in the post-processing of defect location information, can automatically complete the accurate segmentation, feature quantification, and category determination of defect areas. The entire process requires no manual intervention in the iterative design of defect features and threshold adjustment, achieving a high degree of automation. The output results directly provide structured defect category, location, and contour information, greatly improving quality inspection efficiency and consistency, and providing reliable and quantifiable data support for real-time quality control and process optimization on the production line. Attached Figure Description

[0015] The invention will now be further described with reference to the accompanying drawings.

[0016] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Please see Figure 1 As shown, this invention is a method for identifying fabric defects based on mattress fabric quality inspection, comprising the following steps: S1: Acquire images of the fabric surface to obtain raw image data; S2: Perform dual-domain feature representation processing on the original image data to generate corresponding spatial domain image data and frequency domain spectral data. The frequency domain spectral data is used to characterize the periodicity of the fabric surface texture. S3: Construct a dual-path collaborative sensing structure, which includes a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. The spatial feature path is used to receive and process spatial domain image data and output multi-level spatial features. The frequency domain prior path is used to receive and process frequency domain spectrogram data and output global periodic prior features. S4: Based on the dual-path collaborative sensing structure, defect feature extraction and localization are performed. The cross-domain fusion unit generates spatial modulation weights for multi-level spatial features according to global periodic prior features, so as to suppress the texture feature response that conforms to the periodic pattern and enhance the non-periodic abnormal feature response, thereby outputting defect localization information. S5: Based on the defect location information, generate fabric quality inspection results that include the defect category and location.

[0019] In S1, images of the fabric surface are acquired to obtain raw image data, specifically including: The mattress fabric to be tested is laid flat on a conveyor belt moving at a constant speed. An industrial area array camera is fixedly installed directly above the conveyor belt. The camera is equipped with a high-resolution linear polarizing lens, and its imaging axis is perpendicular to the plane of the conveyor belt. On the same side of the camera lens, at a specific angle to the fabric surface, a uniformly diffused light source with adjustable brightness is installed. A polarizer is also installed in front of this light source, and its polarization direction is orthogonal to the polarization direction of the lens to eliminate interference from specular reflections from the fabric surface.

[0020] Image acquisition is triggered and synchronized using a photoelectric sensor. When the fabric moves along the conveyor belt and its leading edge reaches a preset starting position within the camera's field of view, the photoelectric sensor is triggered and generates a pulse signal. This pulse signal is sent to the image acquisition card, which controls the industrial area scan camera to perform exposure and capture. By adjusting the conveyor belt speed and the camera frame rate, a predetermined overlap area is ensured between adjacent images, thereby achieving continuous and complete imaging of the fabric.

[0021] The raw data captured by the camera is uncompressed color image data. This data is transmitted in real time to the image processing unit via a high-speed data interface. The image processing unit first appends a metadata header to each image, containing a capture timestamp, production line batch number, and fabric location code. Then, it caches the image data with metadata in a designated memory area, forming the raw image data that can be directly accessed in subsequent steps. This process ensures the independence and traceability of each frame of image data.

[0022] In S2, the original image data undergoes dual-domain feature representation processing to generate corresponding spatial domain image data and frequency domain spectral data. The frequency domain spectral data is used to characterize the periodicity of the fabric surface texture, specifically including: First, the original color image data is converted into grayscale image data. This conversion is achieved by linearly combining the red, green, and blue color channel components of each pixel with different weights. Specifically, the red channel value is multiplied by 0.299, the green channel value by 0.578, and the blue channel value by 0.114, and then the three products are added together to obtain the grayscale value of the pixel. This process iterates through all pixels in the image, ultimately generating grayscale image data that contains only brightness information.

[0023] Secondly, to reduce edge effects in subsequent spectral analysis, windowing smoothing is performed on the aforementioned grayscale image data. Specifically, the Hanning window function is used, whose value is generated by the cosine function, with a center value of 1 and edge values ​​approaching 0. Each pixel value of the grayscale image data is multiplied by the corresponding Hanning window function value to obtain the preprocessed grayscale image data. This step effectively suppresses spectral leakage caused by abrupt changes in brightness at image boundaries.

[0024] Next, a two-dimensional fast Fourier transform is performed on the preprocessed grayscale image data. This transform converts the spatial domain image data into complex form data in the frequency domain, i.e., the initial spectrum data. Each element in the initial spectrum data is a complex number, containing both real and imaginary values, which together characterize the amplitude and phase of the sinusoidal wave components at different frequencies and directions in the image.

[0025] Based on the obtained initial spectral data, its amplitude information is calculated to generate a spectral amplitude map. The calculation process is as follows: for each complex element in the initial spectral data, first, the real part is squared to obtain the squared real part value, and then the imaginary part is squared to obtain the square imaginary part value; subsequently, the squared real part value and the square imaginary part value are added together; finally, the square root operation is performed on the summation result. After completing the above calculations for all elements in the initial spectral data, the resulting two-dimensional matrix is ​​the spectral amplitude map, which intuitively reflects the intensity distribution of each frequency component in the image.

[0026] Next, a logarithmic operation is performed on the spectrum amplitude plot. Specifically, a very small constant (1) is added to each value in the spectrum amplitude plot, and then the base-10 logarithmic value of the sum is calculated. This process compresses the numerical differences in the high dynamic range of the spectrum plot, making the weaker high-frequency components more visually and numerically apparent, thus obtaining a logarithmic spectrum plot.

[0027] Finally, the logarithmic spectrogram is normalized to generate the final frequency domain spectrogram data. The specific normalization method is as follows: First, find the maximum and minimum values ​​in the entire logarithmic spectrogram; then, subtract the minimum value from each value in the graph; next, divide the difference obtained in the previous step by the difference between the maximum and minimum values; the result of this calculation linearly maps all values ​​to a closed interval between zero and one. The normalized data obtained after this step is the frequency domain spectrogram data used to clearly characterize the periodicity of the fundamental frequency, harmonics, and other patterns of the fabric surface texture.

[0028] In S3, a dual-path collaborative sensing structure is constructed, comprising a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. The spatial feature path receives and processes spatial domain image data, outputting multi-level spatial features. The frequency domain prior path receives and processes frequency domain spectral data, outputting global periodic prior features, specifically including: First, a frequency domain prior pathway is constructed. This pathway processes the input frequency domain spectral data to extract and compress features representing global texture periodicity. The first convolutional layer of the first processing sequence uses 16 3x3 convolutional kernels, processing the input data with stride one and zero-padding method one. The parameters of each convolutional kernel are convolved with the input data, the results are summed, and a learnable bias value is superimposed. Then, a nonlinear result is output through a modified linear unit activation function. The first pooling layer uses max pooling with a 2x2 window, downsampling the output of the first convolutional layer with stride two, and selecting the maximum value within each window as the output. The second convolutional layer uses 32 3x3 convolutional kernels, processing in the same way as the first convolutional layer, further extracting features from the output of the first pooling layer. The second pooling layer also uses max pooling, with the same window and stride as the first pooling layer, compressing the output of the second convolutional layer. Finally, the data output by the second pooling layer is the global periodic prior feature.

[0029] Secondly, a spatial feature pathway is constructed. This pathway aims to extract multi-scale features from spatial domain image data. The second processing sequence includes parallel high-resolution and low-resolution branches. The high-resolution branch preserves the original dimensions of the input data. Its first convolutional sequence consists of two consecutive convolutional layers: the first layer uses 64 3x3 convolutional kernels with a stride of 1 and zero padding of 1; the second layer uses 64 1x1 convolutional kernels with a stride of 1 and no zero padding. Each convolutional operation is followed by activation with a modified linear unit. The low-resolution branch first reduces the spatial scale through a convolutional operation with a stride of 2, using 64 3x3 convolutional kernels with a stride of 2 and zero padding of 1, halving the dimensions of the output data. Subsequently, its second convolutional sequence has the same structure as the first convolutional sequence of the high-resolution branch, processing the downsampled data. Afterward, the feature data output by the low-resolution branch is upsampled by a factor of two using bilinear interpolation to restore its spatial scale to the size of the feature data from the high-resolution branch. Finally, the upsampled low-resolution feature data is concatenated with the feature data output from the high-resolution branch along the channel dimension, forming a feature data with double the number of channels. This convolutional layer is then immediately fused with a 128-kernel (3x3) convolutional layer with a stride of one and zero padding of one. This convolution is followed by activation using a modified linear unit (MLU). The output of this fusion process represents the feature data of a specific level within the multi-level spatial feature set.

[0030] Finally, a cross-domain fusion unit is constructed. This unit is responsible for integrating features from two pathways. First, the global periodic prior features output from the frequency domain prior pathway are used as input, and a spatial weight map is generated through a mapping process consisting of convolutional layers and activation functions. Specifically, a convolutional layer with one kernel and a size of 1x1 is used to process the global periodic prior features with a stride of one and no zero padding, resulting in a single-channel feature map. Subsequently, a sigmoid activation function is applied to each numerical element of this feature map. This function maps any input value to between 0 and 1, thereby generating a spatial weight map. The closer the value is to one, the higher the probability that the spatial location belongs to a regular periodic texture. Next, the spatial weight map is used to perform weighted modulation on selected levels of the multi-level spatial features output from the spatial feature pathway (such as the features output from the aforementioned fusion processing). The modulation calculation is as follows: for each numerical element in the spatial weight map, the element value is subtracted by a constant 1 to obtain a defect concern weight; then, this defect concern weight is multiplied element-wise by all channel values ​​at the corresponding position in the spatial feature. The weighted and modulated feature data is the fused enhanced feature, which will serve as the basis for generating defect location information in subsequent steps.

[0031] In S4, defect feature extraction and localization are performed based on a dual-path collaborative sensing structure. The cross-domain fusion unit generates spatial modulation weights for multi-level spatial features based on global periodic prior features to suppress texture feature responses that conform to periodic patterns and enhance non-periodic abnormal feature responses, thereby outputting defect localization information, specifically including: First, the global periodic prior features output from the frequency domain prior path of S3 are used as input and fed into the first mapping module to generate an initial spatial modulation weight map. This first mapping module consists of a convolutional layer followed by a normalization layer. The convolutional layer uses a single 3x3 convolutional kernel with a stride of 1 and zero-padding mode 1, aiming to fuse and map the multi-channel periodic prior features into a single-channel preliminary weight response map. Subsequently, this response map is fed into a batch normalization layer. The batch normalization process first calculates the mean and standard deviation of the values ​​at each feature point in the response map for all data within the batch; then, each original value is subtracted from the mean of the corresponding feature point and divided by the standard deviation of that feature point, thus standardizing the numerical distribution; finally, a learnable scaling and translation transformation is applied to the normalized result. This normalization operation ensures the stability of the weight map values. The normalized output is then passed through a sigmoid activation function, which transforms each input value x to a value between zero and one. The transformation rule is: the output value equals one divided by (one plus the natural constant e raised to the power of negative x). After this step, the resulting single-channel two-dimensional data is the initial spatial modulation weight map. The closer the value at each position in the map is to one, the higher the probability that the original image region corresponding to that position conforms to the learned global periodicity.

[0032] Secondly, numerical inversion and nonlinear enhancement processing are performed on the initial spatial modulation weight map to generate a defect enhancement weight map that is more conducive to defect detection. This process consists of three sub-steps. The first step is to perform maximum-minimum normalization processing on the initial spatial modulation weight map. Specifically, the maximum value is found by traversing the weight map. and minimum value For each original value in the graph According to the rules Divide by The first step involves performing calculations to linearly scale all values ​​to a closed interval between zero and one, resulting in a normalized weight map. The second step is to perform numerical inversion. Each element in the normalized weight map is subtracted from a constant (1) to obtain an intermediate weight map. ,Right now .at this time, The larger the median value, the weaker the periodicity at that location, and the higher the probability that it is a potential defect area. The third step involves applying a non-linear mapping based on a preset power exponent to the intermediate weight map to further widen the weight difference between the potential defect area and the background area, thus enhancing contrast. The rule for this mapping is: the final weight value equals the median weight value. of The power, that is The power exponent. It is a real number greater than one, and its specific value is determined by statistical analysis of the training dataset. The calculation method is as follows: from the intermediate weighted graph of all normal samples in the dataset In this context, the mean of the overall numerical distribution is calculated. and standard deviation Then follow the formula Calculations are performed to determine the enhancement intensity. The purpose of this design is to adaptively adjust the enhancement strength based on the density of the data's inherent "periodic regularity." This applies when the background (strong regularity) and defects (weak regularity) are... Insufficient discrimination (standard deviation of distribution) (hours) index This will increase, making the nonlinear stretching effect stronger, thus widening the gap between the two. The result obtained after this nonlinear mapping is the defect enhancement weight map.

[0033] Next, the generated defect enhancement weight map is compared with... In the multi-level spatial features output by the mid-space feature path, a pre-defined intermediate-level feature (e.g., a feature generated after fusing high- and low-resolution branches) is multiplied element-wise. The multiplication rule is: the feature located in the defect enhancement weight map at the coordinate... A single scalar value, located at the same coordinate in the spatial feature. The values ​​of all channels are multiplied separately. This operation mathematically achieves spatial domain modulation: at locations with high defect enhancement weight values ​​(suspected defect regions), the original spatial features are preserved or enhanced; at locations with low defect enhancement weight values ​​(strong periodic background regions), the original spatial features are suppressed. The output data after modulation is the candidate defect feature that has been purified and enhanced by prior knowledge in the frequency domain.

[0034] Finally, further convolution and non-linear activation processing is performed on the modulated candidate defect features to output accurate defect localization information. This process consists of a convolutional layer and an activation function sequentially. The convolutional layer uses 64 3x3 convolutional kernels, performing convolution operations on the candidate defect features with a stride of one and zero padding to aggregate contextual information and integrate features. Subsequently, the output of the convolutional layer is passed through a Sigmoid activation function. After processing by the Sigmoid function, each value in the output data is mapped to the interval between zero and one, which can be interpreted as the probability that the corresponding image pixel location belongs to the defect region. This final two-dimensional probability distribution map is the defect localization information, which clearly indicates the probability that each pixel in the image is a defect, providing a direct basis for subsequent judgment and quantification.

[0035] In S5, based on the defect location information, fabric quality inspection results containing the defect category and location are generated, specifically including: First, the defect location information output by S4, i.e., the defect probability distribution map, is subjected to binarization segmentation based on an adaptive threshold. The adaptive threshold is calculated using Otsu's method. Specifically, the histogram distribution of all pixel values ​​in the probability distribution map is statistically analyzed. All possible thresholds between zero and one are iterated through. The inter-class variance is calculated after classifying pixels into "foreground" (defect) and "background" categories using each candidate threshold as the boundary. The threshold that maximizes this inter-class variance is determined as the final adaptive segmentation threshold. This threshold is then used to binarize the probability map, setting pixels with values ​​greater than or equal to the threshold to a value of one (representing foreground points), and pixels with values ​​less than the threshold to a value of zero (representing background points). Subsequently, eight-neighborhood connected component analysis is performed on the resulting binary image. Each region formed by connecting pixels with values ​​of one is labeled, and its minimum bounding rectangle and the precise pixel contour enclosed by that rectangle are extracted. All extracted contours constitute a preliminary set of defect region contours.

[0036] Secondly, for each contour in the aforementioned contour set, an image patch enclosed by the smallest bounding rectangle of that contour is extracted from its corresponding original spatial domain image data (i.e., the image acquired by S1 and processed by S2). For each image patch, two key texture features are calculated. The first feature is the consistency of local texture orientation. The calculation process is as follows: First, the image patch is convolved using horizontal and vertical edge detection operators to obtain the gradient value of each pixel in the horizontal direction. and gradient value in the vertical direction Next, the gradient direction angle of each pixel is calculated, and its value is for that pixel. and The result of the arctangent function of the ratio. Then, the directional range from 0 degrees to 180 degrees is evenly divided into several intervals, and the number of gradient direction corners of all pixels in the image patch in each interval is counted to form a direction histogram. The local texture direction consistency index is defined as the square of the maximum frequency value in the direction histogram, divided by (the sum of the squares of all frequency values ​​in the direction histogram, multiplied by the total number of intervals). The value of this calculation result is between 0 and 1, and the larger the value, the more consistent the texture direction. The second feature is the contrast based on the gray-level co-occurrence matrix. The construction process is as follows: first, the image patch is converted into a grayscale image, a fixed spatial relationship is preset (for example, a pixel and its right adjacent pixel), and the grayscale value of the previous pixel in all pixel pairs that satisfy the spatial relationship is counted. And the grayscale value of the next pixel is The probability of their occurrence is thus formed into a co-occurrence probability matrix. The contrast eigenvalues ​​of this matrix are calculated using the following rule: traversing all... and , each Corresponding probability value Multiply and Square the difference, then sum all these products.

[0037] Next, the local texture orientation consistency feature value (a scalar) and the gray-level co-occurrence matrix contrast feature value (a scalar) calculated for the same image patch are concatenated in sequence to form a defect description vector containing two elements. This vector comprehensively characterizes the region's properties in terms of both texture orientation order and the degree of drastic local gray-level changes.

[0038] Finally, the generated defect description vector is matched against a predefined defect feature template library to determine the final category of each defect region. The template library is constructed as follows: sample images containing various known defects (such as stains, broken yarn, holes, etc.) are collected beforehand. For each sample region, its defect description vector is calculated using the aforementioned method. The average of the two components of the vectors for all samples belonging to the same category is calculated, thus obtaining the standard feature vector template for each type of defect. During matching, the Euclidean distance between the description vector of the defect to be determined and the standard feature vector of each category in the template library is calculated. The Euclidean distance is calculated as follows: the two elements at corresponding positions of the defect to be determined and a standard vector are subtracted, each difference is squared, the two squared values ​​are added, and the square root of the sum is taken. The defect category corresponding to the standard vector with the smallest Euclidean distance to the defect to be determined is determined as the final category of the defect region to be determined. Finally, the contour coordinates of each defect area (such as the coordinates of the top left corner, width, and height of the smallest bounding rectangle) are combined with the defect category it is determined to be, and organized according to a predetermined data format (such as Extensible Markup Language format) to generate a complete and structured fabric quality inspection result document.

[0039] The working principle of this invention is as follows: First, raw image data of the fabric surface is acquired using a polarized light source and a camera. This data is then processed using dual-domain feature representation to generate spatial domain image data and frequency domain spectral data representing the periodicity of the texture. Next, a dual-path collaborative sensing structure is constructed, comprising a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. Multi-level spatial features and global periodic prior features are extracted from both the spatial and frequency domains. Based on this, the cross-domain fusion unit generates spatial modulation weights according to the periodic prior features, and performs weighted modulation on the spatial features to suppress periodic texture responses and enhance abnormal responses, ultimately outputting defect location information. Finally, by performing adaptive threshold segmentation, texture feature extraction, and template matching on the defect location information, accurate determination of the defect category is achieved, and a structured quality inspection result containing defect category and location information is generated.

[0040] The foregoing has provided a detailed description of one embodiment of the present invention, but this description is merely a preferred embodiment and should not be construed as limiting the scope of the invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the patent coverage of this invention.

Claims

1. A method for identifying fabric defects based on mattress fabric quality inspection, characterized in that, Includes the following steps: S1: Acquire images of the fabric surface to obtain raw image data; S2: Perform dual-domain feature representation processing on the original image data to generate corresponding spatial domain image data and frequency domain spectral data. The frequency domain spectral data is used to characterize the periodicity of the fabric surface texture. S3: Construct a dual-path collaborative sensing structure, which includes a spatial feature path, a frequency domain prior path, and a cross-domain fusion unit. The spatial feature path is used to receive and process spatial domain image data and output multi-level spatial features. The frequency domain prior path is used to receive and process frequency domain spectrogram data and output global periodic prior features. S4: Based on the dual-path collaborative sensing structure, defect feature extraction and localization are performed. The cross-domain fusion unit generates spatial modulation weights for multi-level spatial features according to global periodic prior features, so as to suppress the texture feature response that conforms to the periodic pattern and enhance the non-periodic abnormal feature response, thereby outputting defect localization information. S5: Based on the defect location information, generate fabric quality inspection results that include the defect category and location.

2. The fabric defect image recognition method based on mattress fabric quality inspection according to claim 1, characterized in that, S2 specifically includes: Convert the original image data into grayscale image data; Perform a two-dimensional Fourier transform on the grayscale image data to obtain the corresponding initial spectrum data, and calculate the amplitude information of the initial spectrum data to generate a spectrum amplitude diagram; Logarithmic operations are performed on the spectral amplitude plot to obtain a logarithmic spectrum plot. The logarithmic spectrum plot is then normalized to finally generate frequency domain spectrum data that characterizes the periodicity of the fabric surface texture.

3. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 2, characterized in that, The generation of the spectral amplitude map specifically includes: Windowing smoothing is performed on the grayscale image data to reduce spectral leakage, resulting in preprocessed grayscale image data; The preprocessed grayscale image data is input into a preset two-dimensional fast Fourier transform process to obtain initial spectral data containing complex numbers; Based on the initial spectrum data, calculate the squared real part and squared imaginary part of each frequency component corresponding to the initial spectrum data. The sum of the squared real part and the squared imaginary part is then taken as a square root to generate the spectral amplitude diagram.

4. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 1, characterized in that, S3 specifically includes: A frequency domain prior pathway is constructed. Through a first processing sequence consisting of multiple cascaded convolutional and pooling layers, features are extracted and compressed from the input frequency domain spectrogram data, and global periodic prior features are output. A spatial feature pathway is constructed, and a second processing sequence containing parallel high-resolution and low-resolution processing streams is used to extract multi-scale features from the input spatial domain image data and output multi-level spatial features. A cross-domain fusion unit is constructed. The cross-domain fusion unit first maps the global periodic prior features into a spatial weight map. Then, the spatial weight map is used to perform weighted modulation on selected level features in the multi-level spatial features, and the fused enhanced features are output as the basis for defect localization information.

5. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 4, characterized in that, The output multi-level spatial features specifically include: The input spatial domain image data is simultaneously input into both the high-resolution branch and the low-resolution branch; the high-resolution branch maintains the original spatial scale of the input data and processes it through the first convolution sequence; the low-resolution branch first reduces the spatial scale of the data through a convolution operation with a stride greater than one, and then processes it through the second convolution sequence. Upsample the feature data output from the low-resolution branch to the same spatial scale as the feature data from the high-resolution branch; The upsampled low-resolution feature data and the feature data output by the high-resolution branch are concatenated and fused by channel splicing to generate and output one layer of features in the multi-level spatial features.

6. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 1, characterized in that, S4 specifically includes: The global periodic prior features are input into a first mapping module consisting of a convolutional layer and a normalization layer to generate an initial spatial modulation weight map. The initial spatial modulation weight map is numerically inverted to generate a defect enhancement weight map. The defect enhancement weight map is multiplied element-wise with the preset intermediate level features in the multi-level spatial features to obtain the modulated candidate defect features. Convolution and nonlinear activation are performed on the candidate defect features to output defect location information that represents the probability distribution of the defect region.

7. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 6, characterized in that, The step of performing numerical inversion processing on the initial spatial modulation weight map to generate a defect enhancement weight map specifically includes: The initial spatial modulation weight map is subjected to maximum and minimum value normalization to obtain a normalized weight map with values ​​ranging from 0 to 1. Subtract a constant from each numerical element in the normalized weighted graph to obtain the intermediate weighted graph; A nonlinear mapping based on a preset power exponent is performed on the intermediate weight map to further amplify the weight difference between defective and non-defective regions, ultimately generating a defect-enhanced weight map.

8. The method for image recognition of fabric defects based on mattress fabric quality inspection according to claim 1, characterized in that, S5 specifically includes: Perform adaptive threshold-based binarization segmentation and connected component analysis on the defect location information to obtain a preliminary set of defect region contours; For each contour in the preliminary set of defect region contours, the corresponding image patch is extracted from the spatial domain image data, and the local texture direction consistency and contrast features of the gray-level co-occurrence matrix of the image patch are calculated. The local texture direction consistency and contrast features are concatenated to form a defect description vector; The defect description vector is matched with a predefined defect feature template library to determine the final category of each defect region, and a structured fabric quality inspection result is generated by combining its contour coordinates.