Cloth defect feature extraction and detection method
By combining frequency domain analysis and phase propagation model with local perturbation variance and back-and-forth propagation deviation, we have achieved accurate characterization of fabric texture rhythm and anomaly detection, solving the problems of low efficiency and high false detection rate in existing technologies, and significantly improving the accuracy and robustness of defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHANGSHU BAOFENG SPECIAL FIBER
- Filing Date
- 2026-01-16
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies are inefficient and have high false positive and false negative rates in fabric defect detection, especially in cases with complex textures, fine defects, or low contrast, where their adaptability and robustness are insufficient.
By extracting the main frequency and main weave angle through frequency domain analysis, and combining the phase response and propagation deviation models, defects are screened out by adopting a joint judgment mechanism of local disturbance variance and back-and-forth propagation deviation.
It improves the accuracy and robustness of fabric defect detection, reduces the false detection rate and missed detection rate, and has a better detection effect on fine, low-contrast defects, thus improving the level of automation and reliability.
Smart Images

Figure CN121962072A_ABST
Abstract
Description
A method for feature extraction and detection of fabric defects Technical Field
[0001] This invention relates to the field of fabric quality inspection technology, specifically a method for feature extraction and detection of fabric defects. Background Technology
[0002] In the textile industry, the control of fabric quality directly affects the quality of the final product and its market competitiveness. During the production process, fabrics often develop various defects due to factors such as loom malfunctions, yarn defects, and fluctuations in process parameters, including warp breaks, weft breaks, stains, and holes. Traditionally, the detection of fabric defects mainly relies on manual visual inspection. This method is not only inefficient and labor-intensive, but also easily affected by subjective factors such as personnel experience and fatigue, resulting in inconsistent inspection results and failing to meet the high-speed, high-precision production demands of the modern textile industry.
[0003] With the development of machine vision technology, automated defect detection has gradually become a research and application hotspot. Existing image processing-based detection methods mainly include grayscale statistical methods, texture analysis methods, and frequency domain analysis methods. For example, some methods extract grayscale or texture features from fabric images and combine them with threshold segmentation or classifiers for defect identification. These methods are effective in scenarios with simple textures and obvious defects, but they often perform poorly in cases with complex textures, subtle defects, or low contrast with the background, resulting in high false positive and false negative rates. Other methods employ frequency domain analysis, such as two-dimensional Fourier transform and wavelet transform, to detect texture anomalies by analyzing the frequency features of the image. However, these methods are usually sensitive to periodic changes in texture and struggle to accurately distinguish between normal texture fluctuations and real defects. Especially in fabric images with variable texture directions and complex local structures, the adaptability and robustness of frequency domain methods remain insufficient.
[0004] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a method for feature extraction and detection of fabric defects, so as to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a method for feature extraction and detection of fabric defects, comprising the following steps: Step 1: acquiring a grayscale image of the fabric to be detected, referred to as the first fabric image; performing frequency domain analysis on the first fabric image to obtain the principal frequency and principal weave angle of the first fabric image, and determining the phase response of the first fabric image under the rhythm of the principal frequency and principal weave angle; Step 2: for each pixel, acquiring its nearest pixel in the principal weave angle direction; predicting the phase response of each pixel at the nearest pixel based on the principal frequency, principal weave angle, and the phase response of the pixel and the nearest pixel; and calculating the phase deviation by combining the phase response of the nearest pixel and the predicted phase response; Step 3: calculating based on the phase deviation. Step 4: For each pixel with poor propagation, obtain the predicted phase response of its nearest pixel at that pixel, combine the phase response of the poorly propagated pixel to obtain the back-propagation phase deviation of the poorly propagated pixel, and combine the phase deviation of the poorly propagated pixel and the back-propagation phase deviation to obtain the round-trip propagation deviation of the poorly propagated pixel; Step 5: Calculate the average value of the phase deviation within the window centered on each pixel with poor propagation, and combine the round-trip propagation deviation to set the fabric defect judgment rule, and filter out defects from the poorly propagated pixels based on the fabric defect judgment rule.
[0007] Further, in the spatial domain, a rectangular coordinate axis is established with the center of the first fabric image as the origin, the horizontal direction to the right as the positive X-axis, and the vertical direction upward as the positive Y-axis, to represent each pixel of the first fabric image. A two-dimensional Fourier transform is performed on the first fabric image to obtain the amplitude spectrum along the X-axis and Y-axis frequencies of the first fabric image in the frequency domain, where the X-axis and Y-axis frequencies of the first fabric image are used as the frequency coordinates in the frequency domain. The radius from each point in the amplitude spectrum to the center of the spectrum is calculated to obtain the frequency domain radius. A preset frequency domain radius threshold is set, and amplitude maxima points are selected in the frequency domain that are greater than the frequency domain radius threshold to form a candidate peak set. In the candidate peak set, if two amplitude maxima points exhibit a conjugate symmetry relationship, the two amplitude maxima points are called a candidate peak pair. In the candidate peak pair, the square of the amplitude of each amplitude maxima point is calculated, and the squares of the two amplitudes are summed to obtain the joint energy. The candidate peak pair with the largest joint energy is taken as the main peak pair, and the average frequency domain radius of each amplitude maxima point in the main peak pair is taken as the main frequency. In the candidate peak pair, the following calculations are performed: The Y-axis frequency at each amplitude maxima is divided by the X-axis frequency to obtain the frequency ratio. The inverse tangent function of this frequency ratio is then calculated to obtain the positive interlacing angle. The average positive interlacing angle of the main peak at each amplitude maxima is taken as the main positive interlacing angle. The angle orthogonal to the main positive interlacing angle is called the main weaving angle. The first fabric image is filtered based on the main frequency and the main weaving angle, and the filtered result is convolved with the first fabric image to obtain the complex response of the first fabric image under the main frequency and main weaving angle rhythm. The phase angle of the complex response is obtained as the phase response of the first fabric image under the main frequency and main weaving angle rhythm.
[0008] Furthermore, the logic for filtering the first fabric image based on the dominant frequency and the dominant weave angle is as follows: In the spatial domain, the coordinate axes of the first fabric image are converted into coordinate axes pointing from the X-axis to the direction of the dominant weave angle, which are called the weave direction coordinate axes. For each pixel in the rectangular coordinates, its dominant frequency is combined with the weave direction coordinate axis and substituted into the two-dimensional complex Gabor function to obtain the filtering result.
[0009] Furthermore, the logic for obtaining the predicted phase response is as follows: For each pixel, in the weave direction coordinate axis, the pixels adjacent to this pixel are called neighboring pixels. The neighboring pixel with the smallest absolute difference from the pixel's X-axis value, and whose X-axis value is not less than the pixel's X-axis value, is selected and called the nearest pixel in the main weave direction angle. The absolute difference is then calculated... The product of the main frequency and the phase of that point is added to obtain the predicted phase of the nearest pixel.
[0010] Furthermore, the logic for obtaining the local perturbation variance is as follows: the absolute difference between the phase of the nearest pixel and the predicted phase is called the phase deviation of that pixel; using that pixel as the center, a... The window defines the region where the pixel is located. Within this region, the phase deviation of all pixels is calculated. The variance of the phase deviation of all pixels within this region that have the nearest pixel is calculated to obtain the perturbation variance. This perturbation variance is then used as the local perturbation variance within the window centered on each pixel.
[0011] Furthermore, the condition for judging smooth propagation is: if the perturbation variance within the area centered on a pixel is greater than a preset perturbation variance threshold, then the pixel is called a pixel with poor propagation.
[0012] Furthermore, the logic for obtaining the backhaul deviation is as follows: For each pixel with poor propagation, obtain its nearest pixel, calculate the absolute difference between the nearest pixel and the pixel with poor propagation on the X-axis, and calculate the absolute difference with... The product of the main frequency and the negative of the product is added to the phase response of the nearest pixel to obtain the predicted phase response of the nearest pixel at the poorly propagated pixel, which is called the back propagation phase response. The absolute difference between the back propagation phase response and the phase response of the poorly propagated pixel is called the back propagation phase deviation. The absolute difference between the phase deviation of the poorly propagated pixel and the back propagation phase deviation is calculated as the round-trip propagation deviation of the poorly propagated pixel.
[0013] Furthermore, the fabric defect judgment rule is as follows: if a preset phase deviation threshold and a back-and-forth propagation deviation threshold are set, if the average phase deviation within the window centered on each poorly propagated pixel is less than the phase deviation threshold, and the back-and-forth propagation deviation is less than the back-and-forth propagation deviation threshold, then the pixel is not a defect; otherwise, the pixel is a defect.
[0014] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention achieves accurate characterization of fabric texture rhythm and high-sensitivity detection of abnormal propagation by combining frequency domain analysis and phase propagation models. First, by extracting the main frequency and main weave angle and combining them with phase response analysis, the normal texture pattern of the fabric can be accurately described. Second, by designing forward and reverse propagation deviation calculations, the ability to identify local structural anomalies is enhanced, effectively distinguishing between natural texture variations and real defects. Finally, by introducing a joint judgment mechanism of local disturbance variance and back-and-forth propagation deviation, the accuracy and robustness of defect detection are significantly improved, especially for subtle, low-contrast defects, thereby reducing the false detection rate and the missed detection rate, and improving the automation level and reliability of fabric quality control. Attached Figure Description
[0015] Figure 1 is a schematic diagram of the overall method flow of the present invention; Figure 2 is a schematic diagram of the defect identification results of the fabric in the present invention. Detailed Implementation
[0016] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0017] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0018] Example: Please refer to Figures 1 and 2. This invention provides a technical solution: a method for feature extraction and detection of fabric defects, the specific steps of which include: Step 1: Obtaining a grayscale image of the fabric to be detected, referred to as the first fabric image; performing frequency domain analysis on the first fabric image to obtain the principal frequency and principal weave angle of the first fabric image, and determining the phase response of the first fabric image under the rhythm of the principal frequency and principal weave angle; further, in the spatial domain, establishing a rectangular coordinate axis with the center of the first fabric image as the origin, the horizontal direction to the right as the positive X-axis, and the vertical direction upward as the positive Y-axis, to represent each pixel of the first fabric image; performing a two-dimensional Fourier transform on the first fabric image to obtain the amplitude spectrum along the X-axis and Y-axis frequencies of the first fabric image in the frequency domain, respectively. This is expressed as frequency coordinates with the X and Y axes of the first fabric image as the frequency domain. The radius from each point in the amplitude spectrum to the center of the spectrum is calculated to obtain the frequency domain radius; the formula is:
[0019] in, For frequency domain radius, The frequency coordinates of the X-axis of the first fabric image. The frequency coordinate of the Y-axis of the first fabric pattern. Frequency coordinates are The amplitude of time.
[0020] A preset frequency domain radius threshold is used to select amplitude maxima points in the frequency domain that are greater than the threshold, thus forming a candidate peak set. It should be noted that these maxima are two-dimensional maxima, meaning they are located within a certain range. The corresponding maximum value within the 8-neighborhood is existing technology and will not be elaborated upon here.
[0021] Selecting amplitude maxima points in the frequency domain above the frequency domain radius threshold effectively extracts the dominant frequency components corresponding to the periodic weaving texture in fabric images, while suppressing interference from low-frequency DC components (i.e., overall image brightness) and high-frequency noise, thus accurately characterizing the periodic structural features of the fabric texture. By setting the frequency domain radius threshold, low-frequency energy representing the uniform background of the image near the spectral center can be filtered out, allowing the analysis to focus on the mid-to-high frequency region that truly reflects the texture periodicity. Further selecting amplitude maxima points within this region can accurately capture the main resonance peak of the texture in the frequency domain. This robustly identifies the main periodicity and direction information of the fabric texture in the two-dimensional frequency domain (i.e., the subsequent dominant frequency and main weaving direction angle), laying a stable and reliable frequency domain feature foundation for subsequent phase analysis and defect detection. This enhances the ability to characterize the main pattern of texture propagation, improves the adaptability of subsequent defect detection algorithms to the propagation background, and reduces the risk of misjudgment caused by uneven illumination or image noise.
[0022] The preset frequency domain radius threshold can be obtained using existing technology. In this embodiment, it is determined through a statistical method of spectral energy distribution. Specifically, statistical analysis is performed on the spectra of a large number of normal fabric samples to observe the distribution pattern of amplitude spectrum energy with frequency domain radius. Typically, energy will exhibit a significant peak within a certain radius range. The threshold is set after the first significant rise point of the energy distribution curve, for example, selecting the radius value corresponding to when the cumulative energy percentage reaches 5%-10% of the total energy, thereby filtering out low-frequency background. Other methods can also be used, which are existing technologies and will not be elaborated upon here.
[0023] In the candidate peak set, if there exist two amplitude maxima points that exhibit a conjugate symmetry relationship, if and satisfy Then it is considered and The relationship exhibits conjugate symmetry, which is a theoretically strict conjugate symmetry relationship, but difficult to strictly satisfy in engineering. However, it is practically satisfied in engineering. Therefore, in this embodiment, and The absolute difference is considered to satisfy the conjugate symmetry relationship if it is less than 1% of the minimum value.
[0024] Two amplitude maxima are called candidate peak pairs. Within each candidate peak pair, the square of the amplitude of each amplitude maxima is calculated, and the sum of the squares of the two amplitudes is taken as the joint energy. The candidate peak pair with the largest joint energy is selected as the dominant peak pair, and the average frequency domain radius of each amplitude maxima in the dominant peak pair is taken as the dominant frequency. By identifying and pairing amplitude maxima points (candidate peak pairs) that exhibit conjugate symmetry in the spectrum, we can capture the essential manifestation of texture periodicity in its real-imaginary symmetry. Selecting the peak pair with the largest joint energy as the dominant peak pair ensures that the algorithm locks onto the most significant and stable periodic pattern in the texture, thereby resisting interference from noise and non-dominant texture components. Then, by calculating the average frequency domain radius of this peak pair, the dominant frequency (i.e., spatial period) of the texture can be robustly estimated. In the candidate peak pair, the Y-axis frequency to X-axis frequency at each amplitude maxima is calculated to obtain the frequency ratio. Then, the inverse tangent function of this frequency ratio is calculated to obtain the positive interlacing angle. The average value of the positive interlacing angles at each amplitude maxima of the main peak pair is taken as the main positive interlacing angle. The main positive interlacing angle determined by the main peak in the frequency domain is the direction of the fastest change, while the actual weaving direction is its orthogonal (perpendicular) direction. Therefore, the angle orthogonal to the main positive interlacing angle is called the main weaving angle. Due to conjugate symmetry, the frequency domain radius and inverse tangent function of the two peaks in the candidate peak pair are usually exactly the same. Considering that non-strict conjugate symmetry is allowed in engineering, the average value operation is performed.
[0025] The first fabric image is filtered based on the dominant frequency and the dominant weave angle. The logic for filtering the first fabric image based on the dominant frequency and the dominant weave angle is as follows: In the spatial domain, the coordinate axes of the first fabric image are transformed into coordinate axes pointing from the X-axis to the direction of the dominant weave angle, which are called the weave direction coordinate axes. For each pixel in the rectangular coordinates, its dominant frequency is combined with the weave direction coordinate axis and substituted into the two-dimensional complex Gabor function to obtain the filtering result.
[0026] The formula for converting to the weave direction coordinate axis is:
[0027] in, The coordinates are on the rectangular coordinate axes. For the weaving direction coordinate axis, Main weaving direction angle; the filtering result is expressed as:
[0028] in, The result of the filtering is as follows. Let be the spatial scale parameter, which is a constant, typically taken as . 3-4 times, The imaginary unit, Main frequency.
[0029] This is done to construct a bandpass filter that perfectly matches the inherent rhythm of the fabric texture in both frequency and direction, thereby optimally extracting the periodic components in the image that conform to this rhythm, while suppressing irrelevant background, noise, and texture interference from other directions.
[0030] By rotating the image coordinate axes to align with the principal weave direction angle (weave direction coordinate axis) and parameterizing the two-dimensional complex Gabor function using the principal frequency characterizing the spatial period of the texture, we effectively create an analytical kernel in the spatial domain whose direction and frequency are both adaptive to the current fabric texture. This kernel is a complex sine wave oscillating at the principal frequency in the weave direction and locally constrained by a Gaussian envelope in the vertical direction, which allows it to strongly resonate with regular fluctuations along the texture direction.
[0031] The filtered result is then convolved with the first fabric image to obtain the complex response of the first fabric image under the main frequency and main weave direction rhythm. The phase angle of the complex response is then obtained as the phase response of the first fabric image under the main frequency and main weave direction rhythm. Convolving the filtered result with the first fabric image is essentially performing an adaptive Gabor filtering process in the spatial domain. Its purpose is to accurately extract the local texture periodic components oscillating along the main weave direction at the main frequency from the original image and resolve them as complex responses containing amplitude and phase. This adaptive Gabor filtering can faithfully separate the complex responses (especially phase information) synchronized with the texture primitives from the original grayscale image, generating a phase field. This phase field accurately characterizes the position (phase angle) of each pixel in its local texture periodic waveform. This lays an accurate and robust foundation for subsequent anomaly detection (defects disrupt this continuity) by analyzing the continuity of phase propagation in the texture direction, significantly enhancing the algorithm's adaptability to texture changes and the sensitivity of defect detection.
[0032] Step 2: For each pixel, obtain its nearest pixel in the main weave angle direction. Based on the main frequency, main weave angle, and the phase response of the pixel and the nearest pixel, predict the phase response of each pixel in the nearest pixel. Combine the phase response of the nearest pixel and the predicted phase response to calculate the phase deviation. The logic for obtaining the predicted phase response is as follows: For each pixel, in the weave coordinate axis, the pixels adjacent to the pixel are called neighboring pixels. Find the neighboring pixel with the smallest absolute difference from the pixel's X-axis value and whose X-axis value is not less than the pixel's X-axis value, and call this pixel the nearest pixel in the main weave angle direction. This is done to determine a clear and unique "next" neighboring reference point on the phase propagation path for each pixel along the main weave angle (i.e., the main direction of the texture), thereby quantifying the local consistency of phase propagation along the texture direction.
[0033] By selecting neighboring points with the smallest X-coordinate difference that is not less than the current point, the algorithm establishes a unidirectional, ordered phase propagation chain along the texture direction. This simulates the expected behavior in an ideal, regular texture, where the phase value should smoothly and continuously increase or periodically change along the texture direction. This step provides the necessary spatial correspondence for calculating the phase prediction deviation of each pixel to its "next" point.
[0034] Since the neighborhood is symmetrical about the pixel, there are usually two minimum absolute differences. Setting "X value is not less than the pixel" ensures that there is always a direction to choose from between the two pixels.
[0035] In an ideal, flawless, regular texture, its grayscale (or reflectivity) along the weave angle should approximate a waveform with a stable spatial frequency (dominant frequency). The phase extracted by Gabor filtering characterizes the position of the pixel within the texture waveform period. If there are no defects, the phase response at its next position is predictable.
[0036] Calculate the absolute difference and The product of the dominant frequency and the phase at that point is used as the predicted phase of the nearest pixel. The predicted phase reflects the degree of local detuning of the texture rhythm during spatial propagation. It is a measurement used to quantify the matching error at a specific pixel location between the actually observed texture fluctuations and the ideal periodic model established based on the global dominant frequency and dominant direction.
[0037] The absolute difference between the phase of the nearest pixel and the predicted phase is called the phase deviation of that pixel. The phase deviation directly reflects the degree of local detuning when the texture phase propagates along the main weave angle, that is, the matching error between the actual observed phase change and the predicted value of the ideal periodic model based on the global main frequency. The larger the deviation value, the more significant the break or jump between the local texture structure (such as the phase value) at that pixel and its downstream adjacent points, violating the rule that the texture waveform should propagate smoothly and continuously. This indicates a high risk of poor propagation at this location, which may be caused by physical continuity disruption directly by defects (such as broken yarns or stains), or it may originate from non-defect interference (such as shadows, wrinkles, or pattern boundaries).
[0038] Step 3: Calculate the local perturbation variance within a window centered on each pixel based on the phase deviation, and set a smooth propagation judgment condition. Pixels with poor propagation are then filtered out based on this condition. The logic for obtaining the local perturbation variance is as follows: the absolute difference between the phase of the nearest pixel and the predicted phase is called the phase deviation of that pixel; using that pixel as the center, a... The window defines the region where the pixel is located. Within this region, the phase deviation of all pixels is calculated. The variance of the phase deviation of all pixels within this region that have the nearest pixel is calculated to obtain the perturbation variance. This perturbation variance is then used as the local perturbation variance within the window centered on each pixel.
[0039] The perturbation variance reflects the dispersion of the phase deviation values of all pixels within a local neighborhood centered on a given pixel, i.e., the collective disorder or inconsistency of texture rhythm propagation in that region. A larger value indicates more severe fluctuations and a lack of coordination in the phase deviation of points within that region, resulting in widespread and disordered interruptions or distortions in the periodic structure of the texture. Therefore, the propagation smoothness judgment condition is set as follows: if the perturbation variance within a region centered on a given pixel is greater than a preset perturbation variance threshold, then that pixel is considered a poorly propagated pixel.
[0040] This not only means that there may be defects (such as large areas of stains or disordered tissue), but may also indicate that the area is a normal boundary of texture patterns, a strong shadow edge, or other areas with high spatial variability. Therefore, high perturbation variance indicates that the local environment where the center point is located is extremely unstable in terms of texture phase propagation, and is an important candidate anomalous area that needs to be further identified in subsequent steps.
[0041] Step 4: For each poorly propagated pixel, obtain the predicted phase response of its nearest pixel at that poorly propagated pixel. Combine this with the phase response of the poorly propagated pixel to obtain the backpropagation phase deviation of the poorly propagated pixel. Combine the phase deviation of the poorly propagated pixel and the backpropagation phase deviation to obtain the round-trip propagation deviation of the poorly propagated pixel. Further, the logic for obtaining the backpropagation deviation is as follows: For each poorly propagated pixel, obtain its nearest pixel, calculate the absolute difference between the nearest pixel and the poorly propagated pixel on the X-axis, and calculate the absolute difference with... The product of the main frequency and the negative of the product is added to the phase response of the nearest pixel. This is used as the predicted phase response of the nearest pixel at the pixel with poor propagation, and is called the backpropagation phase response. The absolute difference between the backpropagation phase response and the phase response of the pixel with poor propagation is called the backpropagation phase deviation. The purpose of calculating the backpropagation phase deviation is to examine the bidirectional consistency and structure of phase propagation anomalies. That is, not only predicting the next point from the previous point (forward propagation), but also predicting back to the current point from the "next point" (the nearest pixel), and evaluating the error of this reverse prediction. The backpropagation phase deviation reflects the matching error when retrieving the phase of the current point from the downstream point. The larger the value, the more "abrupt and unreasonable" the phase of the current point appears from the downstream point. This means that the break in phase propagation is likely to be bidirectional and structural, rather than unidirectional and gradual.
[0042] The absolute difference between the phase deviation and the return phase deviation of the pixel with poor propagation is calculated, and each difference is taken as the round-trip propagation deviation of the pixel with poor propagation.
[0043] The back-and-forth propagation deviation reflects the overall mismatch in the prediction of texture phase during bidirectional propagation between a pair of local adjacent pixels. It combines the positive error (phase deviation) in predicting downstream points from the current point with the negative error (back-propagation phase deviation) inferring current points from downstream points, characterizing the overall inconsistency and non-reciprocity of the phase relationship between these two points.
[0044] The larger the back-and-forth propagation deviation, the more bidirectional and structural the break in the texture phase is. The phase relationship between the current point and its nearest neighbor, regardless of the direction of prediction, significantly deviates from the actual observation, indicating a fundamental interruption in the texture continuity between the two points at the physical or visual level. This effectively distinguishes between genuine structural defects (such as broken yarns or holes, whose phase breaks are bidirectional) and certain false anomalies (such as unidirectional phase drift caused by gradual changes in illumination, whose reverse prediction may still match). The core technical effect is that by combining the forward phase deviation and the reverse back-propagation phase deviation, the algorithm can calculate the back-propagation deviation, a more robust and specific feature. A genuine defect typically causes failure in both forward and reverse propagation simultaneously, resulting in a larger back-and-forth propagation deviation; while many unstructured local disturbances may only disrupt unidirectional propagation. Therefore, this step significantly improves the algorithm's ability to distinguish between defects and false anomalies, reducing the false detection rate.
[0045] Step 5: Calculate the average phase deviation within the window centered on each poorly propagated pixel, and combine it with the back-and-forth propagation deviation to set the fabric defect judgment rule. Based on the fabric defect judgment rule, filter out defects from the poorly propagated pixels.
[0046] The average phase deviation reflects the average severity of the phase deviation from the ideal propagation model of all pixels within a local window centered on a pixel with poor propagation; that is, the collective average intensity of texture deharmonicity in that region. The larger the value, the deeper the deviation of the window region from the normal texture rhythm as a whole, and the more widespread and consistent the texture structure anomaly is in space, rather than isolated noise.
[0047] It can further identify anomalies at the regional statistical level. A real defect (such as a stain) usually causes most pixels in a region to show a significant phase deviation, thus resulting in a higher average value; while an isolated point with poor propagation (such as caused by noise from a single pixel) may have a large deviation itself, but the surrounding area may still be relatively normal, resulting in a lower average value within the window.
[0048] By introducing the average value of the phase deviation as a criterion and combining it with the structural feature of back-and-forth propagation deviation, the algorithm constructs a more robust rule for judging fabric defects. This dual criterion effectively filters out isolated, unidirectional, or localized false anomalies (such as noise points or weak gradient edges), while ensuring that real defect areas that are spatially continuous but structurally bidirectionally broken are accurately captured. This ultimately significantly improves the specificity of defect detection, maintaining a high detection rate while greatly reducing the system's false detection rate.
[0049] Furthermore, the fabric defect judgment rule is as follows: if a preset phase deviation threshold and a back-and-forth propagation deviation threshold are set, if the average phase deviation within the window centered on each poorly propagated pixel is less than the phase deviation threshold, and the back-and-forth propagation deviation is less than the back-and-forth propagation deviation threshold, then the pixel is not a defect; otherwise, the pixel is a defect.
[0050] The average value of the phase deviation corresponds to "spatial saliency". It requires that the texture detuning (phase deviation) in the local area where the candidate point is located must reach a certain average intensity and spatial coherence. This ensures that the detected anomaly is not an isolated noise point or a weak fluctuation, but a deviation pattern that is widespread and consistent in the area, which is consistent with the spatial distribution characteristics of defects (such as a stain or a broken yarn).
[0051] The back-and-forth propagation deviation corresponds to "structural disruption." It requires that the bidirectional logic of phase propagation between a candidate point and its nearest neighbor in the texture direction is disrupted. This characterizes a fundamental break or interruption in the periodic structure of the texture at that location, rather than merely a unidirectional, gradual misalignment. This condition ensures that the detected anomalies are defects that truly disrupt the texture continuity pattern (such as holes, knots, severe skew), rather than artifacts caused by lighting gradations or shadows that may only affect unidirectional propagation.
[0052] The pixel with poor propagation already reflects the phase abnormality during texture propagation. On this basis, if either of the above two conditions also reflects an abnormality, it can be basically determined that the pixel with poor propagation is a defect.
[0053] Please refer to Figure 2, which is a schematic diagram of the defect identification results of fabric in this invention, where a, b, and c are three fabric images containing defects.
[0054] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0055] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0056] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0057] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that cannot be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for feature extraction and detection of fabric defects, characterized in that, The specific steps include: Step 1: Acquire a grayscale image of the fabric to be detected, referred to as the first fabric image. Perform frequency domain analysis on the first fabric image to obtain the principal frequency and principal weave angle of the first fabric image, and determine the phase response of the first fabric image under the rhythm of the principal frequency and principal weave angle; Step 2: For each pixel, obtain its nearest pixel in the principal weave angle direction. Based on the principal frequency, principal weave angle, and the phase response of the pixel and the nearest pixel, predict the phase response of each pixel at the nearest pixel. Combine the phase response of the nearest pixel and the predicted phase response to calculate the phase deviation; Step 3: Calculate the local perturbation variance within the window centered on each pixel based on the phase deviation. Step 4: For each pixel with poor propagation, obtain the predicted phase response of its nearest pixel at that pixel, combine the phase response of the pixel with the phase response of the pixel with poor propagation to obtain the back-propagation phase deviation of the pixel with poor propagation, and combine the phase deviation of the pixel with the back-propagation phase deviation to obtain the back-and-forth propagation deviation of the pixel with poor propagation; Step 5: Calculate the average value of the phase deviation within the window centered on each pixel with poor propagation, and combine the back-and-forth propagation deviation to set the fabric defect judgment rule, and filter out defects from the pixels with poor propagation based on the fabric defect judgment rule.
2. The method for feature extraction and detection of fabric defects according to claim 1, characterized in that: In the spatial domain, a rectangular coordinate axis is established with the center of the first fabric image as the origin, the horizontal direction to the right as the positive X-axis, and the vertical direction upward as the positive Y-axis, to represent each pixel of the first fabric image. A two-dimensional Fourier transform is performed on the first fabric image to obtain the amplitude spectrum along the X-axis and Y-axis frequencies of the first fabric image in the frequency domain, where the X-axis and Y-axis frequencies of the first fabric image are used as the frequency coordinates in the frequency domain. The radius from each point in the amplitude spectrum to the center of the spectrum is calculated to obtain the frequency domain radius. A preset frequency domain radius threshold is set, and amplitude maxima points are selected in the frequency domain that are greater than the frequency domain radius threshold to form a candidate peak set. In the candidate peak set, if two amplitude maxima points exhibit a conjugate symmetry relationship, the two amplitude maxima points are called a candidate peak pair. In the candidate peak pair, the square of the amplitude of each amplitude maxima point is calculated, and the sum of the squares of the two amplitudes is used as the joint energy. The candidate peak pair with the largest joint energy is used as the principal peak pair, and the average frequency domain radius of each amplitude maxima point in the principal peak pair is used as the principal frequency. In the candidate peak pair, the following calculations are performed: The Y-axis frequency at each amplitude maxima is divided by the X-axis frequency to obtain the frequency ratio. The inverse tangent function of this frequency ratio is then calculated to obtain the positive interlacing angle. The average positive interlacing angle of the main peak at each amplitude maxima is taken as the main positive interlacing angle. The angle orthogonal to the main positive interlacing angle is called the main weaving angle. The first fabric image is filtered based on the main frequency and the main weaving angle, and the filtered result is convolved with the first fabric image to obtain the complex response of the first fabric image under the main frequency and main weaving angle rhythm. The phase angle of the complex response is obtained as the phase response of the first fabric image under the main frequency and main weaving angle rhythm.
3. The method for feature extraction and detection of fabric defects according to claim 2, characterized in that: The logic for filtering the first fabric image based on the dominant frequency and dominant weave direction angle is as follows: In the spatial domain, the coordinate axes of the first fabric image are transformed into coordinate axes pointing from the X-axis to the dominant weave direction angle, called the weave direction coordinate axis. For each pixel in the rectangular coordinates, its dominant frequency is combined with the weave direction coordinate axis and substituted into the two-dimensional complex Gabor function to obtain the filtering result.
4. The method for feature extraction and detection of fabric defects according to claim 1, characterized in that: The logic for obtaining the predicted phase response is as follows: For each pixel, in the weave direction coordinate axis, the pixels adjacent to this pixel are called neighboring pixels. The neighboring pixel with the smallest absolute difference from the pixel's X-axis value, and whose X-axis value is not less than the pixel's X-axis value, is selected and called the nearest pixel in the main weave direction angle. The absolute difference is then calculated... The product of the main frequency and the phase of that point is added to obtain the predicted phase of the nearest pixel.
5. The method for feature extraction and detection of fabric defects according to claim 4, characterized in that: The logic for obtaining the local perturbation variance is as follows: the absolute difference between the phase of the nearest pixel and the predicted phase is called the phase deviation of that pixel; using that pixel as the center, a... The window defines the region where the pixel is located. Within this region, the phase deviation of all pixels is calculated. The variance of the phase deviation of all pixels within this region that have the nearest pixel is calculated to obtain the perturbation variance. This perturbation variance is then used as the local perturbation variance within the window centered on each pixel.
6. The method for feature extraction and detection of fabric defects according to claim 5, characterized in that: The condition for judging smooth propagation is: if the perturbation variance within the area centered on a pixel is greater than the preset perturbation variance threshold, then the pixel is called a pixel with poor propagation.
7. The method for feature extraction and detection of fabric defects according to claim 6, characterized in that: The logic for obtaining the return propagation deviation is as follows: For each pixel with poor propagation, obtain its nearest pixel, calculate the absolute difference between the nearest pixel and the pixel with poor propagation along the X-axis, and calculate the absolute difference with... The product of the main frequency and the negative of the product is added to the phase response of the nearest pixel to obtain the predicted phase response of the nearest pixel at the poorly propagated pixel. This is called the back-propagation phase response. The absolute difference between the back-propagation phase response and the phase response of the poorly propagated pixel is called the back-propagation phase deviation. The absolute difference between the phase deviation of the poorly propagated pixel and the back-propagation phase deviation is calculated as the round-trip propagation deviation of the poorly propagated pixel.
8. The method for feature extraction and detection of fabric defects according to claim 7, characterized in that: The fabric defect judgment rule is as follows: if the preset phase deviation threshold and back-to-back propagation deviation threshold are set, if the average phase deviation within the window centered on each poorly propagated pixel is less than the phase deviation threshold, and the back-to-back propagation deviation is less than the back-to-back propagation deviation threshold, then the pixel is not a defect; otherwise, the pixel is a defect.