A defect positioning method and system
By calculating the defect confidence and texture confidence of pixel points in the surface image of textile fabrics, combined with preset thresholds and weights, the problem that YOLO neural network cannot accurately locate the defect position in the surface defect detection of textile fabrics is solved, achieving a higher level of accuracy of defect positioning.
Patent Information
- Application Number
- CN202411337636.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-25
AI Technical Summary
The existing YOLO neural network-based textile fabric surface defect detection method is inaccurate in the marking process due to the diversity of the surface texture of the textile fabric, and the defect location cannot be accurately positioned.
By acquiring the weaving surface image and preprocessing it, it is divided into multiple regions of equal size, calculate the defect confidence of each pixel point in the area, and mark the defects according to the preset threshold, combining texture confidence and defect weights to distinguish the true to improve positioning accuracy.
It realizes accurate positioning of defects in the surface image of textile fabrics, improves the accuracy and reliability of defect detection, and can more clearly display the shape and size of defects, distinguishing isolated noise points from real defect areas.
Smart Images

Figure CN118864459B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a defect positioning method and system. Background Art
[0002] The textile industry is an industry with a long history and plays an important role in the global economy. It involves processing natural and chemical fibers into various yarns, silks, threads, ribbons, fabrics and their dyeing and finishing products. In the textile production process, defect detection of cloth is a key quality control link. Defects on the surface of the fabric, such as damage, stains, color difference, etc., will not only seriously affect the appearance quality of the product and make the product lose competitiveness in the market, but also may reduce the performance of the product, thereby affecting the consumer's experience. Therefore, strengthening quality control in the textile production process and improving the defect-free rate of cloth are of great significance to enhancing the market competitiveness of textile enterprises.
[0003] At present, a patent application document with publication number CN110490874A discloses a textile fabric surface defect detection method based on a YOLO neural network. The textile fabric surface defect detection method based on a YOLO neural network includes real-time acquisition of textile fabric surface images; using a pre-established YOLO neural network detection model to perform defect recognition on the real-time acquired textile fabric surface images to obtain recognition results including defect types and defect locations; and outputting defect recognition result data.
[0004] The above patent application document uses the YOLO neural network to establish a target detection model for cloth defects, which can identify information including the type and location of defects. However, during the neural network training process, due to factors such as the diversity of textile surface textures, the training data set is not accurately labeled, which leads to model learning errors and the inability to accurately locate the location of defects. Summary of the invention
[0005] In order to solve the above technical problem that the position of the defect cannot be accurately located, the present invention provides solutions in the following aspects.
[0006] In a first aspect, a defect locating method comprises:
[0007] Acquire the fabric surface image and preprocess it to obtain a grayscale image; divide the grayscale image into multiple regions of equal size, and calculate the defect confidence of each pixel in the region; mark the pixel whose defect confidence is greater than the preset defect threshold as a defect, and mark the location of the defect in the grayscale image;
[0008] Among them, the defect weight is calculated. When the defect weight is greater than or equal to the preset weight threshold, the defect confidence satisfies the relationship: , otherwise, the defect confidence satisfies the relationship: ; In the formula, For the Grayscale image In the region The defect confidence of each pixel, For the Grayscale image The defect weight of each region, For the Grayscale image In the region The texture confidence of each pixel, It is an exponential function with the natural constant e as its base.
[0009] By adopting the above technical solution, the acquired grayscale image is first divided into multiple areas of equal size to perform a more detailed defect analysis in the local area, traverse the pixels in the area, calculate the defect confidence of the pixels, and set a threshold to distinguish which pixels have a defect confidence high enough to be considered as a real defect, thereby clearly marking the location of the defect in the image and improving the accuracy of locating defects on the fabric surface.
[0010] In one embodiment, the defect threshold is one of the median, the third quartile, and the average value of the defect confidence in the grayscale image.
[0011] Using the median, third quartile, or mean as the defect threshold can resist the influence of outliers to a certain extent.
[0012] In one embodiment, marking the position of the defect in the grayscale image further includes:
[0013] Connect adjacent defects to form a continuous defect area, determine the boundary of the defect area, and locate the position of the defect on the grayscale image.
[0014] By connecting adjacent defects, the shape and size of the defects can be more clearly displayed, making the defects easier to identify and helping to distinguish isolated noise points from real defective areas.
[0015] In one embodiment, the Grayscale image The steps for obtaining the defect weight of each area include:
[0016] The first Grayscale image The mode of the texture confidence of all pixels in a region is taken as the regional confidence of the region;
[0017] Filter out The other areas in the grayscale image are The area where the difference of regional confidence of the areas is less than or equal to the regional threshold;
[0018] The first Grayscale image The defect weight of each region satisfies the relationship:
[0019] ; In the formula, For the Grayscale image The defect weight of each region, is the number of regions after screening, For all areas in the filtered area and the The average Euclidean distance of the regions, For normalization processing.
[0020] Selecting the mode of texture confidence to represent the general condition of the area can help determine the classic texture features of the area, and then screen out other areas that are similar to this area in texture features. By considering the similarities and differences between regions, a defect weight is calculated to quantify the severity of the defect in the area.
[0021] In one embodiment, the texture confidence satisfies the relationship:
[0022] ; In the formula, For the Grayscale image In the region The texture confidence of each pixel, For the Grayscale image In the region The neighborhood complexity of pixels, For the Grayscale image The average neighborhood complexity of all pixels in the region, is the average of the neighborhood complexity of the same pixel on all grayscale images in the grayscale image sequence, is the average of the average neighborhood complexity of the same area of all grayscale images in the grayscale image sequence, is an exponential function with the natural constant e as the base; among them, all grayscale images are sorted in chronological order, starting with A grayscale image is taken as the center point, and a set number of grayscale images before and after the center point are intercepted to construct a grayscale image sequence.
[0023] By considering local texture changes and the significance of these changes in the context of the overall texture, the texture confidence of each pixel is calculated, which can more accurately identify areas with significant differences from the surrounding texture.
[0024] In one embodiment, the step of obtaining the neighborhood complexity includes:
[0025] Calculate the Pixels and The grayscale difference of the average grayscale value of all pixels in the eight neighborhoods of the pixel; calculate the Pixels and The gradient difference of the average gradient value of all pixels in the eight neighborhoods of a pixel point; then the neighborhood complexity satisfies the relationship:
[0026] ; In the formula, For the Grayscale image In the region The neighborhood complexity of pixels, is the grayscale difference, is the gradient difference, is the grayscale weight, is the gradient weight, For normalization processing.
[0027] In one embodiment, the neighborhood complexity is optimized, and the optimized neighborhood complexity satisfies the relationship:
[0028] ; In the formula, is the optimized neighborhood complexity, For the The neighborhood complexity of any neighborhood that is farther than the eight neighborhoods. is the weight coefficient.
[0029] By combining the complexity of smaller and larger neighborhoods, it is possible to capture both local details and global trends in the image, which helps to more fully understand the texture features of the image and thus improve the accuracy of the analysis.
[0030] In a second aspect, a defect locating system includes: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned defect locating method is implemented.
[0031] The beneficial effects of the present invention are:
[0032] By combining the complexity of the smaller neighborhood and the larger neighborhood of the pixel point, the present invention can fully understand the texture features of the image, and then calculate the texture confidence of the pixel point, and calculate the defect weight of the area by comparing the texture confidence inside and outside the area, and combine the texture confidence with the defect weight to determine the possibility of the pixel point being marked as a defect, thereby accurately locating the position of the defect on the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0034] Figure 1 It is a method flow chart of steps S1 to S3 in a defect locating method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0036] The embodiment of the present invention discloses a defect location method, referring to Figure 1 , including steps S1 to S3, which are specifically as follows:
[0037] S1: Obtain a fabric surface image and preprocess it to obtain a grayscale image.
[0038] In the embodiment of the present invention, a camera or a scanning device is used to photograph the surface of the finished woven fabric slowly conveyed on the automatic fabric inspection machine to obtain a plurality of woven fabric surface images.
[0039] In order to improve the image quality and ensure that subsequent image analysis and processing can be performed more accurately, an adaptive filter such as a median filter or a Gaussian filter can be used to remove noise from the fabric surface image, and then an adaptive histogram equalization can be used to improve the global contrast of the fabric surface image. Finally, the fabric surface image is converted into a grayscale image.
[0040] S2: Divide the grayscale image into multiple regions of equal size and calculate the defect confidence of each pixel in the region.
[0041] After obtaining the grayscale image of the fabric surface in the above step S1, in order to analyze the local features of the grayscale image more carefully, the grayscale image is divided into multiple regions of equal size, all pixels in the region are traversed, and the defect confidence that the pixel belongs to the abnormal defect area is calculated, and then a probability value is provided for each detected anomaly, indicating the possibility that the anomaly is a real defect.
[0042] In the embodiment of the present invention, any pixel point in any area of any grayscale image is selected for the following analysis, for example: Grayscale image In the region Pixels.
[0043] First, the initial selection All pixels in the eight neighborhoods of a pixel are calculated. Pixels and The grayscale difference of the average grayscale value of all pixels in the eight neighborhoods of the pixel is calculated. Pixels and The gradient difference of the average gradient values of all pixels in the eight neighborhoods of a pixel.
[0044] Then, considering the grayscale difference and gradient difference obtained above, the first Grayscale image In the region The neighborhood complexity of pixels satisfies the following relationship:
[0045]
[0046] In the formula, For the Grayscale image In the region The neighborhood complexity of pixels, For the Pixels and The grayscale difference of the average grayscale value of all pixels in the eight neighborhoods of a pixel, For the Pixels and The gradient difference of the average gradient value of all pixels in the eight neighborhoods of a pixel, is the grayscale weight, is the gradient weight, For normalization processing.
[0047] Further expand the neighborhood farther than the eight neighborhoods, such as a neighborhood of 5×5, 7×7 or larger size. In the embodiment of the present invention, the neighborhood of 5×5 size is selected. Combine the information of the expanded neighborhood with the first Grayscale image In the region Pixel points are optimized, and the neighborhood complexity after optimization satisfies the relationship:
[0048]
[0049] In the formula, is the optimized neighborhood complexity, For the The neighborhood complexity of the pixel point in the neighborhood farther than the eight neighborhoods, is the weight coefficient, which is 0.5 in the embodiment of the present invention. The method of obtaining is similar to that of obtaining .
[0050] The analysis of the eight-neighborhood and an extended neighborhood based on the eight-neighborhood helps capture texture features at different scales. A smaller neighborhood may be more suitable for identifying fine textures, while a larger neighborhood is suitable for identifying coarse or large-scale textures.
[0051] According to the above Grayscale image In the region The process of obtaining the neighborhood complexity of a pixel point can be similarly used to obtain the Grayscale image The neighborhood complexity of all pixels in the region. Then calculate the Grayscale image The average neighborhood complexity of all pixels in the region. Then calculate The average neighborhood complexity corresponding to all regions in the grayscale image.
[0052] It should be noted that the neighborhood complexity of the calculation reflects the The pixel point is located in the The local features in the region, the average neighborhood complexity calculated represents the The texture features of the entire area.
[0053] Secondly, sort all grayscale images in chronological order. The grayscale image is taken as the center point to intercept a set number of grayscale images before and after the center point to construct a grayscale image sequence. The grayscale image is the center point, and the grayscale image before and after the center point is intercepted, marked as Grayscale image, grayscale images and construct a grayscale image sequence.
[0054] Calculate the Grayscale image In the region The texture confidence of each pixel satisfies the following relationship:
[0055]
[0056] In the formula, For the Grayscale image In the region The texture confidence of each pixel, For the Grayscale image In the region The neighborhood complexity of pixels, For the Grayscale image The average neighborhood complexity of all pixels in the region, is the same pixel point on all grayscale images in the grayscale image sequence ( The average value of the neighborhood complexity of pixels), is the same area of all grayscale images in the grayscale image sequence ( The average of the average neighborhood complexity of regions), It is an exponential function with the natural constant e as its base.
[0057] When the difference between neighborhood complexity and regional complexity is small, the exponential part is close to zero, so A value close to 1 indicates that there is a high degree of confidence that the pixel belongs to the normal texture area.
[0058] In another embodiment, Grayscale image In the region The texture confidence of each pixel also satisfies the following relationship:
[0059]
[0060] In the formula, For the Grayscale image In the region The texture confidence of each pixel, is the variance of the neighborhood complexity corresponding to the grayscale image sequence, is the variance of the average neighborhood complexity corresponding to the grayscale image sequence, It is an exponential function with the natural constant e as its base.
[0061] Finally, according to the above calculation Grayscale image In the region The texture confidence of each pixel can be calculated in the same way. Grayscale image All texture confidences in the region are Grayscale image The mode of the texture confidence of all pixels in a region is taken as the regional confidence of the region.
[0062] Filter out The other areas in the grayscale image are The difference of the regional confidences of the regions is less than or equal to the regional threshold (set to 0.2 in the embodiment of the present invention);
[0063] The first Grayscale image The defect weight of each region satisfies the relationship:
[0064]
[0065] In the formula, For the Grayscale image The defect weight of each region, is the number of regions after screening, For all areas in the filtered area and The average Euclidean distance of the regions, For normalization processing.
[0066] In the above calculation Grayscale image After the defect weights of the regions are determined, a weight threshold is set. In the embodiment of the present invention, the weight threshold is 0.5. In other embodiments, the weight threshold can be adjusted according to historical defect data and processing experience.
[0067] When the defect weight is greater than or equal to the preset weight threshold, calculate the Grayscale image In the region The defect confidence of each pixel satisfies the following relationship:
[0068]
[0069] On the contrary, Grayscale image In the region The defect confidence of each pixel satisfies the following relationship:
[0070]
[0071] In the formula, For the Grayscale image In the region The defect confidence of each pixel, For the Grayscale image The defect weight of each region, For the Grayscale image In the region The texture confidence of each pixel, It is an exponential function with the natural constant e as its base.
[0072] When the defect weight is greater than or equal to the weight threshold, the first formula mentioned above is used to calculate the defect confidence, which means that if the defect weight of the area is higher, the texture confidence of the pixels in the area will be reduced to a greater extent, thereby highlighting the possible abnormalities of the pixels; conversely, if the defect weight is less than the weight threshold, the second formula mentioned above is used to calculate the defect confidence. In this case, the defect weight has less impact on the texture confidence, which means that even if the texture confidence is low, the abnormality of the pixel will not be over-emphasized.
[0073] According to the above calculation Grayscale image In the region The defect confidence of each pixel can be calculated in the same way. The defect confidence of all pixels in the grayscale image.
[0074] S3: Mark the pixel points whose defect confidence is greater than a preset threshold as defects, and mark the positions of the defects in the grayscale image.
[0075] A defect threshold is preset, and its value is the median, the third quartile or the average value of all defect confidences in the grayscale image. In the embodiment of the present invention, the third quartile of the defect confidence is preferably used as the preset defect threshold.
[0076] Traverse each pixel in the grayscale image, mark those pixels whose defect confidence is greater than or equal to the preset threshold as defects, and then draw and mark all the locations marked as defects in the grayscale image.
[0077] It should be noted that after marking the position of the defect in the grayscale image, adjacent defects can be further connected to form a continuous defect area to determine the boundary of the defect, so as to more accurately identify and locate the defect area in the image.
[0078] At this point, the positioning of defects on the fabric surface is completed.
[0079] Subsequent measures can be taken promptly, such as adjusting production parameters or repairing defects, to ensure product quality.
[0080] The embodiment of the present invention further discloses a defect locating system, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the defect locating method according to the present invention is implemented.
[0081] The system also includes other components familiar to those skilled in the art, such as a communication bus and a communication interface. The configuration and functions of these components are known in the art and will not be described in detail here.
[0082] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module or both. Any such computer storage medium may be part of a device or accessible or connectable to a device.
[0083] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0084] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A defect location method, characterized in that: include: Acquire the fabric surface image and preprocess it to obtain a grayscale image; Divide the grayscale image into multiple regions of equal size and calculate the defect confidence of each pixel in the region; Mark the pixels whose defect confidence is greater than the preset defect threshold as defects, and mark the locations of the defects in the grayscale image; Among them, the defect weight is calculated. When the defect weight is greater than or equal to the preset weight threshold, the defect confidence satisfies the relationship: , otherwise, the defect confidence satisfies the relationship: ; In the formula, For the Grayscale image In the region The defect confidence of each pixel, For the Grayscale image The defect weight of each region, For the Grayscale image In the region The texture confidence of each pixel, is an exponential function with the natural constant e as base; No. Grayscale image The steps for obtaining the defect weight of a region include: Grayscale image The mode of the texture confidence of all pixels in the region is taken as the regional confidence of the region; The other areas in the grayscale image are The difference of regional confidence of the regions is less than or equal to the preset regional threshold; The first Grayscale image The defect weight of each region satisfies the relationship: ; In the formula, is the number of regions after screening, For all areas in the filtered area and the The average Euclidean distance of the regions, For normalization processing; The texture confidence satisfies the relationship: ; In the formula, For the Grayscale image In the region The neighborhood complexity of pixels, For the Grayscale image The average neighborhood complexity of all pixels in the region, is the average of the neighborhood complexity of the same pixel on all grayscale images in the grayscale image sequence, is the average of the average neighborhood complexity of the same area of all grayscale images in the grayscale image sequence; where all grayscale images are sorted in chronological order, starting with the A grayscale image is taken as the center point, and a set number of grayscale images before and after the center point are intercepted to construct a grayscale image sequence.
2. A defect location method according to claim 1, characterized in that: The defect threshold is one of the median, the third quartile, and the average value of the defect confidence in the grayscale image.
3. A defect location method according to claim 2, characterized in that: The step of marking the position of the defect in the grayscale image further comprises: Connect adjacent defects to form a continuous defect area, determine the boundary of the defect area, and locate the position of the defect on the grayscale image.
4. A defect location method according to claim 1, characterized in that: The steps of obtaining the neighborhood complexity include: Calculate the Pixels and The grayscale difference of the average grayscale value of all pixels in the eight neighborhoods of the pixel; calculate the Pixels and The gradient difference of the average gradient value of all pixels in the eight neighborhoods of a pixel point; then the neighborhood complexity satisfies the relationship: ; In the formula, For the Grayscale image In the region The neighborhood complexity of pixels, is the grayscale difference, is the gradient difference, is the grayscale weight, is the gradient weight, For normalization processing.
5. A defect location method according to claim 4, characterized in that: The neighborhood complexity is optimized, and the optimized neighborhood complexity satisfies the relationship: ; In the formula, is the optimized neighborhood complexity, For the The neighborhood complexity of any neighborhood that is farther than the eight neighborhoods. is the weight coefficient.
6. A defect location system, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the defect locating method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Textile cloth surface defect detection method based on YOLO neural network
CN110490874A
Textile fabric surface defect detection method and system based on semi-supervised network
CN114842005A
Visual inspection method for textile quality
CN116843688A
