An intelligent character defect detection algorithm based on edge shape matching

Through an intelligent detection algorithm based on edge shape matching, combined with an adaptive image pyramid algorithm and threshold judgment, the problems of low detection efficiency of printed characters and large impact of illumination changes in the existing technology are solved, and high-precision and real-time defect detection is achieved.

CN112884746BActive Publication Date: 2024-08-27QINGDAO STAR-RISING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110215572.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-22
Publication Date
2024-08-27
Estimated Expiration
2041-02-22

AI Technical Summary

Technical Problem

The existing technology has problems in the quality inspection of printed characters, such as low manual detection efficiency and not robust to illumination changes and rotation, making it difficult to meet the needs of industrial automation.

Method used

Adopt an intelligent detection algorithm based on edge shape matching, obtain gradient data through Sobel operator filtering, determine the optimal edge segmentation threshold, combine rough screening and fine screening to find defect points, and use the adaptive image pyramid algorithm and threshold to determine the search that ends early Strategy.

Benefits of technology

It achieves high-precision real-time detection of printing character defects, can accurately detect the defect location of targets at random angles in complex lighting environments, and meets the real-time requirements of industrial inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112884746B
    Figure CN112884746B
Patent Text Reader

Abstract

The present invention discloses an intelligent detection algorithm for character defects based on edge shape matching, including: the algorithm is based on the gradient data obtained after filtering by the Sobel operator, and according to the length of the edge connected domain, the optimal edge segmentation threshold is determined to obtain the gradient direction and coordinates of the edge contour point as matching information. According to the matching degree of the contour points, a combination of coarse screening and fine screening is used to find defective points, and then the character defect area is marked based on the method of finding the connected domain based on the defective point filling. In order to make the matching algorithm meet the real-time requirements, an adaptive image pyramid algorithm and a search strategy that ends early through threshold judgment are adopted. The similarity measurement adopted by the present invention is not affected by occlusion, confusion, linear and nonlinear illumination changes, so character printing defects can still be quickly and accurately located in an environment with changing illumination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the detection of character quality defects in electronic product printing, and in particular to an intelligent character defect detection algorithm based on edge shape matching, which is suitable for related printed character defect detection in various electronic devices. Background Art

[0002] With the rapid development of industrial automation technology, the level of production and manufacturing has gradually improved, and consumers' requirements for product quality have also continued to increase. Therefore, it is very important to control the quality of the product production process.

[0003] In many industrial productions, the printing quality inspection of products still uses traditional manual inspection. Manual inspection mainly relies on the human eye to carefully observe the fonts, characters, and numbers printed on the products, and make judgments based on existing experience or standard models to complete product defect detection. Traditional manual inspection methods are relatively flexible and can quickly adapt to the inspection tasks they are responsible for; however, they require a long period of high mental concentration during inspection, and are easily affected by fatigue or psychological factors, resulting in a decrease in inspection accuracy. At the same time, human eye inspection requires sample-by-sample observation, which is inefficient and difficult to meet the needs of industrial automation.

[0004] Most of the existing product printing quality defect detection methods use a grayscale-based template matching algorithm to locate the printing area, and use the difference between the template image and the located area to achieve target defect detection. This method can effectively detect the color, boundary, and shape of printed fonts, but is greatly affected by changes in lighting and is not robust to rotation. Summary of the invention

[0005] In order to avoid the shortcomings of traditional manual detection and the deficiencies of existing methods, an intelligent character defect detection algorithm based on edge shape matching is proposed. This method is based on the gradient data obtained after Sobel operator filtering, and determines the optimal edge segmentation threshold according to the length of the edge connected domain. The gradient direction and coordinates of the edge contour point are obtained as matching information. According to the matching degree of the contour point, a combination of coarse screening and fine screening is used to find the defect point, and then the character defect area is marked by filling the neighborhood of the defect point to find the connected domain. In order to make the matching algorithm meet the real-time requirements, an adaptive image pyramid algorithm and a search strategy that ends early by threshold judgment are adopted. The results show that this method can achieve high-precision real-time detection of printed character defects.

[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0007] An intelligent character defect detection algorithm based on edge shape matching includes the following steps:

[0008] A. Template creation: Extract the contour points that best describe the printed characters to remove the influence of texture and noise, and use the obtained contour points to calculate their coordinate positions and normalized gradient direction vectors to create templates. Since the target angle in the image to be detected is random, in order to obtain the precise position of the target, a template is created every certain rotation angle step.

[0009] B. Contour matching: Find the gradient direction of the image to be detected, use the dot product value of the gradient of the template edge contour point and the gradient of the corresponding point of the image to be detected as the similarity measure, and obtain the position of the target character on the image to be detected by sliding the window pixel by pixel.

[0010] C. Defect detection and positioning: After obtaining the position of the target on the image to be detected, the defect points are found by combining coarse screening and fine screening according to the matching degree of the character contour points, and the defect position is located by the method of filling the defect points and finding the minimum circumscribed rectangle.

[0011] D. Accelerated search strategy: In order to make the defect detection algorithm meet the real-time requirements of industrial detection, an adaptive image pyramid algorithm and a search strategy that ends early through threshold judgment are adopted.

[0012] The character defect intelligent detection algorithm, wherein the step A specifically includes: firstly, using the Sobel operator to obtain the image grayscale value of the edge detection in the horizontal and vertical directions, but since the image edge obtained by the Sobel operator will be affected by noise, in order to remove the influence of noise and texture, on the basis of extracting the image edge by the Sobel operator, all edge gradient amplitudes are determined, and the edges greater than the edge gradient threshold are extracted from the template image through non-maximum suppression, and then the edges are further segmented at the high curvature points, and the edge image is processed by the Two-Pass connected region marking algorithm to obtain the number of connected domains, and the total edge length is calculated by dividing the number of connected domains to obtain the average edge length. The gradient amplitude corresponding to the maximum value of the average length is set as the edge segmentation threshold. Regarding the determination of the template rotation angle step, the rotation angle step is calculated according to the cosine theorem for the contour point farthest from the template center around the template center. In order to avoid mismatching, the rotation angle step should not be set too large. At the same time, in order to avoid repeated matching, the rotation angle step should not be set too small. In this method, the angle corresponding to the rotation of the line connecting the contour point farthest from the template center and the template center point by 2 pixels is used as the rotation step.

[0013] The character defect intelligent detection algorithm, wherein the step B specifically further comprises: after obtaining the optimal edge contour segmentation threshold, using the obtained contour point coordinate position and the normalized gradient direction vector to make a template, the template is converted into a series of character contour points P i =(X i , Y i) T , i = 1, 2, ... n, corresponding to each point to obtain the normalized gradient direction vector d i =(t i ,u i ) T For the image to be detected, use the Sobel operator to filter and calculate the normalized gradient direction vector e of each point (X, Y) x,y =(v x,y , w x,y ) T . The similarity measurement function is:

[0014]

[0015] The character defect intelligent detection algorithm, wherein the step C specifically further includes: after contour matching, each contour point has a matching degree. In the process of defect extraction, a combination of coarse screening and fine screening is used to find defect points, and a method based on filling the defect points to find the minimum circumscribed rectangle is used to extract defects.

[0016] The character defect intelligent detection algorithm, wherein the step D specifically includes that since the matching score in the area outside the target character of the image to be detected is low, the calculation can be terminated in advance at the non-target point and the matching at the next position can be performed. This can effectively speed up the algorithm processing speed and reduce the amount of calculation in the matching process. The strategy of setting a threshold to terminate the calculation can reduce the algorithm running time, but this does not change the complexity of the algorithm. Therefore, the complexity of the algorithm can be reduced by constructing a multi-layer image pyramid.

[0017] The present invention has the following advantages:

[0018] The present invention provides an intelligent character defect detection algorithm based on edge shape matching. According to the average edge length, the optimal edge segmentation threshold is obtained, and the contour points that can best describe the characters are extracted to remove the influence of texture and noise. The coordinate position and the normalized gradient direction vector of the obtained contour points are calculated to make a template. This makes it convenient to perform defect analysis based on the matching degree of each character contour point after matching the target on the image to be detected. The gradient direction is used as the matching feature instead of the gradient size, so that the feature is robust to lighting changes. The adaptive image pyramid algorithm and the search strategy of terminating early through threshold judgment are adopted to make this method meet the real-time requirements of industrial detection. In complex lighting environments, the defect position of targets with random angles in the image to be detected can be detected in real time and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 The figure is a flow chart of an intelligent character defect detection algorithm based on edge shape matching in the present invention.

[0020] Figure 2 Schematic diagram of the template image and the extracted character contour.

[0021] Figure 3 Determine the schematic for the rotation step size.

[0022] Figure 4 The following is an example of a printed character defect image and the detection result diagram. DETAILED DESCRIPTION

[0023] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0024] The present invention provides an intelligent character defect detection algorithm based on edge shape matching, such as Figure 1 As shown, the specific steps are as follows:

[0025] The first step is to extract the contour points that best describe the printed characters to remove the influence of texture and noise, and use the obtained contour points to calculate their coordinate positions and normalized gradient direction vectors to make templates. Since the target angle in the image to be detected is random, in order to obtain the precise position of the target, a template is made every certain rotation angle step.

[0026] Regarding the determination of the rotation angle step, such as Figure 3 As shown, let point O be the center point of the template, point A be the farthest contour point, point B be the point after point A is rotated, let the side length AB = 1, OA = OB = a, and use the cosine theorem to find the angle between OA and OB horn.

[0027] The second step is to find the gradient direction of the image to be detected, and use the dot product value of the gradient of the template edge contour point and the gradient of the corresponding point of the image to be detected as the similarity metric, and calculate the position of the target character on the image to be detected by sliding the window pixel by pixel. The similarity metric function is:

[0028] Where, d i =(t i ,u i ) T is the template character contour point P i =(X i , Y i ) T , i = 1, 2, ... n normalized gradient direction vector, e x,y =(v x,y , w x,y ) T is the normalized gradient direction vector of each point (X, Y) in the image to be detected.

[0029] The third step is to find the defect points by combining coarse screening and fine screening according to the matching degree of character contour points after obtaining the position of the target on the image to be detected, and locate the defect position based on the method of filling the defect points and finding the minimum circumscribed rectangle.

[0030] After the target character position is detected on the image to be detected, the points with a target character contour point score greater than or equal to 0.75 are removed, and the points with a score less than 0.75 are retained. Taking into account the influence of noise, the contour points obtained after rough screening may not be the real defect points, so further screening is required. Considering that noise points generally exist in isolation, a certain area of ​​the points obtained by rough screening is traversed. If there are more than a certain number of points with a score less than 0.75 in the area, the point is considered to be a real defect point. After obtaining the real defect point, it is not convenient to determine the specific defect position because the defect point exists discretely. Therefore, in order to locate the area where the character defect is located, the grayscale value in the 12×12 area around the defect point is filled with 255, and the grayscale value of other positions is set to 0. Then find the minimum circumscribed rectangle where the binary image contour is located, which is the character defect area.

[0031] Step 4: In order to make the defect detection algorithm meet the real-time requirements of industrial detection, an adaptive image pyramid algorithm and a search strategy that ends early through threshold judgment are adopted.

[0032] Since the matching score is low in the area outside the target character of the image to be detected, a certain strategy can be adopted to end the calculation in advance at the non-target point and perform matching at the next position. According to the similarity measurement function, we can get the partial sum formula of the similarity measurement as follows:

[0033] Because the vector d i and e x,y is the normalized gradient direction vector, so from the formula, if the sum of the first j items is less than j / n, then the sum of the remaining nj items is less than (nj) / n=1-j / n, so when the partial sum satisfies S j <S min -1+j / n(S min is the set threshold), the calculation of this position can be ended and the calculation of the next position can be carried out.

[0034] This method uses an adaptive image pyramid algorithm. When the number of contour points in a certain layer of the image pyramid is around a certain value, and the number of contour points in the next higher layer is less than this value, the character image still has relatively complete contour feature points in this layer, and we define this layer as the highest layer of the image pyramid. This method sets the number of contour points to 100.

[0035] Figure 4This is an example of a printed character defect image and a detection result diagram. We can see that the target character contour points are accurately matched, and the defect position is also accurately detected. The detection time is within 1 second, indicating that the method of the present invention can achieve high-precision real-time detection of printing defects.

[0036] Of course, the above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiments. It should be noted that all equivalent substitutions and obvious deformation forms made by any technician familiar with the field under the guidance of this specification fall within the essential scope of this specification and should be protected by the present invention.

Claims

1. An intelligent character defect detection algorithm based on edge shape matching, characterized in that: The following steps are involved: A. Template making: Extract the contour points that best describe the printed characters to remove the influence of texture and noise, and use the obtained contour points to calculate their coordinate positions and normalized gradient direction vectors to make templates. Since the target angle in the image to be detected is random, in order to obtain the precise position of the target, a template is made every certain rotation angle step; B. Contour matching: Find the gradient direction of the image to be detected, use the dot product value of the gradient of the template edge contour point and the gradient of the corresponding point of the image to be detected as the similarity measure, and calculate the position of the target character on the image to be detected by sliding the window pixel by pixel; C. Defect detection and positioning: After obtaining the position of the target on the image to be detected, the defect points are found by combining coarse screening and fine screening according to the matching degree of the character contour points, and the defect position is located by the method of filling the defect points and finding the minimum circumscribed rectangle; D. Accelerated search strategy: In order to make the defect detection algorithm meet the real-time requirements of industrial detection, an adaptive image pyramid algorithm and a search strategy that ends early through threshold judgment are used; In step A, the specific extraction method is as follows: Among them, in order to remove the influence of noise and texture, on the basis of extracting the image edge with Sobel operator, all edge gradient amplitudes are determined, edges greater than the edge gradient threshold are extracted from the template image and subjected to non-maximum suppression, and then the edges are further segmented at high curvature points. The edge image is processed using the Two-Pass connected region marking algorithm to obtain the number of connected domains, and the total edge length is calculated and divided by the number of connected domains to obtain the average edge length. The gradient amplitude corresponding to the maximum value of the average length is set as the edge segmentation threshold; In step B, the specific extraction method is as follows: After obtaining the optimal edge contour segmentation threshold, the obtained contour point coordinates and the normalized gradient direction vector are used to create a template, which is converted into a series of character contour points P i =(X i , Y i ) T , i = 1, 2, ... n, corresponding to each point to obtain the normalized gradient direction vector d i =(t i ,u i ) T , for the image to be detected, use the Sobel operator to filter and calculate the normalized gradient direction vector e of each point (X, Y) x,y =(v x,y ,w x,y ) T .

2. According to claim 1, the character defect intelligent detection algorithm based on edge shape matching is characterized in that: In step C, the specific extraction method is as follows: After contour matching, each contour point has a matching degree. In the process of defect extraction, a combination of coarse screening and fine screening is used to find defect points, and defects are extracted based on the method of filling the defect points and finding the minimum circumscribed rectangle.