CN-121998995-A - Fabric defect recognition method and system based on image processing
Abstract
The invention relates to the technical field of fabric defect recognition, in particular to a fabric defect recognition method and system based on image processing, wherein the method comprises the steps of collecting normal images of jacquard knitted fabrics and processing the normal images to obtain normal gray images; the method comprises the steps of sampling normal gray images to obtain a plurality of window images, carrying out hierarchical clustering on the window images to obtain a plurality of clusters, training a convolution self-encoder for each cluster, counting the reconstruction errors of all pixels after all window images in each cluster are reconstructed by the convolution self-encoder, establishing a reconstruction error distribution reference library, collecting and processing images to be detected of jacquard knitted fabric to obtain window images to be detected, inputting the window images to be detected into the convolution self-encoder of the matched clusters to obtain a reconstruction error map, combining the reconstruction error distribution reference library of the clusters, and identifying and extracting defect areas by a self-adaptive area growth method. The invention obviously improves the accuracy and the robustness of defect detection.
Inventors
- Zheng Fangling
- ZHENG LEIYONG
- Cui Weihui
Assignees
- 宁波欧美晟针织有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260410
Claims (10)
- 1. The fabric defect identification method based on image processing is characterized by comprising the following steps: Extracting global texture features from the gray images, and performing self-adaptive amplification treatment on the gray images according to the global texture features to obtain preprocessed normal gray images; Performing sliding sampling on the normal gray level images by adopting windows with uniform sizes to obtain a plurality of window images, performing multi-scale wavelet decomposition on each window image, determining the optimal decomposition layer number, combining the global texture features and the texture features corresponding to the optimal decomposition layer number to construct regional feature vectors of each window image, performing hierarchical clustering on the basis of the regional feature vectors to obtain a plurality of cluster clusters, respectively training a convolution self-encoder for each cluster, counting the reconstruction errors of pixels after all window images in each cluster are reconstructed by the convolution self-encoder, and establishing a reconstruction error distribution reference library; the method comprises the steps of collecting a to-be-detected image of jacquard knitted fabric to be detected, carrying out preprocessing and sliding sampling on the to-be-detected image identical to a normal image to obtain a plurality of to-be-detected window images, adopting a construction method identical to that of the window images to construct regional characteristic vectors of each to-be-detected window image, matching cluster clusters according to the regional characteristic vectors, inputting the to-be-detected window images into a convolution self-encoder of the matched cluster clusters to obtain a reconstruction error map, combining a reconstruction error distribution reference library of the cluster clusters, and identifying and extracting defect areas in the to-be-detected window images through a self-adaptive regional growth method.
- 2. The fabric defect recognition method based on image processing according to claim 1 is characterized in that the adaptive amplification processing of the gray image according to the global texture features comprises the steps of carrying out local binary pattern coding on the gray image to generate a coding image, counting the occurrence probability of each coding value in the coding image, calculating the entropy value of the coding image, normalizing to obtain the global texture features, presetting the maximum amplification factor and the minimum amplification factor, calculating the difference between the maximum amplification factor and the minimum amplification factor, calculating the product between the difference and the global texture features, calculating the sum of the product and the minimum amplification factor, rounding down the sum to obtain an up-sampling rate, and carrying out amplification processing on the gray image based on the up-sampling rate to obtain a normal gray image.
- 3. The fabric defect recognition method based on image processing according to claim 1, wherein the multi-scale wavelet decomposition is carried out on each window image and the optimal decomposition layer number is determined, wherein the multi-scale wavelet decomposition is carried out on the window image, the orthogonal wavelet decomposition is carried out on the window image in a continuous scale, the corresponding low-frequency sub-bands and the high-frequency sub-bands in multiple directions of each layer are obtained, the change rate of energy of the low-frequency sub-bands of two adjacent decomposition layer numbers is calculated, the decomposition layer number with the change rate being smaller than a preset threshold value for the first time is taken as the optimal decomposition layer number, and if all the change rates are larger than or equal to the preset threshold value, the layer number with the smallest difference value between the change rate and the preset threshold value is selected as the optimal decomposition layer number.
- 4. The fabric defect recognition method based on image processing according to claim 3, wherein the construction of the regional feature vector of each window image comprises the steps of calculating the ratio of the sum of energies of high-frequency sub-bands corresponding to the optimal decomposition layer number of the window image to the sum of energies of all sub-bands to obtain regional texture complexity, calculating the ratio of the energy of each high-frequency sub-band corresponding to the optimal decomposition layer number to the sum of energies of all high-frequency sub-bands to obtain the energy duty ratio of each high-frequency sub-band, and jointly forming the regional feature vector of the window image by the optimal decomposition layer number of the global texture feature of the gray image to which the window image belongs, the regional texture complexity of the window image and the energy duty ratio of each high-frequency sub-band.
- 5. The fabric defect recognition method based on image processing according to claim 1 is characterized in that hierarchical clustering based on regional feature vectors comprises the steps of constructing a cluster tree by adopting a bottom-up aggregation hierarchical clustering algorithm by taking Euclidean distance between regional feature vectors of any two window images as similarity measurement, traversing from top to bottom from a root node of the cluster tree, stopping splitting the cluster when the maximum Euclidean distance between the regional feature vectors of all window images in the cluster is smaller than a preset value, otherwise continuing traversing downwards, and forming a final cluster set by all the cluster clusters corresponding to the nodes stopped to be split.
- 6. The fabric defect recognition method based on image processing according to claim 5, wherein the building of the reconstruction error distribution reference library comprises inputting window images in a final cluster set into a corresponding convolution self-encoder to generate reconstruction images corresponding to the window images, calculating absolute differences of each pixel between each window image and each reconstruction image as reconstruction errors of the pixel, and counting average values and standard deviations of the reconstruction errors of each pixel in all window images as the reconstruction error distribution reference library of the cluster.
- 7. The fabric defect recognition method based on image processing according to claim 1 is characterized in that the method for recognizing and extracting defect areas in a window image to be detected through a self-adaptive area growth method comprises the steps of calculating area texture complexity of the window image to be detected, calculating the number of seed points based on the area texture complexity, selecting seed points based on reconstruction errors of pixels in a reconstruction error map of the window image to be detected and Euclidean distance between every two pixels, starting area growth from all the seed points in parallel, taking the neighborhood pixels into the defect areas when the neighborhood pixels meet growth conditions and continuing to expand the defect areas as new seed points, and stopping growth when no new neighborhood pixels meet the growth conditions or the area of the defect areas exceeds a preset maximum growth area to obtain a defect area mask of the window image to be detected.
- 8. The fabric defect recognition method based on image processing according to claim 7, wherein the growth condition is that the reconstruction error of a neighborhood pixel is larger than or equal to the regional growth threshold of the neighborhood pixel, and the calculation method of the regional growth threshold of each pixel comprises the steps of calculating the local texture complexity of the pixel based on the energy of the pixel in a low-frequency sub-band and a high-frequency sub-band corresponding to the optimal decomposition layer number of a window image to be detected, adding the local texture complexity of the pixel and a preset reference coefficient to obtain a growth threshold coefficient, obtaining the mean value and the standard deviation of the reconstruction error of a normal pixel at the corresponding position of the pixel from a reconstruction error distribution reference library of clusters matched with the window image to be detected, and calculating the sum value of the product of the standard deviation and the growth threshold coefficient to obtain the regional growth threshold of the pixel.
- 9. The method for identifying the defects of the fabric based on image processing according to claim 7 is characterized by further comprising the steps of marking any pixel on the image to be detected as a defect in any defect area mask of the image to be detected of the window to be detected covering the pixel, marking the pixel as the defect in a final fusion result to finally obtain a fusion defect mask, performing morphological opening operation on the fusion defect mask to remove isolated noise points, performing morphological closing operation to fill micro holes of the defect area, and performing connected domain analysis on the processed fusion defect mask to obtain a continuous and complete defect area.
- 10. An image processing-based fabric defect recognition system comprising a processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement the image processing-based fabric defect recognition method of any one of claims 1-9.
Description
Fabric defect recognition method and system based on image processing Technical Field The invention relates to the technical field of fabric defect identification. In particular to a fabric defect recognition method and system based on image processing. Background With the rapid development of machine vision technology, an automatic defect detection method based on image processing is gradually applied to the textile field. However, in a practical industrial scene, the jacquard knitted fabric has obvious texture heterogeneity, the same piece of fabric can simultaneously comprise a plain color area, a jacquard area and a plain color-jacquard mixed area, and defects can appear in any area and have various forms. Meanwhile, the characteristic difference between the natural fluctuation of the texture of the normal fabric and the slight defects is small, and the single characteristic is difficult to distinguish effectively. In the prior art, when the problems are treated, all fabrics and all areas are generally detected uniformly by adopting fixed windows, fixed analysis scales and fixed model parameters. However, the method has the defects that the model generalization capability is poor due to the fact that the method cannot adapt to texture complexity differences among different fabrics, the detection precision is difficult to ensure due to the fact that the method cannot adapt to texture characteristics of different areas in the same fabric, false detection is easy to occur in the areas with complex textures, and fine defects in the areas with smooth textures are easy to miss detection. Therefore, a method and a system for identifying defects of fabric based on image processing are needed in the art to solve the problems of poor defect identification precision and easy missed detection and false detection in the prior art. Disclosure of Invention In order to solve the technical problems of poor defect recognition precision and easy missed detection and false detection existing in the prior art, the invention provides the following aspects. In a first aspect, a method for identifying defects in fabric based on image processing includes: Extracting global texture features from the gray images, and performing self-adaptive amplification treatment on the gray images according to the global texture features to obtain preprocessed normal gray images; Performing sliding sampling on the normal gray level images by adopting windows with uniform sizes to obtain a plurality of window images, performing multi-scale wavelet decomposition on each window image, determining the optimal decomposition layer number, combining the global texture features and the texture features corresponding to the optimal decomposition layer number to construct regional feature vectors of each window image, performing hierarchical clustering on the basis of the regional feature vectors to obtain a plurality of cluster clusters, respectively training a convolution self-encoder for each cluster, counting the reconstruction errors of pixels after all window images in each cluster are reconstructed by the convolution self-encoder, and establishing a reconstruction error distribution reference library; the method comprises the steps of collecting a to-be-detected image of jacquard knitted fabric to be detected, carrying out preprocessing and sliding sampling on the to-be-detected image identical to a normal image to obtain a plurality of to-be-detected window images, adopting a construction method identical to that of the window images to construct regional characteristic vectors of each to-be-detected window image, matching cluster clusters according to the regional characteristic vectors, inputting the to-be-detected window images into a convolution self-encoder of the matched cluster clusters to obtain a reconstruction error map, combining a reconstruction error distribution reference library of the cluster clusters, and identifying and extracting defect areas in the to-be-detected window images through a self-adaptive regional growth method. Preferably, the self-adaptive amplification processing of the gray image according to the global texture feature comprises the steps of carrying out local binary pattern coding on the gray image to generate a coding image, counting the occurrence probability of each coding value in the coding image, calculating the entropy value of the coding image and normalizing to obtain the global texture feature, presetting the maximum amplification factor and the minimum amplification factor, calculating the difference between the maximum amplification factor and the minimum amplification factor, calculating the product between the difference and the global texture feature, calculating the sum of the product and the minimum amplification factor, and carrying out downsampling on the sum to obtain an upsampling magnification, and carrying out amplification processing on the gray image based on the upsampling magnificat