A method for detecting the quality of denim fabric based on visual detection

CN122820541APending Publication Date: 2026-09-25韶关市北纺智造科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610675491.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-15
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

[0003]现有最接近的技术方案通常包括人工目检、基于阈值和边缘的传统机器视觉方法、基于通用卷积网络或目标检测网络的识别方法,以及基于频域、模板或局部相似性的异常检测方法,但这些方案大多或者停留在灰度差异和纹理统计层面,容易将染色深浅变化、局部反光和绒毛起伏误判为缺陷,或者依赖大样本训练而缺少对牛仔织纹连续关系的专门刻画,或者虽然利用了织物的重复纹理特性,却难以把牛仔面料特有的方向推进关系、局部线状织纹支撑以及结构断裂边界同时纳入统一分析过程,因此在布面轻微褶皱、速度波动、照明变化和染整状态差异存在时,容易出现误检率高、漏检率高、定位不稳定以及不同批次适应性不足的问题

Benefits of technology

本发明首先针对牛仔面料表面图像中织纹方向强、染色扰动大、局部反光和绒毛干扰明显的特点,构建能够突出主织纹方向连续程度的织纹检测基图,使后续检测对象从普通外观灰度转向织纹结构本身;随后以该织纹检测基图为基础,不再依赖一般性的像素突变,而是围绕局部线状织纹支撑与中心位置塌陷之间的空间矛盾提取疑似缺陷区域,使候选区域的形成过程直接对应断纱、跳纱和局部组织错位等牛仔面料典型结构异常;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122820541A_ABST
    Figure CN122820541A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of fabric detection, in particular to a denim fabric quality detection method based on visual detection, which converts a surface image into a single-channel brightness graph, calculates a gradient graph of the single-channel brightness graph, calculates a direction response value of each pixel point in a preset direction in the gradient graph, constructs a direction response graph, merges the direction response graph into a weave detection base graph, selects a sampling point along the preset direction, calculates linear support strength in the preset direction based on a detection value and the sampling point, calculates suspected defect strength, constructs a suspected defect area set based on the suspected defect strength, filters suspected areas based on authenticity scores, constructs a real defect area set, calculates area quality influence scores of defect areas in the real defect area set, aggregates the area quality influence scores to form a quality judgment index of an entire frame, and constructs a quality detection result based on the area quality influence scores and the quality judgment index.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of fabric inspection technology, and more particularly to a method for inspecting the quality of denim fabric based on visual inspection. Background Technology

[0002] Denim fabric, a widely used woven material in clothing, bags, and home textiles, directly affects the consistency of its surface quality during subsequent cutting, sewing, washing, and finished product appearance. Therefore, continuous and stable surface quality testing is usually required during weaving, dyeing, and final inspection. Compared to ordinary plain weave or low-texture materials, denim fabric has stronger directional structure, more obvious periodic texture, and more complex appearance fluctuations. In particular, common twill weaves can form continuous texture bands extending in a specific direction in images. Differences in indigo dyeing, changes in washing processes, surface nap, sizing residue, fabric tension fluctuations, and uneven lighting can visually superimpose a large number of unstable light and dark variations. This means that the real quality problems in denim fabric often do not manifest as simple bright spots, dark spots, or general color differences, but rather as yarn breaks, skipped yarns, weft skew, local misalignment, weave interruptions, and regional structural instability, all of which disrupt the continuous structure of the fabric.

[0003] The closest existing technical solutions typically include manual visual inspection, traditional machine vision methods based on thresholds and edges, recognition methods based on general convolutional networks or object detection networks, and anomaly detection methods based on frequency domain, templates, or local similarity. However, most of these solutions either remain at the level of grayscale differences and texture statistics, easily misjudging variations in dyeing depth, local reflections, and pile undulations as defects, or rely on large sample training and lack specific characterization of the continuous relationship of denim weave, or although they utilize the repeating texture characteristics of fabrics, they are difficult to simultaneously incorporate the directional progression relationship, local linear weave support, and structural fracture boundaries unique to denim fabrics into a unified analysis process. Therefore, when there are slight wrinkles on the fabric surface, speed fluctuations, lighting changes, and differences in dyeing and finishing conditions, problems such as high false detection rate, high false detection rate, unstable positioning, and insufficient adaptability to different batches are likely to occur.

[0004] Furthermore, existing technologies lack a detection chain that converges layer by layer around the characteristics of denim twill weave, and have not yet formed a continuous methodological system from weave structure enhancement, candidate anomaly extraction, authenticity determination to quality conclusion output. Therefore, it is difficult to reliably distinguish between real weave structure damage and non-defect visual disturbances. Based on this, if a visual detection method can be established based on the objective law that local weave in denim fabric has directional continuity and that real defects will cause weave collapse within the area while retaining normal weave support outside the area, then this method can more effectively overcome the shortcomings of existing technologies, such as high false detection rates, weak authenticity determination, and insufficient on-site stability in complex texture environments. This method would be based on a weave detection base map, use convergence of suspected defect areas as a transition, rely on the authenticity determination of the area as a key factor, and ultimately complete the quality grade output. Summary of the Invention

[0005] The purpose of this invention is to provide a visual inspection-based method for inspecting the quality of denim fabrics, in order to solve the problems mentioned in the background section.

[0006] To achieve the above objectives, the present invention provides a visual inspection-based method for quality inspection of denim fabrics, comprising: A surface image of denim fabric is acquired, the surface image is converted into a single-channel brightness map, the gradient map of the single-channel brightness map is calculated, the directional response value of each pixel in the gradient map in a preset direction is calculated, a directional response map is constructed based on the directional response value, the directional response maps are merged into a texture detection base map, and the detection value of each pixel on the texture detection base map is calculated. Sampling points are selected along a preset direction. The linear support strength in the preset direction is calculated based on the detection value and the sampling points. The suspected defect strength is calculated based on the linear support strength and the sampling points. A set of suspected defect regions is constructed based on the suspected defect strength. For each suspected region in the suspected defect region set, the region center is obtained based on the pixel coordinates inside the region. The corresponding principal axis direction is calculated based on the second central moment of the region center. The authenticity score of each suspected region is calculated based on the principal axis direction and the texture detection base map. The suspected regions are filtered based on the authenticity score to construct a set of real defect regions. For each defect region in the set of real defect regions, calculate the regional quality impact score of the defect region. Summarize the regional quality impact scores of all defect regions in the same frame to form the quality judgment index of the whole frame. Construct the quality detection result based on the regional quality impact score and the quality judgment index.

[0007] In some embodiments, constructing a set of suspected defect regions based on the suspected defect intensity specifically includes: The texture detection base map is divided into multiple local blocks according to the fabric travel direction and width direction; The distribution of the suspected defect intensity is statistically analyzed in each local block, and the suspected defect intensity greater than the threshold is taken as the suspected threshold for the local block; When the intensity of the suspected defect corresponding to a pixel in the local block is greater than the suspected threshold, it is marked as a suspected abnormal point. By marking the eight-neighbor connected regions, the spatially adjacent suspected anomalies are merged into candidate regions; For each candidate region, the area and unfolding length along the main direction are calculated. Regions whose area reaches the preset lower limit and have continuous unfolding characteristics along the main direction are retained, and finally a set of suspected defective regions is formed.

[0008] In some embodiments, the step of filtering suspected areas based on the authenticity score to construct a set of real defect areas specifically includes: Suspected areas with an authenticity score greater than the judgment threshold are classified into the set of real defect areas; During the inclusion process, the pixel set and minimum bounding rectangle of the suspected region are retained.

[0009] In some embodiments, calculating the authenticity score of each suspected region based on the main axis direction and the texture detection base map specifically includes: Construct the minimum outer matrix of the suspected region, and based on the texture detection base map, calculate the linear support strength and extract the maximum and second linear support strengths; Obtain the direction angle corresponding to the maximum linear support strength. Based on the main axis direction, translate a certain distance along the normal on both sides of the main axis to construct a side band parallel to the main axis. Calculate the average pixel value of the side band and the suspected area respectively. A true scoring function is constructed based on the maximum linear support strength, the second linear support strength, the orientation angle, and the average pixel value, and a true score is output through the scoring function.

[0010] In some embodiments, calculating the regional quality impact score of each defect region in the set of real defect regions specifically includes: Within the minimum bounding rectangle of each defect region, calculate the principal axis direction corresponding to the defect region; Project the pixels of the defect area onto the principal axis and the principal axis normal to generate the region length and region width of the defect area, and count the number of pixels in the defect area. Based on the defect region, construct left and right side bands parallel to the main axis direction, calculate the pixel mean of each side band, and take the average of the pixel mean of the left and right side bands. The regional quality impact score of the defective region is calculated based on the average value, number of pixels, region length, and region width.

[0011] In some embodiments, the suspected defect strength is generated by a defect strength calculation function, the parameters of which include linear support strength, weighting coefficient of directional separation term, mean value of linear support strength in a preset direction, and second linear support strength in the preset direction.

[0012] In some embodiments, the main axis direction is generated by calculating a direction function, the parameters of which include the second-order central moment, the cumulative value of the square of the lateral offset, the cumulative value of the square of the longitudinal offset, the cumulative value of the product of the lateral offset and the longitudinal offset, and a preset small positive value.

[0013] In some embodiments, the parameters of the scoring function include the number of pixels in the suspected region, the linear support strength, the maximum value of the linear support strength, the second linear support strength, the value of the candidate region on the texture detection base map, the orientation angle, the principal axis direction, the average pixel value, and the weighting coefficient.

[0014] In some embodiments, the region quality score is calculated and generated by a quality score function, and the parameters of the region quality score include the number of pixels in the region, the total number of pixels in the current detection frame, the mean of the pixel average, and the pixel average.

[0015] In some embodiments, the directional response value is generated by calculating a directional response function, the parameters of which include the horizontal and vertical coordinates of the single-channel brightness map, the horizontal gradient value, the vertical gradient value, and a preset directional angle.

[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention first addresses the characteristics of denim fabric surface images, such as strong weave direction, large dyeing disturbance, obvious local reflection, and significant fuzz interference. It constructs a weave detection base map that highlights the continuity of the main weave direction, shifting the subsequent detection focus from ordinary appearance grayscale to the weave structure itself. Then, based on this weave detection base map, instead of relying on general pixel abrupt changes, it extracts suspected defect areas around the spatial contradiction between local linear weave support and central collapse. This allows the formation process of candidate areas to directly correspond to typical structural anomalies in denim fabrics such as yarn breakage, yarn skipping, and local tissue misalignment. Based on this, the authenticity of the candidate region is further determined by utilizing the main axis direction of the candidate region, the texture collapse along the main direction within the region, the consistency of the local main support direction, and the restoration relationship of the normal texture bands on both sides of the region. This distinguishes real structural defects from dyeing fluctuations, slight reflections, and random appearance disturbances. Finally, the real defect region is transformed into a quality inspection result with location, shape, and severity information. The quality level is then output by combining the region coverage, the extension characteristics along the texture direction, and the overall defect impact.

[0017] Compared to existing technologies, the innovation of this invention lies not in simply superimposing several image algorithms, but in forming a structured detection link that closely serves the actual working conditions of denim fabrics. This elevates the detection process from "discovering anomalies" to confirming whether the anomalies constitute real quality defects and providing directly usable quality conclusions. As a result, more stable denim fabric quality detection is achieved under complex textures, complex dyeing and finishing conditions, and fluctuating industrial conditions. Attached Figure Description

[0018] Figure 1 A flowchart of a visual inspection-based denim fabric quality inspection method provided in this application embodiment. Detailed Implementation

[0019] 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.

[0020] refer to Figure 1 As shown in the figure, this application provides a method for quality inspection of denim fabric based on visual inspection, including: S1: Obtain a surface image of the denim fabric, convert the surface image into a single-channel brightness map, calculate the gradient map of the single-channel brightness map, calculate the directional response value of each pixel in the gradient map in a preset direction, construct a directional response map based on the directional response value, merge the directional response maps into a texture detection base map, and calculate the detection value of each pixel on the texture detection base map. As the denim fabric is laid out and passes through the inspection station, an industrial camera fixed directly above the fabric surface captures images of the denim fabric. The camera used is an area-array industrial camera with a fixed-focus lens. The lens optical axis is perpendicular to the fabric surface. Illumination employs linear diffused light sources arranged along the width of the fabric to maintain the twill pattern stable in the image and reduce the occlusion of the fabric boundaries by local reflections. Before processing, the image... First, map to a unified map arrive Within this range, it is then converted into a single-channel brightness map, and subsequent calculations are all based on this normalized image. The process is as follows. Denim fabric has a twill weave structure with a clearly defined main direction, so the directional derivative approach is used here to extract the weave direction information. In specific implementation, we first use... The Sobel kernel calculates the horizontal and vertical gradients respectively, obtaining the results compared to the image. Gradient plots of consistent size and Then, the directional response is calculated in four preset directions, and the four directions are respectively taken as follows: , , and This is to cover the warp and weft directions and common twill directions of denim fabric. The directional response values ​​are calculated using a directional response function, which is: ; In the formula, Indicates the position of a pixel. In direction The directional response value; and These represent the horizontal and vertical coordinates of a pixel in the image, respectively. Indicates position The horizontal gradient value is derived from the image. Obtained by convolution with Sobel horizontal convolution kernel; Indicates position The vertical gradient value is derived from the image. Obtained by convolution with Sobel vertical convolution kernel; This represents the preset direction angle, and its value is... , , or ; and These are the cosine and sine values ​​of the corresponding direction angles, respectively. This formula originates from the directional derivative of a two-dimensional image. The standard expression, in which the image gradient vector is composed of and Composed of, the direction unit vector is composed of and It constitutes the structure; based on this, the absolute value is taken to characterize the intensity of change in that direction. Taking a certain point as an example, if calculated by Sobel... , Then when hour, The directional response at that point is ;when At that time, the directional response is This shows that the response at this point is stronger in the diagonal weave direction.

[0021] After the four-directional response maps are formed, the responses of each pixel in the four directions are synthesized into a texture detection base map. This process uses a dominant response proportion construction method, so that the normal denim twill area has a high proportion in the dominant direction, while the responses of dyeing fluctuations, nap reflections, and local random undulations in the four directions are more dispersed, thus being suppressed in the synthesized result. The detection value of the texture detection base map is calculated using the following formula: ; In the formula, Indicates the location of the texture detection base map. The detected value; , , and Representing positions respectively exist , , and The response values ​​in four preset directions are calculated by substituting the corresponding direction angles into the previous formula; This indicates that the maximum value is selected from the responses in four directions; This represents a pre-defined very small positive value, which can be taken as [value] during implementation. ; and This still represents the current pixel position. The formula constructs the saliency of the principal directions using normalized ratios. The numerator corresponds to the strongest texture direction response at the current position, and the denominator corresponds to the overall response in the four directions. When performing local calculations using the aforementioned ratios and configuration parameters, if the responses in the four directions at a certain point are respectively... , , , ,Pick Then the point This indicates that there is a clear main weave direction at that location; if the responses of the four directions at another point are respectively , , , Then its This indicates that the response at this location is relatively dispersed in all directions, more closely resembling surface stray variations. The resulting... It is a spatial distribution map of the clarity of the main direction, followed by... The above adopts A fixed-window moving average is used to maintain local continuity, ensuring the continuity of diagonal stripe regions, while sudden disturbances at single points or in small areas are naturally weakened in the neighborhood averaging. For example, a certain Original neighborhood center point Six of the eight points around it are located arrive Between, the other two points are respectively and Then, after averaging the neighborhood values, the position is approximately It remains at a high level; if a certain isolated bright spot is original The surrounding eight points mostly fall on arrive Between these values, the average of the neighborhood values ​​will fall back to approximately [value missing]. After the above processing, S1 outputs the texture detection base map. This image is different from the original image. Maintaining a one-to-one correspondence between pixel positions, the numerical value is used to characterize the continuity of the main texture direction at the corresponding position, and subsequent operations can be directly based on the detection values. Extract suspected defect areas.

[0022] S2: Select sampling points along a preset direction, calculate the linear support strength along the preset direction based on the detected values ​​and sampling points, calculate the suspected defect strength based on the linear support strength and sampling points, and construct a set of suspected defect regions based on the suspected defect strength, specifically including: S2 directly uses the texture detection base map output by S1 as input to extract suspected defect areas in a coordinate system that corresponds one-to-one with the fabric surface position. S1 has mapped the continuity of the main weave direction on the surface of the denim fabric to... Therefore, this step no longer repeats the construction of directional information, but instead establishes suspected defect criteria based on "whether the local weave support is continuous and whether the current position has deviated from that continuous support." In normal areas, denim typically exhibits continuous banded high values ​​along the twill direction, while yarn breaks, skipped yarns, and localized weave misalignment will manifest as: the surrounding area still has banded weave support, but the central position... The value suddenly drops or detaches from the strip support. Based on this characteristic, first at each pixel position... Linear support strength is extracted along four preset directions. This process originates from the mathematical concept of a one-dimensional moving average, simply extending the averaging of a traditional horizontal window to directional line segments, thus aligning the mean calculation with the direction of the denim twill. In specific implementation, in... , , and Take lengths of in each of the four directions. discrete line segments, Pick At that time, take continuous values ​​in each direction. There are 10 sampling points; if the sampling position falls at a non-integer coordinate, bilinear interpolation is used to sample from the four adjacent pixels. The value at that position is calculated. The mean value of the direction line segment is calculated using the following formula: ; In the formula, Indicates position In direction Linear support strength; This represents the half-length of the direction line segment, which is taken as the actual fabric inspection value. or ; Represents the discrete sampling index on the line segment, with a value of arrive ; Pick , , or ; This represents the detection value of the texture detection base map obtained by S1 at the corresponding coordinate position; and Used to set discrete index Mapped to spatial coordinates in the current direction. This formula averages the local weave along a preset direction, yielding "how strong the continuous weave support is along that direction around the current position." For example, consider... and At that time, if the five sampling points corresponding to this direction The values ​​are respectively , , , , Then there is If the same location is in , , The five-point averages in the three directions are respectively , , This indicates that the neighborhood where the location is located mainly follows... The direction maintains continuous weave support, which is consistent with the spatial distribution of the twill weave commonly found in denim.

[0023] After obtaining the linear support strength in four directions, the strength of suspected defects is further constructed. This structure combines the classic local contrast approach and the directional competition approach: local contrast describes the difference between the current position and the surrounding reference structure, while directional competition describes whether this difference occurs under the premise of a clear main direction. When applying these two approaches to denim fabric inspection, the local reference is no longer taken as the average of the ordinary neighborhood, but as the maximum value among the four directional supports, because a true twill weave should form the strongest support in a certain direction; at the same time, the difference between the maximum directional support and the second largest directional support is introduced to characterize whether the main direction is clear. In this way, the suspected defect intensity will only increase significantly when both "obvious twill support exists around" and "the current position is detached from this support" occur simultaneously. Based on this logic, the defect intensity calculation function is defined as: ; In the formula, Indicates position The strength of the suspected defects; , , and These represent the linear support strength at the same location in four preset directions; the position symbols have been omitted for brevity. ; This represents the average strength of the support in four directions, i.e. ; This represents the second largest value among the four directions of support strength; The weighting coefficients representing the direction separation terms can be taken as follows in field applications: arrive Typical value ; Take a very small positive value, for example The first term of this formula is the maximum value of the linear support minus the value at the current position. This indicates the degree of collapse of the current position relative to the strongest surrounding weave band, and then... Normalization ensures a uniform scale across regions with different weave densities; the second term, composed of the difference between the maximum and second-largest support, indicates the presence of a clear main direction within that neighborhood, and is then incorporated into the total suspected intensity using the same normalization method. The sum of the two terms forms... This answers two questions simultaneously: whether the current position is significantly lower than the strongest surrounding weave band, and whether the strongest surrounding weave band is sufficiently defined. Only when both conditions are met... The higher the quality, the better. This structure corresponds to the defect pattern of "continuous twill bands with local breaks" in denim fabric.

[0024] Substituting the aforementioned formula into the local data yields a clear calculation process. Taking a specific location as an example, if the linear support strengths in the four directions are respectively... , , , The detection value of the texture detection base map at the current position is ,Pick , The average value in the four directions is The maximum value is The second largest value is After substituting, the first term is... The second item is ,so This result indicates that there is a very clear presence around this location. The weave is supported by a twill pattern, but the weave strength at this current location is significantly low, consistent with the characteristics of a broken yarn or localized structural instability. Looking at another location, if the support strength in the four directions is respectively... , , , Current location ,but The maximum value is The second largest value is The first item is approximately The second term is approximately The sum is approximately This value is at a low level, corresponding to slight fluctuations within a normal twill weave, rather than a suspected defect. This set of substitutions directly illustrates how the previous formula generates directional support, and how the subsequent formula converts it into a suspected strength that conforms to the characteristics of a denim defect.

[0025] Calculate point by point on the entire fabric texture detection base map. Then, the image is divided into multiple local blocks according to the direction of fabric movement and the width direction, and statistics are collected within each local block. The distribution of pixels is analyzed, and the higher quantile value is used as the suspected threshold for the local block. Pixels exceeding this local threshold are marked as suspected anomalies. Then, through eight-neighbor connected region labeling, spatially adjacent suspected anomalies are merged into candidate regions. For each candidate region, the region area and unfolding length along the main direction are further calculated. Regions with an area reaching a preset lower limit and continuous unfolding characteristics along a certain main direction are retained. Finally, a set of suspected defect regions is formed. . Each region in the dataset consists of a set of adjacent pixel coordinates, and its minimum bounding rectangle can be recorded. Thus, S2 completes the process of converting the output from S1... Set up in the suspected defect area Transformation: S1 compresses the original denim image into a main weave continuity map; S2 follows the spatial organizational characteristics of the denim twill. The region described above, characterized by "continuous texture surrounding the current location with localized collapse," is extracted to obtain the suspected defect area input required for subsequent authenticity determination. .

[0026] S3: For each suspected region in the suspected defect region set, the region center is obtained based on the pixel coordinates within the region. The corresponding principal axis direction is calculated based on the second-order central moment of the region center. The authenticity score of each suspected region is calculated based on the principal axis direction and the texture detection base map. The suspected regions are then filtered based on the authenticity score to construct a set of true defect regions, specifically including: S3 is the set of suspected defect areas output by S2. Starting from this point, the following is a summary of the key points. Each suspected area Each region has already recorded its own pixel coordinate set and corresponding bounding range. Therefore, corresponding sub-regions can be extracted from the fabric detection base map generated in S1 according to the same coordinate position, forming a local analysis object facing the current candidate region. S2 completes the task of "finding the key locations in the entire fabric surface that deserve special attention", and S3 completes the task of "retaining the areas in these locations that truly destroy the denim fabric structure". This layer of judgment revolves around the true defect morphology of denim fabric: broken yarns, skipped yarns, and local misalignment usually stretch into short bands or thin strips along a certain direction. There will be continuous fabric collapse inside the area, while the normal fabric on both sides of the area will continue to maintain high support. Therefore, the authenticity judgment no longer stops at the comparison of strength at a single point, but simultaneously examines the main axis direction of the candidate region, the degree of collapse along the main axis direction inside the region, and the degree of recovery of the parallel fabric bands on both sides of the region. The practical significance of doing so is that, although changes in dyeing depth and slight reflection may also form local suspected areas in S2, these areas usually do not have a stable main axis, nor will they form a "strong outside and weak inside" fabric band relationship on both sides; on the contrary, true structural defects usually have these two spatial characteristics.

[0027] For each candidate region First, the center of the region is determined based on the pixel coordinates within the region. Then, the principal axis direction of the region is calculated using the second-order central moment in the image geometric moments. This calculation originates from image moments and rigid body principal axis analysis, and is mathematically equivalent to finding the principal direction of the two-dimensional covariance matrix of the region's coordinate distribution. The result represents "the most dominant direction of development of the region." In the current scenario, this direction is not used to describe the geometric shape itself, but rather to ensure that subsequent texture realism determination always follows the actual extension direction of the candidate region. If the region is indeed formed by broken or skipped yarns, its principal axis direction will usually be close to the extension direction of the nearby twill band; if the region only comes from random undulations, its principal axis direction is often unstable. The principal axis direction is calculated using a direction function, the expression of which is: ; In the formula, Indicates candidate region The direction of the main axis; , and Representing regions The second-order central moments are obtained by summing the offsets of all pixel coordinates within the region relative to the coordinates of the region's center point by point, where... This is the cumulative value of the squared horizontal offset. This is the cumulative value of the squared vertical offset. This is the cumulative value of the product of the horizontal offset and the vertical offset; This is a preset small positive value used to ensure the stability of the denominator. This expression comes from the characteristic direction formula of a second-order central moment symmetric matrix; this application directly adopts its principal direction form and uses this direction for subsequent texture continuity verification. Taking a suspected area as an example, if statistical analysis yields... , , ,Pick Then there is This indicates that the candidate region is located approximately along the edge of the image. The direction of the expansion is as follows. This result will directly determine the subsequent methods of "how to count internal collapse along the main axis and how to sample the support on both sides of the region". Therefore, there is a strict sequential relationship between the previous formula and the subsequent authenticity score.

[0028] In obtaining Then, an authenticity score is established around the regional axis. Specifically, this involves: within the region... Within the minimum bounding rectangle, based on the texture detection baseline of S1, and following the same direction line segment mean calculation process as S2, the linear support strength in the four preset directions is recalculated point by point. , , and For each position Take the maximum value from these four support strengths as... Take the second largest value as And the direction angle corresponding to the attainment of the maximum value is denoted as Then, based on the direction of the regional principal axis... Translate along the normal direction on both sides of the main axis by a distance equivalent to half the width of the region, constructing two side bands parallel to the main axis: a left band and a right band. Count the total pixels within the left band. Average value and all pixels in the right band The average value is calculated, and the average of the two values ​​is recorded as the average fabric support value on both sides of the region. Thus, the region authenticity assessment uses four types of quantities simultaneously: the degree of local collapse within the region, the directional exclusivity of local main supports, the consistency between local main supports and the region's principal axis, and the degree of recovery of the outer texture band relative to the region's interior. These quantities are synthesized into a scoring function, which outputs an authenticity score. The expression for the scoring function is: ; In the formula, Indicates candidate region Authenticity rating; Indicates the area Number of pixels within; , , and Representing positions respectively The linear support strength in four preset directions, which are determined by the region in the current step. corresponding The sub-region was recalculated point by point. This represents the maximum value among the four supporting directions; This represents the second largest value among the four supporting directions; This indicates that the texture detection base map generated by S1 is located at... The detected value; Indicates position Obtain The corresponding direction angle, whose value comes from , , and One of the four directions; The direction of the principal axis of the region calculated by the previous formula; This indicates the degree of consistency between the local main support direction and the regional main axis direction at that point; Represents all pixels within the region average value; Indicates the parallel lateral bands on both sides of the region The average of the averages; The weighting coefficient for the side support item can be set to a value that can be determined on-site. ; It is a small positive value. The first part of this expression consists of the product of three terms: the first term... The second item describes the degree of localized fabric collapse. The third term describes the degree of exclusivity of the primary direction relative to the secondary direction. Describe the degree of consistency between the local principal direction and the regional principal axis; Part Two Describes the degree of restoration of the weave bands on both sides of the region relative to the interior of the region. This constitutes... It also characterized the fracture strength, directional purity, and boundary structure relationship within the region.

[0029] With the aforementioned principal axis direction approximately Taking the candidate region as an example, suppose the region has a total of Pixels, of which typical locations, after recalculation, have , , And the corresponding direction Then the terms with the same direction are The collapse item is The direction exclusive item is The contribution of this point after multiplying the three is approximately . If within the area The average result calculated for each pixel is approximately Meanwhile, the average value within this region is The average values ​​of the parallel side bands on both sides of the main shaft are respectively and ,but ;Pick At that time, the side support item is Ultimately there are If the typical location of another type of candidate region satisfies , , Furthermore, the angle between the local direction and the principal axis of the region is relatively large, making the direction-consistent term approximately [missing information]. The single-point contribution is approximately ; and then combine , Side support item at the time ,overall It will remain stable below the aforementioned actual defect area.

[0030] Throughout the entire fabric, Each candidate region is scored for authenticity using the method described above. Subsequently, based on the statistical results of the sample fabric obtained during the debugging phase of this workstation, a judgment threshold was set, and... Areas exceeding the threshold are included in the set of true defect areas. This process preserves the pixel set and minimum bounding rectangle of these regions for use in the next step of defect identification and quality inspection conclusion output. Thus, S3 takes the set of suspected defect areas output by S2. Based on this, regional-level realism convergence was achieved: S2 is responsible for reducing the abnormal locations in the entire fabric detection base map to a small number of candidate regions, and S3 further utilizes the coupling relationship between the principal axis direction of the candidate regions and the internal fabric collapse and external fabric recovery to filter out the regions that truly correspond to denim fabric structure damage, ultimately obtaining the set of real defect regions. .

[0031] S4: Summarize the regional quality impact scores of all defective regions within the same frame to form the overall frame quality assessment. The invention constructs quality detection results based on the regional quality impact scores and quality assessment indicators, specifically including: S4 is the set of real defect areas output by S3. Based on the texture detection base map generated by S1, the confirmed real defects are transformed into results that can be directly used for quality inspection judgment and on-site identification. In the denim fabric scenario, the factors that truly influence the quality conclusion include the extent of the defect coverage, the extension characteristics along the weave direction, and the degree of attenuation within the defect area relative to the surrounding normal weave bands. In practical implementation, firstly... Each region Extract its smallest bounding rectangle, and then obtain the principal axis direction of the region from the region pixel coordinates using the same principal axis direction calculation method as S3. Then, the region pixels are projected onto the principal axis direction and the principal axis normal direction, and the projection range is taken as the region length. and area width And count the number of pixels in the region area. Along the same principal axis, translate each side of the region by a distance equivalent to half the region's width along the normal direction, constructing two side bands parallel to the principal axis. Statistical analysis is then performed on the values ​​within these side bands. The average value is taken as the mean value of the outer fabric support of the region. Simultaneously, the statistics of all pixels within the region are calculated. The average value is denoted as Based on this, a region quality scoring function is constructed by combining the proportion of the region area to the total frame area, the degree of attenuation of the region's internal texture relative to the outer texture band, and the elongation of the region's shape. Its expression is: ; In the formula, Represents the actual defect area Regional quality impact score; Indicates the area Number of pixels within; This represents the total number of pixels in the current detection frame, a value determined by the fixed imaging resolution of the detection system. Represents the parallel lateral bands on both sides of the region The average of the averages; Represents all pixels within the region average value; Indicates the area The projected length along the principal axis; Indicates the area The width of the projection along the principal axis normal; The morphological enhancement coefficient can be determined based on the statistical results of on-site sample fabrics. arrive Typical value ; This is a preset small positive value. This expression consists of the product of three parts: Describe the scope of the defects. Describes the degree of weave attenuation within the region relative to the surrounding normal weave band. The description describes the slender reinforcement along the principal axis of the region. Substituting a set of actual calculated values ​​into the aforementioned formula illustrates that if a real defect region satisfies... , , , , , ,Pick The area term is approximately The texture attenuation term is approximately The morphological term is approximately Therefore, the quality impact score for this area is [score missing]. If another real defect region satisfies , , , , The area term is approximately The texture attenuation term is approximately The morphological term is approximately ,then Its quality impact is significantly lower than that of the previous elongated texture defect area.

[0032] After obtaining the regional quality impact score for each real defect area, the scores of all real defect areas within the same detection frame are summarized to form the overall frame quality assessment index, and the quality detection conclusion is output based on this index. This summarization process uses a combination of "cumulative impact + maximum impact": the cumulative impact reflects the overall defect burden within the current detection frame, and the maximum impact reflects the decisive role of the most severe single defect on the local fabric quality. The overall frame quality assessment index is calculated using the following formula: ; In the formula, This indicates the quality assessment metric for the currently detected frame; This represents the set of actual defect regions output by S3; This represents the regional quality impact score calculated using the previous formula; This represents the cumulative score of all real defect areas within the current detection frame; This indicates the highest single-area score. This represents the maximum defect enhancement coefficient, which can be determined based on the statistical results of the test sample fabric. arrive Typical value This formula has a direct logical connection with the previous one: the previous formula first identifies each actual defect area. Convert to regional impact score Then, the scores from all regions are aggregated into a single frame quality assessment index. Taking the two regions mentioned earlier as examples, if the current detection frame contains only these two real defect regions, then... , ,Pick The cumulative impact is approximately The maximum impact is approximately Therefore, the overall frame quality assessment metric is During the workstation debugging phase, statistics can be compiled on sample fabrics of known quality grades. The distribution, for example, is The detection frame corresponds to a qualified frame, and will The detection frame corresponds to the one that needs to be re-inspected. The detection frame corresponds to an unqualified frame. According to this classification method, the above detection frame should be output as unqualified. Meanwhile, S4... The pixel coordinates of each real defect area are used to directly render the area outline or minimum bounding rectangle on the display interface of the detection terminal, and the area location and area score are also displayed. And whole frame quality assessment indicators Included in the quality inspection results .so, It includes both defect identification results and quality inspection conclusions: the former indicates the location of the defect, and the latter provides the current quality grade of the denim fabric. After this processing, S4 sets up the actual defect areas output by S3. Converted into denim fabric quality test results that can be used directly on the ground. .

[0033] The above embodiments are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for quality inspection of denim fabric based on visual inspection, characterized in that, include: A surface image of denim fabric is acquired, the surface image is converted into a single-channel brightness map, the gradient map of the single-channel brightness map is calculated, the directional response value of each pixel in the gradient map in a preset direction is calculated, a directional response map is constructed based on the directional response value, the directional response maps are merged into a texture detection base map, and the detection value of each pixel on the texture detection base map is calculated. Sampling points are selected along a preset direction. The linear support strength in the preset direction is calculated based on the detection value and the sampling points. The suspected defect strength is calculated based on the linear support strength and the sampling points. A set of suspected defect regions is constructed based on the suspected defect strength. For each suspected region in the suspected defect region set, the region center is obtained based on the pixel coordinates inside the region. The corresponding principal axis direction is calculated based on the second central moment of the region center. The authenticity score of each suspected region is calculated based on the principal axis direction and the texture detection base map. The suspected regions are filtered based on the authenticity score to construct a set of real defect regions. For each defect region in the set of real defect regions, calculate the regional quality impact score of the defect region. Summarize the regional quality impact scores of all defect regions in the same frame to form the quality judgment index of the whole frame. Construct the quality detection result based on the regional quality impact score and the quality judgment index.

2. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The construction of a set of suspected defect regions based on the suspected defect intensity specifically includes: The texture detection base map is divided into multiple local blocks according to the fabric travel direction and width direction; The distribution of the suspected defect intensity is statistically analyzed in each local block, and the suspected defect intensity greater than the threshold is taken as the suspected threshold for the local block; When the intensity of the suspected defect corresponding to a pixel in the local block is greater than the suspected threshold, it is marked as a suspected abnormal point. By marking the eight-neighbor connected regions, the spatially adjacent suspected anomalies are merged into candidate regions; For each candidate region, the area and unfolding length along the main direction are calculated. Regions whose area reaches the preset lower limit and have continuous unfolding characteristics along the main direction are retained, and finally a set of suspected defective regions is formed.

3. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The process of filtering suspected areas based on the authenticity score to construct a set of real defect areas specifically includes: Suspected areas with an authenticity score greater than the judgment threshold are classified into the set of real defect areas; During the inclusion process, the pixel set and minimum bounding rectangle of the suspected region are retained.

4. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The calculation of the authenticity score for each suspected area based on the main axis direction and the texture detection base map specifically includes: Construct the minimum outer matrix of the suspected region, and based on the texture detection base map, calculate the linear support strength and extract the maximum and second linear support strengths; Obtain the direction angle corresponding to the maximum linear support strength. Based on the main axis direction, translate a certain distance along the normal on both sides of the main axis to construct a side band parallel to the main axis. Calculate the average pixel value of the side band and the suspected area respectively. A true scoring function is constructed based on the maximum linear support strength, the second linear support strength, the orientation angle, and the average pixel value, and a true score is output through the scoring function.

5. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The calculation of the regional quality impact score for each defect region in the set of real defect regions specifically includes: Within the minimum bounding rectangle of each defect region, calculate the principal axis direction corresponding to the defect region; Project the pixels of the defect area onto the principal axis and the principal axis normal to generate the region length and region width of the defect area, and count the number of pixels in the defect area. Based on the defect region, construct left and right side bands parallel to the main axis direction, calculate the pixel mean of each side band, and take the average of the pixel mean of the left and right side bands. The regional quality impact score of the defective region is calculated based on the average value, number of pixels, region length, and region width.

6. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The suspected defect strength is generated by a defect strength calculation function, the parameters of which include linear support strength, weighting coefficient of directional separation term, mean value of linear support strength in a preset direction, and second linear support strength in the preset direction.

7. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The main axis direction is generated by calculating a direction function, the parameters of which include the second-order central moment, the cumulative value of the square of the lateral offset, the cumulative value of the square of the longitudinal offset, the cumulative value of the product of the lateral offset and the longitudinal offset, and a preset small positive value.

8. The method for quality inspection of denim fabric based on visual inspection according to claim 4, characterized in that, The parameters of the scoring function include the number of pixels in the suspected region, the linear support strength, the maximum value of the linear support strength, the second linear support strength, the value of the candidate region on the texture detection base map, the orientation angle, the principal axis direction, the average pixel value, and the weight coefficient.

9. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The region quality score is calculated and generated by a quality score function. The parameters of the region quality score include the number of pixels in the region, the total number of pixels in the current detection frame, the mean of the pixel average, and the pixel average value.

10. The method for quality inspection of denim fabric based on visual inspection according to claim 1, characterized in that, The directional response value is generated by calculating the directional response function, the parameters of which include the horizontal and vertical coordinates of the single-channel brightness map, the horizontal gradient value, the vertical gradient value, and the preset directional angle.