Image defect detection method and device based on convolutional neural network model

The image defect detection method using a convolutional neural network model, which utilizes a sparse dictionary and a low-rank matrix to reconstruct the model, solves the problem of insufficient accuracy in defect detection in low-resolution images and achieves efficient defect image extraction.

CN121860967APending Publication Date: 2026-04-14CHONGQING COLLEGE OF ELECTRONICS ENG
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING COLLEGE OF ELECTRONICS ENG
Filing Date
2025-12-29
Publication Date
2026-04-14

Smart Images

  • Figure CN121860967A_ABST
    Figure CN121860967A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, and discloses an image defect detection method and device based on a convolutional neural network model, and the method comprises the steps: obtaining a defect-free image, and forming a reference image set; learning the reference image set through a convolutional neural network to obtain a sparse dictionary corresponding to the reference image set; preprocessing the to-be-detected image to obtain a first to-be-processed image; based on the sparse dictionary and a preset sparse rate threshold, performing defect judgment on the first to-be-processed image to obtain a defect judgment result; if the defect judgment result is that the to-be-detected image has defects, extracting a pixel matrix corresponding to the to-be-detected image; performing separation processing on the pixel matrix through a low-rank matrix reconstruction model to obtain a target pixel matrix; and restoring the target pixel matrix into an image to obtain a defect image in the to-be-detected image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and specifically to an image defect detection method and apparatus based on a convolutional neural network model. Background Technology

[0002] Image defect detection methods are widely used in industrial manufacturing. They can be used to extract scratches on glass or rust spots on smooth steel, screening out defective products and improving yield. For example, the manufacturing process of touch screens is quite complex. Due to mechanical errors, environmental factors, and human operation, various defects are inevitable in each production process. Each stage may produce different defects. For different types of defects, some are organic, such as scratches, cracks, glass inclusions, and edge chipping. Once these defects appear, the product is unqualified and cannot be repaired. Defects such as dirt, dust, and fingerprints are non-organic and can be removed by cleaning or wiping. Therefore, it is necessary to detect and identify various defects in touch screens, screen out defective touch screens, improve yield, and thus reduce the cost of touch screen production.

[0003] Existing image defect extraction methods typically compare the image to be detected with a standard image to determine if defects exist. Contour extraction techniques are then used to extract defects from the image to be detected. However, when detecting defects in low-resolution images, the low resolution leads to low contrast between the image to be detected and the standard image, resulting in poor defect feature recognition. Furthermore, low resolution also makes it difficult for existing image defect extraction methods to accurately distinguish between foreground and background regions, hindering the accurate extraction of defect contours and ultimately leading to insufficient accuracy in defect detection. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention proposes an image defect detection method and apparatus based on a convolutional neural network model to solve the aforementioned technical problems.

[0005] Firstly, an image defect detection method based on a convolutional neural network model is provided, including: Obtain defect-free images to form a reference image set; A sparse dictionary corresponding to the reference image set is obtained by learning the reference image set through a convolutional neural network; The image to be detected is preprocessed to obtain the first image to be processed. Based on the sparse dictionary and the preset sparsity threshold, the first image to be processed is subjected to defect judgment to obtain the defect judgment result. If the defect determination result indicates that the image to be detected has a defect, then the pixel matrix corresponding to the image to be detected is extracted; The pixel matrix is ​​separated by a low-rank matrix reconstruction model to obtain the target pixel matrix; The target pixel matrix is ​​restored to an image to obtain the defect image in the image to be detected.

[0006] Furthermore, acquiring defect-free images and combining them with reference images includes: Extract defect-free images from the Internet or from databases pre-collected and stored by users; All extracted defect-free images are integrated to form a reference image set.

[0007] Furthermore, a sparse dictionary corresponding to the reference image set is obtained by learning the reference image set through a convolutional neural network, including: The hierarchical and structural features of each reference image in the reference image set are extracted one by one by a convolutional neural network to obtain a set of feature information corresponding to the number of reference images. The convolutional neural network is trained using a standard sparse dictionary as a training benchmark, combined with the aforementioned feature information. The trained convolutional neural network performs sparse representation of all feature information to obtain a sparse dictionary in matrix form.

[0008] Furthermore, the image to be detected is preprocessed to obtain a first image to be processed, including: The image to be detected is enhanced by using an image super-resolution method based on the Transformer self-attention mechanism to obtain the enhanced image to be detected. The enhanced image to be detected is binarized to obtain a binarized image; By combining median filtering and Gaussian filtering methods, the binarized image is denoised to obtain the first image to be processed.

[0009] Furthermore, based on the sparse dictionary and a preset sparsity threshold, defect judgment is performed on the first image to be processed to obtain defect judgment results, including: Based on the sparse dictionary, a sparse matrix corresponding to the first image to be processed is constructed using a general sparse matrix construction method. The target sparsity of the first image to be processed is obtained by calculating the ratio of the number of zero elements in the sparse matrix to the total number of elements. The average sparsity of the reference image set is obtained by calculating the ratio of the number of zero elements in the sparse dictionary to the total number of elements. Compare the absolute value of the difference between the target sparsity rate and the average sparsity rate with the magnitude of the preset sparsity rate threshold; If the absolute value of the difference is greater than the preset sparsity threshold, the defect judgment result is that the image to be detected has a defect; If the absolute value of the difference is less than or equal to the preset sparsity threshold, the defect judgment result is that the image to be detected has no defects.

[0010] Furthermore, if the defect determination result indicates that the image to be detected has a defect, then the pixel matrix corresponding to the image to be detected is extracted, including: Obtain the RGB value of each pixel in the image to be detected, and determine the RGB value as the pixel value corresponding to each pixel to form a set of pixel values; The arrangement order of each pixel in the image to be detected is obtained, and the arrangement order is determined as the position information corresponding to each pixel to form a set of position information. The element arrangement order is determined by the location information set, and the element values ​​are determined by the pixel value set to construct the pixel matrix corresponding to the image to be detected.

[0011] Furthermore, the pixel matrix is ​​separated using a low-rank matrix reconstruction model to obtain the target pixel matrix, including: A low-rank matrix reconstruction model is constructed, which decomposes the pixel matrix into a low-order matrix and a sparse matrix, wherein the sparse matrix is ​​the target pixel matrix. The low-rank matrix reconstruction model is optimized by a preset objective function. The optimization direction of the objective function is to minimize the weighted sum of the kernel norm of the low-rank matrix and the norm of the target pixel matrix. The weights of the weighted sum are determined by the decomposition parameters. The augmented Lagrange multiplier method is used to optimize the objective function by combining a preset multiplier matrix and a preset penalty parameter, thereby obtaining the augmented Lagrange function; The low-rank matrix parameters and sparse matrix parameters in the augmented Lagrangian function are optimized by iterative update until the preset convergence condition is met or the maximum number of iterations is reached. The final sparse matrix parameters obtained after optimization are determined as the target pixel matrix.

[0012] Further, the target pixel matrix is ​​restored to an image to obtain the defect image in the image to be detected, including: Extract the pixel value and position information corresponding to each element in the target pixel matrix; According to the arrangement order corresponding to the location information, the pixels with the same pixel value as the element are placed at the corresponding positions in the image to be detected; By restoring the corresponding values ​​of all pixels, a defect image in the image to be detected is formed.

[0013] Secondly, an image defect detection device based on a convolutional neural network model is provided, which, based on any one of the preceding descriptions of an image defect detection method based on a convolutional neural network model, includes: The acquisition module is configured to acquire defect-free images and form a reference image set. The learning module is configured to learn the reference image set through a convolutional neural network to obtain a sparse dictionary corresponding to the reference image set; The preprocessing module is configured to preprocess the image to be detected to obtain the first image to be processed; The judgment module is configured to perform defect judgment on the first image to be processed based on the sparse dictionary and a preset sparsity threshold, and obtain the defect judgment result. The extraction module is configured to extract the pixel matrix corresponding to the image to be detected if the defect judgment result indicates that the image to be detected has a defect. The separation processing module is configured to separate the pixel matrix using a low-rank matrix reconstruction model to obtain the target pixel matrix; The restoration module is configured to restore the target pixel matrix into an image to obtain a defect map in the image to be detected.

[0014] The invention employing the above technical solution has the following advantages: This invention enhances the image by performing image enhancement, denoising, and binarization on the image to be detected, making the outline of the defect image clearer and thus improving the accuracy of subsequent defect image extraction. Furthermore, by using the augmented Lagrange multiplier method to address the norm joint minimization problem in obtaining the optimal solution of the objective function, the defect image extraction problem is transformed into a foreground and background segmentation problem, thereby improving the accuracy and efficiency of defect image extraction. Attached Figure Description

[0015] To more clearly illustrate the specific embodiments of the present invention, the accompanying drawings used in the specific embodiments will be briefly described below. In all the drawings, the elements or parts are not necessarily drawn to scale.

[0016] Figure 1 This is a flowchart of an image defect detection method based on a convolutional neural network model according to the present invention; Figure 2 This is a flowchart of an image defect detection device based on a convolutional neural network model according to the present invention. Detailed Implementation

[0017] The embodiments of the technical solution of the present invention will now be described in detail with reference to the accompanying drawings. These embodiments are merely illustrative of the technical solution of the present invention and are therefore intended to limit the scope of protection of the present invention.

[0018] like Figures 1-2 As shown, an image defect detection method based on a convolutional neural network model according to the present invention includes: Step S01: Obtain defect-free images to form a reference image set; Step S02: Learn the reference image set through a convolutional neural network to obtain the sparse dictionary corresponding to the reference image set; Step S03: Preprocess the image to be detected to obtain the first image to be processed; Step S04: Based on the sparse dictionary and the preset sparsity threshold, perform defect judgment on the first image to be processed to obtain the defect judgment result; Step S05: If the defect judgment result indicates that the image to be detected has a defect, then extract the pixel matrix corresponding to the image to be detected. Step S06: Separate the pixel matrix using a low-rank matrix reconstruction model to obtain the target pixel matrix; Step S07: Restore the target pixel matrix to an image to obtain the defect image in the image to be detected.

[0019] In this embodiment, acquiring a defect-free image and forming a reference image combination includes: Extract defect-free images from the Internet or from databases pre-collected and stored by users; All extracted defect-free images are integrated to form a reference image set.

[0020] Specifically, this invention uses the augmented Lagrange multiplier method to solve the problem of joint norm minimization in the process of obtaining the optimal solution of the objective function value. By taking into account that industrial products such as glass and flat steel have structural textures, the problem of extracting defect images from the image to be detected is transformed into a problem of segmenting the foreground and background of the image to be detected. This improves the accuracy and efficiency of extracting defect images from the image to be detected.

[0021] In this embodiment, a sparse dictionary corresponding to the reference image set is obtained by learning from the reference image set through a convolutional neural network, including: The hierarchical and structural features of each reference image in the reference image set are extracted one by one by a convolutional neural network to obtain a set of feature information corresponding to the number of reference images. The convolutional neural network is trained using a standard sparse dictionary as the training benchmark and combined with feature information. The trained convolutional neural network performs sparse representation of all feature information to obtain a sparse dictionary in matrix form.

[0022] Specifically, this can be achieved by extracting defect-free images from sources including but not limited to the internet and databases (where users collect and store defect-free images together) to obtain a reference image set; using a convolutional neural network to extract hierarchical and structured features from each reference image in the reference image set, resulting in k feature information sets; where k is the number of reference images in the reference image set; and training the convolutional neural network model using a standard sparse dictionary and the feature information from the feature information sets, enabling the convolutional neural network to sparsely represent the feature information in the k feature information sets using the standard sparse dictionary, thus obtaining a sparse dictionary. The sparse dictionary can be understood as the sparse representation (vector) of the feature information in the k feature information sets. The mathematical form of the sparse dictionary is a matrix.

[0023] In this embodiment, the image to be detected is preprocessed to obtain a first image to be processed, including: An image super-resolution method based on Transformer self-attention mechanism is used to perform image enhancement processing on the image to be detected, resulting in an enhanced image to be detected. The enhanced image to be detected is binarized to obtain the binarized image. By combining median filtering and Gaussian filtering methods, the binarized image is denoised to obtain the first image to be processed.

[0024] In this embodiment, based on a sparse dictionary and a preset sparsity threshold, defect judgment is performed on the first image to be processed to obtain a defect judgment result, including: Based on the sparse dictionary, a general sparse matrix construction method is used to construct the sparse matrix corresponding to the first image to be processed. The target sparsity of the first image to be processed is obtained by calculating the ratio of the number of zero elements in the sparse matrix to the total number of elements. Calculate the ratio of the number of zero elements in the sparse dictionary to the total number of elements to obtain the average sparsity of the reference image set; Compare the absolute value of the difference between the target sparsity and the average sparsity with the preset sparsity threshold. If the absolute value of the difference is greater than the preset sparsity threshold, the defect judgment result is that the image to be detected has a defect; If the absolute value of the difference is less than or equal to the preset sparsity threshold, the defect judgment result is that the image to be detected has no defects.

[0025] Specifically, the first image to be processed can be obtained by performing image enhancement processing, binarization processing and denoising processing on the image to be detected, obtaining the sparsity rate corresponding to the first image to be processed, obtaining the target sparsity rate, obtaining the first sparsity rate by obtaining a preset sparsity dictionary, and then determining whether the image to be detected is a defective image by judging the relationship between the absolute value of the difference between the target sparsity rate and the first sparsity rate and a preset sparsity rate threshold, and obtaining the judgment result.

[0026] Image enhancement processing is performed on the image to be detected.

[0027] One approach is to perform image enhancement processing on the image to be detected by using a general image enhancement processing method (such as an image super-resolution method based on the self-attention mechanism of Transformer).

[0028] The image to be detected is binarized and then denoised to obtain a first image to be processed. Specifically, the image to be detected can be binarized and denoised using a general binarization method and a general denoising method to obtain the first image to be processed.

[0029] Construct the sparse matrix corresponding to the first image to be processed to obtain the target sparse matrix; After obtaining the first image to be processed, a sparse matrix corresponding to the first image to be processed can be constructed using a general sparse matrix construction method based on a preset sparse dictionary to obtain the target sparse matrix.

[0030] The sparsity corresponding to the first image to be processed is obtained based on the target sparse matrix to obtain the target sparsity. After obtaining the target sparse matrix, the sparsity of the first image to be processed can be obtained by taking the ratio between the number of zero elements (0 vectors) in the target sparse matrix and the total number of elements in the target sparse matrix.

[0031] The average sparsity of the reference images in the reference image set is obtained according to the preset sparse dictionary, and the sparsity is obtained. Since a sparse dictionary is a sparse representation of the feature information in a set of k feature information, the sparsity can be obtained by calculating the ratio between the number of zero elements in the sparse dictionary and the total number of elements in the sparse dictionary.

[0032] The determination of whether the image to be detected is defective is based on the target sparsity and the sparsity, and the determination result is obtained.

[0033] Specifically, it can be determined by judging whether the absolute value of the difference between the target sparsity rate and the current sparsity rate is greater than a preset sparsity rate threshold. If the absolute value of the difference between the target sparsity rate and the current sparsity rate is greater than the preset sparsity rate threshold, the image to be detected is determined to be a defective image. If the absolute value of the difference between the target sparsity rate and the current sparsity rate is less than or equal to the preset sparsity rate threshold, the image to be detected is determined to be a defect-free image. The sparsity rate thresholds can be determined by user input or by system default.

[0034] In this embodiment, if the defect determination result indicates that the image to be detected has a defect, then the pixel matrix corresponding to the image to be detected is extracted, including: Obtain the RGB value of each pixel in the image to be detected, and determine the RGB value as the pixel value corresponding to each pixel to form a set of pixel values; The arrangement order of each pixel in the image to be detected is obtained, and the arrangement order is determined as the position information corresponding to each pixel, forming a set of position information. The element arrangement order is determined by the location information set, and the element value is determined by the pixel value set, thus constructing the pixel matrix corresponding to the image to be detected.

[0035] In this embodiment, the pixel matrix is ​​separated using a low-rank matrix reconstruction model to obtain the target pixel matrix, including: A low-rank matrix reconstruction model is constructed, which decomposes the pixel matrix into a low-order matrix and a sparse matrix, with the sparse matrix being the target pixel matrix. The low-rank matrix reconstruction model is optimized by a pre-defined objective function. The optimization direction of the objective function is to minimize the weighted sum of the kernel norm of the low-rank matrix and the norm of the target pixel matrix. The weights of the weighted sum are determined by the decomposition parameters. The augmented Lagrange multiplier method is used to optimize the objective function by combining a preset multiplier matrix and a preset penalty parameter, resulting in the augmented Lagrange function. The low-rank matrix parameters and sparse matrix parameters in the augmented Lagrangian function are optimized through iterative updates until the preset convergence condition is met or the maximum number of iterations is reached. The parameters of the sparse matrix obtained after optimization are determined as the target pixel matrix.

[0036] Specifically, this can be achieved by acquiring the pixel value and position information corresponding to each pixel in the image to be detected, obtaining a set of pixel values ​​and a set of position information, constructing a pixel value matrix corresponding to the image to be detected using the pixel values ​​in the set of pixel values ​​and the position information in the set of position information, obtaining a first matrix; constructing a low-rank matrix reconstruction model to extract the low-rank matrix in the pixel matrix, and using the low-rank matrix reconstruction model to extract the low-rank matrix in the first pixel matrix according to a preset multiplier matrix and a preset penalty parameter, obtaining the target pixel matrix. The preset multiplier matrix and preset penalty parameter can be determined by user input or by system default.

[0037] Extract the pixel matrix corresponding to the image to be detected to obtain the first pixel matrix.

[0038] This can be achieved by obtaining the RGB values ​​of each pixel in the image to be detected, determining the RGB values ​​of each pixel as the pixel value for each pixel, and obtaining a set of pixel values. Simultaneously, the arrangement order of each pixel in the image to be detected can be obtained, determining the arrangement order of each pixel as the position information for each pixel, and obtaining a set of position information. The pixel values ​​in the pixel value set correspond one-to-one with the position information in the position information set. After obtaining the pixel value set and the position information set, the pixel values ​​in the pixel value set can be used as the numerical values ​​corresponding to elements in a first matrix, and the position information in the position information set can be used as the arrangement order of elements in the first pixel matrix, resulting in a first pixel matrix.

[0039] Based on the preset multiplier matrix and preset penalty parameters, the low-rank matrix in the first pixel matrix is ​​extracted using a low-rank matrix reconstruction model to obtain the target pixel matrix.

[0040] Since industrial products such as glass and flat steel have structural textures, the defect-free areas in glass and flat steel have certain similarities and regularities, resulting in the matrix corresponding to the defect-free area image of glass and flat steel having low rank. When defects (scratches, rust spots, etc.) appear on glass and flat steel, the defects will destroy the structural texture of glass and flat steel, and destroy the low rank of the matrix corresponding to the image of glass and flat steel, thus exhibiting sparsity. Therefore, the defect image can be extracted from the image to be detected by separating the sparse matrix in the first matrix.

[0041] Since the low-rank matrix reconstruction model continuously optimizes its internal objective function to minimize the function value under preset conditions, the process of extracting the low-rank matrix from the first pixel matrix using the low-rank matrix reconstruction model is actually a process of continuously optimizing the internal objective function of the low-rank matrix reconstruction model.

[0042] Specifically, the objective function can be obtained by constructing the function to be optimized in the low-rank matrix reconstruction model through norm minimization. The objective function can be expressed as follows: In the formula Represents the first matrix; This represents the sparse matrix in the first matrix, i.e., the target pixel matrix; This represents the low-rank matrix in the first matrix; Represent the objective function; This indicates the operation of taking the minimum value; Represents a low-rank matrix The corresponding nuclear norm is used to measure the degree of low rank of the low-rank matrix in the first matrix; The decomposition parameters can be determined by user input or by system default. Represents the target pixel matrix corresponding to Norm, used to measure the sparsity of the target pixel matrix.

[0043] After obtaining the objective function, an augmented Lagrange function can be constructed using the augmented Lagrange multiplier method based on a preset multiplier matrix and preset penalty parameters, resulting in a first objective function. The first objective function is expressed as follows: In the formula Denotes the first objective function; This represents the parameters of the low-rank matrix, with an initial value of 0; This represents the parameters of the sparse matrix, with an initial value of 0; This represents a predefined multiplier matrix; This indicates the preset penalty parameters; Represents the parameters of a low-rank matrix The corresponding nuclear norm; Represents the target pixel matrix parameters corresponding Norm; The dot product operator for matrices; denot represents the Fibonacci norm of the matrix.

[0044] After obtaining the first objective function, the maximum number of iterations of the low-rank matrix reconstruction model can be set by the experience value of professionals or the historical value recorded in the system, so as to obtain the target number of iterations; that is, the low-rank matrix reconstruction model can obtain the optimal solution of the first objective function through continuous iteration.

[0045] After obtaining the target number of iterations, the sparse matrix parameters can be updated using a singular value thresholding operation to obtain updated sparse matrix parameters. The low-rank matrix parameters can then be updated using a soft thresholding operation to obtain updated low-rank matrix parameters. The preset multiplier matrix can then be updated using the updated sparse matrix parameters and the updated low-rank matrix parameters to obtain updated multiplier matrices. Finally, the updated sparse matrix parameters, the updated low-rank matrix parameters, and the updated multiplier matrix can be substituted into the first objective function to calculate the function value, thereby completing one iteration of the low-rank matrix reconstruction model.

[0046] The updated multiplier matrix can be obtained by updating the preset multiplier matrix using the updated sparse matrix parameters and the updated low-rank matrix parameters, as shown in the following formula: In the formula This represents the updated multiplier matrix; This represents the number of iterations in the current low-rank matrix reconstruction model, when... When, it indicates that the parameters in the low-rank matrix reconstruction model are at their initial values; This represents the predefined multiplier matrix; This indicates the preset penalty parameters; Represents the first matrix; Updated low-rank matrix parameters; This represents the updated sparse matrix parameters.

[0047] After completing one iteration, the updated sparse matrix parameters and the updated low-rank matrix parameters can be substituted into the preset convergence condition judgment formula corresponding to the low-rank matrix reconstruction model to determine whether the low-rank matrix reconstruction model has converged. If the low-rank matrix reconstruction model has converged, the updated sparse matrix parameters are output to obtain the target pixel matrix. If the low-rank matrix reconstruction model has not converged, the sparse matrix parameters, the updated low-rank matrix parameters, and the updated multiplier matrix are updated again until the preset convergence condition corresponding to the low-rank matrix reconstruction model is met or the number of iterations reaches the target number of iterations. Finally, the final function value obtained by the target first function is output to obtain the target function value.

[0048] Specifically, the updated sparse matrix parameters and the updated low-rank matrix parameters can be substituted into the preset convergence condition judgment formula corresponding to the low-rank matrix reconstruction model using the method shown in the following formula to determine whether the low-rank matrix reconstruction model has converged: In the formula Represents the first matrix; This represents the updated low-rank matrix parameters obtained after the Nth iteration; This represents the updated sparse matrix parameters obtained after the Nth iteration; Denotes the Fibonacci norm of a matrix; This represents the convergence verification parameter, which is a small positive number and can be determined by user input or by the system default. After the low-rank matrix reconstruction model reaches the convergence condition, the updated sparse matrix parameters obtained in the last iteration of the low-rank matrix reconstruction model when the objective function value is obtained can be used to determine the target pixel matrix.

[0049] In this embodiment, the target pixel matrix is ​​restored to an image to obtain a defect image in the image to be detected, including: Extract the pixel value and position information corresponding to each element in the target pixel matrix; According to the arrangement order corresponding to the position information, the pixels with the same pixel value as the element are placed at the corresponding positions in the image to be detected; By reconstructing the corresponding pixels, a defect image is formed in the image to be detected.

[0050] Specifically, the target image can be obtained by acquiring the pixel value and position information corresponding to each element in the target pixel matrix, and then restoring each element in the target pixel matrix to a pixel according to the pixel value and position information. Alternatively, each element in the target pixel matrix can be restored to a pixel by placing a pixel with the same pixel value as an element in the target pixel matrix at the position corresponding to the position information of the element.

[0051] In other embodiments, an image defect detection device based on a convolutional neural network model is provided, and an image defect detection method based on a convolutional neural network model based on any of the preceding embodiments is provided, comprising: The acquisition module is configured to acquire defect-free images and form a reference image set. The learning module is configured to learn from the reference image set through a convolutional neural network to obtain a sparse dictionary corresponding to the reference image set; The preprocessing module is configured to preprocess the image to be detected to obtain the first image to be processed; The judgment module is configured to perform defect judgment on the first image to be processed based on a sparse dictionary and a preset sparsity threshold, and obtain the defect judgment result. The extraction module is configured to extract the pixel matrix corresponding to the image to be detected if the defect judgment result indicates that the image to be detected has a defect. The separation processing module is configured to separate the pixel matrix using a low-rank matrix reconstruction model to obtain the target pixel matrix; The restoration module is configured to restore the target pixel matrix into an image, thereby obtaining a defect map in the image to be detected.

[0052] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of the claims and specification of the present invention.

Claims

1. An image defect detection method based on a convolutional neural network model, characterized in that, include: Obtain defect-free images to form a reference image set; A sparse dictionary corresponding to the reference image set is obtained by learning the reference image set through a convolutional neural network; The image to be detected is preprocessed to obtain the first image to be processed; Based on the sparse dictionary and the preset sparsity threshold, the first image to be processed is subjected to defect judgment to obtain the defect judgment result. If the defect determination result indicates that the image to be detected has a defect, then the pixel matrix corresponding to the image to be detected is extracted; The pixel matrix is ​​separated by a low-rank matrix reconstruction model to obtain the target pixel matrix; The target pixel matrix is ​​restored to an image to obtain the defect image in the image to be detected.

2. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, Acquire defect-free images and combine them with reference images, including: Extract defect-free images from the Internet or from databases pre-collected and stored by users; All extracted defect-free images are integrated to form a reference image set.

3. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, A sparse dictionary corresponding to the reference image set is obtained by learning from the reference image set using a convolutional neural network, including: The hierarchical and structural features of each reference image in the reference image set are extracted one by one by a convolutional neural network to obtain a set of feature information corresponding to the number of reference images. The convolutional neural network is trained using a standard sparse dictionary as a training benchmark, combined with the aforementioned feature information. The trained convolutional neural network performs sparse representation of all feature information to obtain a sparse dictionary in matrix form.

4. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, The image to be detected is preprocessed to obtain the first image to be processed, including: The image to be detected is enhanced by using an image super-resolution method based on the Transformer self-attention mechanism to obtain the enhanced image to be detected. The enhanced image to be detected is binarized to obtain a binarized image; By combining median filtering and Gaussian filtering methods, the binarized image is denoised to obtain the first image to be processed.

5. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, Based on the sparse dictionary and a preset sparsity threshold, defect judgment is performed on the first image to be processed to obtain defect judgment results, including: Based on the sparse dictionary, a sparse matrix corresponding to the first image to be processed is constructed using a general sparse matrix construction method. The target sparsity of the first image to be processed is obtained by calculating the ratio of the number of zero elements in the sparse matrix to the total number of elements. The average sparsity of the reference image set is obtained by calculating the ratio of the number of zero elements in the sparse dictionary to the total number of elements. Compare the absolute value of the difference between the target sparsity rate and the average sparsity rate with the magnitude of the preset sparsity rate threshold; If the absolute value of the difference is greater than the preset sparsity threshold, the defect judgment result is that the image to be detected has a defect; If the absolute value of the difference is less than or equal to the preset sparsity threshold, the defect judgment result is that the image to be detected has no defects.

6. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, If the defect determination result indicates that the image to be detected has a defect, then the pixel matrix corresponding to the image to be detected is extracted, including: Obtain the RGB value of each pixel in the image to be detected, and determine the RGB value as the pixel value corresponding to each pixel to form a set of pixel values; The arrangement order of each pixel in the image to be detected is obtained, and the arrangement order is determined as the position information corresponding to each pixel to form a set of position information. The element arrangement order is determined by the location information set, and the element values ​​are determined by the pixel value set to construct the pixel matrix corresponding to the image to be detected.

7. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, The pixel matrix is ​​separated using a low-rank matrix reconstruction model to obtain the target pixel matrix, including: A low-rank matrix reconstruction model is constructed, which decomposes the pixel matrix into a low-order matrix and a sparse matrix, wherein the sparse matrix is ​​the target pixel matrix. The low-rank matrix reconstruction model is optimized by a preset objective function. The optimization direction of the objective function is to minimize the weighted sum of the kernel norm of the low-rank matrix and the norm of the target pixel matrix. The weights of the weighted sum are determined by the decomposition parameters. The augmented Lagrange multiplier method is used to optimize the objective function by combining a preset multiplier matrix and a preset penalty parameter, thereby obtaining the augmented Lagrange function; The low-rank matrix parameters and sparse matrix parameters in the augmented Lagrangian function are optimized by iterative update until the preset convergence condition is met or the maximum number of iterations is reached. The final sparse matrix parameters obtained after optimization are determined as the target pixel matrix.

8. The image defect detection method based on a convolutional neural network model according to claim 1, characterized in that, The target pixel matrix is ​​restored to an image to obtain the defect image in the image to be detected, including: Extract the pixel value and position information corresponding to each element in the target pixel matrix; According to the arrangement order corresponding to the location information, the pixels with the same pixel value as the element are placed at the corresponding positions in the image to be detected; By restoring the corresponding values ​​of all pixels, a defect image in the image to be detected is formed.

9. An image defect detection device based on a convolutional neural network model, characterized in that, An image defect detection method based on a convolutional neural network model according to any one of claims 1 to 8 includes: The acquisition module is configured to acquire defect-free images and form a reference image set. The learning module is configured to learn the reference image set through a convolutional neural network to obtain a sparse dictionary corresponding to the reference image set; The preprocessing module is configured to preprocess the image to be detected to obtain the first image to be processed; The judgment module is configured to perform defect judgment on the first image to be processed based on the sparse dictionary and a preset sparsity threshold, and obtain the defect judgment result. The extraction module is configured to extract the pixel matrix corresponding to the image to be detected if the defect judgment result indicates that the image to be detected has a defect. The separation processing module is configured to separate the pixel matrix using a low-rank matrix reconstruction model to obtain the target pixel matrix; The restoration module is configured to restore the target pixel matrix into an image to obtain a defect map in the image to be detected.