A method and system for detecting irregular edge defects

By acquiring the points of the irregular edge and generating an oblique rectangle, and performing grayscale statistics and enhancement processing, the problem of low efficiency in irregular edge defect detection is solved, and fast and accurate irregular edge defect detection is achieved.

CN115880270BActive Publication Date: 2025-10-03SHENZHEN LINGYUN VISION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211707527.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2025-10-03
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

In industrial visual inspection, the detection efficiency of irregular edge defects is low, especially when the grayscale in the edge area changes suddenly. The existing technology is complex to operate and it is difficult to detect irregular edge defects quickly and effectively.

Method used

By obtaining all points of the irregular edge, calculating the tangent slope to generate an oblique rectangle perpendicular to the tangent, performing grayscale statistics to construct the grayscale background of the irregular edge, and using median filtering and least squares curve fitting to enhance the defect, the target to be inspected is segmented by combining morphological processing and area screening.

Benefits of technology

It realizes the rapid detection of irregular edge defects, has good adaptability and detection accuracy, can better restore the true background of defects, and improves detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115880270B_ABST
    Figure CN115880270B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of industrial visual inspection technology, and in particular, relates to a method and system for detecting irregular edge defects. The method and system for detecting irregular edge defects of the present application obtain all points of the irregular edge and arrange them in order; calculate the tangent slope of each point position, and generate an oblique rectangle perpendicular to the tangent according to the tangent slope; perform grayscale statistics on each oblique rectangle to obtain a background grayscale value set of each oblique rectangle; use the background grayscale value set to construct the irregular edge grayscale background; then, based on the feature of smooth grayscale changes of continuous edges, perform defect enhancement on the image and segment the target to be inspected. Since the present application extracts all points of the irregular edge and obtains the contour parameters of the target to be inspected, and adaptively constructs the background according to the path of the contour of the target to be inspected, it can better restore the real background of the defect, and then achieve rapid detection of the target defect by enhancing the defect. It has good adaptability and detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial visual inspection technology, and in particular to a method and system for detecting irregular edge defects. Background Art

[0002] Machine vision is a rapidly developing branch of artificial intelligence in the field of industrial visual inspection. Simply put, machine vision replaces the human eye in measurement and judgment. A machine vision system uses a machine vision product (i.e., an image capture device, available in CMOS and CCD) to convert captured objects into image signals. This signal is then transmitted to a dedicated image processing system, which obtains the object's morphological information and converts it into a digital signal based on pixel distribution, brightness, color, and other information. The image system then performs various operations on these signals to extract the target's features and, based on the resulting analysis, controls the operation of on-site equipment.

[0003] In industrial visual inspection, core areas are often easier to detect due to the stable grayscale values ​​of the surrounding areas. However, edge areas are more difficult to detect due to the sudden grayscale changes between the target and the background. This often requires the construction of special filters to enhance the inspection image before performing segmentation. Therefore, different filters are generally required for edge areas of different shapes and positions, making the operation more complex and difficult for on-site technicians to master quickly. This affects the efficiency of inspecting defects, especially those with irregular edges. Summary of the Invention

[0004] The present application provides a method and system for detecting irregular edge defects to solve the current problem of low efficiency in detecting irregular edge defects.

[0005] The technical solutions adopted in this application are as follows:

[0006] In a first aspect of the present application, a method for detecting irregular edge defects is provided, comprising the following steps:

[0007] Get all the points of the special-shaped edge and arrange them in order;

[0008] Calculate the slope of the tangent at each point, and generate an oblique rectangle perpendicular to the tangent according to the slope of the tangent;

[0009] Perform grayscale statistics on each oblique rectangle to obtain the background grayscale value set of each oblique rectangle;

[0010] Construct the grayscale background of the irregular edge using the background grayscale value set;

[0011] Then, based on the feature of smooth grayscale changes of continuous edges, the image defects are enhanced and the target to be inspected is segmented.

[0012] In conjunction with the first aspect of the present application, in some embodiments, the step of constructing the irregular edge grayscale background using the background grayscale value set includes:

[0013] Perform median filtering on the background gray value set array;

[0014] The background grayscale value set array after median filtering is subjected to least squares curve fitting to obtain a true background array. The true background array means the true background grayscale value of each oblique rectangle. The true background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

[0015] In combination with the first aspect of the present application, in some embodiments, it also includes: for the detection of defects of different sizes, the irregular edge grayscale background is constructed by adjusting the median filter scale and the power value of the least squares method in the step of constructing the irregular edge grayscale background.

[0016] In conjunction with the first aspect of the present application, in some embodiments, the median filter scale is n / 20, and the power value of the least squares method is less than or equal to the fourth order.

[0017] In conjunction with the first aspect of the present application, in some embodiments, the step of enhancing defects in the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges includes:

[0018] The final target defect is extracted using morphological processing and area screening.

[0019] In conjunction with the first aspect of the present application, in some embodiments, after the step of calculating the slope of the tangent at each point position and generating an oblique rectangle perpendicular to the tangent according to the tangent slope, the method further includes:

[0020] Masks the image to produce a skewed rectangle perpendicular to the tangent lines.

[0021] In conjunction with the first aspect of the present application, in some embodiments, the step of obtaining all points of the irregular edge and arranging them in sequence further includes:

[0022] The number of all points for obtaining the irregular edge is reduced by interpolation.

[0023] In conjunction with the first aspect of the present application, in some embodiments, the step of performing defect enhancement on the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges further includes:

[0024] Each oblique rectangle is traversed again to obtain a grayscale value set of the image within the oblique rectangle, and the grayscale value set of the image within the oblique rectangle is segmented using a true background array to obtain an initial target defect.

[0025] A second aspect of the present application provides a system for detecting irregular edge defects, comprising:

[0026] Contour point extraction unit, used to obtain all points of the irregular edge and arrange them in order;

[0027] The oblique rectangle production unit is used to calculate the slope of the tangent at each point and generate an oblique rectangle perpendicular to the tangent according to the slope of the tangent;

[0028] A grayscale statistics unit, configured to perform grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle;

[0029] A background construction unit is used to construct a grayscale background of an irregular edge using a background grayscale value set;

[0030] The target segmentation unit is used to enhance the defects of the image and segment the target to be inspected based on the characteristics of smooth grayscale changes of continuous edges.

[0031] In conjunction with the second aspect of the present application, in some embodiments, the present invention further includes a real background unit configured to perform the following steps:

[0032] Perform median filtering on the background gray value set array;

[0033] The background grayscale value set array after median filtering is subjected to least squares curve fitting to obtain a true background array. The true background array means the true background grayscale value of each oblique rectangle. The true background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

[0034] The beneficial effects of adopting the technical solution of this application are as follows:

[0035] The present application discloses a method and system for detecting defects on irregular edges. The method obtains all points on the irregular edge and arranges them in order; calculates the slope of the tangent at each point, and generates an oblique rectangle perpendicular to the tangent based on the tangent slope; performs grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle; uses the background grayscale value set to construct an irregular edge grayscale background; and then, based on the characteristic of smooth grayscale changes on continuous edges, enhances the image and segments the target to be inspected. Since the present application extracts all points on the irregular edge and obtains the contour parameters of the target to be inspected, and adaptively constructs the background based on the path of the target's contour, it can better restore the true background of the defect. Furthermore, by enhancing the defect, it achieves rapid detection of the target defect. The system has good adaptability and detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0037] Figure 1 This is a flowchart of an embodiment of the first aspect of the present application;

[0038] Figure 2 This is a schematic diagram of extracting the detection area in the embodiment of the first aspect of the present application;

[0039] Figure 3 This is a flowchart of constructing a grayscale background with an irregular edge in another embodiment of the first aspect of the present application.

[0040] Figure 4 A schematic diagram of generating an oblique rectangle in an embodiment of the first aspect of the present application;

[0041] Figure 5 This is a schematic diagram of a background grayscale value set in an embodiment of the first aspect of the present application;

[0042] Figure 6 This is a schematic diagram of a true background grayscale value set in an embodiment of the first aspect of the present application;

[0043] Figure 7 This is a schematic diagram of segmenting a target to be inspected in an embodiment of the first aspect of the present application;

[0044] Figure 8A This is a schematic diagram of an oblique rectangle generated by unmasking in an embodiment of the first aspect of the present application;

[0045] Figure 8B for Figure 8A Schematic diagram of the middle mask processing;

[0046] Figure 8C for Figure 8B Schematic diagram of the oblique rectangle generated after mask processing. DETAILED DESCRIPTION

[0047] The following embodiments are described in detail, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numbers in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following embodiments are not intended to represent all possible implementations consistent with the present application. They are merely examples of systems and methods consistent with certain aspects of the present application, as detailed in the claims.

[0048] See also Figure 1 , which is a flowchart of an embodiment of the first aspect of this application.

[0049] In a first aspect of the present application, a method for detecting irregular edge defects is provided, comprising the following steps:

[0050] S101, obtain all points of the irregular edge and arrange them in order;

[0051] S102, calculating the slope of the tangent line at each point, and generating an oblique rectangle perpendicular to the tangent line according to the slope of the tangent line;

[0052] S103, performing grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle;

[0053] S104, constructing a grayscale background of an irregular edge using a background grayscale value set;

[0054] S105 , based on the feature of smooth grayscale changes of continuous edges, the image is enhanced for defects and the target to be inspected is segmented.

[0055] refer to Figure 2 In some embodiments, regarding the method of obtaining all points of the irregular edge, the acquisition method can be through a threshold value, or through an edge detection method, etc., the purpose of which is to obtain the precise outline of the target to be inspected, which is not limited in this application. In order to obtain the precise outline of the target to be inspected, any method can be selected to obtain all points of the irregular edge, and the acquired points can be arranged in sequence. In addition, the distance between all points of the acquired irregular edge is generally not less than one image pixel distance, and it can also depend on the detection accuracy. The smaller the distance, the higher the accuracy and the more accurate the defect detection. But at the same time, the quality requirements for the image to be inspected will also be further improved, which will also have a certain impact on the computing speed and time during the later traversal.

[0056] refer to Figure 3 In conjunction with the first aspect of the present application, in some embodiments, the step of constructing a grayscale background of an irregular edge using a background grayscale value set includes:

[0057] S201, performing median filtering on the background gray value set array;

[0058] S202, using least squares curve fitting to the background grayscale value set array after median filtering to obtain a real background array, wherein the real background array means the real background grayscale value of each oblique rectangle, and the real background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

[0059] In combination with the first aspect of the present application, in some embodiments, it also includes: for the detection of defects of different sizes, the irregular edge grayscale background is constructed by adjusting the median filter scale and the power value of the least squares method in the step of constructing the irregular edge grayscale background.

[0060] refer to Figure 2 and Figure 4 In some embodiments, in actual operation, the detection region Region and the image to be detected Image are first obtained. The detection region is generally input by positioning and will not be expanded here. All points of the outer contour of the detection region are obtained, and the detection region is processed to obtain the region contour point set list_P(x,y); the tangent slope k of each point of the contour is calculated and the oblique rectangular statistical matrix P is generated; n (x,y) is a point on the contour, P n-1 (x,y) and P n+1 (x,y) is the point P n If there are two adjacent points (x, y), then the slope k at that point can be obtained. n :

[0061] k n =(y n-1 -y n+1 ) / (x n-1 -x n+1 )

[0062] According to the slope and the coordinates of the point, an oblique rectangle Rect can be generated, such as Figure 4 As shown; the length of the oblique rectangle Rect is the range C of the detection area, and the width of the oblique rectangle is point P n-1 (x,y) and P n+1 The distance D between two points (x, y); perform grayscale statistics on the oblique rectangle to obtain the background grayscale value set list_Bgv, such as Figure 5 shown.

[0063] Traverse list_Rect and obtain the median M of the grayscale values ​​of all points in the oblique rectangle list_Rect of Image, and pass it into the background grayscale value set list_Bgv, list_Bgv = [M0, M1, M2, ..., Mn];

[0064] In some embodiments, the background grayscale value set can actually be understood as a grayscale background with an irregular edge, i.e., a grayscale linear background. The image to be detected is two-dimensional data, and list_Bgv is the one-dimensional data of the image compressed and reduced along the vertical contour line. Here, Mn represents the grayscale background value at the nth oblique rectangle.

[0065] In some embodiments, background enhancement may be performed by the following methods:

[0066] First, perform a median filter of size n / 20 on the list_Bgv array to remove suspected interference caused by defects;

[0067]

[0068] Secondly, use the least squares curve fitting to get the real background list_Bgv_R, such as Figure 6 shown.

[0069] After image enhancement, the target defect needs to be segmented. In some embodiments, by traversing each oblique rectangle Rect, the grayscale value GrayValues ​​of the image in the oblique rectangle is obtained, and the grayscale value list_Bgv_R is used to segment the image to obtain the initial target defect. However, the target defect has a certain degree of interference. Figure 7 As shown; therefore, the initial target defect results still need to be screened, for example, the defect pair area is extracted and binary screened to obtain the final target defect.

[0070] In conjunction with the first aspect of the present application, in some embodiments, the median filter scale is n / 20, and the power value of the least squares method is less than or equal to the fourth order.

[0071] In fact, the median filter scale can be designed accordingly according to the size of the defect. For different defect scales, a single filter may not be able to construct a better background to detect defects, so several filter scales are needed to detect all defects. In addition, in appearance inspection, the background is generally relatively uniform, and the grayscale changes will not be too large. Therefore, the power value of the least squares method generally uses the fourth order or less to meet the requirements. In some embodiments of the present application, the third order can be selected.

[0072] In conjunction with the first aspect of the present application, in some embodiments, the step of enhancing defects in the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges includes:

[0073] The final target defect is extracted using morphological processing and area screening.

[0074] In conjunction with the first aspect of the present application, in some embodiments, after the step of calculating the slope of the tangent at each point position and generating an oblique rectangle perpendicular to the tangent according to the tangent slope, the method further includes:

[0075] Masks the image to produce a skewed rectangle perpendicular to the tangent lines.

[0076] In the background construction stage of some embodiments, a mask can be used together. For example, after generating list_Rect, a mask operation can be performed on it to remove unnecessary statistical areas, making the grayscale value statistics more accurate and the background reconstruction closer to the real background, which is conducive to the rapid detection of target defects. Figure 8A As shown in FIG. 1 , a schematic diagram of an oblique rectangle generated without masking in the embodiment of the first aspect of the present application is shown. After masking, as shown in FIG. 1 , Figure 8BAs shown in , unnecessary statistical areas are removed, making the grayscale value statistics more accurate and the background reconstruction closer to the real background; Figure 8C The figure shows a schematic diagram of the oblique rectangle produced after masking. Since the mask covers the upper and lower areas, the oblique rectangle is limited and the statistical area becomes smaller, making the grayscale value statistics more accurate and more efficient. The principle of the mask operation adopted in this application is: (1) Set the mask to Mask. The shape and size of Mask are not fixed and can be set arbitrarily; (2) Traverse list_Rect and perform the Difference operation on each Rect using Mask.

[0077] In conjunction with the first aspect of the present application, in some embodiments, the step of obtaining all points of the irregular edge and arranging them in sequence further includes:

[0078] The number of all points for obtaining the irregular edge is reduced by interpolation.

[0079] In the above embodiment, although interpolation processing may result in a certain degree of loss in accuracy, in scenes with a uniform background, the grayscale consistency around the contour is generally good, and the impact of appropriate interpolation on accuracy can be ignored. On the contrary, it can effectively improve the algorithm's operating speed, save computing time, and indirectly improve the efficiency of target defect detection.

[0080] In conjunction with the first aspect of the present application, in some embodiments, the step of performing defect enhancement on the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges further includes:

[0081] Each oblique rectangle is traversed again to obtain a grayscale value set of the image within the oblique rectangle, and the grayscale value set of the image within the oblique rectangle is segmented using a true background array to obtain an initial target defect.

[0082] A second aspect of the present application provides a system for detecting irregular edge defects, comprising:

[0083] Contour point extraction unit, used to obtain all points of the irregular edge and arrange them in order;

[0084] The oblique rectangle production unit is used to calculate the slope of the tangent at each point and generate an oblique rectangle perpendicular to the tangent according to the slope of the tangent;

[0085] A grayscale statistics unit, configured to perform grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle;

[0086] A background construction unit is used to construct a grayscale background of an irregular edge using a background grayscale value set;

[0087] The target segmentation unit is used to enhance the defects of the image and segment the target to be inspected based on the characteristics of smooth grayscale changes of continuous edges.

[0088] In conjunction with the second aspect of the present application, in some embodiments, the present invention further includes a real background unit configured to perform the following steps:

[0089] Perform median filtering on the background gray value set array;

[0090] The background grayscale value set array after median filtering is subjected to least squares curve fitting to obtain a true background array. The true background array means the true background grayscale value of each oblique rectangle. The true background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

[0091] The present application discloses a method and system for detecting defects on irregular edges. The method obtains all points on the irregular edge and arranges them in order; calculates the slope of the tangent at each point, and generates an oblique rectangle perpendicular to the tangent based on the tangent slope; performs grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle; uses the background grayscale value set to construct an irregular edge grayscale background; and then, based on the characteristic of smooth grayscale changes on continuous edges, enhances the image and segments the target to be inspected. Since the present application extracts all points on the irregular edge and obtains the contour parameters of the target to be inspected, and adaptively constructs the background based on the path of the target's contour, it can better restore the true background of the defect. Furthermore, by enhancing the defect, it achieves rapid detection of the target defect. The system has good adaptability and detection accuracy.

[0092] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.

[0093] Similar parts between the embodiments provided in this application can be referenced to each other. The specific implementation methods provided above are only a few examples under the overall concept of this application and do not constitute a limitation on the scope of protection of this application. For those skilled in the art, any other implementation methods expanded based on the scheme of this application without expending creative work shall fall within the scope of protection of this application.

Claims

1. A method for detecting irregular edge defects, characterized in that: The following steps are involved: Get all the points of the special-shaped edge and arrange them in order; Calculate the slope of the tangent at each point, and generate an oblique rectangle perpendicular to the tangent according to the slope of the tangent; Perform grayscale statistics on each oblique rectangle to obtain the background grayscale value set of each oblique rectangle; Construct the grayscale background of the irregular edge using the background grayscale value set; Then, based on the characteristics of smooth grayscale changes of continuous edges, the image is enhanced and the target to be inspected is segmented; The step of constructing the grayscale background of the irregular edge by using the background grayscale value set includes: Perform median filtering on the background gray value set array; The background grayscale value set array after median filtering is subjected to least squares curve fitting to obtain a true background array. The true background array means the true background grayscale value of each oblique rectangle. The true background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

2. The method for detecting irregular edge defects according to claim 1, wherein: Also includes: For the detection of defects of different sizes, the grayscale background of irregular edge is constructed by adjusting the median filter scale and the power value of the least square method in the step of constructing the grayscale background of irregular edge.

3. The method for detecting irregular edge defects according to claim 2, wherein: The median filter scale is n / 20, and the power value of the least square method is less than or equal to the fourth order.

4. The method for detecting irregular edge defects according to claim 1, wherein: The step of enhancing defects in the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges includes: The final target defect is extracted using morphological processing and area screening.

5. The method for detecting irregular edge defects according to claim 1, wherein: After the steps of calculating the slope of the tangent line at each point and generating an oblique rectangle perpendicular to the tangent line according to the slope of the tangent line, the method further includes: Masks the image to produce a skewed rectangle perpendicular to the tangent lines.

6. The method for detecting irregular edge defects according to claim 1, wherein: The step of obtaining all points of the irregular edge and arranging them in order further includes: The number of all points for obtaining the irregular edge is reduced by interpolation.

7. The method for detecting irregular edge defects according to claim 1, wherein: The step of enhancing defects in the image and segmenting the target to be inspected based on the feature of smooth grayscale changes of continuous edges further includes: Each oblique rectangle is traversed again to obtain a grayscale value set of the image within the oblique rectangle, and the grayscale value set of the image within the oblique rectangle is segmented using a true background array to obtain an initial target defect.

8. A special-shaped edge defect detection system, characterized in that: include: Contour point extraction unit, used to obtain all points of the irregular edge and arrange them in order; The oblique rectangle production unit is used to calculate the slope of the tangent at each point and generate an oblique rectangle perpendicular to the tangent according to the slope of the tangent; A grayscale statistics unit, configured to perform grayscale statistics on each oblique rectangle to obtain a background grayscale value set for each oblique rectangle; A background construction unit is used to construct a grayscale background of an irregular edge using a background grayscale value set; The target segmentation unit is used to enhance the image defects and segment the target to be inspected based on the characteristics of smooth grayscale changes of continuous edges; The invention also includes a real background unit configured to perform the following steps: Perform median filtering on the background gray value set array; The background grayscale value set array after median filtering is subjected to least squares curve fitting to obtain a true background array. The true background array means the true background grayscale value of each oblique rectangle. The true background array is used to segment the image grayscale value set within the oblique rectangle to obtain the initial target defect.

Citation Information

Patent Citations

  • Edge positioning method and device, storage medium and electronic equipment

    CN111882570A

  • Image edge point acquisition method and device

    CN111968144A