A method for automatic identification and cutting of metal strip surface defects based on edge detection
By generating high-quality defect areas through edge detection and clustering modules, the problems of false detection and missed detection in metal strip surface defect detection are solved, efficient and accurate defect identification and cutting are achieved, and quantitative assessment of defect levels is provided.
Patent Information
- Application Number
- CN202411929663.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-12-26
AI Technical Summary
In the existing technology of metal strip surface defect detection, the input image contains a large amount of irrelevant information, which leads to false detection or missed detection. In addition, the defect types and background noise in different scenes vary significantly, and fixed parameters are difficult to adapt, resulting in inaccurate detection results and unreasonable cropping.
Adopting the edge detection-based method, by setting the parameter list, edge detection module, clustering module, boundary condition judgment module and defect level judgment module, a defect recognition and cutting model is constructed to quickly locate the defect ROI, filter out irrelevant information, and generate high-quality defect areas.
It improves the real-time and accuracy of detection, solves the problems of false detection and missed detection in detection results, generates a complete and continuous defect area, realizes the quantitative evaluation of defect level, and provides standardized results for actual quality detection.
Smart Images

Figure CN119863440B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an automatic recognition and cutting method for metal strip surface defects based on edge detection, and belongs to the field of computer vision. Background Art
[0002] Metal strips are widely used in aerospace, automotive, electronics, construction, and other key fields, and their surface quality significantly impacts the overall performance of the product. Therefore, surface defect detection is a critical step in the production process, and the simultaneous collection of surface defect visual data facilitates subsequent analysis of the causes of defects, thereby improving production processes and enhancing quality. However, in defect detection tasks, the input image contains a large amount of irrelevant information (such as background noise or normal areas), which can easily interfere with the final detection results, leading to false or missed detections. Directly processing the entire image is not only computationally intensive, but also sparsely populated with effective information, making it difficult to accurately identify defect areas. Therefore, developing a metal strip surface defect detection and cropping software that can quickly locate defect regions of interest (ROIs), filter irrelevant information, and focus resources on critical areas for detection has important research significance and practical application value.
[0003] However, in diverse industrial defect detection task scenarios, the defect types, shapes, sizes, distribution densities and background noise conditions in different scenarios vary significantly. If a single fixed parameter is used, it will be difficult for the system to adapt to all detection requirements, resulting in false detections or missed detections. Therefore, in order to solve the problems of false detection, missed detection and unreasonable cropping caused by "lack of adaptability of fixed parameters", the key parameters of edge detection, clustering, boundary conditions and defect level judgment modules are flexibly configured to provide the system with greater adjustability and adaptability. Users can optimize parameters according to actual application scenarios and defect data to improve the generalization ability of the algorithm and the maintainability and practicality of the system, so that detection tasks can maintain high accuracy and high robustness in different environments.
[0004] Defect detection methods based on deep learning rely heavily on high-performance hardware, while the Canny edge detection method does not require a complex training process and has low requirements for computing resources. It is suitable for running on low-performance devices and is applicable to real-time industrial detection scenarios. The edge detection module can quickly identify defect edges in the image and generate defect contours. In addition, the edge detection results can often provide clear contours of the defect area, providing basic data support for subsequent steps such as clustering and boundary clipping. However, edge detection is easily affected by noise interference, resulting in false detection or missed detection. By reasonably adjusting the input image parameter information and parameterizing the parameter threshold of edge detection, noise interference can be effectively controlled, further improving the robustness and accuracy of detection, and providing reliable basic data for subsequent steps.
[0005] During edge detection, complex defects are often segmented into multiple regions, resulting in fragmented defects and compromising the integrity of the inspection results. By using a clustering algorithm to aggregate scattered defects, we can ensure that fragmented breakpoint defects are identified as a whole, generating a complete and continuous defect region. This improves the rationality of defect ROIs, avoiding the cropping of irrelevant background or the omission of defect information. By optimizing the integrity of inspection results through clustering algorithms, we can provide high-quality input for subsequent cropping boundary calculations and defect grade determination. This approach addresses the pain points of fragmented inspection and provides high-quality data support for subsequent defect ROI cropping and analysis.
[0006] During the defect ROI cropping process, improper boundary settings can lead to interference from irrelevant information or loss of defect information. By properly setting boundary conditions, the cropping boundaries can be iteratively optimized to ensure the accuracy of the defect ROI. The core of boundary condition judgment lies in iteratively optimizing the proposed ROI area to ensure the rationality and accuracy of the cropping boundaries. In industrial inspection, the setting of the cropping boundary directly affects the defect recognition results: too large a boundary may introduce background noise, while too small a boundary may truncate the critical defect area. By parameterizing the cropping shape, the white space, and the minimum cropping area, the problem of unreasonable cropping can be resolved, resulting in the generation of high-quality defect ROIs.
[0007] Industrial defect detection requires not only detecting the location of defects but also assessing their severity. Simple defect detection alone cannot meet practical needs. Defect grade assessment is a crucial step in quality control. Simply detecting defect areas cannot quantify defect grades, hindering practical applications. By building a defect grade judgment module, defects within the cropped ROI area are calculated and graded based on set thresholds. This allows for the output of a quantitative defect ROI grade, resolving the issue of ambiguous defect assessment and providing standardized results for actual quality inspection and decision-making. Summary of the Invention
[0008] To address the issues of large input image size, sparse effective information, and the tendency to interfere with detection results, leading to false or missed detections, the present invention provides a method for automatically identifying and cropping surface defects in metal strips based on edge detection. By setting a parameter list, an edge detection module, a clustering module, a boundary condition judgment module, and a defect level judgment module, a defect identification and cropping model is constructed to rapidly locate defect ROIs, effectively filter out irrelevant information, concentrate resources on detecting key areas, dynamically calculate cropping ROI coordinates, and map the coordinates back to the original image to perform ROI cropping on the original image, thereby achieving automatic identification and cropping of surface defects in metal strips.
[0009] The technical solution of the present invention is: a method for automatically identifying and cutting surface defects of metal strips based on edge detection, characterized in that it includes the following steps:
[0010] S1. Set parameter list: specify in advance the parameter information that the method needs to use during operation.
[0011] S2. Construct edge detection module: Use Gaussian blur and contrast enhancement method to enhance the features of input image, and use Canny operator to detect edges of the enhanced features. The upper and lower thresholds of Canny operator are automatically calculated according to the pixel value of the image. The lower threshold T can be automatically calculated by calculating the pixel value mean μ and pixel value standard deviation σ of the input image data. low and high threshold T high , and its calculation formula can be expressed as:
[0012] T low =max(0,μ-σ)
[0013] T high =min(255,μ+σ).
[0014] S3. Construct a clustering module: cluster all defects detected in a single-frame image using a distance clustering method based on the defect centroid position, and set the clustering threshold according to the value in the parameter list set in step S1.
[0015] S4. Build a boundary condition determination module: Defects clustered in the same cluster by the clustering module in step S3 are considered the same defect. The minimum bounding box is calculated, and the vertex / base pixel coordinates and center coordinates of the box are considered the vertex / base pixel coordinates and center coordinates of the defect. Based on the calculated vertex / base pixel coordinates and the thresholds in the parameter list set in step S1, the proposed cropping boundary coordinates are iteratively calculated.
[0016] S5. Construct a defect level judgment module: treat all defects within the proposed cutting boundary coordinates as single defects and perform level judgment, accumulate the pixel areas of all defects within the proposed cutting boundary coordinates and judge them with the defect level threshold in the parameter list set in step S1, and output the defect level and coordinates based on the judgment result.
[0017] Furthermore, the metal strip in step S1 includes but is not limited to stainless steel, titanium alloy, aluminum alloy and other materials.
[0018] Furthermore, the step S2 will automatically calculate the vertex / bottom pixel coordinates of the segmented defect feature, and calculate the current defect centroid coordinates based on the obtained defect edge coordinates.
[0019] Furthermore, if the defect detected in step S2 has an unclosed edge, the unclosed area will be automatically completed and the defect coordinate information and center of mass position will be recalculated.
[0020] Furthermore, the iterative calculation of the coordinates of the proposed cropping boundary described in step S4 includes: when the cropping area white space threshold is specified in the parameter list in step S1, a white space pixel threshold is added around the cropping area; when the cropping area is specified as a square in the parameter list in step S1, the pixel distance of the long side of the cropping area is automatically calculated, and this is used as the side length of the square, and the short side is compensated to this distance; when the minimum cropping pixel threshold is specified in the parameter list in step S1, each side length of the cropping area is automatically calculated to see whether it meets the minimum cropping pixel threshold. If not, the unsatisfied side is automatically compensated to the threshold.
[0021] In general, compared with the existing technical solutions, the present invention adopts a new idea and method, which can achieve the following beneficial effects:
[0022] 1. In order to solve the problem of large input image size, sparse effective information, and easy interference with detection results leading to false detection or missed detection in defect detection tasks, the present invention proposes a method for automatic recognition and cropping of surface defects of metal strips based on edge detection. By performing defect ROI recognition and cropping on the input image data, the input image resolution is reduced, which can further reduce the computing requirements, improve the real-time detection, and alleviate the problem of missed detection or false detection that is prone to occur in traditional methods.
[0023] 2. The present invention divides the defect recognition and cropping process into five stages: setting parameter list, edge detection module, clustering module, boundary condition judgment module, and defect level judgment module. By processing the input image and extracting key ROI features, defects in the image can be identified and cropped more efficiently.
[0024] 3. The edge detection module proposed in the present invention can enhance low-quality images and automatically extract feature edges, and automatically calculate the threshold required for the Canny operator based on image pixel information, saving parameter adjustment time. The present invention alleviates the fragmentation problem of single defects caused by limited detection accuracy through a clustering module. By adopting a clustering module to aggregate scattered defects, it ensures that fragmented breakpoint defects can be identified as a whole, generating a complete and continuous defect area. Improve the rationality of the defect ROI and avoid cutting irrelevant backgrounds or missing defect information. The present invention iteratively optimizes the cutting boundary through parameterized control of the cutting shape, blank area and minimum cutting area to ensure the accuracy of the defect ROI, solve the pain point of unreasonable cutting, and generate higher quality defect ROI. The present invention dynamically calculates the pixel area of all defects in the proposed cutting ROI through a defect level judgment module, and classifies the level according to the set threshold, which can achieve quantitative defect level output, solve the problem of unclear defect assessment, and provide standardized results for actual quality detection and decision-making. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings, which constitute part of this application, are provided to enhance further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are provided to explain the present invention and do not constitute improper limitations of the present invention. In the accompanying drawings:
[0026] Figure 1 This is a flow chart of a method for automatically identifying and cutting metal strip surface defects based on edge detection proposed by the present invention;
[0027] Figure 2 This is the structure diagram of the edge detection module;
[0028] Figure 3 It is the clustering module structure diagram;
[0029] Figure 4 This is the structural diagram of the boundary condition judgment module;
[0030] Figure 5 This is the structure diagram of the defect level judgment module;
[0031] Figure 6 Schematic diagram of treating surface defects of titanium strip in Example 1 (white frame lines demonstrate cutting positions);
[0032] Figure 7 Schematic diagram of treating surface defects of titanium strip in Example 2 (white frame lines demonstrate cutting positions); DETAILED DESCRIPTION
[0033] The invention will be further described below with reference to the accompanying drawings and embodiments, but the content of the present invention is not limited to the scope of the drawings.
[0034] like Figure 1 As shown, a method for automatic recognition and cutting of metal strip surface defects based on edge detection is characterized in that: based on a set parameter list, an edge detection module, a clustering module, a boundary condition judgment module, and a defect level judgment module, the cutting ROI coordinates are calculated, and the coordinates are mapped back to the original image to perform ROI cutting on the original image, so as to further realize automatic recognition and cutting of metal strip surface defects.
[0035] The parameter setting list includes: setting the corresponding parameters required during the operation of the method in advance. The parameter list and types required to be set are shown in Table 1.
[0036] Table 1 Parameter list
[0037]
[0038] Figure 2 This is the flow chart for edge detection module execution. Gaussian blur and contrast enhancement methods are used to enhance the features of the input image, and the Canny operator is used to perform edge detection on the enhanced features. The high and low thresholds in the Canny operator are automatically calculated based on the pixel values of the image. The calculation formula can be expressed as:
[0039] T low =max(0,μ-σ)
[0040] T high =min(255,μ+σ).
[0041] Among them, T low , T high Represent the low threshold and high threshold respectively, μ represents the pixel mean of the input image, and σ represents the pixel standard deviation of the input image, which are defined as follows:
[0042]
[0043] Among them, x i is the pixel value and N is the total number of pixels in the image.
[0044] The coordinates of the current defect's centroid are calculated based on the defect edge coordinates detected by the Canny operator. If the detected defect has an unclosed edge, the unclosed area will be automatically filled and the defect coordinate information and centroid position will be recalculated.
[0045] Figure 3 This is a flowchart for the clustering module. It uses distance clustering to cluster all defects in a single image based on their centroid locations. The clustering threshold is specified by the "Distance Cluster Threshold" parameter in the parameter list. When multiple defects are clustered together, the algorithm treats them as a single defect and updates the corresponding pixel coordinates.
[0046] Figure 4 This is the flow chart for the boundary condition determination module. In this stage, defects in the same cluster, clustered by the clustering module, are considered the same defect. The minimum bounding box is calculated, and the vertex / bottom pixel coordinates and center coordinates of the box are used as the vertex / bottom pixel coordinates and center coordinates of the defect. Based on the calculated vertex / bottom pixel coordinates and the thresholds set in the parameter list, the boundary coordinates of the proposed cropped ROI are iteratively calculated.
[0047] The iterative calculation of the proposed cropping boundary coordinates includes: when the cropping area white space threshold is specified in the parameter list, adding a white space pixel threshold around the cropping area. The specific execution process can be expressed as follows: when the specified cropping area white space is d, the actual cropping area coordinates can be expressed as: x min =x min -d,x max =x max +d,y min =y min -d,y max =y max +d.
[0048] When the cropping area is specified as a square in the parameter list, the pixel distance of the long side of the cropping area is automatically calculated and used as the side length of the square, and the short side is compensated to this distance. The specific execution process can be expressed as follows: When the cropping ROI is specified as a square in the parameter list, it will find max{(x max -x min ),(y max -y min )} as the side length of the cutting defect ROI, and compensate the other side to the length of the side. Assuming that the y-axis direction is the long side, recalculate the x {min,max} , and its calculation formula can be expressed as:
[0049]
[0050] Among them, center x is the x-coordinate of the defect centroid.
[0051] When the minimum cropping pixel threshold is specified in the parameter list, the length of each side of the cropping area is automatically calculated to see if it meets the minimum cropping pixel threshold. If not, the unsatisfied side is automatically compensated to the threshold size. The specific execution process can be expressed as follows: When the "minimum cropping image size" is specified in the parameter list, if the distance between one or both sides of the area to be cropped is less than the set threshold, the proposed cropping coordinates of the part less than the threshold are recalculated. Assuming that the image y-axis direction meets the threshold, but the x-axis direction does not meet the threshold, the x-axis coordinates are recalculated. The calculation formula can be expressed as follows:
[0052]
[0053] Among them, center x is the x coordinate of the defect centroid, d thre Specifies the minimum crop image size threshold.
[0054] Figure 5 This is a flowchart for the defect level judgment module. In this stage, all defects within the coordinates of the boundary to be cut will be regarded as single defects and graded. The pixel areas of all defects within the coordinates of the boundary to be cut will be accumulated and judged with the defect level threshold specified in the parameter list. The defect level and coordinates will be output based on the judgment result. The specific process can be expressed as follows: After obtaining the coordinates of the defect ROI to be cut, traverse all defects within the coordinates and sum up all defect areas. The summation result is compared with the initially set defect area grading threshold to determine the defect level within the ROI. At the same time, the pixel coordinates of the center point of the ROI area are calculated. The coordinates are the absolute position coordinates of the current defect ROI in the original image. Assuming that the defect area grading threshold specified in the parameter list is set to [300,100], the defect level classification settings are as follows,
[0055]
[0056] Example 1:
[0057] See also Figure 1 、 Figure 2 、 Figure 3 、 Figure 4 、 Figure 5 and Figure 6 The present invention proposes a method for automatically identifying and cutting metal strip surface defects based on edge detection, comprising the following steps:
[0058] S1. Set parameter list: In this embodiment, the image resolution is 257×257, the cluster distance threshold is set to 10, the cropping margin is set to 0, the minimum cropping image size is set to 0, whether to crop to a square is set to False, and the defect level judgment threshold is set to [300,100].
[0059] S2. Build an edge detection module: This module uses Gaussian blur and contrast enhancement methods to enhance the input image's features. It then uses the Canny operator to perform edge detection on these enhanced features. The upper and lower thresholds for the Canny operator are automatically calculated based on the image's pixel values. The coordinates of the current defect's center of mass are calculated based on the defect's edge coordinates detected by the Canny operator. If the detected defect has unclosed edges, the unclosed areas are automatically filled in, and the defect coordinates and center of mass are recalculated.
[0060] S3. Construct a clustering module: cluster all defects detected in a single frame image using a distance clustering method based on the defect centroid position, with the clustering threshold being 10 set in step S1.
[0061] S4. Constructing a boundary condition judgment module: iteratively calculating the coordinates of the proposed cutting boundaries of the defects clustered by the clustering module in step S3.
[0062] S5. Construct a defect level judgment module: treat all defects within the proposed cutting boundary coordinates as single defects and perform level judgment, accumulate the pixel areas of all defects within the proposed cutting boundary coordinates and judge them with the [300,100] set in step S1, and output the defect level and the coordinates of the cutting ROI center point based on the judgment results.
[0063] Figure 6 The results of Example 1 when processing surface defect images of titanium metal strips are shown. The first line shows the input original image data with a resolution of 257×257. The second line shows the defect recognition effect of the corresponding image after processing by Example 1 and the proposed cropped defect ROI area after iteration according to the initial set parameters (replaced by a white frame line, and the frame line coordinates are mapped back to the original image as the cropping coordinates).
[0064] Example 2:
[0065] See also Figure 1 、 Figure 2 、 Figure 3 、 Figure 4 、 Figure 5 and Figure 7 The present invention proposes a method for automatically identifying and cutting metal strip surface defects based on edge detection.
[0066] S1. Set parameter list: In this embodiment, the image resolution is 257×257, the cluster distance threshold is set to 10, the cropping margin is set to 10, the minimum cropping image size is set to 20, whether to crop to a square is set to True, and the defect level judgment threshold is set to [300,100].
[0067] S2. Construct edge detection module: Use Gaussian blur and contrast enhancement methods to enhance the features of the input image, and use the Canny operator to detect the edges of the enhanced features. The upper and lower thresholds of the Canny operator are automatically calculated based on the pixel values of the image. The coordinates of the current defect center of mass are calculated based on the defect edge coordinates detected by the Canny operator. If the edges of the detected defect are not closed, the unclosed area will be automatically filled and the defect coordinate information and center of mass position will be recalculated.
[0068] S3. Construct a clustering module: cluster all defects detected in a single frame image using a distance clustering method based on the defect centroid position, with the clustering threshold being 10 set in step S1.
[0069] S4. Constructing a boundary condition judgment module: iteratively calculating the coordinates of the proposed cutting boundaries of the defects clustered by the clustering module in step S3.
[0070] S5. Construct a defect level judgment module: treat all defects within the proposed cutting boundary coordinates as single defects and perform level judgment, accumulate the pixel areas of all defects within the proposed cutting boundary coordinates and judge them with the [300,100] set in step S1, and output the defect level and the coordinates of the cutting ROI center point based on the judgment results.
[0071] Figure 7 The results of Example 2 when processing surface defect images of titanium metal strips are shown, where the first line shows the input original image data with a resolution of 257×257. The second line shows the defect recognition effect of the corresponding image after processing by Example 2 and the proposed cropped defect ROI area after iteration according to the initial set parameters (replaced by a white frame line, and the frame line coordinates are mapped back to the original image as the cropping coordinates).
[0072] The specific embodiments of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Various changes can be made within the knowledge of ordinary technicians in this field without departing from the scope of the present invention.
Claims
1. A method for automatically identifying and cutting metal strip surface defects based on edge detection, characterized in that: The following steps are involved: S1. Set parameter list: specify the parameter information needed for the method to be used during operation in advance; S2. Construct edge detection module: Use Gaussian blur and contrast enhancement method to enhance the features of input image, and use Canny operator to detect edges of the enhanced features. The upper and lower thresholds of Canny operator are automatically calculated according to the pixel value of the image. The lower threshold T can be automatically calculated by calculating the pixel mean μ and pixel standard deviation σ of the input image data. low , and high threshold T high , and its calculation formula is expressed as: T low =max(0,μ-σ) T high =min(255,μ+σ); S3. Constructing a clustering module: clustering all defects detected in a single frame image using a distance clustering method based on the defect centroid position, with the clustering threshold set according to the value in the parameter list set in step S1; S4. Constructing a boundary condition judgment module: treating the defects in the same cluster clustered by the clustering module in step S3 as the same defect, calculating its minimum bounding box, and using the vertex / bottom pixel coordinates and center point coordinates of the box as the vertex / bottom pixel coordinates and center point coordinates of the defect; iteratively calculating the coordinates of the proposed cropping boundary based on the calculated vertex / bottom pixel coordinates and the threshold value in the parameter list set in step S1; S5. Construct a defect level judgment module: treat all defects within the proposed cutting boundary coordinates as single defects and perform level judgment, accumulate the pixel areas of all defects within the proposed cutting boundary coordinates and judge them with the defect level threshold in the parameter list set in step S1, and output the defect level and coordinates based on the judgment result.
2. The method for automatically identifying and cutting metal strip surface defects based on edge detection according to claim 1, characterized in that: The metal strip material includes stainless steel, titanium alloy and aluminum alloy.
3. The method for automatically identifying and cutting metal strip surface defects based on edge detection according to claim 1, characterized in that: The step S2 further includes: obtaining defect feature edge information after processing with a Canny operator, counting the vertex / bottom pixel coordinates of each defect feature, and calculating the centroid coordinates of the current defect feature in combination with the obtained defect edge information.
4. The method for automatically identifying and cutting metal strip surface defects based on edge detection according to claim 1, characterized in that: The step S2 further includes: if the detected defect feature has an unclosed edge, completing the unclosed area, collecting statistics on the completed defect edge information, and recalculating the centroid coordinates of the current defect feature.
5. The method for automatically identifying and cutting metal strip surface defects based on edge detection according to claim 1, characterized in that: The iterative calculation of the proposed cropping boundary coordinates in step S4 includes: When the cropping area white threshold is specified in the parameter list in step S1, a white pixel threshold is added around the cropping area; When the cropping area is specified as a square in the parameter list in step S1, the pixel distance of the long side of the cropping area is automatically calculated and used as the side length of the square, and the short side distance is compensated to this distance; When the minimum cropping pixel threshold is specified in the parameter list in step S1, the length of each side of the cropping area is automatically calculated to see whether it meets the minimum cropping pixel threshold. If not, the length of each side that does not meet the threshold is automatically compensated to the threshold.
Citation Information
Patent Citations
Defect detection method for irregular metal machining surface based on depth learning
CN109636772A
Defect detection algorithm based on edge smoothness
CN113570553A