A method for detecting image defects

By generating an anchor box and graph neural network adaptive aspect ratio, the problem of low defect detection efficiency of large-sized prints for corrugated cartons is solved, and fast and accurate defect detection is achieved.

CN114820445BActive Publication Date: 2025-04-15GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210279053.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-21
Publication Date
2025-04-15
Estimated Expiration
2042-03-21

AI Technical Summary

Technical Problem

The prior art has poor image defect detection effect on large-sized printed materials of corrugated cartons, and the existing methods have complex detection process and low efficiency.

Method used

The combination of gradient feature extraction, convolutional neural network and graph neural network is used to generate an anchor box with aspect ratio adaptive adaptiveness. The deep relationship between anchor box is obtained by fusing the gradient attention mechanism and graph neural network, and clustering and defect detection are performed.

Benefits of technology

It realizes rapid and accurate positioning and defect detection of Chinese text information in corrugated carton images, improving detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114820445B_ABST
    Figure CN114820445B_ABST
Patent Text Reader

Abstract

The present invention discloses an image defect detection method, comprising: S1: extracting gradient features of an image to be detected to obtain a gradient map; inputting the image to be detected into a convolutional neural network for training to obtain a feature map; S2: fusing the gradient map with the feature map to obtain a feature map of a fused gradient attention mechanism; S3: obtaining a number of anchor boxes with adaptive aspect ratios; S4: obtaining the deep relationship between each anchor box; S5: clustering and merging the anchor boxes according to the deep relationship between each anchor box to obtain a text output area; S6: comparing the text output area with a standard image to complete defect detection of the image to be detected. The present invention generates an anchor box with adaptive aspect ratios, and uses a graph neural network to obtain the deep relationship between each anchor box, so that the anchor boxes can be better clustered and merged, and the text information on the image to be detected can be quickly and accurately located, which facilitates the processing of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image detection algorithm research, and in particular to an image defect detection method. Background Art

[0002] In today's era, the development of artificial intelligence is unstoppable and has had a significant impact on the industrial manufacturing industry. Visual inspection is one of the important links in industrial production and manufacturing. Corrugated box high-screen printing equipment has the characteristics of high-screen high-resolution printing, fast speed, large width, and complex and changeable printing pattern texture. At this stage, the industry faces the key common problem of lack of production back-end visual inspection equipment, and it is difficult to guarantee the printing quality and stability. Therefore, a method for high-speed real-time online defect detection of images on printed corrugated boxes is needed.

[0003] In recent years, the methods and technologies of defect detection have developed rapidly. The main detection methods are as follows: 1. Using high-speed image scanning algorithms, linear and nonlinear filters with dynamic size, threshold and transformation are used to detect edges and boundaries for further analysis. 2. Perform template matching to find the location of defects. 3. Extract image description rules from local areas. These detection methods are suitable for defect detection problems where defect models cannot be prepared, such as scratch or overlay detection, texture image analysis, etc.

[0004] All of the above methods ultimately perform defect detection in the form of image difference, which makes these methods work better on small-sized printed products such as cigarette packaging paper, but not so good on large-sized printed products such as corrugated paper boxes. Therefore, it is very important to provide a text detection method with good results in the defect detection of paper box images.

[0005] The prior art discloses a Chinese invention application of a method and device for visually inspecting printing defects of a corrugated paper packaging box. The method comprises taking a standard corrugated paper packaging box printed product as a standard sample, placing the standard sample on a workbench and positioning it; creating a template library of a product standard: a detection system collects a flawless printed product of the standard sample, sets standard parameters and detection algorithms of each detection item through positioning setting and detection setting, and saves it with the barcode of the corrugated paper packaging box as the name, and establishing and saving a template of a standard reference standard; taking a corrugated paper packaging box to be tested as a test sample, and a detection system scans the barcode of the test sample to obtain a template of a standard reference standard with the same barcode; creating a template of a product standard to be tested: placing the test sample on a workbench and positioning it, selecting and capturing the test sample image through the detection system, resetting the positioning setting and detection setting to obtain a template of a product standard; starting the detection, comparing and analyzing the test sample image of the product standard template with the template of the standard reference standard, and judging whether the product standard template has defects. However, the method is complicated in the process of inspecting the printed products of the corrugated paper packaging box, and has low efficiency. Summary of the invention

[0006] The invention provides an image defect detection method, which is used for performing high-speed defect detection on an image to be detected.

[0007] The objective of the present invention is achieved by at least one of the following technical solutions: a method for detecting image defects, comprising the following steps:

[0008] S1: Extract gradient features of the image to be detected to obtain a gradient map; input the image to be detected into a convolutional neural network for training to obtain a feature map;

[0009] S2: Fuse the gradient map with the feature map to obtain a feature map with a fused gradient attention mechanism;

[0010] S2: Input the feature map of the fused gradient attention mechanism into the convolutional neural network and train to obtain several anchor boxes with adaptive aspect ratios;

[0011] S4: Build a graph neural network, upgrade the dimensions of several aspect ratio adaptive anchor boxes to obtain vectors, input the vectors into the graph neural network for learning, and obtain the deep relationship between the anchor boxes;

[0012] S5: clustering and merging the anchor boxes according to the deep relationship between the anchor boxes to obtain the text output area;

[0013] S6: Compare the text output area with the standard image to complete the defect detection of the image to be detected.

[0014] The deep relationship refers to the corresponding connection relationship between the anchor boxes;

[0015] In the above scheme, the graph neural network is a graph neural network disclosed in the prior art;

[0016] The present invention generates an anchor point frame with adaptive aspect ratio and uses a graph neural network to obtain the deep relationship between the anchor point frames, so that the anchor point frames can be better clustered and merged, and the position of the text information on the image to be detected can be quickly and accurately located, which facilitates the processing of defect detection.

[0017] Furthermore, in step S1, the image to be detected is a carton packaging printed material image.

[0018] Furthermore, in step S1, when extracting gradient features of the image to be detected, the horizontal gradient value and the vertical gradient value of the gradient feature of the image to be detected are calculated respectively, and the larger gradient value is taken as the final gradient value;

[0019] The process is as follows: For the pixel point i with coordinates (x, y) in the image to be detected, the larger one is selected from the gradients in the horizontal direction and the vertical direction for assignment as the final gradient value g of the pixel point i. i , and its expression is as follows:

[0020]

[0021] Among them, f(x, y) refers to the pixel value of the pixel point i at the image coordinates (x, y).

[0022] In the above solution, the final gradient values form a gradient map, which can better retain gradient features.

[0023] Furthermore, the feature map described in step S1 is a 16-dimensional feature map.

[0024] In the above solution, the 16-dimensional feature map can retain a certain number of features without making the entire network overly large and redundant.

[0025] Furthermore, step S2 is specifically as follows:

[0026] The final gradient value is normalized to obtain a weight value, and then the weight value is fused with the feature map to obtain a feature map of the fusion gradient attention mechanism;

[0027] Among them, the feature value T of the feature map of the fusion gradient attention mechanism at the k-th dimensional pixel point i i,k The expression is as follows:

[0028]

[0029] Among them, N is the set of all pixel points, and t i,k is the feature value of the pixel point i in the feature map at the k-th (1 < k < 16) dimension.

[0030] In the above solution, by obtaining the feature map of the fusion gradient attention mechanism, the text region in the image to be detected can be detected more quickly.

[0031] Furthermore, in step S3, among the information of the anchor boxes obtained by training, the width of the anchor box is in a proportional relationship with the height of the anchor box. Among them, the expression of the anchor box B is as follows:

[0032] B = (x, y, h, r, cosθ, sinθ, c)

[0033] Among them, x and y are the image coordinate points of the anchor box, h is the height of the anchor box, r is the aspect ratio of the width to the height of the anchor box, θ is the angle formed by the side of the anchor box close to the horizontal direction and the horizontal direction, and c is the confidence of the anchor box.

[0034] Furthermore, in step S4, the vector is input into the graph neural network for learning to obtain the deep relationship between the anchor boxes. The process is as follows:

[0035] Before the vector is input into the graph neural network, multiple local graphs are constructed for each image to be detected. The local graphs are composed of several nodes, and each local graph only contains part of the anchor point box.

[0036] Calculate the similarity E of the Euclidean distance between local graph nodes S , as auxiliary information to help the graph neural network obtain the deep relationship between the anchor boxes, E S The expression is:

[0037]

[0038] Among them, D(p, v i ) is the hub p and node v i The distance between m and W m are the height and width of the image, V p are all the nodes in the local graph where the hub p is located;

[0039] Where D(p,v i ) is as follows:

[0040]

[0041] Among them, x p is the horizontal coordinate of the center p, For node v i The horizontal axis, y p is the ordinate of the center p, For node v i The vertical coordinate of

[0042] Set constraints G on the hub p iou , whose expression is:

[0043]

[0044] Among them, ξ is the set threshold, G p is the local graph G p , G q is the local graph G q , hub p and hub q are in the same text instance T, G p ∪G q is the local graph G p and the local graph G q The union of G p ∩G q is the local graph G p and the local graph G qThe intersection of;

[0045] In the above scheme, the deep relationship between the anchor boxes refers to the connection relationship between the anchor boxes. The hub refers to the anchor box with higher confidence, which is used as a node to generate the local graph. The restriction condition G iou The role of is to prevent too many identical nodes between different local graphs; building multiple local graphs can improve the learning speed of graph neural networks.

[0046] Furthermore, the specific process of step S5 is as follows:

[0047] The deep relationship between each anchor box is judged through the graph neural network, the correlation between each anchor box is judged, each anchor box is grouped, and the anchor boxes with high correlation are screened out. The anchor boxes with high correlation are connected to obtain the text prediction area, and NMS is used to reduce redundancy. BFS is used to cluster and merge the connected anchor boxes to obtain the text output area;

[0048] The loss function L is set for the text prediction area, and its expression is as follows:

[0049]

[0050] Where b is the text prediction area, c is the confidence of the anchor box, l is the coordinate position of the anchor box, g is the actual text area, N is the number of anchor boxes matching the actual text area, and L conf is the cross entropy loss function of the text prediction area confidence, L loc Position loss function for text prediction area;

[0051] Cross entropy loss function L of text prediction area confidence conf , which is expressed as follows:

[0052]

[0053] in, is the true label of the text prediction area, the positive class is 1 and the negative class is 0;

[0054] Position loss function L of text prediction area loc , which is expressed as follows:

[0055]

[0056] Among them, m is the Euclidean distance between the position of the text prediction area b and the actual text area, and its expression is as follows:

[0057]

[0058] In the above scheme, by setting the loss function, the accuracy of the anchor box can be judged by referring to the position and confidence of the anchor box at the same time, thereby improving the accuracy of the graph neural network.

[0059] In the above scheme, NMS (Non-Maximum Suppression) is used to reduce redundancy, and BFS (Breadth First Search) is used to cluster and merge the connected anchor boxes, and the anchor boxes with high correlation determined by the graph neural network are connected to obtain the text output area, thereby improving the negative impact of background noise information on the anchor boxes.

[0060] In the above scheme, high correlation means that the possibility of connection between anchor boxes is high.

[0061] Furthermore, the specific process of step S6 is as follows:

[0062] The obtained text output area is cut to obtain a number of image blocks, and the number of image blocks are respectively input into the standard image for comparative analysis, and a sliding window operation is performed on the standard image block to measure the similarity between the image block after the text output area is cut and the standard image block, and defect detection is performed based on the matched similarity to determine whether there is a position defect or a content defect, thereby completing the defect detection of the image to be detected; wherein the standard image refers to a perfect, flawless printed image, which is composed of standard image blocks;

[0063] When judging whether there is a position defect or a content defect, a threshold needs to be set. After measuring the similarity between the image block after the text output area is cut and the standard image block, the similarity between the text output area and the standard image is obtained. If the similarity is lower than the set threshold, it is determined that a position defect or a content defect is detected, and then the image to be detected is determined to have a defect; if the position defect or the content defect is not detected, it is determined that the image to be detected is flawless.

[0064] Furthermore, the present invention provides an image defect detection system for implementing an image defect detection method, comprising: a feature extraction module, a fusion gradient attention mechanism module, an anchor box clustering merging module and a standard image comparison module, wherein:

[0065] The feature extraction module is used to extract gradient features of the image to be detected to obtain a gradient map; and the image to be detected is input into a convolutional neural network to obtain a feature map through training;

[0066] The fused gradient attention mechanism module is used to fuse the gradient map with the feature map to obtain a feature map of the fused gradient attention mechanism;

[0067] The anchor point frame clustering and merging module is used to cluster and merge the anchor point frames according to the deep relationship between the anchor point frames to obtain a text output area;

[0068] The standard image comparison module is used to compare the text output area with the standard image to determine whether the text output area has defects.

[0069] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:

[0070] The present invention proposes an image defect detection method, which generates an anchor point frame with adaptive aspect ratio to better fit the text area in the image to be detected, and uses a graph neural network to obtain the deep relationship between each anchor point frame, so that the anchor point frames can be better clustered and merged, and the text information and text positions of different scales on the image to be detected can be located more quickly and accurately, which facilitates the processing of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;

[0072] In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and are not the sizes of actual products;

[0073] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.

[0074] Figure 1 A flow chart of the steps of detecting image defects to be detected in an image defect detection method provided by an embodiment of the present invention;

[0075] Figure 2 A schematic diagram of an application of an image defect detection method to be detected provided by an embodiment of the present invention;

[0076] Figure 3 A schematic diagram of the network structure of an anchor box generation algorithm provided in one embodiment of the present invention. DETAILED DESCRIPTION

[0077] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0078] Example 1

[0079] For easier understanding, see Figure 1 and Figure 2 The present application provides an embodiment of an image defect detection method, comprising the following steps:

[0080] S1: Extract gradient features of the image to be detected to obtain a gradient map; input the image to be detected into a convolutional neural network for training to obtain a feature map;

[0081] S2: Fuse the gradient map with the feature map to obtain a feature map with a fused gradient attention mechanism;

[0082] S3: Input the feature map of the fused gradient attention mechanism into the convolutional neural network and train to obtain several anchor boxes with adaptive aspect ratios;

[0083] S4: Build a graph neural network, upgrade the dimensions of several aspect ratio adaptive anchor boxes to obtain vectors, input the vectors into the graph neural network for learning, and obtain the deep relationship between the anchor boxes;

[0084] S5: clustering and merging the anchor boxes according to the deep relationship between the anchor boxes to obtain the text output area;

[0085] S6: Compare the text output area with the standard image to complete the defect detection of the image to be detected.

[0086] The deep relationship refers to the corresponding connection relationship between the anchor boxes;

[0087] The present invention generates an anchor point frame with adaptive aspect ratio and uses a graph neural network to obtain the deep relationship between the anchor point frames, so that the anchor point frames can be better clustered and merged, and the position of the text information on the image to be detected can be quickly and accurately located, which facilitates the processing of defect detection.

[0088] Example 2

[0089] On the basis of Example 1, the scheme is described in combination with specific implementation examples to further reflect the technical effects of the scheme, specifically:

[0090] S1: Extract gradient features of the image to be detected to obtain a gradient map; input the image to be detected into a convolutional neural network for training to obtain a feature map;

[0091] S2: Fuse the gradient map with the feature map to obtain a feature map with a fused gradient attention mechanism;

[0092] S3: Input the feature map of the fused gradient attention mechanism into the convolutional neural network and train to obtain several anchor boxes with adaptive aspect ratios;

[0093] S4: Build a graph neural network, upgrade the dimensions of several aspect ratio adaptive anchor boxes to obtain vectors, input the vectors into the graph neural network for learning, and obtain the deep relationship between the anchor boxes;

[0094] S5: clustering and merging the anchor boxes according to the deep relationship between the anchor boxes to obtain the text output area;

[0095] S6: Compare the text output area with the standard image to complete the defect detection of the image to be detected.

[0096] Specifically, in step S1, the image to be detected is a carton packaging printed matter image.

[0097] In the specific implementation process, text detection can locate the text area in the image by analyzing the information of the image, usually marking the words or text lines in the form of a bounding box. There are often a large number of text areas in carton printing. Applying the text detection task to carton defect detection can quickly locate the area where the carton text is located, and then perform subsequent operations on the area to more quickly and accurately determine whether there are printing defects in the area.

[0098] Specifically, in step S1, when performing gradient feature extraction on the image to be detected, the horizontal gradient value and the vertical gradient value of the image to be detected are calculated respectively, and the larger gradient value is taken as the final gradient value;

[0099] The process is as follows: for the pixel i with coordinates (x, y) in the image to be detected, the larger one is selected from the horizontal gradient and the vertical gradient to be assigned as the final gradient value g of the pixel i. i , which is expressed as follows:

[0100]

[0101] Where f(x, y) refers to the pixel value of pixel i at image coordinates (x, y).

[0102] Specifically, the feature map is a 16-dimensional feature map.

[0103] Specifically, step S2 is as follows:

[0104] The final gradient value is normalized to obtain the weight value, and then the weight value is fused with the feature map to obtain the feature map of the fused gradient attention mechanism, thereby improving the attention of the convolutional neural network to the edge area of ​​the text in the image to be detected.

[0105] In the specific implementation process, the text information in the image to be detected has the characteristic of clear boundaries. The gradient value of pixel point i on the image to be detected is fused with the 16-dimensional feature map to obtain the feature map of the fused gradient attention mechanism, thereby enhancing the weight of the boundary area of ​​the image to be detected in the convolutional neural network task.

[0106] Among them, the feature value T of the feature map of the fusion gradient attention mechanism at the k-th dimension pixel i i,k The expression is as follows:

[0107]

[0108] where N is the set of all pixel points, and t i,k is the feature value of the pixel point i in the k-th (1 < k < 16) dimension of the feature map.

[0109] Specifically, in step S3, among the information of the anchor boxes obtained by training, the width of the anchor box is in a proportional relationship with the height of the anchor box, that is, the feature map integrating the gradient attention mechanism is input into the convolutional neural network to obtain a series of ordered rectangular anchor boxes. Each anchor box B formed is associated with a set of geometric attributes. The expression of the anchor box B is as follows:

[0110] B = (x, y, h, r, cosθ, sinθ, c)

[0111] where x and y are the image coordinate points of the anchor box, h is the height of the anchor box, r is the aspect ratio of the width to the height of the anchor box, θ is the angle formed by the side of the anchor box close to the horizontal direction and the horizontal direction, and c is the confidence of the anchor box.

[0112] In the specific implementation process, since the anchor box is usually only connected to its adjacent anchor boxes, constructing a complete image for each prediction task will lead to low computational efficiency. Therefore, multiple local maps are constructed for each image to be detected, and each local map only contains some anchor boxes, which improves the efficiency of the relationship between anchor boxes and the learning speed of the graph neural network.

[0113] In the specific implementation process, in step S3, an anchor box generation algorithm network is constructed. The anchor box generation algorithm network includes 5 downsampling modules, 5 upsampling modules, and 2 fully connected layers. The constructed anchor box generation algorithm network is used as the convolutional neural network. As Figure 3 shown, the feature map integrating the gradient attention mechanism in the image to be detected is successively downsampled through 5 downsampling modules in the anchor box generation algorithm network, and then each downsampling module is upsampled respectively to obtain the upsampling output result. After fusing the upsampling output results, they are input into two fully connected layers to generate anchor boxes with an adaptive aspect ratio. The anchor box regression corresponds to the position coordinates of the anchor box, and the anchor box classification is to judge whether the anchor box is an anchor box containing text.

[0114] Specifically, in step S4, the vector is input into the graph neural network for learning to obtain the deep relationship between each anchor box. The process is as follows:

[0115] Before the vector is input into the graph neural network, multiple local maps are constructed for each image to be detected. The local map consists of several nodes, and each local map only contains some anchor boxes;

[0116] Calculate the similarity E of the Euclidean distance between the nodes of the local map S , as auxiliary information to help the graph neural network obtain the deep relationship between the anchor boxes, ES The expression is:

[0117]

[0118] Among them, D(p, v i ) is the hub p and node v i The distance between m and W m are the height and width of the image, V p is the set of all nodes in the local graph where the hub p is located;

[0119] Where D(p,v i ) is as follows:

[0120]

[0121] Among them, x p is the horizontal coordinate of the center p, For node v i The horizontal axis, y p is the ordinate of the center p, For node v i The vertical coordinate of .

[0122] In the specific implementation process, in order to avoid the occurrence of many identical local graphs during the training process, which leads to the accumulation of sample gradients, a restriction condition G is set for the hub p in step S4. iou , whose expression is:

[0123]

[0124] Among them, ξ is the set threshold, G p is the local graph G p , G q is the local graph G q , hub p and hub q are in the same text instance T, G p ∪G q is the local graph G p and the local graph G q The union of G p ∩G q is the local graph G p and the local graph G q The intersection of .

[0125] Specifically, the specific process of step S5 is:

[0126] The deep relationship between each anchor box is judged through the graph neural network, the correlation between each anchor box is judged, each anchor box is grouped, and the anchor boxes with high correlation are screened out. The anchor boxes with high correlation are connected to obtain the text prediction area, and NMS is used to reduce redundancy. BFS is used to cluster and merge the connected anchor boxes to obtain the text output area;

[0127] The loss function L is set for the text prediction area, and its expression is as follows:

[0128]

[0129] Where b is the text prediction area, c is the confidence of the anchor box, l is the coordinate position of the anchor box, g is the actual text area, N is the number of anchor boxes matching the actual text area, and L conf is the cross entropy loss function of the text prediction area confidence, L loc Position loss function for text prediction area;

[0130] Cross entropy loss function L of text prediction area confidence conf , which is expressed as follows:

[0131]

[0132] in, is the true label of the text prediction area, the positive class is 1 and the negative class is 0;

[0133] Position loss function L of the text prediction area loc , which is expressed as follows:

[0134]

[0135] Among them, m is the Euclidean distance between the position of the text prediction area b and the actual text area, and its expression is as follows:

[0136]

[0137] In the above scheme, by setting the loss function, the accuracy of the anchor box can be judged by referring to the position and confidence of the anchor box at the same time, thereby improving the accuracy of the graph neural network.

[0138] In the above scheme, NMS (Non-Maximum Suppression) is used to reduce redundancy, and BFS (Breadth First Search) is used to cluster and merge the connected anchor boxes, and the anchor boxes with high correlation determined by the graph neural network are connected to obtain the text output area, thereby improving the negative impact of background noise information on the anchor boxes.

[0139] Specifically, the specific process of step S6 is:

[0140] The obtained text output area is cut to obtain a number of image blocks, and the number of image blocks are respectively input into the standard image for comparative analysis, and a sliding window operation is performed on the standard image block to measure the similarity between the image block after the text output area is cut and the standard image block, and defect detection is performed based on the matched similarity to determine whether there is a position defect or a content defect, thereby completing the defect detection of the image to be detected; wherein the standard image refers to a perfect, flawless printed image, which is composed of standard image blocks;

[0141] When judging whether there is a position defect or a content defect, a threshold needs to be set. After measuring the similarity between the image block after the text output area is cut and the standard image block, the similarity between the text output area and the standard image is obtained. If the similarity is lower than the set threshold, it is determined that a position defect or a content defect is detected, and then the image to be detected is determined to have a defect; if the position defect or the content defect is not detected, it is determined that the image to be detected is flawless.

[0142] The present invention proposes an image defect detection method, which generates an anchor point frame with adaptive aspect ratio to better fit the text area in the image to be detected, constructs multiple local graphs for each image to be detected, and each local graph only contains part of the anchor point frame. The anchor point frame with adaptive aspect ratio is input into a graph neural network for learning, so that the anchor point frame can be better clustered and merged, and the text information and the position of the text of different scales on the image to be detected can be located more quickly and accurately, thereby greatly improving the defect detection efficiency of the text area in the printed image.

[0143] Example 3

[0144] Specifically, based on the above embodiments, the scheme is described in combination with specific implementation examples to further reflect the technical effects of the scheme, which are specifically:

[0145] The present invention provides an image defect detection system, comprising: a feature extraction module, a fusion gradient attention mechanism module, an anchor box clustering merging module and a standard image comparison module, wherein:

[0146] The feature extraction module is used to extract gradient features of the image to be detected to obtain a gradient map; and the image to be detected is input into a convolutional neural network to obtain a feature map through training;

[0147] The fused gradient attention mechanism module is used to fuse the gradient map with the feature map to obtain a feature map of the fused gradient attention mechanism;

[0148] The anchor point frame clustering and merging module is used to cluster and merge the anchor point frames according to the deep relationship between the anchor point frames to obtain a text output area;

[0149] The standard image comparison module is used to compare the text output area with the standard image to determine whether the text output area has defects.

[0150] In this embodiment, an image defect detection system is constructed to realize rapid positioning of images in cartons containing text printed in various scales, and to locate the position of the text in the image, so as to better conduct research on image defect detection.

[0151] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled 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 list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A method for detecting image defects, characterized in that: The following steps are involved: S1: Extract gradient features of the image to be detected to obtain a gradient map; input the image to be detected into a convolutional neural network for training to obtain a feature map; S2: Fuse the gradient map with the feature map to obtain the feature map of the fused gradient attention mechanism, specifically: Normalize the final gradient value to get the weight value, and then fuse the weight value with the feature map to get the feature map of the fused gradient attention mechanism; Among them, the feature value T of the feature map of the fusion gradient attention mechanism at the k-th dimension pixel i i,k The expression is as follows: Among them, g i is the final gradient value of pixel i. The method of obtaining the value is to calculate the horizontal gradient value and the vertical gradient value of the image to be detected respectively when extracting the gradient feature of the image to be detected, and take the larger gradient value as the final gradient value. N is the set of all pixel points, t i,k is the eigenvalue of pixel i in the kth dimension in the feature map, 1 <k<16; S3: Input the feature map of the fused gradient attention mechanism into the convolutional neural network and train to obtain several anchor boxes with adaptive aspect ratios; S4: Build a graph neural network, upgrade the dimensions of several aspect ratio adaptive anchor boxes to obtain vectors, input the vectors into the graph neural network for learning, and obtain the deep relationship between the anchor boxes; S5: clustering and merging the anchor boxes according to the deep relationship between the anchor boxes to obtain the text output area; S6: Compare the text output area with the standard image to complete the defect detection of the image to be detected.

2. The image defect detection method according to claim 1, characterized in that: In step S1, the image to be detected is a carton packaging printed image.

3. The image defect detection method according to claim 1, characterized in that: In step S1, when performing gradient feature extraction on the image to be detected, the horizontal gradient value and the vertical gradient value of the image to be detected are calculated respectively, and the larger gradient value is taken as the final gradient value; The process is as follows: for the pixel i with coordinates (x, y) in the image to be detected, the larger one is selected from the horizontal gradient and the vertical gradient to be assigned as the final gradient value g of the pixel i. i , which is expressed as follows: Where f(x, y) refers to the pixel value of pixel i at image coordinates (x, y).

4. The image defect detection method according to claim 1, characterized in that: In step S1, the feature map is a 16-dimensional feature map.

5. The image defect detection method according to claim 1, characterized in that: In step S3, the anchor box expression is as follows: B=(x,y,h,r,cosθ,sinθ,c) Among them, x and y are the image coordinates of the anchor box, h is the height of the anchor box, r is the aspect ratio of the anchor box, θ is the angle between the horizontal side of the anchor box and the horizontal direction, and c is the confidence of the anchor box.

6. The image defect detection method according to claim 1, characterized in that: In step S4, the vector is input into the graph neural network for learning to obtain the deep relationship between the anchor boxes. The process is as follows: Before the vector is input into the graph neural network, multiple local graphs are constructed for each image to be detected. The local graphs are composed of several nodes, and each local graph only contains part of the anchor point box. Calculate the similarity E of the Euclidean distance between local graph nodes S , whose expression is: Among them, D(p, v i ) is the hub p and node v i The distance between m and W m are the height and width of the image, V p is the set of all nodes in the local graph where the hub p is located; Among them, D(p, v i ) is as follows: Among them, x p is the horizontal coordinate of the center p, x vi For node v i The horizontal axis, y p is the ordinate of the center p, y vi For node v i The vertical coordinate of Set constraints G on the hub p iou , whose expression is: Among them, ξ is the set threshold, G p is the local graph G p , G q is the local graph G q , hub p and hub q are in the same text instance T, G p ∪G q is the local graph G p and the local graph G q The union of G p ∩G q is the local graph G p and the local graph G q The intersection of .

7. The image defect detection method according to claim 1, characterized in that: The specific process of step S5 is: The deep relationship between each anchor box is judged through the graph neural network, the correlation between each anchor box is judged, each anchor box is grouped, and the anchor boxes with high correlation are screened out. The anchor boxes with high correlation are connected to obtain the text prediction area, and NMS is used to reduce redundancy. BFS is used to cluster and merge the connected anchor boxes to obtain the text output area; The loss function L is set for the text prediction area, and its expression is as follows: Where b is the text prediction area, c is the confidence of the anchor box, l is the coordinate position of the anchor box, g is the actual text area, N is the number of anchor boxes matching the actual text area, and L conf is the cross entropy loss function of the text prediction area confidence, L loc Position loss function for text prediction area; Cross entropy loss function L of text prediction area confidence conf , which is expressed as follows: in, is the true label of the text prediction area, the positive class is 1 and the negative class is 0; Position loss function L of text prediction area loc , which is expressed as follows: Among them, m is the Euclidean distance between the position of the text prediction area b and the actual text area, and its expression is as follows:

8. The image defect detection method according to claim 1, characterized in that: The specific process of step S6 is: The obtained text output area is cut to obtain a number of image blocks, and the number of image blocks are respectively input into the standard image for comparative analysis, and a sliding window operation is performed on the standard image block to measure the similarity between the image block after the text output area is cut and the standard image block, and defect detection is performed based on the matched similarity to determine whether there is a position defect or a content defect, thereby completing the defect detection of the image to be detected; wherein the standard image refers to a perfect, flawless printed image, which is composed of standard image blocks; When judging whether there is a position defect or a content defect, a threshold needs to be set. After measuring the similarity between the image block after the text output area is cut and the standard image block, the similarity between the text output area and the standard image is obtained. If the similarity is lower than the set threshold, it is determined that a position defect or a content defect is detected, and then the image to be detected is determined to have a defect; if the position defect or the content defect is not detected, it is determined that the image to be detected is flawless.

9. An image defect detection system, comprising: Feature extraction module, fusion gradient attention mechanism module, anchor box clustering merging module and standard image comparison module, where: The feature extraction module is used to extract gradient features of the image to be detected to obtain a gradient map; and the image to be detected is input into a convolutional neural network to obtain a feature map through training; The fused gradient attention mechanism module is used to fuse the gradient map with the feature map to obtain the feature map of the fused gradient attention mechanism, specifically: Normalize the final gradient value to get the weight value, and then fuse the weight value with the feature map to get the feature map of the fused gradient attention mechanism; Among them, the feature value T of the feature map of the fusion gradient attention mechanism at the k-th dimension pixel i i,k The expression is as follows: Among them, g i is the final gradient value of pixel i. The method of obtaining the value is to calculate the horizontal gradient value and the vertical gradient value of the image to be detected respectively when extracting the gradient feature of the image to be detected, and take the larger gradient value as the final gradient value. N is the set of all pixel points, t i,k is the eigenvalue of pixel i in the kth dimension in the feature map, 1 <k<16; The anchor point frame clustering and merging module is used to cluster and merge the anchor point frames according to the deep relationship between the anchor point frames to obtain a text output area; The standard image comparison module is used to compare the text output area with the standard image to determine whether the text output area has defects.

Citation Information

Patent Citations

  • A cloth defect detection method based on regional fusion characteristics

    CN109685766A

  • Industrial product anomaly detection method, system and device and storage medium

    CN114066811A