Defect classification method based on database comparison

Through the database comparison method, the defect detection and classification of the fabric output by the weaving machine is used to detect and classify defects from the fabric output by the weaving machine, which solves the problem of low detection accuracy of small and medium-sized defects in the existing technology, and achieves more accurate defect identification and Classification.

CN118898754BActive Publication Date: 2024-12-06SHAANXI BOYU TEXTILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411399832.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2024-12-06
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

The prior art is difficult to accurately detect and classify small area defects in the fabric output by the loom, resulting in low classification accuracy.

Method used

Using the defect classification method based on database comparison, by obtaining the grayscale image output by the loom, determining the texture characteristic value of the target pixel point and calculating the filtering degree value, filtering the pixel point according to the filtering degree value, combining it with the preset database The stored defect images are compared to determine the defect area and type.

Benefits of technology

The accuracy of accurate detection and classification of defects in the fabric is improved, and the pixel points and defect areas in the grayscale image can be better identified, so as to achieve more detailed defect classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118898754B_ABST
    Figure CN118898754B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image data processing technology, and in particular to a defect classification method based on database comparison. The method includes: obtaining a grayscale image of a cloth to be detected output by a loom; determining the texture feature value of a target pixel in the grayscale image; determining the filtering degree value of the target pixel according to the texture feature value of the target pixel; filtering the target pixel using the filtering degree value of the target pixel, and when the texture feature value of the target pixel after filtering is greater than a preset feature threshold, the target pixel after filtering is used as a defective pixel; the area composed of defective pixels is used as a defective area, and the defect type of the defective area is determined according to the defective area and a preset image containing defects in a preset database. Through the above technical scheme, the classification result of defects in the cloth to be detected can be obtained more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image data processing, and in particular to a defect classification method based on database comparison. Background Art

[0002] The fabric output by the loom may have defects such as poor interlacing of warp and weft yarns, oil stains, uneven colors, color spots, and weaving defects caused by improper operation or machine failure during the weaving process. Different treatment methods can be used to deal with different types of defects accordingly. For example, the poor interlacing of warp and weft yarns in the fabric can be treated, and the oil stains in the fabric can be partially cleaned. Therefore, in order to facilitate the corresponding treatment of defects in the fabric, the defects in the fabric output by the loom can be determined.

[0003] In the related art, for example, in the Chinese patent application document with publication number CN108133472A, a textile defect detection method is provided, including: using a CMOS camera to collect various types of defective parts and non-defective parts of the textile, respectively obtaining defective samples and non-defective samples, and storing them; collecting image information of the sample to be tested, and performing image preprocessing; using non-local mean filtering to perform texture enhancement on the texture image; processing the texture-enhanced textile image to obtain a texture contour image of the textile image; constructing a feature model of the texture contour image; matching and comparing the feature model with the non-defective sample, and when the difference between the offset and the average offset is greater than a preset threshold, determining that the feature model is a defect model; when the difference between the offset and the average offset is less than the preset threshold, determining that the feature model is a qualified model; matching and comparing the defect model with the defective sample one-to-one, and classifying and storing the defective samples.

[0004] The related technology mainly determines the defective fabric by comparing the image of the fabric with the defective sample. However, the area of ​​the defects in the fabric may be small, and it may be difficult to determine the defects in the fabric by directly comparing the images. Therefore, the related technology is difficult to accurately detect the defects in the fabric, and thus it is difficult to accurately classify the defects in the fabric. Summary of the invention

[0005] In order to overcome the problem that it is difficult to accurately classify defects in fabrics in the related art, the present application provides a defect classification method based on database comparison, including: obtaining a grayscale image of the fabric to be detected output by a loom, and determining a texture feature value of a target pixel in the grayscale image, where the target pixel is any pixel in the grayscale image; determining a filtering degree value of the target pixel according to the texture feature value of the target pixel, wherein the filtering degree value is negatively correlated with the texture feature value; filtering the target pixel using the filtering degree value of the target pixel, and when the texture feature value of the target pixel after filtering is greater than a preset feature threshold, treating the filtered target pixel as a defect pixel; treating an area composed of defect pixels as a defect area, and determining the defect type of the defect area according to the defect area and a preset image containing defects in a preset database; wherein the texture feature value of the target pixel is determined in the following manner: , F is the texture feature value, norm is the normalization function, L is the number of rows of the grayscale image, H is the number of columns of the grayscale image, and A is the number of other pixels in the neighborhood. is the grayscale difference between the target pixel and the mth pixel in its neighborhood. is the grayscale difference between the pixel at the ath row and the bth column in the grayscale image and the mth other pixel in its neighborhood.

[0006] In this way, according to the texture eigenvalue of the target pixel, the filtering degree value of the target pixel is determined, and the target pixel is filtered using the filtering degree value of the target pixel. Since the filtering degree value is negatively correlated with the texture eigenvalue, the pixel with a smaller texture eigenvalue can be filtered to a lower degree, and the pixel with a larger texture eigenvalue can be filtered to a higher degree, taking into account both the retention of the features of the pixel with a larger texture eigenvalue and the filtering of noise pixels in the grayscale image. When the texture eigenvalue of the target pixel after filtering is greater than the preset feature threshold, the target pixel after filtering is taken as a defective pixel, and the pixel with a larger texture eigenvalue has a higher probability of being a defect. Therefore, the defective pixel in the grayscale image of the fabric to be inspected can be determined more accurately.

[0007] Since more accurate defect pixel points in the grayscale image of the cloth to be detected can be obtained, when there are defects in the cloth to be detected, a more accurate classification result of the defects in the cloth to be detected can be obtained.

[0008] Optionally, the filtering degree value of the target pixel is determined according to the texture eigenvalue of the target pixel, including: determining a pixel pair consisting of the target pixel and adjacent pixels in a specified direction; obtaining multiple grayscale co-occurrence matrices of the grayscale image in multiple specified directions, and determining a first eigenvalue of the target pixel according to the multiple grayscale co-occurrence matrices and the multiple pixel pairs of the target pixel in multiple specified directions, the first eigenvalue being used to characterize the degree of difference between the frequency of the grayscale combination of the pixel pair in the grayscale co-occurrence matrix and the maximum frequency in the grayscale co-occurrence matrix; taking the product of the texture eigenvalue of the target pixel and the first eigenvalue as the second eigenvalue, and obtaining the filtering degree value of the target pixel according to the difference between a preset value and the second eigenvalue, wherein the preset value is greater than the upper limit of the second eigenvalue of the target pixel.

[0009] In this way, the product of the texture eigenvalue of the target pixel and the first eigenvalue is used as the second eigenvalue, the first eigenvalue and the texture eigenvalue can be combined, and the probability of the pixel being a defect can be more accurately characterized by the second eigenvalue; according to the difference between the preset value and the second eigenvalue, the filtering degree value of the target pixel is obtained to ensure that the filtering degree value is negatively correlated with the texture eigenvalue, so that a lower filtering degree value can be set for a pixel with a higher probability of being a defect, and a higher filtering degree value can be set for a pixel with a lower probability of being a defect, taking into account both the filtering of noise pixels in the grayscale image and the retention of the characteristics of the defect.

[0010] Optionally, multiple grayscale co-occurrence matrices of a grayscale image in multiple specified directions are obtained in the following manner: determining the frequency of occurrence of a grayscale combination in the grayscale image along a specified direction; obtaining the grayscale co-occurrence matrix of the grayscale image in the specified direction based on the frequency of occurrence of different grayscale combinations in the grayscale image along the specified direction, so as to obtain different grayscale co-occurrence matrices corresponding to different specified directions; wherein the grayscale combination includes two identical or different grayscale levels, and the grayscale levels included in different grayscale combinations are different.

[0011] In this way, by determining the grayscale co-occurrence matrix of the grayscale image in a specified direction, it is helpful to describe the characteristics of the pixel points in the cloth to be detected.

[0012] Optionally, determining the first eigenvalue of the target pixel point according to multiple gray level co-occurrence matrices and multiple pixel pairs of the target pixel point in multiple specified directions includes: , where V is the first eigenvalue of the target pixel and M is the number of specified directions; It is the ratio of the frequency of the gray level combination of the pixel pairs of the target pixel in the k specified directions in the gray level co-occurrence matrix of the k specified direction to the maximum frequency in the gray level co-occurrence matrix of the k specified direction.

[0013] In this way, the ratio of the frequency of the grayscale combination of the pixel pairs of the target pixel in the specified direction in the grayscale co-occurrence matrix of the specified direction to the maximum frequency in the grayscale co-occurrence matrix of the specified direction can characterize the degree of difference between the target pixel and the normal area in the specified direction. By combining the characteristics of the target pixel in multiple specified directions, the limitation of the target pixel in a single specified direction can be avoided.

[0014] Optionally, the multiple specified directions include the following four directions: a horizontal direction, a direction with an angle of 45° to the horizontal direction, a vertical direction, and a direction with an angle of 135° to the horizontal direction.

[0015] Optionally, the target pixel point is filtered using the filtering degree value of the target pixel point, including: taking the product of the filtering degree value and the preset filtering coefficient as the target filtering coefficient of the target pixel point; and filtering the target pixel point using the target filtering coefficient using the target filter.

[0016] Optionally, the target filter includes any one of the following filters: a mean filter, a Gaussian filter, and a median filter.

[0017] Optionally, the preset database stores defect types corresponding to preset images, and determines the defect type of the defect area according to the defect area and the preset image containing the defect in the preset database, including: performing feature comparison between the defect area and the preset image containing the defect in the preset database, and determining the feature comparison result between the defect area and the preset image; according to the feature comparison result, determining a target preset image matching the defect area from multiple preset images containing defects; and using the defect type corresponding to the target preset image as the defect type of the defect area in the fabric to be detected.

[0018] In this way, compared with comparing the entire grayscale image of the fabric to be inspected with an image without defects, since the object of comparison is a smaller image area, the details of the defects can be better reflected in the smaller image area, so a more detailed comparison result can be obtained, thereby obtaining a more accurate defect classification result.

[0019] The technical solution provided by the embodiments of the present application may include the following beneficial effects: according to the texture eigenvalue of the target pixel point, the filtering degree value of the target pixel point is determined, and the target pixel point is filtered using the filtering degree value of the target pixel point. Since the filtering degree value is negatively correlated with the texture eigenvalue, the pixel point with a smaller texture eigenvalue can be filtered to a lower degree, and the pixel point with a larger texture eigenvalue can be filtered to a higher degree, taking into account both the retention of the features of the pixel point with a larger texture eigenvalue and the filtering of noise pixels in the grayscale image; when the texture eigenvalue of the target pixel point after filtering is greater than a preset feature threshold, the target pixel point after filtering is regarded as a defective pixel point, and the pixel point with a larger texture eigenvalue has a higher probability of being a defect. Therefore, the defective pixel point in the grayscale image of the fabric to be inspected can be determined more accurately.

[0020] Since more accurate defect pixel points in the grayscale image of the cloth to be detected can be obtained, when there are defects in the cloth to be detected, a more accurate classification result of the defects in the cloth to be detected can be obtained.

[0021] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0023] Figure 1 The figure is a flow chart showing a defect classification method based on database comparison according to an exemplary embodiment. DETAILED DESCRIPTION

[0024] Here, exemplary embodiments are described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application.

[0025] First, a brief introduction is given to the application scenarios of the embodiments of the present application. In the application scenarios of the present application, the fabric may have defects such as poor interlacing of warp and weft yarns, oil stains, uneven colors, color spots, and weaving defects caused by improper operation or machine failure during the weaving process. Different defects can be handled in corresponding ways; in order to facilitate targeted treatment of different defects in the fabric, the defects in the fabric to be tested can be detected so as to classify the defects in the fabric to be tested.

[0026] Currently, when defects in fabric to be inspected are detected, the method is mainly carried out by comparing the image of the fabric to be inspected with the image without defects. However, the detection accuracy that can be obtained by comparing the image without defects is low. For example, there is a large difference between the shape of the determined defect and the actual shape of the defect, or there is a large difference between the area of ​​the determined defect and the actual area of ​​the defect, which affects the classification result of the defects in the fabric to be inspected. Therefore, it is difficult to accurately classify the defects in the fabric to be inspected.

[0027] In response to the above technical problems, an embodiment of the present application provides a defect classification method based on database comparison, which determines the second eigenvalue of the target pixel according to the sum of multiple first eigenvalues ​​of the target pixel in multiple specified directions, determines the defect area in the grayscale image according to the second eigenvalue of the target pixel in the grayscale image, and determines the defect type of the defect area according to the defect area and a preset image containing defects in a preset database. Since the first eigenvalue is determined according to the frequency of the grayscale level combination of the pixel pair corresponding to the target pixel in the grayscale co-occurrence matrix, it can better characterize the characteristics of the target pixel and can more accurately determine the defect area in the grayscale image.

[0028] Since the defects in the fabric to be detected are determined based on the features of the pixels in the grayscale image, compared with directly comparing the grayscale image of the fabric to be detected with the image without defects, it is possible to better extract the tiny defects in the fabric to be detected, thereby improving the detection accuracy of the defects in the fabric to be detected. Therefore, when there are actually defects in the fabric to be detected, the classification results of the defects in the fabric to be detected can be obtained more accurately.

[0029] Figure 1 is a flow chart showing a defect classification method based on database comparison according to an exemplary embodiment. Figure 1 As shown, the method includes the following steps.

[0030] In step S101, a grayscale image of the cloth to be detected output by the loom is obtained, and texture feature values ​​of target pixels in the grayscale image are determined.

[0031] The surface image of the fabric to be detected output by the loom can be collected by an image acquisition device, and a grayscale image can be obtained by graying the surface image. The fabric output by the loom is usually a single-color fabric. Therefore, the grayscale image can reduce the subsequent calculation amount while retaining the characteristics of the fabric.

[0032] The target pixel is any pixel in the grayscale image. The texture feature value of the target pixel can be determined in the following way:

[0033] , F is the texture feature value, norm is the normalization function, L is the number of rows of the grayscale image, H is the number of columns of the grayscale image, and A is the number of other pixels in the neighborhood. is the grayscale difference between the target pixel and the mth pixel in its neighborhood. is the grayscale difference between the pixel at the ath row and the bth column in the grayscale image and the mth other pixel in its neighborhood.

[0034] The number of image rows of the grayscale image corresponds to the width of the grayscale image, and the number of image columns of the grayscale image corresponds to the height of the grayscale image; the neighborhood range can be a 3×3 area centered on the pixel point, or the neighborhood range can be a 5×5 area centered on the pixel point, or the neighborhood range can be a 7×7 area centered on the pixel point.

[0035] The grayscale difference between the target pixel and other pixels in the neighborhood of the target pixel can reflect the difference in grayscale features between the target pixel and other pixels in the neighborhood of the target pixel.

[0036] In the calculation formula of the texture feature value in the embodiment of the present application, the grayscale difference between the target pixel and other pixels within the target pixel is determined, and the grayscale difference between other pixels other than the target pixel in the grayscale image and pixels in the neighborhood of other pixels is determined. Compared with directly comparing the grayscale values ​​of the target pixel with other pixels other than the target pixel in the grayscale image, this can better characterize the degree of difference between the target pixel and other pixels other than the target pixel in the grayscale image.

[0037] Compared with the difference between the normal area and other normal areas, the difference between the defective area and the normal area is greater, and compared with the proportion of the normal area in the grayscale image of the fabric to be tested, the proportion of the defective area in the grayscale image of the fabric to be tested is smaller. and , is the grayscale difference between the target pixel and the mth pixel in the neighborhood. It is the grayscale difference between the pixel located in the ath row and the bth column in the grayscale image and the mth other pixel in its neighborhood, so that the obtained texture feature value can better characterize the difference between the target pixel and other pixels.

[0038] The greater the difference between the target pixel and other pixels, the greater the texture complexity of the neighborhood where the target pixel is located. Therefore, the texture eigenvalue can better characterize the texture complexity of the neighborhood where the target pixel is located.

[0039] F is the texture eigenvalue of the target pixel, which is used to characterize the texture complexity of the neighborhood of the target pixel. For the cloth output by the loom, since the types of grayscale values ​​of the pixels in the defects in the cloth are more diverse, such as spinning defects, oil stains or uneven color, the texture complexity of the defects in the cloth is usually higher than that of the normal area in the cloth.

[0040] The larger the texture eigenvalue is, the higher the texture complexity of the neighborhood range of the target pixel is, and the target pixel has a higher probability of being located at the defect of the fabric to be detected; on the contrary, the smaller the texture eigenvalue is, the lower the texture complexity of the neighborhood range of the target pixel is, and the target pixel has a lower probability of being located at the defect of the fabric to be detected. The texture eigenvalue can reflect the characteristics of the neighborhood range where the target pixel is located, so as to determine the defective pixel in the grayscale image.

[0041] In step S102, the filtering degree value of the target pixel point is determined according to the texture feature value of the target pixel point, and the target pixel point is filtered using the filtering degree value of the target pixel point. When the texture feature value of the target pixel point after filtering is greater than a preset feature threshold, the target pixel point after filtering is treated as a defective pixel point.

[0042] Since the texture eigenvalue can better characterize the texture complexity of the neighborhood range where the target pixel is located, and the higher the texture complexity of the neighborhood range where the pixel in the fabric to be detected is, the higher the probability that the pixel is located at a defect; on the contrary, the lower the texture complexity of the neighborhood range where the pixel in the fabric to be detected is, the lower the probability that the pixel is located at a defect, and the higher the probability that the pixel belongs to a normal area in the fabric.

[0043] The filtering degree value is negatively correlated with the texture eigenvalue. The larger the texture eigenvalue of the target pixel, the smaller the filtering degree value corresponding to the target pixel. Since the texture eigenvalue of the target pixel can reflect the probability that the target pixel is a defect, a smaller filtering degree value can better retain the defects in the grayscale image during the filtering process, so as to more accurately determine the defective pixels in the grayscale image.

[0044] On the contrary, since the filtering degree value is negatively correlated with the texture eigenvalue, the smaller the texture eigenvalue of the target pixel, the larger the filtering degree value corresponding to the target pixel. Since the texture eigenvalue of the target pixel can reflect the probability that the target pixel is a defect, a larger filtering degree value can weaken the characteristics of pixels other than defects in the grayscale image after filtering, so as to more accurately determine the defective pixels in the grayscale image.

[0045] Compared with applying the same degree of filtering to all pixels in the entire grayscale image, it can take into account both the retention of the features of defects in the grayscale image and the filtering of noise pixels in the grayscale image.

[0046] At the same time, by setting a smaller filtering degree value for pixels with larger texture eigenvalues, and setting a larger filtering degree value for pixels with smaller texture eigenvalues, the pixel values ​​of the pixels after filtering and the pixel values ​​of other surrounding pixels change, and the noise pixels in the grayscale image are filtered out.

[0047] In one embodiment, the texture feature value of the target pixel may be subtracted from the upper limit of the texture feature values ​​of all pixels to obtain the filtering degree value corresponding to the target pixel.

[0048] For example, when the texture eigenvalues ​​of all pixels range from 0 to 1, 1 is the upper limit of the texture eigenvalues ​​of all pixels, so that the filtering degree value of the pixel with the largest texture eigenvalue is the smallest, and the filtering degree value of the pixel with the smallest texture eigenvalue is the largest.

[0049] When re-determining the texture feature value of the target pixel point after filtering, since the influence of the noise pixels in the grayscale image is eliminated, the texture feature value of the target pixel point obtained can better characterize the probability that the target pixel point is a defect, therefore, it helps to determine a more accurate defective pixel point.

[0050] For example, when defective pixels are determined directly based on the texture feature values ​​of target pixels that have not been filtered, noise pixels in the grayscale image may be regarded as defective pixels. However, since these noise pixels exist in the grayscale image, there are no defects in the actual positions corresponding to the noise pixels in the grayscale image. When the defects are subsequently processed, it may cause a waste of manpower and material resources.

[0051] By filtering the target pixel points according to the texture feature values ​​of the target pixel points before filtering, and determining the texture feature values ​​of the target pixel points after filtering, since the influence of noise pixels existing in the grayscale image is excluded, when the defective pixels are determined according to the texture feature values ​​of the target pixel points after filtering, the defective pixels in the grayscale image can correspond to the actual defects in the fabric to be inspected, thereby reducing the waste of manpower or material resources in the subsequent processing of the defects.

[0052] When the texture feature value of the target pixel after filtering is greater than the preset feature threshold, it means that the target pixel after filtering is likely to be a defect, and the target pixel can be used as a defect pixel to obtain the defect area in the grayscale image.

[0053] The preset feature threshold may be set according to actual needs. For example, when the texture feature value of the target pixel point ranges from 0 to 1, the preset feature threshold may be set between 0.6 and 0.8.

[0054] In one embodiment, the target pixel point is filtered using the filtering degree value of the target pixel point, including: taking the product of the filtering degree value and the preset filtering coefficient as the target filtering coefficient of the target pixel point; and filtering the target pixel point using the target filtering coefficient using the target filter.

[0055] The target filter may be any one of filters such as a mean filter, a Gaussian filter, and a median filter.

[0056] In step S103, the area composed of defective pixels is taken as the defective area, and the defect type of the defective area is determined according to the defective area and a preset image containing defects in a preset database.

[0057] The fabric may have defects such as poor interlacing of warp and weft yarns, oil stains, uneven colors, color spots, and weaving defects. The defect type of the defect area can be determined based on the defect area and the preset images containing the defects in the preset database, so that different types of defect areas can be processed in a targeted manner.

[0058] In one embodiment, the preset database stores defect types corresponding to preset images, and determines the defect type of the defect area according to the defect area and the preset image containing the defect in the preset database, including: performing feature comparison between the defect area and the preset image containing the defect in the preset database, and determining the feature comparison result between the defect area and the preset image; according to the feature comparison result, determining a target preset image matching the defect area from multiple preset images containing defects; and using the defect type corresponding to the target preset image as the defect type of the defect area in the fabric to be detected.

[0059] For example, for different defects that may exist in the fabric, corresponding preset images can be pre-stored in the preset database, and different preset images correspond to different types of defects.

[0060] The defect area in the grayscale image may include multiple defect sub-areas, and different defect sub-areas are distributed at different image positions in the grayscale image of the fabric to be detected. The multiple defect sub-areas can be compared with the preset image containing the defects to determine the type of defects in the defect sub-areas in the fabric to be detected.

[0061] The defect area can be compared with the preset images containing defects in the preset database to determine the feature comparison results between the defect area and the preset image. For example, the same defect area can be matched with the preset images corresponding to different types of defects to obtain the similarity between the defect area and the different preset images after matching; the feature comparison result between the defect area and the preset image can refer to the similarity between the defect area and the preset image determined after the feature comparison.

[0062] The feature comparison between the defect area and the preset image can be achieved through matching methods such as SIFT (Scale-Invariant Feature Transform) matching, SURF (Speeded Up Robust Features) matching, and HOG (Histogram of Oriented Gradients) feature matching.

[0063] Determining a target preset image matching the defect area from a plurality of preset images containing defects according to the feature comparison result may refer to taking the preset image with the highest similarity as the target preset image matching the defect area.

[0064] Since the target preset image is an image that matches the defect area, the type of defects contained in the target preset image is likely to be the same as the type of defects in the defect area in the grayscale image of the cloth to be detected. Using the defect type corresponding to the target preset image as the defect type of the defect area in the cloth to be detected can better realize the classification of defects in the cloth to be detected.

[0065] For example, when the preset image containing oil stains is an image that matches the defect area, it means that the probability that the type of defects contained in the defect area of ​​the cloth to be detected is oil stains is the highest, and the defects in the cloth to be detected can be classified into the category of oil stains so as to process the oil stains in the cloth to be detected.

[0066] Compared with comparing the entire grayscale image of the fabric to be inspected with an image without defects, since the object of comparison is a smaller image area, the details of the defects can be better reflected in the smaller image area, so a more detailed comparison result can be obtained, thereby obtaining a more accurate defect classification result.

[0067] In one embodiment, the defect type of the defect area is determined based on the defect area and a preset image containing the defect in a preset database, including: inputting the defect area and the preset image containing the defect into a similarity comparison model to obtain a similarity comparison result output by the similarity comparison model, the similarity comparison result being used to characterize the similarity between the defect area and the preset image containing the defect; the preset image with the highest similarity represented by the similarity comparison result can be used as a target preset image that matches the defect area; and the defect type corresponding to the target preset image is used as the defect type corresponding to the defect area.

[0068] For example, the similarity comparison model can be obtained by training in the following way: taking a preset image containing defects and the defective area in the fabric as the input of a pre-built initial network model, and taking the similarity value as the output of the initial network model, the similarity value is used to characterize the similarity between the preset image containing defects and the defective area in the fabric, thereby training the initial network model and using the trained initial network model as the similarity comparison model.

[0069] By using the defect classification method based on database comparison provided by the embodiment of the present application, the filtering degree value of the target pixel is determined according to the texture feature value of the target pixel, and the target pixel is filtered using the filtering degree value of the target pixel. Since the filtering degree value is negatively correlated with the texture feature value, the pixel with a smaller texture feature value can be filtered to a lower degree, and the pixel with a larger texture feature value can be filtered to a higher degree, taking into account both the retention of the features of the pixel with a larger texture feature value and the filtering of noise pixels in the grayscale image. When the texture feature value of the target pixel after filtering is greater than a preset feature threshold, the target pixel after filtering is taken as a defective pixel, and the pixel with a larger texture feature value has a higher probability of being a defect. Therefore, the defective pixel in the grayscale image of the fabric to be inspected can be determined more accurately.

[0070] Since more accurate defect pixel points in the grayscale image of the cloth to be detected can be obtained, when there are defects in the cloth to be detected, a more accurate classification result of the defects in the cloth to be detected can be obtained.

[0071] In one embodiment, a filtering degree value of a target pixel is determined based on a texture eigenvalue of the target pixel, including: determining a pixel pair consisting of a target pixel and adjacent pixels in a specified direction; obtaining multiple grayscale co-occurrence matrices of a grayscale image in multiple specified directions, and determining a first eigenvalue of the target pixel based on the multiple grayscale co-occurrence matrices and multiple pixel pairs of the target pixel in multiple specified directions, the first eigenvalue being used to characterize the degree of difference between the frequency of a grayscale combination of the pixel pair in the grayscale co-occurrence matrix and the maximum frequency in the grayscale co-occurrence matrix; taking the product of the texture eigenvalue of the target pixel and the first eigenvalue as a second eigenvalue, and obtaining the filtering degree value of the target pixel based on the difference between a preset value and the second eigenvalue, wherein the preset value is greater than an upper limit of the second eigenvalue of the target pixel.

[0072] Gray Level Co-occurrence Matrix (GLCM) is a method to describe the texture characteristics of an image through the relationship between grayscale pixels in the image. The gray level co-occurrence matrix constructs a matrix by calculating the frequency of co-occurrence of each gray level in the image with its adjacent gray levels, thereby describing the texture characteristics of the image.

[0073] The gray level co-occurrence matrix includes the frequency of occurrence of gray level combinations along a specified direction in a gray level image, and the gray level combinations include two identical or different gray levels.

[0074] For a grayscale image with grayscale levels between 1 and 255, different columns from left to right in the grayscale co-occurrence matrix correspond to different grayscale levels from 1 to 255, and different rows from top to bottom in the grayscale co-occurrence matrix correspond to different grayscale levels from 1 to 255; the frequency recorded in the first row and first column of the grayscale co-occurrence matrix of the grayscale image in a specified direction corresponds to the frequency of the grayscale combination (1, 1) appearing in the grayscale image along the specified direction.

[0075] When the second eigenvalues ​​of all pixels range from 0 to 1, 1 is the upper limit of the second eigenvalue of the pixel, and the second eigenvalue may be a value greater than 1, such as 1.2, 2, etc.

[0076] The first eigenvalue can characterize the degree of difference between the frequency of the grayscale combination of pixel pairs in the grayscale co-occurrence matrix and the maximum frequency in the grayscale co-occurrence matrix. The maximum frequency in the grayscale co-occurrence matrix is ​​usually the frequency corresponding to the normal area in the fabric to be detected. Therefore, the first eigenvalue can characterize the degree of difference between the pixel point and the normal area in the fabric to be detected, thereby characterizing the probability that the pixel point belongs to a defect in the fabric.

[0077] Since the first eigenvalue can characterize the probability that the pixel point belongs to a defect in the fabric, and the texture eigenvalue can characterize the texture complexity of the neighborhood range where the pixel point is located, therefore, taking the product of the texture eigenvalue of the target pixel point and the first eigenvalue as the second eigenvalue, the first eigenvalue and the texture eigenvalue can be combined, and the probability of the pixel point belonging to a defect can be more accurately characterized by the second eigenvalue; according to the difference between the preset value and the second eigenvalue, the filtering degree value of the target pixel point is obtained to ensure that the filtering degree value is negatively correlated with the texture eigenvalue, so that a lower filtering degree value can be set for a pixel point with a higher probability of belonging to a defect, and a higher filtering degree value can be set for a pixel point with a lower probability of belonging to a defect, taking into account both the filtering of noise pixels in the grayscale image and the retention of the characteristics of the defect.

[0078] Different specified directions may correspond to different gray-level co-occurrence matrices, and the multiple specified directions may include the following directions: a horizontal direction, a direction with an angle of 45° to the horizontal direction, a vertical direction, and a direction with an angle of 135° to the horizontal direction; for example, from left to right, from the lower left to the upper right, from top to bottom, and from the upper left to the lower right.

[0079] For example, for the grayscale co-occurrence matrix corresponding to the grayscale image in the horizontal direction, if the grayscale level of the grayscale image is between 1 and 255, the frequency recorded in the first row and first column of the grayscale co-occurrence matrix of the grayscale image in the horizontal direction corresponds to the frequency of the grayscale combination (1, 1) appearing in the grayscale image along the horizontal direction.

[0080] In one embodiment, multiple grayscale co-occurrence matrices of a grayscale image in multiple specified directions are obtained in the following manner: determining the frequency of occurrence of a grayscale combination in the grayscale image along the specified direction; obtaining the grayscale co-occurrence matrix of the grayscale image in the specified direction according to the frequency of occurrence of different grayscale combinations in the grayscale image along the specified direction, so as to obtain different grayscale co-occurrence matrices corresponding to different specified directions, respectively; wherein the grayscale combination includes two identical or different grayscale levels, and the grayscale levels included in different grayscale combinations are different.

[0081] For example, the grayscale level of a pixel in a grayscale image can be an integer between 0 and 255, and different grayscale combinations can be (0, 0), (1, 0), (0, 1), (41, 41), and (41, 42), etc. If the frequency of the grayscale combination (0, 0) appearing along a specified direction in the grayscale image is 10, the frequency corresponding to the grayscale combination (0, 0) in the grayscale co-occurrence matrix is ​​10; for grayscale images with grayscale levels between 1 and 255, the grayscale co-occurrence matrix can include 255 rows and 255 columns, and different columns of the same row in the grayscale co-occurrence matrix correspond to different grayscale levels, and different rows of the same column in the grayscale co-occurrence matrix also correspond to different grayscale levels.

[0082] When the specified direction is the horizontal direction, the target pixel in the grayscale image and the pixel located on the right side of the target pixel can be used to form a pixel pair of the target pixel in the horizontal direction. Since the grayscale co-occurrence matrix records the frequency of the grayscale combination appearing along the specified direction in the grayscale image, the first frequency of the grayscale combination corresponding to the pixel pair in the grayscale co-occurrence matrix can be determined.

[0083] For example, if the grayscale value of the target pixel is 40 and the grayscale value of the pixel to the right of the target pixel is 21, then the grayscale combination of the pixel pair is (40, 21). The first frequency corresponding to the grayscale combination (40, 21) can be determined in the grayscale co-occurrence matrix corresponding to the grayscale image in the horizontal direction.

[0084] When the specified direction is a direction with an angle of 45° to the horizontal direction, a vertical direction, and a direction with an angle of 135° to the horizontal direction, the first frequency of the grayscale combination of the pixel pair in the grayscale co-occurrence matrix in the specified direction can be determined by referring to the process of obtaining the first frequency of the grayscale combination of the pixel pair in the grayscale co-occurrence matrix in the horizontal direction, which will not be repeated here.

[0085] In this way, by determining the grayscale co-occurrence matrix of the grayscale image in a specified direction, it is helpful to describe the characteristics of the pixel points in the cloth to be detected.

[0086] In one embodiment, determining the first eigenvalue of the target pixel point according to the multiple gray level co-occurrence matrices and the multiple pixel pairs of the target pixel point in the multiple specified directions includes: , where V is the first eigenvalue of the target pixel and M is the number of specified directions; It is the ratio of the frequency of the gray level combination of the pixel pairs of the target pixel in the k specified directions in the gray level co-occurrence matrix of the k specified direction to the maximum frequency in the gray level co-occurrence matrix of the k specified direction.

[0087] The maximum frequency in the gray level co-occurrence matrix in the specified direction can reflect the gray level combination that appears most frequently along the specified direction in the fabric to be detected. For example, when the gray level combination with the largest frequency in the gray level co-occurrence matrix in the horizontal direction is (100, 102), it means that the proportion of gray level 100 and gray level 102 adjacent to the fabric to be detected in the horizontal direction is the largest, and the defects in the fabric to be detected usually only account for a small part of the fabric to be detected, and most areas of the fabric to be detected usually do not have defects. The gray level combination (100, 102) has a greater probability of being the gray level combination corresponding to the normal area of ​​the fabric to be detected.

[0088] If the frequency corresponding to the grayscale combination in the grayscale co-occurrence matrix in the specified direction is small, it means that the grayscale combination is not the main grayscale combination of the cloth to be detected in the specified direction, and the pixel point where the grayscale combination is located has a lower probability of being a pixel point in the normal area of ​​the cloth to be detected, or the pixel point where the grayscale combination is located has a higher probability of being a defect in the cloth to be detected.

[0089] The frequency of the grayscale combination of the pixel pairs of the target pixel in the k specified directions in the grayscale co-occurrence matrix of the kth specified direction is compared with the maximum frequency in the grayscale co-occurrence matrix of the kth specified direction. Since the second frequency is the maximum frequency in the grayscale co-occurrence matrix in the specified direction, the grayscale combination corresponding to the maximum frequency in the grayscale co-occurrence matrix in the specified direction has a higher probability of belonging to the normal area in the cloth to be detected. Therefore, it can provide a reference for determining whether the target pixel belongs to the pixel in the normal area, thereby providing a better reference for determining whether the target pixel belongs to a defect in the cloth to be detected.

[0090] The fabric to be tested has a relatively obvious repeatability feature in the vertical direction, but may not have a relatively obvious repeatability feature in the direction at an angle of 45° with the horizontal direction.

[0091] Here, the ratio of the frequency of the grayscale combination of the pixel pairs of the target pixel in the specified direction in the grayscale co-occurrence matrix of the specified direction to the maximum frequency in the grayscale co-occurrence matrix of the specified direction can characterize the degree of difference between the target pixel and the normal area in the specified direction. By combining the characteristics of the target pixel in multiple specified directions, the limitation of the target pixel in a single specified direction can be avoided.

[0092] It should be understood that the features of some embodiments of the various applications described herein may be combined with each other, unless specifically stated otherwise.

[0093] Although terms such as "first", "second", and "third" may be used herein to describe various components, parts, regions, layers, or sections, these components, parts, regions, layers, or sections are not limited to these terms. Instead, these terms are only used to distinguish one component, part, region, layer, or section from another component, part, region, layer, or section. Therefore, without departing from the teachings of the examples described herein, the first component, part, region, layer, or section mentioned in the examples may also be referred to as the second component, part, region, layer, or section.

[0094] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description herein, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0095] In addition, the word "exemplary" is used herein to mean serving as an example, instance, or diagram. Any aspect or design described herein as "exemplary" is not necessarily to be understood as being advantageous over other aspects or designs. Instead, the use of the word exemplary is intended to present concepts in a concrete manner. As used herein, the term "or" is intended to mean an inclusive "or" rather than an exclusive "or".

[0096] Likewise, although the present application has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art upon reading and understanding this specification and the accompanying drawings. With particular regard to the various functions performed by the components (e.g., elements, resources, etc.) described above, unless otherwise noted, the terms used to describe such components are intended to correspond to any component (functionally equivalent) that performs the specific functions of the described components, even if not structurally equivalent to the disclosed structures.

[0097] Additionally, while particular features of the present application may have been disclosed with respect to only one of several implementations, such features may be combined with one or more other features of other implementations as may be desired and advantageous for any given or particular application.

[0098] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application, and the specification and embodiments are only considered as exemplary.

[0099] It should be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.

Claims

1. A defect classification method based on database comparison, characterized in that: include: Obtain a grayscale image of the fabric to be detected output by the loom, and determine the texture feature value of a target pixel point in the grayscale image, where the target pixel point is any pixel point in the grayscale image; According to the texture feature value of the target pixel point, a filtering degree value of the target pixel point is determined, and the filtering degree value is negatively correlated with the texture feature value; the target pixel point is filtered using the filtering degree value of the target pixel point, and when the texture feature value of the target pixel point after filtering is greater than a preset feature threshold, the target pixel point after filtering is regarded as a defective pixel point; The area formed by the defective pixels is taken as the defective area, and the defect type of the defective area is determined according to the defective area and a preset image containing the defect in a preset database; Among them, the texture feature value of the target pixel is determined by the following method: , F is the texture feature value, norm is the normalization function, L is the number of rows of the grayscale image, H is the number of columns of the grayscale image, and A is the number of other pixels in the neighborhood. is the grayscale difference between the target pixel and the mth pixel in its neighborhood. is the grayscale difference between the pixel at the ath row and the bth column in the grayscale image and the mth other pixel in its neighborhood.

2. The defect classification method based on database comparison according to claim 1 is characterized in that: According to the texture feature value of the target pixel point, the filtering degree value of the target pixel point is determined, including: Determine a pixel pair consisting of a target pixel and adjacent pixels in a specified direction; Acquire multiple gray level co-occurrence matrices of the gray level image in multiple specified directions, and determine a first eigenvalue of the target pixel according to the multiple gray level co-occurrence matrices and multiple pixel pairs of the target pixel in the multiple specified directions, wherein the first eigenvalue is used to characterize the degree of difference between the frequency of the gray level combination of the pixel pair in the gray level co-occurrence matrix and the maximum frequency in the gray level co-occurrence matrix; The product of the texture eigenvalue of the target pixel and the first eigenvalue is used as the second eigenvalue, and the filtering degree value of the target pixel is obtained according to the difference between the preset value and the second eigenvalue, and the preset value is greater than the upper limit of the second eigenvalue of the target pixel.

3. The defect classification method based on database comparison according to claim 2 is characterized in that: Multiple gray-level co-occurrence matrices of a gray-level image in multiple specified directions are obtained by: Determine the frequency of occurrence of a gray level combination along a specified direction in a grayscale image; According to the frequencies of occurrence of different gray level combinations in the gray image along the specified direction, a gray level co-occurrence matrix of the gray image in the specified direction is obtained, so as to obtain different gray level co-occurrence matrices corresponding to different specified directions respectively; The gray level combination includes two identical or different gray levels, and different gray level combinations include different gray levels.

4. The defect classification method based on database comparison according to claim 2 is characterized in that: The determining the first eigenvalue of the target pixel point according to the multiple gray level co-occurrence matrices and the multiple pixel pairs of the target pixel point in the multiple specified directions includes: , where V is the first eigenvalue of the target pixel and M is the number of specified directions; It is the ratio of the frequency of the gray level combination of the pixel pairs of the target pixel in the k specified directions in the gray level co-occurrence matrix of the k specified direction to the maximum frequency in the gray level co-occurrence matrix of the k specified direction.

5. The defect classification method based on database comparison according to any one of claims 2 to 4, characterized in that: The multiple specified directions include the following four directions: The horizontal direction, the direction with an angle of 45° to the horizontal direction, the vertical direction, and the direction with an angle of 135° to the horizontal direction.

6. The defect classification method based on database comparison according to claim 1 is characterized in that: The target pixel is filtered using the filtering degree value of the target pixel, including: The product of the filtering degree value and the preset filtering coefficient is used as the target filtering coefficient of the target pixel point; The target pixel point is filtered using the target filter coefficient.

7. The defect classification method based on database comparison according to claim 6 is characterized in that: The target filter includes any one of the following filters: Mean filter, Gaussian filter and median filter.

8. The defect classification method based on database comparison according to claim 1 is characterized in that: The preset database stores defect types corresponding to preset images, and according to the defect area and the preset image containing the defect in the preset database, determining the defect type of the defect area includes: Perform feature comparison between the defect area and a preset image containing the defect in a preset database, and determine a feature comparison result between the defect area and the preset image; According to the feature comparison result, determining a target preset image matching the defect area from a plurality of preset images containing defects; The defect type corresponding to the target preset image is used as the defect type of the defect area in the fabric to be detected.