A fabric defect detection method and system based on sparse dictionary optimization
Through the sparse dictionary optimization method and least squares method, the sparse encoding problem is solved, the time-consuming learning of sparse dictionary is achieved, the efficiency and accuracy of real-time fabric defect detection is achieved, the error detection rate is reduced, and the needs of industrial automation detection are met.
Patent Information
- Application Number
- CN202211666370.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-23
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-12-23
AI Technical Summary
In the prior art, the learning and solving of sparse dictionaries takes a long time, and it is difficult to meet the real-time fabric defect detection requirements in industrial scenarios. The traditional method has a high error detection rate, making it difficult to achieve efficient automated detection.
The sparse dictionary preferential method is adopted, and the sparse dictionary learning and sub-dictionary preference are combined with the least squares method and the non-maximum suppression principle to optimize the sparse encoding problem, reduce the detection time and reduce the error detection rate.
It realizes the efficiency and accuracy of real-time fabric defect detection in industrial scenarios, reduces the error detection rate, and meets the needs of industrial automation inspection.
Smart Images

Figure CN116091423B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of textiles, and in particular, to a fabric defect detection method and system based on sparse dictionary optimization. Background Art
[0002] Fabric defects are caused by reasons such as raw material processes, mechanical failures, and human factors during the production process. The presence of defects on the surface of textiles seriously reduces the product quality and leads to a decrease in the fabric price. As an important part of product quality control, detection plays an important role in the production process, and defect detection is the key part. At present, defect detection is mainly completed manually. However, due to the low detection rate, slow speed, and high personnel costs of manual cloth inspection, it cannot meet the requirements of high-efficiency and high-quality intelligent production. Therefore, it is of great significance to apply fast and reliable image processing technology to defect detection to achieve automatic detection of fabric defects. The most important role in the sparse representation theory is the sparse dictionary. The learned sparse dictionary can better adapt to the signal characteristics and allows the dictionary learning to express the input signal more effectively. For defect detection, the sparse dictionary can well express and approximate the original fabric texture structure. Therefore, applying the sparse dictionary method to fabric defect detection can achieve satisfactory results. However, the learning and solution of the sparse dictionary are time-consuming and difficult to meet the real-time detection requirements in industrial scenarios. Therefore, there is an urgent need for a new fabric defect detection method based on the sparse dictionary. Summary of the Invention
[0003] To this end, embodiments of the present invention provide a fabric defect detection method and system based on sparse dictionary optimization, which are used to solve the problem that when applying the sparse dictionary method to fabric defect detection in the prior art, the learning and solution of the sparse dictionary are time-consuming and difficult to meet the real-time detection requirements in industrial scenarios.
[0004] To solve the above problems, embodiments of the present invention provide a fabric defect detection method based on sparse dictionary optimization, and the method includes:
[0005] S1: Collect an image of the fabric to be detected, and divide the image into a normal image and a detection image;
[0006] S2: Set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information;
[0007] S3: Set sub-dictionaries, optimize the sparse dictionary D to obtain a dictionary set containing multiple sub-dictionaries;
[0008] S4: For the preprocessed detection image, reconstruct it using the dictionary set, and calculate to obtain a residual image;
[0009] S5: Perform threshold segmentation on the residual image to obtain a defect image block, and perform misdetection suppression processing on the defect image block to obtain a final defect image block;
[0010] S6: Record and mark the final defect image block.
[0011] Preferably, in step S1, the normal image is an image without defects, and the detection image is an image with defects.
[0012] Preferably, in step S2, setting the sparse dictionary specifically includes: setting the dictionary size, sub-window size, and regularization parameter of the sparse dictionary.
[0013] Preferably, in step S2, the method for preprocessing the normal image includes: image block arrangement, centering, and normalization.
[0014] Preferably, in step S3, setting the sub-dictionary specifically includes: the dictionary size, sub-window size, sub-window overlapping method, and reconstruction error upper limit of the sub-dictionary.
[0015] Preferably, in step S3, the method for optimizing the sparse dictionary D to obtain a dictionary set including multiple sub-dictionaries includes the following steps:
[0016] S31: Input the normal image block sample set The learned sparse dictionary D, initialize the dictionary The number of sub-dictionary atoms k, the reconstruction error bound L;
[0017] S32: Initialize the iteration period i = 1;
[0018] S33: Randomly select k dictionary atoms from the sparse dictionary D to form a sub-dictionary S i ;
[0019] S34: Update S through the formula , and add S i , to the dictionary set S; i
[0020]
[0020] S35: Delete the image block data that meets the condition , and update the image block sample set X;
[0021] S36: Determine whether the image block sample set X is an empty set. When the image block sample set The iteration period i = i + 1, and return to execute step S33; when the image block sample set Output the grouped dictionary set S = {S1, S2,..., S q}.
[0022] Preferably, in step S4, for the preprocessed detection image, reconstruct it using the dictionary set, and the steps to obtain the residual image through calculation are as follows:
[0023] S41: Extract all image patches of the detection image X, arrange them into column vectors and combine them into matrix X t ;
[0024] S42: Use all sub-dictionaries S in the dictionary set and S i to solve for the corresponding coefficients of matrix X t using the least squares method. According to the formula X ri = D×α i , obtain the reconstructed image X ri ;
[0025] S43: According to the formula X εi = ||X t - X ri || 2 , obtain the residual image X εi ;
[0026] where D is the sparse dictionary, α i is the encoding sparse matrix, X ri is the reconstructed image, X t is the image matrix after block extraction and arrangement, and X εi is the residual image.
[0027] Preferably, in step S5, perform threshold segmentation on the residual image to obtain the defect blocks, and the value formula of the threshold is as follows:
[0028] Th = μ + c + τ
[0029] where μ and τ are the average value and standard value of the image patches of the residual image X ε , and c is a predetermined constant.
[0030] Preferably, in step S5, perform false detection suppression processing on the defect image blocks to obtain the final defect image blocks, including the following steps:
[0031] S51: Input the sample set B t = [b1, b2,..., b n of the segmented defect image blocks, the reconstruction error C t = [c1, c2,..., c n corresponding to the defect image blocks, and the suppression degree control coefficient σ;
[0032] S52: Find the maximum reconstruction error and its corresponding image block in the current image;
[0033] S53: Calculate the threshold δ according to the formula δ = σ × max[c1, c2,..., c n .
[0034] S54: Divide all defect blocks into two categories according to the threshold δ. The first category is the defect image blocks where c i is greater than the threshold δ. For the corresponding defect image block b i , i regard it as a true defect image block, and add b i to the defect image block B t ; The second category is the defect image blocks where c i is less than or equal to the threshold δ. Such defect image blocks are detected errors. For the corresponding defect image block b i , i reject it; In addition, when all defect blocks are in the first category, this image is a defect-free image;
[0035] S55: Output the defect image block B t = [b1, b2,..., b m .
[0036] The embodiment of the present invention also provides a fabric defect detection system based on sparse dictionary optimization. The system includes:
[0037] A fabric image acquisition module, which is used to acquire the image of the fabric to be detected and divide the image into a normal image and a detection image;
[0038] A sparse dictionary D acquisition module, which is used to set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information;
[0039] A sparse dictionary D optimization module, which is used to set sub-dictionaries, optimize the sparse dictionary D, and obtain a dictionary set containing multiple sub-dictionaries;
[0040] An image processing module, which is used to reconstruct the preprocessed detection image by using the dictionary set, calculate the residual image; perform threshold segmentation on the residual image to obtain defect image blocks, and perform false detection suppression processing on the defect image blocks to obtain the final defect image blocks;
[0041] A fabric defect recording and marking module, which is used to record and mark the final defect image blocks.
[0042] It can be seen from the above technical solutions that the present invention application has the following advantages:
[0043] 1. Existing learning-based defect detection methods, especially deep learning algorithms, require a large amount of data sets and high hardware conditions, and the real-time performance of automatic detection is poor. The present invention proposes a dictionary grouping optimization strategy, which transforms the time-consuming sparse coding problem into a least squares problem, greatly reducing the detection time of the algorithm and meeting the real-time detection requirements in industrial scenarios;
[0044] 2. The dictionary grouping strategy proposed by the present invention enables the complementary of different sub-dictionaries, which is conducive to the approximation of fabric images, highlighting the defect parts. For the noise in the images, the non-maximum suppression principle is utilized to propose a false detection suppression algorithm, and the reconstruction error is used as a basis to screen the defect blocks after image segmentation, reducing the false detection rate. The detection method proposed by the present invention can greatly improve the positive detection rate of defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly describe the drawings required in the embodiments. By referring to the drawings, the features and advantages of the present invention will be more clearly understood. The drawings are schematic and should not be construed as limiting the present invention in any way. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. Among them:
[0046] Figure 1 is a flowchart of a fabric defect detection method based on sparse dictionary optimization provided;
[0047] Figure 2 is a flowchart of real-time fabric defect detection;
[0048] Figure 3 is a diagram of algorithm selection and parameter input in the algorithm preloading stage;
[0049] Figure 4 is an interactive interface diagram in the algorithm preloading stage;
[0050] Figure 5 is an effect diagram of selvage positioning;
[0051] Figure 6 is a partial detection result diagram of real-time detection of plain white greige fabric;
[0052] Figure 7 is a partial detection result diagram of real-time detection of plain mercerized fabric;
[0053] Figure 8 is a block diagram of a fabric defect detection system based on sparse dictionary optimization provided. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0054] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0055] As Figure 1 shown, an embodiment of the present invention provides a fabric defect detection method based on sparse dictionary optimization, and the method includes:
[0056] S1: Collect an image of the fabric to be detected, and divide the image into a normal image and a detection image;
[0057] S2: Set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information;
[0058] S3: Set sub-dictionaries, optimize the sparse dictionary D to obtain a dictionary set containing multiple sub-dictionaries;
[0059] S4: For the preprocessed detection image, reconstruct it using the dictionary set, and calculate to obtain a residual image;
[0060] S5: Perform threshold segmentation on the residual image to obtain defect image blocks, and perform false detection suppression processing on the defect image blocks to obtain the final defect image blocks;
[0061] S6: Record and mark the final defect image blocks.
[0062] The present invention provides a fabric defect detection method and system based on sparse dictionary optimization. The present invention performs sparse dictionary learning on the normal image after processing to obtain a sparse dictionary D containing normal fabric texture information; optimizes the sparse dictionary D through a dictionary grouping optimization strategy, transforms the time-consuming sparse coding problem into a least squares problem, greatly reduces the detection time of the algorithm, and improves the time efficiency of the algorithm; for the noise in the image, uses the non-maximum suppression principle, proposes a false detection suppression algorithm, and uses the reconstruction error as a basis to screen the defect blocks after image segmentation, reducing the false detection rate; the present invention meets the real-time detection requirements in industrial scenarios, and has high detection accuracy while having high real-time performance.
[0063] Further, in step S1, it includes:
[0064] The present invention uses an industrial camera to collect images of fabrics. The industrial camera is an area array industrial camera equipped with a CMOS sensor, and its model is Daheng Mercury MER-502-79U3M. A fixed-focus lens with 5 million pixels and a focal length of 50 mm is equipped according to the imaging requirements, and its model is Daheng HN-5024-5M-C2 / 3X.
[0065] Collect the image of the fabric to be detected through the industrial camera, and divide the image into a normal image and a detection image. The normal image is an image that does not contain defects, and the detection image is an image that contains defects.
[0066] Further, in step S2, it includes:
[0067] Set a sparse dictionary. The size of the sparse dictionary is 512, the size of the sub-window is 32×32 pixels, and the regularization parameter is set to 0.6.
[0068] Input the normal (defect-free) fabric sample image, divide it into sub-windows of a certain size, unfold and arrange them into column vectors, and then combine them into a data matrix. Here, the dictionary training speed can be accelerated through centering and normalization. If centering and normalization are performed, then the same processing needs to be carried out on the test image subsequently. Only perform sparse dictionary learning on the sample data matrix, and then obtain the sparse dictionary D containing the texture information of normal fabrics.
[0069] Further, in step S3, it includes:
[0070] Set a sub-dictionary. The size of the sub-dictionary is 14, the size of the sub-window is 32×32 pixels, the sub-window overlapping method is semi-overlapping, and the upper limit of the reconstruction error is adjusted according to different samples.
[0071] Optimize the sparse dictionary D through the dictionary grouping strategy to obtain a dictionary set S = {S1, S2,..., S q}, which is used as the dictionary set for subsequent detection, where k is the number of dictionary elements.
[0072] The dictionary grouping strategy specifically includes the following steps:
[0073] S31: Input the set of normal image blocks The learned sparse dictionary D, initialize the dictionary The number k of sub-dictionary atoms and the reconstruction error bound L;
[0074] S32: Initialize the iteration period i = 1;
[0075] S33: Randomly select k dictionary atoms from the sparse dictionary D to form a sub-dictionary S i ;
[0076] S34: Update S through the formula and add S i to the dictionary set S; i
[0077] S35: Delete the image block data that meets the condition and update the image block sample set X;
[0078] S36: Determine whether the image block sample set X is an empty set. When the image block sample set the iteration period i = i + 1, and return to execute step S33; when the image block sample set output the grouped dictionary set S = {S1, S2,..., S q}.
[0079] Among them, the number of iterations represents the number of sub-dictionaries in the dictionary set S. Generally, about 5 iterations can complete the approximate representation of all image blocks, that is, generally update about 5 sub-dictionaries. Here, the upper limit of the number of iterations is set to 8 times because too many sub-dictionaries occupy more computing power and will affect the detection speed. Considering that S i may not be able to represent any image blocks, the solution of the present invention is to replace other images and adjust the number k of sub-dictionary elements.
[0080] Furthermore, step S4 includes:
[0081] Input the defective image X, also divide the sub-windows to extract all image blocks, arrange them into column vectors and combine them into the matrix X t , and perform the same processing as in the above normal image processing using centering and normalization. Use the above dictionary set S = {S1, S2,..., S q} to reconstruct the image, and obtain the residual image through calculation, which specifically includes the following steps:
[0082] S41: Extract all image blocks of the detected image X, arrange them into column vectors and combine them into the matrix X t ;
[0083] S42: Use all sub-dictionaries S in the dictionary set S i to solve the corresponding coefficients for the matrix X t using the least squares method. According to the formula X ri = D × α i , obtain the reconstructed image X ri ;
[0084] S43: According to the formula X εi = ||X t - X ri || 2 , the residual image X is obtained εi ;
[0085] where D is a sparse dictionary, and α i is an encoding sparse matrix, X ri is a reconstructed image, and X t is the image matrix after block permutation, and X εi is the residual image.
[0086] Furthermore, step S5 includes:
[0087] Performing threshold segmentation on the above residual image to obtain defective blocks, and the value formula of the threshold is as follows:
[0088] Th = μ + c + τ
[0089] where μ and τ are the average value and standard value of the image blocks of the residual image X ε , and c is a predetermined constant (usually an empirical value, which is different for different fabrics).
[0090] If the sum of the reconstruction errors of any image block in the residual image is greater than the specified threshold, then this image block is usually regarded as a defective block. Due to the unwanted noise, when using a lower threshold, it is easy to regard normal image blocks as defective, resulting in a high false detection rate. Especially when taking blocks with overlapping sub-windows, the false detection is particularly serious. To solve this problem, the present invention designs an algorithm for suppressing false detection with reference to the principle of non-maximum suppression.
[0091] The algorithm for suppressing false detection specifically includes the following steps:
[0092] S51: Input the sample set B t = [b1, b2,..., b n of the defective image blocks after segmentation, the reconstruction error C t = [c1, c2,..., c n corresponding to the defective image blocks, and the suppression degree control coefficient σ;
[0093] S52: Find the maximum reconstruction error and its corresponding image block in the current image;
[0094] S53: Calculate the threshold δ according to the formula δ = σ × max[c1, c2,..., c n ;
[0095] S54: Divide all defective blocks into two categories according to the threshold δ. The first category is the defective image blocks with c i greater than the threshold δ. Take the defective image block b i corresponding to c i as the true defective image block, and take b iAdded to the defect image block B t ; The second category, c i Defect image blocks less than or equal to the threshold δ. Such defect image blocks are detected errors, and c i The corresponding defect image block b i is eliminated; in addition, when all defect blocks are in the first category, this image is a defect-free image;
[0096] S55: Output the defect image block B t = [b1, b2,..., b m .
[0097] Furthermore, in step S6, it includes:
[0098] Recording and marking the final defect image blocks.
[0099] To verify the superiority of the detection method of the present invention, the following will be described in combination with a specific experimental process.
[0100] In this experiment, the detection method proposed by the present invention is deployed on a self-developed fabric defect detection device, and the detection accuracy and real-time performance of the algorithm in this paper are evaluated from the level of the entire collected fabric image.
[0101] As Figure 2 shown, the real-time detection process is divided into three major steps: algorithm preloading, adjustment stage, and detection stage. The detection algorithm is programmed in C++ language using the Microsoft Visual Studio (2015) platform, uses the OpenCV 4.1.1 open source library, and is implemented on a computer with an Intel(R) Core(TM) i9-9900K CPU@3.60GHz and 16G RAM.
[0102] I. Real-time detection process
[0103] In the algorithm preloading stage, after selecting the algorithm, input the relevant parameters of the algorithm and load them, and input some parameters. As Figure 3 shown, the settings can be input for the camera and the algorithm respectively, and two algorithms can be used simultaneously, including algorithm switch settings, parameter settings for training and detection, etc.; then enter the adjustment stage. The adjustment stage goes through processes such as cloth feeding, cloth threading, automatic adjustment of camera exposure and white balance, and dictionary learning stage (including sparse dictionary learning and dictionary grouping), and this part is all automatically completed; finally, enter the detection stage, automatically unload the cloth and continuously collect images and put them into the image storage queue, and the image processing module uses the algorithm to process the images until the cloth unloading is completed. As Figure 4 shown, since the images are simply marked on the compressed image interface, there are defect images and defect positions saved in the background.
[0104] II. Cloth edge processing
[0105] Since the maximum width captured by 8 cameras is 2.2 m, while the width of the fabric commonly used is in the range of 1.6 - 1.8 m, the fabric selvage is also within it. The existence of the selvage will affect the accuracy of detection, and the extra blank images outside the selvage will take additional time. Therefore, it is necessary to remove the fabric selvage and the invalid areas. In this paper, a simple background comparison method is used for the positioning and excision of the selvage. By using the background area captured when there is no fabric, the positioning of the selvage can be achieved by finding the peak of the average gray value of the image along the columns, and calculate the average gray value of the columns on both sides of this peak, and remove the part with a higher average gray value. Figure 5 Show an example of finding the selvage position.
[0106] The principle on which the algorithm is based is that the fabric edge usually needs to have a certain strength to prevent dispersion, so the warp density of the fabric edge will be slightly higher than that of the fabric, which will be manifested as darker color and lower pixel value in the image. Therefore, the peak will appear at the selvage part. Figure 5 The selvage positioning effect is good, which proves that this algorithm can accurately find the selvage position and exclude the selvage and the invalid blank areas.
[0107] III. Results and Analysis
[0108] To evaluate the dynamic performance of the dictionary grouping method and the hardware system proposed in the present invention, the relevant algorithms are deployed on the automatic fabric defect detection system and two different fabrics are used for testing. Among them, there are 4 rolls of plain white greige fabric in total, with a total length of about 160 m and a width of 1.6 m. There are 8 rolls of plain mercerized fabric in total, with a total length of 160 m and a width of about 1.4 m. To ensure the complete coverage of the entire fabric, two adjacent image frames overlap by about 10 mm in the image height direction. Since the external trigger mode is adopted to trigger image acquisition, the acquisition frame rate of the camera and the LED light source frequency are automatically adjusted according to the speed encoder moving synchronously with the fabric. The image resolution is set to 2432×896, and the corresponding actual size is 28.9 cm×10.7 cm. At this resolution, it takes about 104 ms to process an image without overlapping of sub - windows and without parallel computing. Theoretically, the machine can run at a maximum speed of 62 m / min. To ensure accuracy and stability, the machine deployed with the algorithm runs at a speed of 45 m / min for real - time detection experiments.
[0109] The parameter selections involved in all methods of this real-time detection are as follows: the number of atoms in the ordinary dictionary is 14; the number of atoms in the sparse dictionary used in grouped dictionary learning is 512, the regularization parameter λ = 0.6, and the grouped dictionary method contains 5 dictionaries, where each sub-dictionary contains 14 dictionary atoms. When using the false detection suppression algorithm, the false detection suppression coefficient σ = 0.67. In this real-time detection, the evaluation metrics of correct detection rate (CDR) and false detection rate (FDR) are still used for evaluation, but the real-time detection is calculated at the image level. That is, one image is taken as a sample, different from the offline test where one image patch is taken as a sample, which may lead to a slight decrease in the importance of the false detection suppression algorithm. Therefore, tests are added and the performance is evaluated. Since the sparse dictionary method is too time-consuming and cannot meet the requirements of real-time detection, only the performance of the ordinary dictionary method and the grouped dictionary method is tested in this experiment. The real-time detection result data of plain white greige fabric is shown in Table 1, and some detection result figures are shown in Figure 6 ; the real-time detection result data of plain mercerized fabric is shown in Table 2, and some detection result figures are shown in Figure 7 .
[0110] Table 1
[0111]
[0112] Table 2
[0113]
[0114] It can be seen from the detection result data of plain white greige fabric in Table 1 that compared with the non-overlapping mode, using sub-window overlap can improve the correct detection rate, while increasing the processing time. The false detection rate is slightly reduced, but it is almost negligible. Using the false detection suppression algorithm can significantly reduce the false detection rate, whether the sub-windows are non-overlapping or semi-overlapping. Compared with the previous offline test, the correct detection rate of this real-time detection experiment has increased slightly, while the false detection rate has increased significantly. The reason is that the false detection rate of real-time detection is calculated at the image level, different from the image patch level used in the previous offline test. Since most of a defective image is the normal area and only a small part is the defective area, when most of the defective areas are truly classified as defective, this image can be regarded as a correct detection, resulting in a slight increase in the correct detection rate. Generally speaking, at the image level, even if the defective area is not completely detected, this image is still a defective image. Therefore, the correct detection rate at the image level is relatively high, that is, the correct detection rate of the dynamic experiment is relatively high. Similarly, since the defective area generally only accounts for a small part of the entire image, the increase in normal images will ultimately reduce the false detection rate, and the evaluation performance based on the image level is equivalent to a reduction in the normal sample size, so the false detection rate will naturally increase. Figure 6Shows partial results of the detection of plain white greige fabric using the grouped dictionary method under real-time detection. From the results in the figure, it can be seen that due to the influence of cotton knots in pure cotton fabrics, there are some misdetections, which are misidentified as defects, and these cotton knots can be removed after washing.
[0115] As can be seen from Table 2, compared with the detection result data of plain white greige fabric, the positive detection rate of plain mercerized fabric is relatively high and the misdetection rate is relatively low, indicating that the detection accuracy of plain mercerized fabric is relatively high. The reason for this situation is that the surface of plain mercerized fabric is relatively clean, without interference such as cotton knots, and the defects are relatively simple and easy to detect. Referring to Figure 7 , it can be found that the defect areas in two of the figures are not completely detected. If evaluated at the image block level, the accuracy will surely be inferior to the detection effect of plain white greige fabric. However, real-time detection is based on the sheet, so that it can meet the requirements of rapid automatic detection in industrial scenarios.
[0116] In summary, the detection scheme in this paper can meet the requirements of real-time defect detection at the algorithm level and has a very considerable accuracy rate. Especially in the case of sub-window overlap and the use of the misdetection suppression algorithm, although it will sacrifice a certain detection speed, the algorithm has a good detection effect for various fabrics and defect types, especially for plain white greige fabric collected under transmitted light. In terms of detection time consumption, the real-time performance of the algorithm generally meets the requirements.
[0117] As Figure 8 shown, the present invention provides a fabric defect detection system based on sparse dictionary optimization, and the system includes:
[0118] A fabric image acquisition module 100, configured to acquire an image of a fabric to be detected and divide the image into a normal image and a detection image;
[0119] A sparse dictionary D acquisition module 200, configured to set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information;
[0120] A sparse dictionary D optimization module 300, configured to set sub-dictionaries and optimize the sparse dictionary D to obtain a dictionary set containing multiple sub-dictionaries;
[0121] An image processing module 400, configured to reconstruct the preprocessed detection image using the dictionary set, calculate to obtain a residual image; perform threshold segmentation on the residual image to obtain a defect image block, and perform misdetection suppression processing on the defect image block to obtain a final defect image block;
[0122] A fabric defect recording and marking module 500, configured to record and mark the final defect image block.
[0123] The system is used to implement the fabric defect detection method based on sparse dictionary optimization described above. To avoid redundancy, it will not be elaborated here.
[0124] Note that the above is only a preferred embodiment of the present invention and the applied technical principles. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described here. Various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.
[0125] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0126] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0127] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the functions in Figure 1 one process or multiple processes and / or blocks Figure 1The functions specified in one or more boxes. These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide for implementing in the process Figure 1 One process or more processes and / or boxes Figure 1 The steps of the functions specified in one or more boxes.
[0128] Obviously, the above embodiments are only examples for clear illustration and are not limitations on the implementation manners. For those of ordinary skill in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to enumerate all the implementation manners here. And the obvious changes or modifications derived therefrom are still within the protection scope of the present invention.
Claims
1. A fabric defect detection method based on sparse dictionary optimization, characterized in that, Including: S1: Collect an image of the fabric to be detected, and divide the image into a normal image and a detection image; S2: Set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information; S3: Set sub-dictionaries, optimize the sparse dictionary D, and obtain a dictionary set containing multiple sub-dictionaries, including the following steps: S31: Input the normal image block sample set The learned sparse dictionary D, initialize the dictionary The number of atoms k in the sub-dictionary, the reconstruction error bound L; S32: Initialize the iteration period i = 1; S33: Randomly select k dictionary atoms from the sparse dictionary D to form a sub-dictionary S i ; S34: Update S through the formula and add S i to the dictionary set S i ; S35: Delete the image block data that meets the condition and update the image block sample set X; S36: Determine whether the set X of image block samples is an empty set. When the set of image block samples The iteration period i = i + 1, and return to execute step S33; when the set of image block samples Output the dictionary set S of groups = {S1, S2, …, S q}; S4: For the detection image after preprocessing, reconstruct it using the dictionary set, and calculate to obtain a residual image; S5: Perform threshold segmentation on the residual image to obtain a defective image block, and perform false detection suppression processing on the defective image block to obtain the final defective image block, including the following steps: S51: Input the set B of defect image block samples after segmentation t = [b1, b2, …, b n , the reconstruction error C corresponding to the defect image block t = [c1, c2, …, c n , the suppression degree control coefficient σ; S52: Find the maximum reconstruction error and its corresponding image block in the current image; S53: Calculate the threshold δ according to the formula δ = σ × max[c1, c2, …, c n . S54: Divide all defect blocks into two categories according to the threshold δ. The first category, c i Defect image blocks larger than the threshold δ. For c i The corresponding defect image block b i Is used as a true defect image block. Add b i To the defect image block B t ; The second category, c i Defect image blocks less than or equal to the threshold δ. Such defect image blocks are detection errors. For c i The corresponding defect image block b i Is removed; In addition, when all defect blocks are in the first category, this image is a defect-free image; S55: Output the defective image block B t = [b1, b2, …, b m ; S6: Record and mark the final defective image block.
2. The fabric defect detection method based on sparse dictionary optimization according to claim 1, characterized in that In step S1, the normal image is an image without defects, and the detection image is an image with defects.
3. The fabric defect detection method based on sparse dictionary optimization according to claim 1, characterized in that In step S2, setting the sparse dictionary specifically includes: setting the dictionary size, sub-window size, and regularization parameter of the sparse dictionary.
4. The fabric defect detection method based on sparse dictionary optimization according to claim 1, characterized in that In step S2, the method for preprocessing the normal image includes: image block arrangement, centering, and normalization.
5. The fabric defect detection method based on sparse dictionary optimization according to claim 1, characterized in that In step S3, setting the sub-dictionaries specifically includes: the dictionary size, sub-window size, sub-window overlapping method, and upper limit of reconstruction error of the sub-dictionaries.
6. The fabric defect detection method based on the optimization of a sparse dictionary according to claim 1, characterized in that In step S4, for the detection image after preprocessing, reconstruct it using the dictionary set, and calculate to obtain a residual image, including the following steps: S41: Extract all image patches of the detection image X, arrange them into column vectors and combine them into a matrix X t ; S42: Utilize the dictionary set and all sub-dictionaries S in S i For matrix X t Solve using the least squares method to obtain the corresponding coefficients. According to the formula X ri = D × α i , obtain the reconstructed image X ri ; S43: According to the formula X εi =‖X t -X ri ‖ 2 , the residual image X εi is obtained; Among them, D is a sparse dictionary, and α i is the encoded sparse matrix, X ri is the reconstructed image, X t is the image matrix after block permutation, and X εi is the residual image.
7. The fabric defect detection method based on sparse dictionary optimization according to claim 1, wherein In step S5, perform threshold segmentation on the residual image to obtain a defective block, and the value formula of the threshold is as follows: Th = μ + c + τ where μ and τ are the mean and standard values of the image patches of the residual image X ε and c is a predetermined constant.
8. A fabric defect detection system based on sparse dictionary optimization, characterized in that, The system is used to implement the fabric defect detection method based on sparse dictionary optimization described in any one of claims 1 to 7, including: A fabric image acquisition module, used to collect an image of the fabric to be detected, and divide the image into a normal image and a detection image; A sparse dictionary D acquisition module, used to set a sparse dictionary, preprocess the normal image and then perform sparse dictionary learning to obtain a sparse dictionary D containing normal fabric texture information; A sparse dictionary D optimization module, used to set sub-dictionaries, optimize the sparse dictionary D, and obtain a dictionary set containing multiple sub-dictionaries; An image processing module, used to reconstruct the detection image after preprocessing using the dictionary set, calculate to obtain a residual image; perform threshold segmentation on the residual image to obtain a defective image block, and perform false detection suppression processing on the defective image block to obtain the final defective image block; A fabric defect record and mark module, used to record and mark the final defective image block.
Citation Information
Patent Citations
Woven-fabric texture flaw detection method based on stable learning dictionaries
CN108230299A
Fabric image defect detection method and system based on category constraint dictionary learning model
CN113793319A