Self-adaptive image edge detection and extraction method and system

Through the adaptive image edge detection method, the threshold value of the Canny operator is automatically optimized using the X-Means clustering algorithm, and combined with spatial distance and edge strength judgment, the problem of degradation of weld image detection accuracy in traditional methods is solved, and efficient and robust weld extraction effect is achieved.

CN119741325APending Publication Date: 2025-04-01CHANGSHU INSTITUTE OF TECHNOLOGY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411899251.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

The traditional Canny operator reduces detection accuracy due to complex background and noise interference in weld images, and the manual selection threshold lacks flexibility, which affects the effect of weld extraction.

Method used

Adaptive image edge detection and extraction method is used to pre-process the weld depth map and calculate the gradient amplitude. The low threshold and high threshold of the Canny operator are automatically optimized using the X-Means clustering algorithm, and the spatial distance, direction consistency and edge strength similarity are judged during the detection process to ensure the adaptability and accuracy of the threshold.

Benefits of technology

It improves the robustness and adaptability of image edge extraction, effectively overcomes the error results in traditional methods, meets the requirements of weld detection and extraction in practical applications, and improves the accuracy and efficiency of weld extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119741325A_ABST
    Figure CN119741325A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive image edge detection and extraction method, which comprises the following steps: preprocessing an acquired weld depth map, the preprocessing comprising gray level conversion, binarization and filtering processing; calculating the gradient magnitude of the preprocessed depth map based on a directivity weight matrix; performing X-Means clustering on the gradient amplitude to obtain a weak edge cluster and a strong edge cluster, calculating a low threshold value of a Canny operator based on a mean value and a variance of the weak edge cluster, and calculating a high threshold value of the Canny operator based on a mean value and a variance of the strong edge cluster; and applying the low threshold value and the high threshold value which are determined by calculation to a Canny operator to execute edge detection, and extracting a welding seam. The invention further discloses a self-adaptive image edge detection and extraction system. The robustness and the self-adaptability of image edge extraction are improved.
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 analysis, and in particular to an adaptive image edge detection and extraction method and system. Background Art

[0002] In the application of welding robot stereo vision, the weld extraction method based on image edge features plays a key role. Among the traditional methods, the Canny operator is widely used due to its excellent edge detection ability, but there are still some problems.

[0003] First, interference factors such as scratches and rust on the surface of the welded workpiece can lead to inaccurate edge detection and produce pseudo edges, which significantly affect the effect of weld extraction. Secondly, the manual selection of thresholds lacks flexibility and is difficult to adapt to the characteristics of different images. This process usually takes a lot of time, especially when processing multiple images. Inefficiency. Since different operators may use different threshold settings, the inconsistency of the results will also affect the stability of product quality. Manually selecting thresholds often relies on the experience and judgment of operators and lacks scientific basis, which may lead to inaccurate results. In addition, under different production environments or lighting conditions, the changes in weld image characteristics may make the manually selected threshold unable to adapt to the new situation, resulting in a decrease in edge detection effect. For complex weld images, selecting a suitable threshold requires considering multiple factors, which increases the complexity and difficulty of parameter adjustment. Summary of the invention

[0004] In view of the defects of the above-mentioned prior art, the present invention provides an adaptive image edge detection and extraction method to solve the problem that the high and low threshold parameters of the Canny operator are difficult to control, resulting in reduced detection accuracy caused by complex background and noise interference in the weld image. The invention also provides an adaptive image edge detection and extraction system for implementing the method.

[0005] The technical solution of the present invention is as follows:

[0006] An adaptive image edge detection and extraction method comprises the following steps:

[0007] S1. Preprocessing the collected weld depth map, wherein the preprocessing includes grayscale conversion, binarization and filtering;

[0008] S2, calculating the gradient amplitude of the preprocessed depth map based on the directional weight matrix;

[0009] S3, performing X-Means clustering on the gradient amplitude to obtain weak edge clusters and strong edge clusters, calculating the low threshold of the Canny operator based on the mean and variance of the weak edge cluster, and calculating the high threshold of the Canny operator based on the mean and variance of the strong edge cluster;

[0010] S4. Apply the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract the weld.

[0011] Furthermore, before step S4, the spatial distance, directional consistency and edge strength similarity judgment are performed, and step S4 is performed only when the spatial distance, directional consistency and edge strength similarity judgments all meet the conditions, otherwise step S3 is repeated;

[0012] The judgment condition of the spatial distance is that the distance between two edge points is not greater than the maximum allowable distance;

[0013] The judgment condition of the direction consistency is that the gradient direction difference between two edge points does not exceed the direction difference threshold;

[0014] The judgment condition for edge strength similarity judgment is that the gradient amplitude difference between two edge points does not exceed the gradient amplitude difference threshold.

[0015] Furthermore, the maximum allowable distance is 1 when the gradient amplitude of the edge point is greater than or equal to the high threshold, and the maximum allowable distance is 0 when the gradient amplitude of the edge point is less than the small threshold. In other cases, the maximum allowable distance is set, and the set maximum allowable distance is 1 to 5; the direction difference threshold is 10 to 30°; and the gradient amplitude difference threshold is 5% to 20% of the gradient amplitude range.

[0016] Furthermore, the method includes step S5, performing noise judgment on the point cloud data of the extracted weld, and when noise points exist, returning to step S3.

[0017] Furthermore, the noise point is: each point p in the point cloud data i Define its neighborhood N(p i ) is the k nearest neighboring points, calculate p i With neighboring point p j The distance d ij =∥p i -p j Calculate the average neighborhood distance μ of each point i , if μ i >μ+ασ is a noise point, where α is the empirical coefficient.

[0018]

[0019] N is the number of points in the point cloud data.

[0020] Furthermore, in step 3, the low threshold of the Canny operator is calculated based on the mean and variance of the weak edge cluster, and the high threshold of the Canny operator is calculated based on the mean and variance of the strong edge cluster as follows:

[0021] THigh =μ2+p High ·σ2, T Low =μ1-p Low ·σ1

[0022] Where T High is the high threshold, T Low is the low threshold, μ1 and σ1 are the mean and variance of the weak edge cluster, μ2 and σ2 are the mean and variance of the strong edge cluster, p H igh is an adaptive value between 0.8 and 0.99, p L ow is an adaptive value ranging from 0.01 to 0.20.

[0023] Further, is an initial random value between 0.8 and 0.99, is an initial random value between 0.01 and 0.20, and β1 and β2 are the set adjustment coefficients.

[0024] Another technical solution of the present invention is an adaptive image edge detection and extraction system, comprising the following modules:

[0025] Preprocessing module: used to preprocess the collected weld depth map, including grayscale conversion, binarization and filtering;

[0026] Gradient amplitude calculation module: used to calculate the gradient amplitude of the preprocessed depth map based on the directional weight matrix;

[0027] Threshold calculation module: used to perform X-Means clustering on the gradient amplitude to obtain weak edge clusters and strong edge clusters, calculate the low threshold of the Canny operator based on the mean and variance of the weak edge cluster, and calculate the high threshold of the Canny operator based on the mean and variance of the strong edge cluster;

[0028] And, a detection and extraction module: used for applying the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract welds.

[0029] Furthermore, it includes a discrimination module: used to judge the spatial distance, directional consistency and edge strength similarity. The detection and extraction module extracts the weld only when the spatial distance, directional consistency and edge strength similarity judgments all meet the conditions. Otherwise, the threshold calculation module recalculates the low threshold and the high threshold and then extracts the weld.

[0030] Furthermore, it includes a noise discrimination module: used for performing noise judgment on the point cloud data of the extracted weld, and when noise points exist, returning to the threshold calculation module to recalculate the low threshold and the high threshold and then extract the weld.

[0031] Compared with the prior art, the present invention has the following advantages:

[0032] The present invention avoids inconsistent results caused by subjective judgment of threshold selection, and automatically optimizes the selection of Canny operator threshold through clustering algorithm X-Means, thereby improving the robustness and adaptability of image edge extraction. In the extraction of weld images, it can effectively overcome the various error results caused by traditional methods and meet the requirements of weld detection and extraction in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 It is a schematic diagram of the process of the adaptive image edge detection and extraction method of the present invention.

[0034] Figure 2 Schematic diagram of the experimental weld and extraction results. DETAILED DESCRIPTION

[0035] The present invention will be further described below in conjunction with the embodiments, but are not intended to limit the present invention.

[0036] An adaptive image edge detection and extraction system according to an embodiment of the present invention includes the following modules:

[0037] Preprocessing module: used to preprocess the collected weld depth map, and the preprocessing includes grayscale conversion, binarization and filtering.

[0038] Gradient amplitude calculation module: used to calculate the gradient amplitude of the preprocessed depth map based on the directional weight matrix.

[0039] Threshold calculation module: used to perform X-Means clustering on the gradient amplitude to obtain weak edge clusters and strong edge clusters, calculate the low threshold of the Canny operator based on the mean and variance of the weak edge cluster, and calculate the high threshold of the Canny operator based on the mean and variance of the strong edge cluster.

[0040] Discrimination module: used to judge the spatial distance, directional consistency and edge strength similarity. The detection and extraction module will extract the weld only when the spatial distance, directional consistency and edge strength similarity judgments meet the conditions. Otherwise, the threshold calculation module will recalculate the low threshold and high threshold and then extract the weld.

[0041] Detection and extraction module: used to apply the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract welds.

[0042] And the noise discrimination module: it is used to judge the noise of the point cloud data of the extracted weld. When there are noise points, the threshold calculation module is used to recalculate the low threshold and high threshold and then extract the weld.

[0043] The adaptive image edge detection and extraction system specifically implements the adaptive image edge detection and extraction method for weld images. Figure 1 As shown, the following steps are included.

[0044] S1. After taking a single photo in the camera field of view using the WiSight surface structured light sensor, the depth map and 3D point cloud data of the workpiece to be welded are obtained. After obtaining the weld depth map, the image needs to be grayscaled first. Grayscale can simplify image data and convert color images into single-channel images, thereby retaining the depth information of the weld and reducing the complexity of subsequent processing. Next, the grayscale image is converted into a binary image containing only two gray levels. After grayscale and binarization, Gaussian filtering is performed to obtain a smooth image while retaining edge information. Define the image after Gaussian filtering as I G (x, y), where is the standard deviation of the Gaussian filter and is the radius of the filter window, which controls the smoothness of the filter.

[0045]

[0046] Where σ is the standard deviation of the Gaussian filter.

[0047] S2, after obtaining the smoothed image I G (x, y), calculate its gradient amplitude, and use an adaptive directional weight matrix W to enhance the sensitivity to the weld edge. i,j To control the gradient strength in different directions so that it is more sensitive to the weld edge.

[0048]

[0049] The generation of W is controlled by the gradient weight sensitive parameter β:

[0050]

[0051] The parameter β controls the sensitivity of the weight matrix to gradient changes. Its value range is between 0.1 and 10 and is adjusted according to the detail complexity of the weld image.

[0052] S3. After calculating the gradient amplitude G(x,y), the X-Means algorithm is used to cluster it into weak edge cluster C1 and strong edge cluster C2. The cluster label of each G(x,y) indicates the cluster to which the point belongs, and is assigned to the weak edge cluster and the strong edge cluster. The extracted mean μ1, μ2 and variance σ1, σ2 are directly output by the clustering algorithm.

[0053] Then calculate the low threshold and high threshold of the Canny operator.

[0054] T High =μ2+p High·σ2, T Low =μ1-p Low σ1,

[0055] Where T High is the high threshold, T Low is the low threshold, μ1 and σ1 are the mean and variance of the weak edge cluster, μ2 and σ2 are the mean and variance of the strong edge cluster, p H igh is an adaptive value of 0.8 to 0.99 based on the edge strength, p L ow is an adaptive value between 0.01 and 0.20 according to the edge strength.

[0056]

[0057] is an initial random value between 0.8 and 0.99, is an initial random value between 0.01 and 0.20, and β1 and β2 are the set adjustment coefficients.

[0058] S3A, the high threshold and low threshold obtained by calculation are introduced into the edge connection process. By setting the appropriate maximum allowable distance d connected It can connect the edges that are broken due to image characteristics or algorithm detection errors to make the edges more complete and coherent. For example, in weld detection, a continuous weld edge line may be detected as multiple discrete segments. connected It can be merged into a whole. And for independent edge points or short segments, if their distance from other edges is greater than d connected This can be removed, which reduces false detection interference in subsequent processing.

[0059] Maximum allowable distance d connected When the gradient amplitude of the edge point is greater than or equal to the high threshold, the maximum allowable distance is 1. When the gradient amplitude of the edge point is less than the small threshold, the maximum allowable distance is 0. In other cases, the maximum allowable distance is set to 1-5. For weld extraction, if the weld edge is narrow, the maximum allowable distance can be set to 3. If the weld is wide, the maximum allowable distance can be set to 5.

[0060] Then, the spatial distance, directional consistency and edge strength similarity are judged. Step S4 is performed only when the spatial distance, directional consistency and edge strength similarity all meet the conditions, otherwise step S3 is repeated.

[0061] Given two edge points (x i ,y i ), (x j ,y j ), whose gradient directions are θ i and θj It can be obtained by gradient calculation, and the gradient amplitudes are G i and G j .

[0062] The judgment condition of spatial distance is

[0063]

[0064] The judgment condition for directional consistency is

[0065] |θ i -θ j |≤θ thresh ,θ thresh The direction difference threshold is generally between 10 and 30°.

[0066] The judgment condition for edge strength similarity is

[0067] |G i -G j |≤G thresh , G thresh is the gradient amplitude difference threshold, which is generally 5% to 20% of the gradient amplitude range.

[0068] S4. Apply the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract the weld.

[0069] S5. Evaluate the edge detection result and perform noise judgment on the point cloud data of the extracted weld. When noise points exist, return to step S3.

[0070] The noise point is: each point p in the point cloud data i Define its neighborhood N(p i ) is the k nearest neighboring points, calculate p i With neighboring point p j The distance d ij =∥p i -p j Calculate the average neighborhood distance μ of each point i , if μ i >μ+ασ is a noise point, where α is an empirical coefficient used to control the sensitivity of detection. For scenes with less noise but high requirements for detail retention, α is 1, and for scenes with more noise but high requirements for weld contour smoothness, α is 2.

[0071]

[0072] N is the number of points in the point cloud data.

[0073] In order to verify the performance of the adaptive image edge detection and extraction method of the present invention, experiments were conducted on five different types of welds, namely, curved, straight, broken line, and two composite welds. The experiment mainly evaluated the image quality and extraction accuracy of each weld under three different working conditions, including interference-free conditions and two different interference conditions. At the same time, the time consumption of automatic parameter adjustment and traditional manual parameter adjustment methods was also compared.

[0074] like Figure 2 As shown, from top to bottom they are: curved weld, straight weld, broken line weld, composite weld 1, composite weld 2. Among them, a) is a physical picture of the workpiece to be welded, showing the actual shape of the weld. b) is the depth map after extraction, showing the depth information of the weld area. c) is the point cloud extraction result of weld detection under working condition 1, showing the performance of the method of the present invention under ideal conditions. d) is the extracted point cloud result under working condition 2, reflecting the weld detection and extraction ability of the method of the present invention under partial interference. e) is the extracted point cloud result under working condition 3, showing the robustness of the method of the present invention under more complex interference.

[0075] Table 1 compares the error, accuracy and parameter adjustment time of the actual position of the workpiece weld of five types of welds under three working conditions. From the experimental results, the method of the present invention shows a fast response capability under the three working conditions, and the automatic parameter adjustment time is significantly shortened. In addition, while maintaining a high response speed, the method of the present invention can take into account both accuracy and weld integrity, indicating that the method of the present invention still has good adaptability and efficiency under different interference conditions.

[0076] Table 1 Extraction algorithm test results indicators

[0077]

[0078]

[0079] The method of the present invention was compared with the traditional manual parameter adjustment method and the adjustment method fused with the K-Means algorithm on the same weld data for weld detection and extraction. 100 experiments were conducted on five types of welds, and the mean of the extraction results of each type of weld was calculated, and the results are summarized in Tables 2 to 4.

[0080] Table 2 Comparison of accuracy of different segmentation algorithms (mm)

[0081] Traditional methods Fusion K-Means algorithm The present invention Curve Type 0.4312 0.3123 0.1189 Straight 0.3863 0.3158 0.1126 Polyline 0.3756 0.3233 0.1281 Composite 1 0.3651 0.3171 0.1373 Composite 2 0.3996 0.3089 0.1293

[0082] Table 3 Comparison of weld integrity of different segmentation algorithms (%)

[0083] Traditional methods Fusion K-Means algorithm The present invention Curve Type 0.9163 0.9668 0.9811 Straight 0.9247 0.9743 0.9936 Polyline 0.9122 0.9535 0.9835 Composite 1 0.9231 0.9541 0.9583 Composite 2 0.9153 0.9487 0.9601

[0084] Table 4 Comparison of parameter adjustment time of different segmentation algorithms (s)

[0085] Traditional methods Fusion K-Means algorithm The present invention Curve Type 15 1.5361 0.7425 Straight 15 1.5427 0.7657 Polyline 15 1.5732 0.7242 Composite 1 15 1.5594 0.7439 Composite 2 15 1.5943 0.7121

[0086] The comparison of the accuracy values ​​in Table 2 shows that the accuracy of the method of the present invention is the best in all weld types, and its error is the smallest, indicating that the accuracy of the detection results is high. In contrast, the accuracy of the traditional manual parameter adjustment method is low, especially in the curved weld, the error is significant, while the accuracy of the fusion K-Means algorithm is between the two, and the accuracy is improved by 0.3mm and 0.2mm on average compared with the other two algorithms. Secondly, the comparison results of the weld integrity in Table 3 show that the integrity of the method of the present invention in various welds is significantly better than other algorithms, and can more accurately maintain the integrity of the weld. The integrity of the traditional manual parameter adjustment method and the fusion K-Means algorithm in some weld types has slightly decreased. In contrast, the weld integrity of the algorithm in this paper has increased by 4% and 6% on average compared with the other two methods. Finally, Table 4 shows the parameter tuning time of each method. The traditional manual parameter adjustment method takes the longest time, while the method of the present invention shows a significant advantage in parameter adjustment time, with the shortest time required, which effectively improves the operation efficiency.

[0087] In summary, the method of the present invention shows strong comprehensive advantages in terms of accuracy, weld integrity and parameter adjustment time, especially in the detection of complex welds, where the performance is particularly outstanding.

Claims

1. An adaptive image edge detection and extraction method, characterized in that: The following steps are involved: S1. Preprocessing the collected weld depth map, wherein the preprocessing includes grayscale conversion, binarization and filtering; S2, calculating the gradient amplitude of the preprocessed depth map based on the directional weight matrix; S3, performing X-Means clustering on the gradient amplitude to obtain weak edge clusters and strong edge clusters, calculating the low threshold of the Canny operator based on the mean and variance of the weak edge cluster, and calculating the high threshold of the Canny operator based on the mean and variance of the strong edge cluster; S4. Apply the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract the weld.

2. The adaptive image edge detection and extraction method according to claim 1, characterized in that: Before step S4, the spatial distance, directional consistency and edge strength similarity judgment are performed, and step S4 is performed only when the spatial distance, directional consistency and edge strength similarity judgments all meet the conditions, otherwise step S3 is repeated; The judgment condition of the spatial distance is that the distance between two edge points is not greater than the maximum allowable distance; The judgment condition of the direction consistency is that the gradient direction difference between two edge points does not exceed the direction difference threshold; The judgment condition for edge strength similarity judgment is that the gradient amplitude difference between two edge points does not exceed the gradient amplitude difference threshold.

3. The adaptive image edge detection and extraction method according to claim 2, characterized in that: The maximum allowable distance is 1 when the gradient amplitude of the edge point is greater than or equal to the high threshold, and the maximum allowable distance is 0 when the gradient amplitude of the edge point is less than the small threshold. In other cases, the maximum allowable distance is set, and the set maximum allowable distance is 1 to 5; the direction difference threshold is 10 to 30°; the gradient amplitude difference threshold is 5% to 20% of the gradient amplitude range.

4. The adaptive image edge detection and extraction method according to claim 1, characterized in that: The method comprises step S5, performing noise judgment on the point cloud data of the extracted weld, and returning to step S3 when noise points exist.

5. The adaptive image edge detection and extraction method according to claim 4, characterized in that: The noise point is: each point p in the point cloud data i Define its neighborhood N(p i ) is the k nearest neighboring points, calculate p i With neighboring point p j The distance d ij =||p i -p j ||Calculate the average neighborhood distance μ of each point i , if μ i >μ+ασ is a noise point, where α is the empirical coefficient. N is the number of points in the point cloud data.

6. The adaptive image edge detection and extraction method according to claim 1, characterized in that: In step 3, the low threshold of the Canny operator is calculated based on the mean and variance of the weak edge cluster, and the high threshold of the Canny operator is calculated based on the mean and variance of the strong edge cluster. Specifically, T High =μ2+p High ·σ2,T Low =μ1-p Low ·s1 Where T High is the high threshold, T Low is the low threshold, μ1 and σ1 are the mean and variance of the weak edge cluster, μ2 and σ2 are the mean and variance of the strong edge cluster, p High is an adaptive value between 0.8 and 0.99, p Low The adaptive value is 0.01 to 0.

20.

7. The adaptive image edge detection and extraction method according to claim 6, characterized in that: is an initial random value between 0.8 and 0.99, is an initial random value between 0.01 and 0.20, and β1 and β2 are the set adjustment coefficients.

8. An adaptive image edge detection and extraction system, characterized in that: Includes the following modules: Preprocessing module: used to preprocess the collected weld depth map, including grayscale conversion, binarization and filtering; Gradient amplitude calculation module: used to calculate the gradient amplitude of the preprocessed depth map based on the directional weight matrix; Threshold calculation module: used to perform X-Means clustering on the gradient amplitude to obtain weak edge clusters and strong edge clusters, calculate the low threshold of the Canny operator based on the mean and variance of the weak edge cluster, and calculate the high threshold of the Canny operator based on the mean and variance of the strong edge cluster; And, a detection and extraction module: used for applying the calculated low threshold and high threshold to the Canny operator to perform edge detection and extract welds.

9. The adaptive image edge detection and extraction system according to claim 8, characterized in that: It includes a discrimination module: used for judging the spatial distance, directional consistency and edge strength similarity. The detection and extraction module extracts the weld only when the spatial distance, directional consistency and edge strength similarity judgments meet the conditions. Otherwise, the threshold calculation module recalculates the low threshold and the high threshold to extract the weld again. The judgment condition of the spatial distance is that the distance between two edge points is not greater than the maximum allowable distance; The judgment condition of the direction consistency is that the gradient direction difference between two edge points does not exceed the direction difference threshold; The judgment condition for edge strength similarity judgment is that the gradient amplitude difference between two edge points does not exceed the gradient amplitude difference threshold.

10. The adaptive image edge detection and extraction system according to claim 8, characterized in that: It includes a noise discrimination module: it is used to perform noise judgment on the point cloud data of the extracted weld. When there are noise points, the threshold calculation module is used to recalculate the low threshold and the high threshold and then extract the weld.

Citation Information

Cited By

  • Rapid calibration method for connecting rod type double-arm direct-driven manipulator

    CN120620241A

  • A quick calibration method for a connecting rod type dual-arm direct-drive manipulator

    CN120620241B