Textile defect detection method based on machine vision
Through the initialization setting and feature extraction of the machine vision system, combined with the support vector machine algorithm, the wrinkle defects of textiles are identified and evaluated, and the problems of detection accuracy, efficiency and cost control in the existing technology are solved, and efficient and accurate defect detection and manage.
Patent Information
- Application Number
- CN202411177179.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2044-08-26
AI Technical Summary
Existing textile defect detection systems are difficult to improve efficiency and control costs while ensuring detection accuracy. Especially in the detection speed and waste of resources in small defect detection of high-end textiles and the identification of wrinkle defects in ordinary textiles.
The machine vision system is adopted to set the camera resolution and algorithm complexity through initialization, image preprocessing and feature extraction, identify and evaluate wrinkle defects, and classify and rating it in combination with the support vector machine algorithm to generate a unified defect description data structure.
The balance between inspection accuracy, efficiency and cost is achieved, the accuracy and automation level of textile defect detection is improved, the characteristics of different textiles are adapted to flexibly adjust the inspection standards, and the scientific and standardized quality management is ensured.
Smart Images

Figure CN119323543A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of information technology, and in particular to a method for detecting textile defects using machine vision. Background Art
[0002] In the field of textile defect detection, as consumers' expectations for product quality continue to increase and production efficiency continues to be pursued, how to ensure detection accuracy while taking into account detection efficiency and cost control has become a key technical challenge. In particular, there is an essential difference in the standards for defect detection between high-end textiles and ordinary textiles. The detection requirements for high-end textiles are extremely strict, and even tiny defects cannot be ignored. This forces the detection system to use high-resolution cameras and complex algorithms to achieve accurate detection. However, such a configuration inevitably leads to a decrease in detection speed and a significant increase in equipment costs. On the contrary, the detection standards for ordinary textiles are relatively loose and tolerate the existence of larger defects. Although the simplified solution can improve detection efficiency, it may ignore those subtle but important defects, especially for the detection of wrinkle defects, the complexity is more prominent. The identification and evaluation of wrinkle defects involves multi-dimensional considerations such as the type, depth, and area of wrinkles, requiring the detection system to establish a comprehensive and sophisticated model to accurately judge different types of wrinkle defects. However, there is a natural contradiction between the complexity of the model and the real-time processing capability. The more complex the model, the greater the computational load and the difficulty of real-time processing. In addition, different textiles have different tolerances for wrinkles. How to flexibly adjust the testing standards in the same testing system so that it can meet the stringent requirements of high-end products without excessively consuming resources has become a technical challenge that needs to be overcome urgently. Summary of the invention
[0003] The present invention provides a method for detecting textile defects using machine vision, which mainly includes:
[0004] According to the textile quality requirements, the corresponding camera resolution parameters, algorithm complexity parameters, and detection sensitivity parameters are obtained from the database, and the machine vision system is initialized and set;
[0005] Using a camera in a machine vision system after initialization to collect images of a textile surface, obtaining raw image data, and performing preprocessing of noise reduction, enhancement, and correction on the raw image data to obtain an optimized textile surface image;
[0006] Perform feature extraction on the optimized textile surface image, extract the texture and morphological features related to wrinkle defects, and construct a feature map that can reflect the characteristics of wrinkles;
[0007] Identifying a region suspected of being a wrinkle defect in the characteristic map, determining the contour of the defect, and obtaining location and range information of the wrinkle defect;
[0008] For the identified wrinkle defect area, calculate the characteristic parameters of wrinkle depth, wrinkle direction, and wrinkle density, and construct a quantitative index of the wrinkle degree, including quantifying the wrinkle characteristics through feature vectors;
[0009] According to a pre-established wrinkle defect type database, pattern matching is performed on the quantified wrinkle features, and if the matching degree exceeds a preset threshold, the specific category of the wrinkle defect is determined;
[0010] The support vector machine algorithm is used to classify the quantitative indicators of wrinkle degree, and combined with the wrinkle depth and density parameters, the wrinkle defects are divided into different levels to evaluate the severity of wrinkles;
[0011] The type, location, scope and severity of wrinkle defects are fused to generate a unified defect description data structure to achieve unified management and analysis of textile wrinkle defects.
[0012] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0013] The present invention discloses a method for detecting textile defects by machine vision, which achieves a balance between detection accuracy, efficiency and cost control; by integrating an intelligent textile defect detection method, enterprises can set customized detection standards for textiles of different grades, that is, meet the strict requirements of high-end products for minor defects, while avoiding excessive investment in ordinary textiles; by using high-resolution cameras and deep learning algorithms, various types of defects can be accurately captured and analyzed, especially in the identification of wrinkle defects, which can comprehensively consider their type, depth and area to form a comprehensive and sophisticated evaluation model; through automated feature extraction, regional segmentation and quantitative index calculation, not only the detection speed is significantly improved, the need for manual participation is reduced, but also the consistency and accuracy of the detection results are ensured. In addition, the detection strategy can be flexibly adjusted according to different textile characteristics, and automatic classification and rating can be achieved through algorithms such as support vector machines (SVM), making the defect management of textiles more scientific and standardized. In summary of the overall technical effects or functions, the implementation of the present invention effectively improves the accuracy and efficiency of textile defect detection, ensures the accuracy and reliability of defect identification through advanced image processing and deep learning technology, and significantly improves the automation level of production quality control through automatic classification and rating, which is of great significance to textile quality management and assurance. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The present invention is a flowchart of a method for detecting textile defects using machine vision.
[0015] Figure 2 It is a schematic diagram of a method for detecting textile defects using machine vision according to the present invention.
[0016] Figure 3 This is another schematic diagram of a method for detecting textile defects using machine vision according to the present invention. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0018] like Figure 1 -3. In this embodiment, a method for detecting textile defects using machine vision may specifically include:
[0019] S101. Obtain corresponding camera resolution parameters, algorithm complexity parameters, and detection sensitivity parameters from a database according to textile quality requirements, and initialize the machine vision system.
[0020] Obtain system parameters corresponding to textile quality requirements, the system parameters including camera resolution parameters, detection sensitivity parameters, image preprocessing parameters and defect classification parameters; initialize and set the machine vision system according to the system parameters. Use a high-speed camera to capture textile images, adjust the image acquisition frequency according to the camera resolution parameters; perform image preprocessing on the captured images according to the image preprocessing parameters to obtain a clear image. Perform feature extraction on the clear image, compare it with the pre-established defect features, and obtain the position coordinates and area information of the suspected defect area. Use the region growing algorithm to accurately segment the suspected defect area; adjust the region growing threshold according to the detection sensitivity parameters; classify the segmentation results by the decision tree algorithm, and adjust the depth and branch conditions of the decision tree according to the defect classification parameters; judge whether the classification result meets the preset defect type; if it does, determine the textile defect type and location information.
[0021] Specifically, according to the textile quality requirements, the corresponding camera resolution parameters, algorithm complexity parameters, detection sensitivity parameters, image preprocessing parameters and defect classification parameters are obtained from the database, and the machine vision system is initialized. A high-speed camera is used to collect textile images, and the image acquisition frequency is adjusted according to the camera resolution parameters set in the initialization. According to the image preprocessing parameters, the collected images are subjected to median filtering denoising, histogram equalization enhancement, and Wiener filtering deblurring to obtain a clear image. For the processed clear image, the support vector machine algorithm is used for feature extraction, and the kernel function type and parameters are adjusted according to the algorithm complexity parameters set in the initialization. The Euclidean distance calculation method is used to compare with the pre-established defect feature library to obtain the position coordinates and area information of the suspected defect area. The suspected defective area is finely segmented by the region growing algorithm. The pixels in the image are grouped into regions with similar features by the region growing algorithm. The region growing threshold is adjusted according to the detection sensitivity parameter set initially. The region growing threshold is used to define the similarity condition between pixels. It is determined based on the difference in pixel intensity (grayscale value), color or other features. The region growing threshold determines which neighboring pixels can be included in the growing region. The segmentation results are classified by the decision tree algorithm. The depth and branch conditions of the decision tree are adjusted according to the initialized defect classification parameters, and finally the textile defect type and location information are obtained. In the textile quality inspection, the corresponding parameters obtained from the database according to the product type are: the camera resolution is set to 4096x3072 pixels, the algorithm complexity parameter is set to 0.8, the detection sensitivity threshold is set to 0.95, the image preprocessing parameters include the median filter window size 5x5, the histogram equalization target gray level 256, the Wiener filter signal-to-noise ratio 10dB, and the defect classification parameters include the maximum depth of the decision tree is 5 and the minimum number of sample segmentations is 10. The high-speed camera collects textile images with a resolution of 4096x3072 at a frequency of 120fps. The images are then subjected to median filtering with a 5x5 window for denoising, histogram equalization with 256 gray levels for contrast enhancement, and Wiener filtering with a signal-to-noise ratio of 10dB for deblurring to obtain clear preprocessed images. For the preprocessed images, support vector machines are used for feature extraction. The kernel function uses the RBF kernel, the γ parameter is set to 0.1, and the C parameter is set to 10 to extract texture, color, and shape features. The extracted features are compared with the pre-established defect feature library for Euclidean distance calculation, and the distance threshold is set to 0.5. When the distance is less than the threshold, the area is marked as a suspected defect area, and its position coordinates and area information are recorded. For the marked suspected defect area, the region growing algorithm is used for fine segmentation. The initial seed point is selected as the center point of the region, and the growth threshold is dynamically adjusted according to the detection sensitivity parameter 0.95. Specifically, when the grayscale difference between the adjacent pixels and the seed point is less than 25.5 (255*0.1), it is included in the segmentation area.Finally, the decision tree algorithm is used to classify the segmentation results. The maximum depth of the tree is 5, the minimum number of sample segmentations is 10, and the classification features include defect area, perimeter, circularity, etc. The final output is the type of textile defects, such as broken yarn, oil stains, holes, etc. and their precise location coordinates.
[0022] S102, using the camera in the machine vision system after initialization to collect images of the textile surface, obtain original image data, and perform pre-processing of noise reduction, enhancement, and correction on the original image data to obtain an optimized textile surface image.
[0023] The original image data is acquired according to the preset camera resolution parameters, and the original image data is collected by the camera from the textile surface and stored in the memory; the original image data is subjected to denoising processing by using the adaptive median filtering method, and the first image after denoising is obtained by dynamically adjusting the filter window size; if the signal-to-noise ratio of the first image is improved by more than a preset threshold value, it is determined that the denoising processing is effective; the first image is subjected to adaptive histogram equalization processing, the image is divided into sub-blocks of a preset size, and a second image with contrast enhancement is obtained by performing histogram equalization on the sub-blocks separately; if the entropy value of the second image increases by more than a preset threshold value, it is determined that the contrast enhancement is effective; the second image is subjected to geometric correction to obtain an affine transformation matrix; the second image is corrected by applying the affine transformation matrix to obtain an optimized textile surface image.
[0024] Specifically, the most suitable acquisition frequency is calculated according to the preset camera resolution parameter 4096x3072 pixels, the acquisition frequency of the high-speed camera is set to 120 frames per second, the original image data is obtained from the textile surface, and the acquired original image data is temporarily stored in the high-speed memory. The original image data is read from the high-speed memory, and an adaptive median filter noise reduction process is performed on it. The filter window size is dynamically adjusted according to the local noise level, ranging from 3x3 to 7x7 pixels, and the signal-to-noise ratio before and after noise reduction is calculated. If the signal-to-noise ratio is improved by more than 5dB, the noise reduction is determined to be effective, and the first image after noise reduction is obtained. Adaptive histogram equalization is performed on the first image, the image is divided into 8x8 sub-blocks, and histogram equalization is performed on each sub-block separately. The target grayscale is set to 256 levels, and the image entropy values before and after enhancement are calculated. If the entropy value increases by more than 0.5, the contrast enhancement is determined to be effective, and the contrast-enhanced second image is obtained. The second image is geometrically corrected, and the SIFT feature points in the image are detected by an image registration method based on feature point matching, matched with a pre-calibrated reference image, and the affine transformation matrix is calculated. The matrix is applied to correct the image, eliminate tilt and deformation, and obtain the final optimized textile surface image. In the process of textile surface image acquisition and optimization, the most suitable acquisition frequency is 120 frames per second according to the preset 4096x3072 pixel resolution parameters. The high-speed camera collects raw images from the textile surface at this frequency, and the data volume of each frame is about 36MB. DDR4 high-speed memory is used for temporary storage, and the storage capacity is 4GB, which can cache about 111 frames of images. Subsequently, the raw image data is read from the high-speed memory and subjected to adaptive median filtering and denoising. The algorithm first calculates the median in a 3x3 window. If the difference between the median and the center pixel value of the window is greater than the preset threshold of 20, the window is expanded to 5x5, until the maximum is 7x7. By calculating the signal-to-noise ratio before and after denoising, it was found that the signal-to-noise ratio increased from the original 15dB to 21dB, exceeding the 5dB threshold, and the denoising was determined to be effective. Then, the denoised image was subjected to adaptive histogram equalization, and the 4096x3072 image was divided into 512 8x8 sub-blocks. Each sub-block was independently histogram equalized, and the target grayscale was 256. The image entropy value was calculated to increase from the original 5.8 to 6.4, and the increase exceeded the 0.5 threshold, confirming that the contrast enhancement was effective. Finally, the SIFT algorithm was used to detect 2000 feature points in the enhanced image, which were matched with the pre-calibrated reference image to screen out 500 pairs of valid matching points. Based on these matching points, the RANSAC algorithm was used to calculate the optimal affine transformation matrix, which contained correction parameters of a rotation angle of 1.2°, a translation of 5 pixels in the x direction, and a translation of 3 pixels in the y direction. The matrix was applied to the image for affine transformation, and finally the optimized textile surface image after geometric correction was obtained.
[0025] S103, performing feature extraction on the optimized textile surface image, extracting texture and morphological features related to wrinkle defects, and constructing a feature map that can reflect wrinkle characteristics.
[0026] Obtain an optimized textile surface image, and use a convolutional neural network to extract features from the textile surface image. According to a preset number of convolutional layers, extract local features of the textile surface image through multi-layer convolution operations to obtain multiple feature maps. For the output feature map of each convolutional layer, add a pooling layer and use a maximum pooling operation to downsample the feature map to obtain a downsampled feature map. Perform dimensionality reduction processing on the high-dimensional features in the downsampled feature map to obtain a feature map. Use a cross-validation method to evaluate the effectiveness of the feature map in the wrinkle recognition task, and determine whether the average accuracy of the feature map meets a preset threshold.
[0027] Specifically, a convolutional neural network is used to extract features from the optimized textile surface image. The local features of the image are extracted through 5 layers of convolution operations. The number of convolution kernels in each layer is set to 32, 64, 128, 256, and 512 respectively. The convolution kernel size is 3x3, the step size is 1, and the padding method is SAME. A pooling layer is added after each convolution layer. The feature map is downsampled using the maximum pooling operation. The pooling window size is set to 2x2 with a step size of 2 to reduce the spatial dimension of the feature map and retain the wrinkle edge information. The BatchNormalization layer and the LeakyReLU activation function are applied to the pooled feature map. The negative semi-axis slope of the LeakyReLU function is set to 0.01 to introduce nonlinear transformation and alleviate the gradient disappearance, and multiple activated feature maps are obtained. The t-SNE algorithm is used to reduce the dimension of high-dimensional features and visualize the feature space to 2 dimensions to generate a feature distribution map. Multiple feature maps are flattened into one-dimensional vectors, and features at different levels are combined through a fully connected layer to obtain a 256-dimensional feature vector. The 128 features most relevant to the wrinkle features are screened out using L1 regularization to construct a feature map reflecting the characteristics of wrinkles. The 5-fold cross-validation method is used to evaluate the effectiveness of the feature map in the wrinkle recognition task, and the average accuracy is calculated and the standard deviation is recorded. In the process of extracting the features of wrinkle defects on the textile surface, the optimized image of 4096x3072 pixels is first input into the convolutional neural network. The network contains 5 convolutional layers, and the number of convolution kernels in each layer is 32, 64, 128, 256, and 512, respectively. The convolution kernel size is 3x3, the step size is 1, and SAME padding is used. After the first layer of convolution, the size of the feature map remains unchanged, and the number of channels becomes 32. The subsequent maximum pooling operation uses a 2x2 window with a step size of 2 to halve the size of the feature map to 2048x1536, while retaining the significant features of the wrinkle edge. After each convolution layer, a BatchNormalization layer is applied, with parameters including mean μ=0, variance σ2=1, epsilon=1e-5, and momentum=0.99. Then, the LeakyReLU activation function is used, and the negative semi-axis slope is set to 0.01, which effectively alleviates the gradient vanishing. After 5 layers of convolutional pooling, a 128x96x512 feature map is obtained. The 512-dimensional features are reduced to 2 dimensions using the t-SNE algorithm, with the perplexity parameter set to 30, the learning rate set to 200, and 1000 iterations to generate a feature distribution scatter plot. The feature map is flattened into a 6,291,456-dimensional vector and reduced to 256 dimensions through a fully connected layer. L1 regularization is applied with a regularization strength of λ=0.01 to screen out the 128 most relevant features to form a wrinkle feature map. Finally, a 5-fold cross validation was performed, with each fold using 80% of the data for training and 20% for testing, resulting in an average accuracy of 95.3% and a standard deviation of 1.2%, verifying the effectiveness of the feature map.
[0028] S104, identifying a region suspected of being a wrinkle defect in the feature map, determining the contour of the defect, and obtaining location and range information of the wrinkle defect.
[0029] According to the distribution of wrinkle eigenvalues of the feature map, the principal component analysis method is used to reduce the multidimensional features to a single eigenvalue, and the initial area of the suspected wrinkle defect is obtained; wherein the initial area is obtained by binarizing the feature map by setting a threshold; a connected domain analysis is performed on the initial area, and if the area of the connected domain is less than the preset threshold, the connected domain is removed. The point with the largest eigenvalue in the remaining connected domain is selected as the seed point for regional growth, and the coordinates and grayscale value of the seed point are recorded in the seed point list. The seed point is taken out from the seed point list, and its neighboring pixels are checked; wherein the grayscale threshold of the neighboring pixels is adaptively calculated by the Otsu algorithm. If the difference between the grayscale value of the neighboring pixel and the grayscale value of the seed point is less than the grayscale threshold, the neighboring pixel is added to the seed point list and the growth area. The centroid coordinates of each defect area are calculated as the position information, and the circumscribed rectangle is calculated as the range information; the outline of the defect area is refined by the Snake algorithm, and the number of iterations is a preset value.
[0030] Specifically, according to the distribution of wrinkle eigenvalues in the feature map, principal component analysis is used to reduce multidimensional features to a single eigenvalue, and the threshold is set as the mean value of the eigenvalue plus two times the standard deviation. The feature map is binarized to obtain the initial area of suspected wrinkle defects. Connected domain analysis is performed on the initial area to remove areas with an area of less than 100 square pixels to reduce misjudgment. The point with the largest eigenvalue in each remaining connected domain is selected as the seed point for regional growth, and the coordinates and grayscale value of the seed point are recorded in the seed point list. A seed point is taken from the seed point list, and its 8 neighboring pixels are checked. The grayscale threshold is adaptively calculated using the Otsu algorithm. If the difference between the grayscale value of the neighboring pixel and the grayscale value of the seed point is less than the threshold, the neighboring pixel is added to the seed point list and the growth area. When the area growth rate of the growth area is less than 1%, the growth process of the current seed point is stopped. Seed point growth is repeated until the seed point list is empty, and multiple wrinkle defect areas are obtained. The centroid coordinates of each defect area are calculated as the position information, and the circumscribed rectangle is calculated as the range information. The Snake algorithm is used to refine the contour of each defect area, and the number of iterations is set to 100 to obtain an accurate defect contour. Finally, the overall defect distribution description is generated, including the number of defects, the location of each defect, and the range information. In the process of textile wrinkle defect recognition, the principal component analysis is first applied to the 128-dimensional feature map, and the principal component with the highest contribution rate is selected as a single eigenvalue. The average eigenvalue is calculated to be 0.5, and the standard deviation is 0.1. Based on this, the threshold is set to 0.7 (0.5+2*0.1). The feature map is binarized, and the area above the threshold is marked as 1, and the area below the threshold is marked as 0, forming an initial suspected wrinkle defect area map. Then, the connected domain analysis is performed, and the 8-connected algorithm is used to mark the connected areas, and the areas with an area of less than 100 square pixels are removed. For the remaining areas, the point with the largest eigenvalue in each connected domain is found as the seed point. For example, if the maximum eigenvalue in a connected domain is 0.85, its coordinates (150, 200) and gray value 180 are added to the seed point list. Take the seed point from the list and use the Otsu algorithm to calculate the grayscale threshold of the 8-neighborhood. Assume that the threshold is 15. Check the 8-neighborhood pixels. If the difference is less than 15, add the pixel to the growth area. When the area of the region increases from 1000 to 1010 (growth rate of 1%), stop the growth of the current seed point. Repeat this process for all seed points, and finally get 3 wrinkle defect areas. Calculate the centroid coordinates of each area, such as (160, 210), (350, 420), (580, 630), and the circumscribed rectangle, such as [(140, 190), (180, 230)]. Use the Snake algorithm to refine the contour of each area, set 100 iterations, and α=0.1, β=0.1, and γ=0.1 in the energy function.Finally, a defect distribution description is generated, and three wrinkle defects are detected, with positions at (160, 210), (350, 420), and (580, 630), and areas of 1200, 1500, and 1800 square pixels, respectively.
[0031] S105. For the identified wrinkle defect area, calculate the characteristic parameters of wrinkle depth, wrinkle direction, and wrinkle density, and construct a quantitative index of the wrinkle degree, including quantifying the wrinkle characteristics through a characteristic vector.
[0032] A gray level co-occurrence matrix is calculated for the wrinkle defect area, and four statistical features of contrast, correlation, energy and homogeneity are extracted according to the gray level co-occurrence matrix. The maximum values of the statistical features in four directions are taken as the final features. The wrinkle defect area is processed to obtain a multidimensional feature vector that characterizes the distribution of wrinkle directions. A multidimensional feature vector that characterizes the wrinkle density is screened out based on the wrinkle defect area. The screened feature vectors are normalized, and the weight of each feature is determined. The principal component analysis method is used to reduce the dimension of the weighted features, and a preset number of principal components are obtained as the quantitative indicators of the wrinkle degree.
[0033] Specifically, for the identified wrinkle defect area, the grayscale co-occurrence matrix is calculated, the distance parameter is set to 1, and the direction angles are set to 0°, 45°, 90°, and 135°. The grayscale co-occurrence matrix in four directions is obtained, and four statistical features of contrast, correlation, energy, and homogeneity are extracted from it. The maximum value of the four directions is taken as the final feature. The higher the contrast value, the greater the wrinkle depth, which is used as a quantitative indicator of the wrinkle depth. The gradient direction histogram algorithm is used to divide the wrinkle defect area into 4x4 grids, and the gradient direction and amplitude of the pixels in each grid are calculated. 360° is evenly divided into 9 directions, and 9-dimensional features are generated for each grid. Finally, a 36-dimensional feature vector is obtained to characterize the distribution of the wrinkle direction. The local binary pattern algorithm is used to select a circular neighborhood with a radius of 2, and the LBP value of each pixel in the wrinkle defect area is calculated. The LBP histogram is statistically obtained to obtain a 256-dimensional feature vector. The complexity of the LBP pattern reflects the density of the wrinkles, which is used as a characterization of the wrinkle density. The recursive feature elimination method is used to select the 100 most relevant features from the above features. The selected feature vectors are normalized, and the weights of each feature are determined by multivariate linear regression. Different weights are assigned according to the regression coefficients for weighted combination. The principal component analysis method is used to reduce the dimension of the weighted features, and the first 10 principal components are selected as the final quantitative indicators of the degree of wrinkles. The stability and reliability of the quantitative indicators are evaluated using 5-fold cross validation, and the average error and standard deviation are calculated. In the analysis of textile wrinkle defects, the grayscale co-occurrence matrix is first calculated for the identified 100x100 pixel defect area, and the distance parameter is set to 1, and the grayscale co-occurrence matrix of 0°, 45°, 90°, and 135° is calculated respectively.
[0034] The matrices of four directions are extracted. Contrast, correlation, energy and homogeneity features are extracted from each matrix, and the maximum value in the four directions is selected as the final feature. For example, the maximum contrast value is 0.85, indicating that the wrinkle depth is large. Then the gradient direction histogram algorithm is applied to divide the defect area into 4x4 grids, each with 25x25 pixels. The gradient direction and amplitude of each pixel are calculated, and 360° is divided into 9 intervals of 40°. The gradient distribution of 9 directions in each grid is counted to generate a 36-dimensional feature vector. For example, the feature of a grid is [0.1, 0.2, 0.3, 0.1, 0.1, 0.05, 0.05, 0.05, 0.05], indicating that the wrinkles in this area are mainly in the direction of 45°-85°. Then the local binary pattern algorithm is used to select a circular neighborhood with a radius of 2 (8 pixels), calculate the difference between the central pixel and the neighboring pixel, obtain an 8-bit binary number, and convert it to a decimal LBP value. The LBP histogram of the entire area is counted to obtain a 256-dimensional feature vector. If the peak in the histogram appears in the bin corresponding to the complex pattern, it means that the wrinkle density is high. Use the recursive feature elimination method to select the 100 most relevant features from the above 292-dimensional features. Normalize the selected features and unify the value range to [0, 1]. Use multivariate linear regression to determine the feature weights, assuming that the regression equation is y = 0.3 * x1 + 0.25 * x2 + 0.2 * x3 + ... + 0.01 * x100. Weighted combination of features is performed according to the regression coefficient. Finally, the principal component analysis method is used to reduce the dimensionality of the 100-dimensional weighted features, and the top 10 principal components with a cumulative contribution rate of 90% are selected as the final wrinkle degree quantitative index. The stability of the indicator is evaluated by 5-fold cross validation, and the average error is 0.05 and the standard deviation is 0.01, which proves that the quantitative indicator has good reliability.
[0035] S106. According to a pre-established wrinkle defect type database, pattern matching is performed on the quantified wrinkle features. If the matching degree exceeds a preset threshold, the specific category of the wrinkle defect is determined.
[0036] Obtain standard feature vectors of various types of defects from a pre-established wrinkle defect type database; based on the standard feature vector, use principal component analysis to reduce the feature vector to a preset dimension and normalize the wrinkle feature; use the k-nearest neighbor algorithm to select k standard samples that are most similar to the wrinkle feature to be classified, and determine the k value through cross-validation; if the confidence of the result of the k-nearest neighbor algorithm is lower than a preset threshold, use all samples in the database to train a support vector machine classifier; input the wrinkle feature to be classified into the support vector machine classifier to obtain classification probability values for each category; if the maximum value of the classification probability value exceeds a preset threshold, and the difference with the second largest value is greater than the preset difference, determine the final category of the wrinkle defect; if the condition is not met, mark the sample as a pending type; feed back the classification result and its confidence to the database for updating the wrinkle defect type database.
[0037] Specifically, the standard feature vectors of each type of defect were extracted from the pre-established wrinkle defect type database, and all feature vectors were uniformly reduced to 50 dimensions using principal component analysis. The quantified wrinkle features were normalized, and the similarity between the wrinkle features to be classified and the standard feature vectors was calculated using the Euclidean distance formula. According to the calculated similarity, the k nearest neighbor algorithm was used to select the k standard samples most similar to the wrinkle features to be classified. The optimal k value was determined to be 5 through 10-fold cross validation. The categories of these five samples were voted for using the majority voting method, and the category with the highest number of votes was obtained as the preliminary wrinkle defect category. The difference in votes between the first two categories with the highest number of votes was calculated. If the difference was greater than 2, the k nearest neighbor result was considered to have high confidence and was directly used; otherwise, subsequent optimization was performed. The support vector machine classifier was trained using all samples in the database, and the radial basis kernel function was selected, with the penalty parameter C set to 1.0 and the kernel function parameter γ set to 0.1. The wrinkle features to be classified are input into the trained support vector machine classifier to obtain the classification probability values of each category. If the highest probability value exceeds the preset threshold of 0.8 and the difference with the second highest probability value is greater than 0.1, the final category of the wrinkle defect is determined; if the conditions are not met, the sample is marked as a pending type. The classification results and their confidence are fed back to the database to update and optimize the wrinkle defect type database and improve the accuracy of subsequent classification. In the wrinkle defect classification process, 1000 standard samples are first extracted from the database, each containing a 200-dimensional feature vector. Principal component analysis is used to reduce all vectors to 50 dimensions, and the cumulative variance contribution rate reaches 95%. The same dimensionality reduction process is performed on the wrinkle features to be classified, and then the Min-Max normalization is used to scale the feature values to the interval [0, 1]. The Euclidean distance between the features to be classified and the standard samples is calculated, such as [0.25, 0.42, 0.18, 0.37, ...]. The k-nearest neighbor algorithm is applied, and the optimal k value is determined to be 5 through 10-fold cross validation, with an average accuracy of 92%. Select the 5 samples with the smallest distance, and assume that their categories are [A, B, A, C, A], and the preliminary category is A through majority voting, with 3 votes. The difference between the top two highest votes is 1 (3-2), which is less than the threshold of 2, and needs to be optimized. Use all 1000 samples to train the support vector machine, and use grid search to determine the optimal parameters C = 1.0, γ = 0.1, and the accuracy of 5-fold cross validation reaches 95%. Input the features to be classified into the trained support vector machine to obtain the probabilities of each category [A: 0.75, B: 0.15, C: 0.10]. The highest probability 0.75 is less than the threshold 0.8, but the difference with the second highest probability 0.60 is greater than 0.1, so the final category is determined to be A. Feedback the result and its confidence 0.75 to the database for subsequent optimization. The whole process is completed on a high-performance server, taking about 0.5 seconds, and achieving fast and accurate classification of wrinkle defects.
[0038] S107. Support vector machine algorithm is used to classify the quantitative indicators of wrinkle degree, and wrinkle defects are divided into different levels by combining wrinkle depth and density parameters to evaluate the severity of wrinkles.
[0039] Perform Z-score normalization on the wrinkle features to obtain the standard normal distribution of the eigenvalues. Obtain the top N features that have the greatest impact on classification. Construct a support vector machine classifier and determine the kernel function based on the training results of the linear kernel function and the radial basis kernel function. Use the grid search method to obtain the optimal penalty parameter C and kernel function parameter γ within the preset parameter range. Use the weighted 5-fold cross-validation method to determine the performance indicators of the support vector machine classifier. If the probability value of the classification result is lower than the threshold, the sample is determined to be a pending category. Determine the wrinkle grade, feature index and confidence level based on the evaluation report.
[0040] Specifically, the features such as the quantitative index of wrinkle degree, wrinkle depth, wrinkle density, and wrinkle direction were normalized by Z-score, and all feature values were converted to a standard normal distribution with a mean of 0 and a standard deviation of 1. The recursive feature elimination method was used to select the most important feature subset, and the top 10 features with the greatest impact on classification were retained. A support vector machine classifier was constructed, and the linear kernel function and the radial basis kernel function were used for training respectively. The more suitable kernel function was selected by comparing the performance of the two kernel functions. The grid search method was used to determine the optimal penalty parameter C and kernel function parameter γ, and the parameter search range was set to C.
[0041] [0.1, 1, 10, 100], γ is [0.001, 0.01, 0.1, 1], and each parameter combination is evaluated. The weighted 5-fold cross-validation method is used to evaluate the performance of the support vector machine classifier, and the weights are set according to the inverse ratio of the number of samples in each category to deal with possible class imbalance problems. According to the statistical distribution of the samples, the boundary values of the three levels of slight, moderate and severe wrinkle defects are determined. The test samples are input into the trained support vector machine classifier to obtain the classification results and corresponding probability values, and the confidence threshold is set to 0.8. When the probability value of the classification result is lower than the threshold, the sample is marked as the "pending" category. Generate an evaluation report, including the wrinkle level, various feature indicators and confidence. You can also use additional test sets to verify the generalization ability of the model, calculate indicators such as accuracy, precision and recall, and evaluate the application effect of the support vector machine classifier in the actual production environment. In the process of wrinkle defect severity assessment, the 20 original features were first Z-score standardized, and the wrinkle depth was converted from the original value of 5.2 mm to the standardized value of 1.3, and the wrinkle density was converted from the original value of 0.8 to -0.5. Then, the recursive feature elimination method was used to select the 10 most important features, including the standardized wrinkle depth, density, direction, etc. through 100 iterations. The support vector machine classifier was constructed to compare the performance of the linear kernel and RBF kernel functions. It was found that the accuracy of the RBF kernel reached 92% in the 5-fold cross validation, which was better than the 88% of the linear kernel, so the RBF kernel was selected. The grid search for the optimal parameters traversed 16 groups of parameter combinations and determined the optimal C = 10, γ = 0.01. In the weighted cross validation, the ratio of the three categories of mild, moderate and severe samples was 6:3:1, and the corresponding weights were set to 1:2:6. According to the statistical distribution of 3000 samples, the mild-moderate boundary was set to the standardized wrinkle depth of 0.5, and the moderate-severe boundary was set to 1.5. After classifying 100 test samples, 85 samples had probability values exceeding the 0.8 threshold, including 50 mild, 25 moderate, 10 severe, and 15 pending. An evaluation report was generated, such as "Sample #37, medium wrinkle level, normalized depth of 0.8, density of -0.2, direction of 45°, confidence of 0.92". The model was validated using 500 additional test samples, with an accuracy of 91%, precision of 89%, recall of 90%, and an F1 score of 0.895, proving that the model has good generalization ability and practical value.
[0042] S108, fusing the type, location, scope, and severity information of wrinkle defects to generate a unified defect description data structure to achieve unified management and analysis of textile wrinkle defects.
[0043] Obtain defect description information with wrinkle defect ID, type, location coordinates and range area, wherein the defect description information is expressed in JSON format; establish a relational database table structure according to the defect description information; perform data verification on the defect description information, verify the data format through regular expressions, and delete duplicate data; perform fusion processing on wrinkle defect information from different sources, including converting the wrinkle defect information into a preset data structure; perform database management operations, wherein the database management operations include data insertion, update, deletion and query.
[0044] Specifically, a unified defect description data structure is designed, including the wrinkle defect ID, type, location coordinates, range area, severity, detection time, image path and other fields, which are expressed in JSON format and dynamic fields are used to store the special attributes of different types of defects to ensure the structure and scalability of data. A relational database table structure is created, including the defect master table and the related type dictionary table and severity level table, primary key and foreign key constraints are set, indexes are established to improve query efficiency, and triggers are used to implement data integrity verification. Input data is verified and cleaned, regular expressions are used to verify data format, duplicate data is deleted, and data quality is ensured. Wrinkle defect information from different sources is uniformly converted into the designed data structure, decision tree algorithm is used to resolve data conflicts, minimum-maximum normalization method is used to unify data scale, data type conversion, unit unification, coordinate system conversion and other issues are handled to ensure data consistency and comparability. Database management functions are implemented, including basic operations such as data insertion, update, deletion, and query, composite indexes are used to optimize query performance, sliding window method is used to calculate defect trends, K-means clustering algorithm is used to analyze defect distribution characteristics, and multi-dimensional data analysis and visualization are supported. Perform data backup and recovery, use incremental backup strategy, and perform full backup regularly to ensure data security and reliability. In the textile wrinkle defect management system, first design a JSON format data structure, which contains fixed fields such as "id", "type", "position", "area", "severity", "time",
[0045] "image_path", and the dynamic field "attributes" to store special attributes. For example,
[0046] {"id":"F001","type":"crease
[0047] ","position":[100,200],"area":50,"severity":3,"time":"2024-07-1110:30:00","image_path":" / images / F001.jpg","attributes":{"crease length
[0048] ":15,"Fold direction":45}}. Create a PostgreSQL database, use a partition table to store defect data by month, and set a B-tree index to optimize queries. When inputting data, use the regular expression"^\d{4}-
[0049] \d{2}-\d{2}\d{2}:\d{2}:\d{2}¥"Verify the time format and delete duplicate records. Data fusion uses the C4.5 decision tree algorithm to resolve conflicts. For example, when two sources report different severity levels, the final level is determined based on features such as area and depth. Min-Max normalization is used to scale all numerical features to [0, 1]
[0050] Interval. Implement database CRUD operations, such as
[0051] SELECT * FROM faults WHERE severity > 2 AND detection time > '2024-07-01' to query severe defects. Use a 30-day sliding window to calculate defect trends and K-means clustering (K = 5) to analyze defect spatial distribution. Perform incremental backups every hour and full backups at 23:00 every day, retaining the backup files for the last 30 days.
[0052] Based on the above embodiments of the present invention, relevant personnel can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the content in the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A method for detecting textile defects using machine vision, characterized in that: The method comprises: According to the textile quality requirements, the corresponding camera resolution parameters, algorithm complexity parameters, and detection sensitivity parameters are obtained from the database, and the machine vision system is initialized and set; Using a camera in a machine vision system after initialization to collect images of a textile surface, obtaining raw image data, and performing preprocessing of noise reduction, enhancement, and correction on the raw image data to obtain an optimized textile surface image; Perform feature extraction on the optimized textile surface image, extract the texture and morphological features related to wrinkle defects, and construct a feature map that can reflect the characteristics of wrinkles; Identifying a region suspected of being a wrinkle defect in the characteristic map, determining the contour of the defect, and obtaining location and range information of the wrinkle defect; For the identified wrinkle defect area, calculate the characteristic parameters of wrinkle depth, wrinkle direction, and wrinkle density, and construct a quantitative index of the wrinkle degree, including quantifying the wrinkle characteristics through feature vectors; According to a pre-established wrinkle defect type database, pattern matching is performed on the quantified wrinkle features, and if the matching degree exceeds a preset threshold, the specific category of the wrinkle defect is determined; The support vector machine algorithm is used to classify the quantitative indicators of wrinkle degree, and combined with the wrinkle depth and density parameters, the wrinkle defects are divided into different levels to evaluate the severity of wrinkles; The type, location, scope and severity of wrinkle defects are fused to generate a unified defect description data structure to achieve unified management and analysis of textile wrinkle defects.
2. The method according to claim 1, wherein: The method of obtaining corresponding camera resolution parameters, algorithm complexity parameters, and detection sensitivity parameters from a database according to textile quality requirements and initializing the machine vision system includes: Acquiring system parameters corresponding to textile quality requirements, wherein the system parameters include camera resolution parameters, detection sensitivity parameters, image preprocessing parameters, and defect classification parameters; Initialize and set the machine vision system according to the system parameters; Using a high-speed camera to capture textile images, and adjusting the image capture frequency according to the camera resolution parameter; Performing image preprocessing on the collected image according to the image preprocessing parameters to obtain a clear image; Extracting features from the clear image and comparing it with pre-established defect features to obtain position coordinates and area information of suspected defect areas; Using a region growing algorithm to accurately segment the suspected defect region; Adjusting the region growth threshold according to the detection sensitivity parameter; Classifying the segmentation results by a decision tree algorithm, wherein the depth and branching conditions of the decision tree are adjusted according to the defect classification parameters; Determine whether the classification result meets the preset defect type; If it meets the requirements, the type and location information of the textile defect are determined.
3. The method according to claim 1, wherein: The method uses the camera in the machine vision system after the initialization setting to collect images of the textile surface, obtains raw image data, performs noise reduction, enhancement, and correction preprocessing on the raw image data, and obtains an optimized textile surface image, including: Acquiring raw image data according to preset camera resolution parameters, wherein the raw image data is collected from the surface of the textile by the camera and stored in a memory; Using an adaptive median filtering method to perform noise reduction processing on the original image data, and obtaining a first image after noise reduction by dynamically adjusting the filter window size; If the signal-to-noise ratio of the first image is improved by more than a preset threshold, it is determined that the noise reduction process is effective; Performing adaptive histogram equalization processing on the first image, dividing the image into sub-blocks of a preset size, and obtaining a second image with enhanced contrast by performing histogram equalization on the sub-blocks separately; If the entropy value of the second image increases by more than a preset threshold, it is determined that the contrast enhancement is effective; Performing geometric correction on the second image to obtain an affine transformation matrix; The second image is corrected by applying the affine transformation matrix to obtain an optimized textile surface image.
4. The method according to claim 1, wherein: The feature extraction is performed on the optimized textile surface image to extract the texture and morphological features related to the wrinkle defects, and construct a feature map that can reflect the wrinkle characteristics, including: Acquire an optimized textile surface image, and use a convolutional neural network to perform feature extraction on the textile surface image; According to a preset number of convolution layers, local features of the textile surface image are extracted through multi-layer convolution operations to obtain multiple feature maps; For each output feature map of the convolutional layer, a pooling layer is added and the feature map is downsampled using a maximum pooling operation to obtain a downsampled feature map; Performing dimensionality reduction processing on the high-dimensional features in the downsampled feature map to obtain a feature map; The cross-validation method is used to evaluate the effectiveness of the feature map in the wrinkle recognition task, and to determine whether the average accuracy of the feature map meets the preset threshold.
5. The method according to claim 1, wherein: The step of identifying a region suspected of being a wrinkle defect in the characteristic map, determining the contour of the defect, and obtaining the location and range information of the wrinkle defect includes: According to the distribution of wrinkle eigenvalues in the feature map, the principal component analysis method is used to reduce the multi-dimensional features to a single eigenvalue, and the initial area of suspected wrinkle defects is obtained; Wherein, the initial region is obtained by performing binarization processing on the feature map by setting a threshold; Performing a connected domain analysis on the initial region, and if the area of the connected domain is smaller than a preset threshold, removing the connected domain; Selecting the point with the largest eigenvalue in the remaining connected domain as the seed point for region growth, and recording the coordinates and grayscale value of the seed point in the seed point list; Take a seed point from the seed point list and check its neighboring pixels; The grayscale threshold of the neighborhood pixels is adaptively calculated by the Otsu algorithm; If the difference between the grayscale value of the neighborhood pixel and the grayscale value of the seed point is less than the grayscale threshold, the neighborhood pixel is added to the seed point list and the growth area; Calculate the centroid coordinates of each defect area as position information, and calculate the bounding rectangle as range information; The contour of the defective area is refined by the Snake algorithm, and the number of iterations is a preset value.
6. The method according to claim 1, wherein: The method calculates characteristic parameters of wrinkle depth, wrinkle direction and wrinkle density for the identified wrinkle defect area, and constructs a quantitative index of wrinkle degree, including quantifying wrinkle characteristics through characteristic vectors, including: Calculating a gray level co-occurrence matrix for the wrinkle defect area, extracting four statistical features of contrast, correlation, energy and homogeneity according to the gray level co-occurrence matrix, and taking the maximum values of the four directions of the statistical features as the final features; Processing the wrinkle defect area to obtain a multi-dimensional feature vector representing the distribution of wrinkle directions; Screening out a multidimensional feature vector representing wrinkle density based on the wrinkle defect area; Normalize the selected feature vectors and determine the weight of each feature; The principal component analysis method is used to reduce the dimension of the weighted features, and a preset number of principal components are obtained as quantitative indicators of the wrinkle degree.
7. The method according to claim 1, wherein: The method of performing pattern matching on the quantified wrinkle features according to the pre-established wrinkle defect type database, and determining the specific category of the wrinkle defect if the matching degree exceeds a preset threshold, includes: Obtaining standard feature vectors of various types of defects from a pre-established wrinkle defect type database; According to the standard feature vector, principal component analysis is used to reduce the feature vector to a preset dimension, and the wrinkle feature is normalized; The k nearest neighbor algorithm is used to select k standard samples that are most similar to the wrinkle features to be classified, and the k value is determined by cross validation; If the confidence level of the k-nearest neighbor algorithm result is lower than a preset threshold, training a support vector machine classifier using all samples in the database; Inputting the wrinkle features to be classified into the support vector machine classifier to obtain classification probability values of each category; If the maximum value of the classification probability value exceeds a preset threshold, and the difference with the second largest value is greater than a preset difference, then the final category of the wrinkle defect is determined; If the condition is not met, the sample is marked as a pending type; The classification result and its confidence level are fed back to the database for updating the wrinkle defect type database.
8. The method according to claim 1, wherein: The support vector machine algorithm is used to classify the quantitative indicators of the wrinkle degree, and the wrinkle defects are divided into different levels by combining the wrinkle depth and density parameters to evaluate the severity of the wrinkles, including: The wrinkle characteristics are normalized by Z-score to obtain the standard normal distribution of the characteristic values; Get the top N features that have the greatest impact on classification; Construct a support vector machine classifier and determine the kernel function based on the training results of the linear kernel function and the radial basis kernel function; Use the grid search method to obtain the optimal penalty parameter C and kernel function parameter γ from the preset parameter range; The weighted 5-fold cross validation method was used to determine the performance indicators of the support vector machine classifier; If the probability value of the classification result is lower than the threshold, the sample is determined to be a pending category; Based on the evaluation report, the wrinkle grade, characteristic index and confidence level are determined.
9. The method according to claim 1, wherein: The data fusion of the type, location, scope, and severity of wrinkle defects is performed to generate a unified defect description data structure to achieve unified management and analysis of textile wrinkle defects, including: Obtain defect description information including wrinkle defect ID, type, location coordinates, and range area, wherein the defect description information is expressed in JSON format; Establishing a relational database table structure according to the defect description information; Perform data verification on the defect description information, verify the data format through regular expressions, and delete duplicate data; Fusing wrinkle defect information from different sources, including converting the wrinkle defect information into a preset data structure; Perform database management operations including data insertion, update and deletion and query.
Citation Information
Patent Citations
Method for automatically detecting and classifying textile flaws based on pattern recognition and image processing
CN102879401A
Non-woven fabric flaw detection and classification method and system based on machine vision
CN113554080A
Defect detection method and device, electronic equipment, computer readable storage medium and product detection method
CN115995023A
Intelligent detection method for cotton cloth surface flaws
CN118014969A
Fabric defect detection method
US20240193752A1
Cited By
Building material quality detection system
CN120125083A
Tobacco leaf grade intelligent classification and quality evaluation method and system based on machine vision
CN120526173A
Textile and garment flaw pattern data processing method based on flaw judgment model
CN120635092A
Textile and garment defect pattern data processing method based on defect judgment model
CN120635092B
Paper defect detection method and system
CN120765547A