An online method and system for detecting punch holes in images based on edge detection

By preprocessing and analyzing punched images using edge detection methods, the problems of low detection efficiency and poor interpretability in existing technologies are solved, achieving efficient and reliable edge detection.

CN122312673APending Publication Date: 2026-06-30ZHEJIANG DELIA AUTOMATION MFG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG DELIA AUTOMATION MFG CO LTD
Filing Date
2026-03-27
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing punch image detection methods are mainly based on machine learning, which leads to low detection efficiency, poor interpretability of the detection process, and a lack of edge detection result evaluation mechanism.

Method used

An edge detection-based method is adopted. By acquiring punched images and performing grayscale and standardization processing, the distribution of adjacent change values ​​is calculated, edge rate analysis is performed, an edge set is constructed, fitting parameters are configured for edge fitting, the maximum edge fitting accuracy is selected, and the detection accuracy is calculated.

Benefits of technology

It improves the accuracy and efficiency of edge detection, eliminates the influence of lighting, optimizes the allocation of computing resources, and enhances the reliability and interpretability of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122312673A_ABST
    Figure CN122312673A_ABST
Patent Text Reader

Abstract

This invention discloses an online detection method and system for punched images based on edge detection, relating to the field of machine vision. The method includes: acquiring and preprocessing an image after punching to obtain a punched image; calculating the adjacency variation value of each pixel to obtain an adjacency variation value distribution; performing punching edge rate analysis based on the adjacency variation value distribution to obtain a punching edge rate distribution and constructing a punching edge set; configuring punching edge fitting parameters based on the punching edge rate distribution; using standard punching edges to fit each punching edge in the punching edge set to obtain an edge fitting accuracy set; selecting the punching edge corresponding to the maximum edge fitting accuracy; calculating the punching detection accuracy based on the maximum edge fitting accuracy and the punching edge set; and using the selected punching edge as the detection result. This invention solves the technical problems of low detection efficiency, poor interpretability of the detection process, and lack of an edge detection result evaluation mechanism in existing technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision, and more specifically to an online method and system for detecting punched images based on edge detection. Background Technology

[0002] In the drilling process of precision manufacturing, due to factors such as tool wear, spindle vibration and uneven material hardness, machining errors such as hole diameter deviation, roundness error and edge burrs will inevitably occur, which directly affect the assembly accuracy and performance of the product.

[0003] However, existing punch image detection methods are mainly based on machine learning for detection and punch image content recognition, which leads to low detection efficiency, poor interpretability of the detection process, and a lack of edge detection result evaluation mechanism. Summary of the Invention

[0004] This application provides an online punch image detection method and system based on edge detection, which addresses the technical problems in the prior art, where existing punch image detection methods mainly rely on machine learning for detection and punch image content recognition, resulting in low detection efficiency, poor interpretability of the detection process, and a lack of edge detection result evaluation mechanism.

[0005] In view of the above problems, this application provides an online detection method and system for punched images based on edge detection.

[0006] In a first aspect, this application provides an online method for detecting punched images based on edge detection, the method comprising: The image after punching is acquired and preprocessed to obtain the punched image. The adjacency change value of each pixel is calculated to obtain the adjacency change value distribution. Based on the adjacent change value distribution, a punching edge rate analysis is performed to obtain the punching edge rate distribution, and a punching edge set is constructed. Based on the punching edge rate distribution, punching edge fitting parameters are configured, and standard punching edges are used to fit the punching edge set one by one to obtain the edge fitting accuracy set. The selected punching edge corresponding to the maximum edge fitting accuracy is then selected. The punch detection accuracy is calculated based on the maximum edge fitting accuracy and the punch edge set, and the selected punch edge is used as the detection result.

[0007] Secondly, the present invention provides an online detection system for punched images based on edge detection, the system comprising: The image acquisition module is used to acquire images after the punching process and perform preprocessing to obtain punched images, calculate the adjacency change value of each pixel, and obtain the adjacency change value distribution; The edge rate analysis module is used to perform punching edge rate analysis based on the adjacent change value distribution, obtain the punching edge rate distribution, and construct the punching edge set; The fitting accuracy filtering module is used to configure the punching edge fitting parameters according to the punching edge rate distribution, use standard punching edges to fit the punching edge set one by one to obtain the edge fitting accuracy set, and filter to obtain the selected punching edge corresponding to the maximum edge fitting accuracy. The detection accuracy acquisition module is used to calculate the punch detection accuracy based on the maximum edge fitting accuracy and the punch edge set, and combine it with the selected punch edge as the detection result.

[0008] One or more technical solutions provided in this application have at least the following technical effects or advantages: This application first acquires the original image after punching and performs preprocessing operations such as grayscale conversion and standardization to effectively eliminate the influence of ambient light on the detection results, obtaining punched images with stable quality. It then calculates the grayscale difference between each pixel and its neighboring pixels, constructing a distribution of adjacency variation values ​​to provide a data foundation for subsequent edge analysis. Secondly, by normalizing the distribution of adjacency variation values, errors caused by contrast differences between different images are eliminated. Threshold filtering is then used to construct a set of punched edges, providing a basis for finding the optimal edge. Thirdly, by calculating the average edge probability of each candidate edge and dynamically adjusting the number of fitting iterations, computational resources are optimized, improving overall processing efficiency. Multiple random fitting iterations are performed on each candidate edge to select the one with the highest fitting accuracy, improving the accuracy of edge localization. Finally, diameter calculation and discreteness analysis are performed on all candidate edges in the punched edge set to calculate the punching detection accuracy, improving the reliability of edge detection quality evaluation. Attached Figure Description

[0009] Figure 1 This is a flowchart illustrating an online punch image detection method based on edge detection according to this application. Figure 2 This is a schematic diagram of the structure of an online punch image detection system based on edge detection according to this application.

[0010] In the attached diagram, the components represented by each number are as follows: Image acquisition module 11, edge rate analysis module 12, fitting accuracy screening module 13, detection accuracy acquisition module 14. Detailed Implementation

[0011] This application provides an online punch image detection method based on edge detection, which specifically solves the technical problems in the prior art, which are that existing punch image detection methods mainly rely on machine learning for detection and punch image content recognition, resulting in low detection efficiency, poor interpretability of the detection process, and lack of edge detection result evaluation mechanism.

[0012] The present invention will now be described in detail with reference to the accompanying drawings.

[0013] Example 1, as Figure 1 As shown, this application provides an online punch image detection method based on edge detection, the method comprising: S10: Acquire the image after the punching process and perform preprocessing to obtain the punched image. Calculate the adjacency change value of each pixel to obtain the adjacency change value distribution. Step S10 in the method provided in this application embodiment includes: The image after the punching process is acquired, and then subjected to grayscale and standardization processing to obtain the punched image. The grayscale value of each pixel in the punched image is calculated by the adjacent grayscale value change to obtain the adjacent change value distribution.

[0014] Specifically, firstly, images of the punched images are acquired using equipment such as industrial cameras, microscopes, or scanners. These images are then converted to grayscale. A color image with, for example, three channels (red, green, and blue) is processed into a grayscale image with only one channel, essentially converting RGB values ​​to grayscale values. This reduces the data volume to one-third of the original, significantly decreasing computational complexity. Grayscale images can be converted using methods such as component analysis, maximum value analysis, and average value analysis. The grayscale value is calculated for each pixel. Component analysis directly uses the brightness value of a single channel from the color image as the grayscale value; maximum value analysis uses the highest brightness value from the three channels; and average value analysis sums the values ​​from the three channels and then calculates the average. Grayscale processing reduces unnecessary interference from lighting and color, highlighting key structural features of the image.

[0015] After grayscale processing, standardization is performed to unify the data format and enhance contrast, in order to eliminate differences between different batches of photos and avoid significant errors in the image caused by changes in lighting due to shooting time.

[0016] Secondly, since the edges of holes exhibit the most drastic changes in grayscale values—for example, a sudden shift from white to black inside the hole, or vice versa—the location of these drastic changes can be identified by calculating the difference between each pixel and its neighbors. Therefore, by calculating the adjacent grayscale value changes for each pixel in the punched image, the distribution of adjacent change values ​​is obtained. If the adjacent change value is small, it indicates that on a flat surface of the workpiece or inside the hole, the grayscale values ​​of adjacent pixels are similar, with a difference close to zero. If the adjacent change value is large, it indicates that at the edge of the hole, adjacent pixels are unevenly distributed, with one bright and one dark pixel. For example, by calculating the difference between the grayscale value of each pixel and the grayscale values ​​of its neighboring 3×3 pixels, and performing the same calculation for each pixel, the distribution of adjacent change values ​​in the punched image can be obtained.

[0017] In step S10 of the method provided in this application embodiment, the grayscale value of each pixel in the punched image is calculated to obtain the adjacent grayscale value distribution, including: Using a preset window, the neighboring pixels of each pixel in the punched image are selected to obtain the set of adjacent pixels; Extract the adjacent gray value set corresponding to the adjacent pixel set, and calculate the average difference between the gray value set and the corresponding pixel value to obtain the adjacent change value; Calculate the adjacency change value of all pixels to obtain the distribution of adjacency change values.

[0018] Specifically, first, a preset window for the punched image is set. Then, using the preset window, the current pixel is taken as the center point of the preset window, and the pixels other than the center point are taken as adjacent pixels. Adjacent pixels are selected for each pixel to construct a set of adjacent pixels.

[0019] Secondly, in a punched image, the neighborhood environment of each pixel is different. Therefore, the calculated adjacency change value is also different. Extract the adjacency gray value set corresponding to the adjacency pixel set, subtract the gray value of the target pixel from each value in the adjacency gray value set, take the absolute value of the difference, and calculate the mean of the difference to obtain the adjacency change value.

[0020] For example, for pixel A, the grayscale value is 55. Its adjacent grayscale value set is: [54,55,53,56,54,55,55,56]. Calculate the absolute difference between A and each of its neighbors, and the differences are [1,0,2,1,1,0,0,1]. Calculate the average difference = (1+0+2+1+1+0+0+1) / 8 = 0.75, so the adjacent change value of point A is 0.75. For pixel B, the grayscale value is 200, and its adjacent grayscale value set is: [201,199,202,200,198,201,200,199]. Calculate the difference [1,1,2,0,2,1,0,1], and the average difference is: (1+1+2+0+2+1+0+1) / 8 = 1, so the adjacent change value of point B is 1.

[0021] Finally, the adjacency variation values ​​of all pixels are calculated to obtain the distribution of adjacency variation values, resulting in a feature map with the same size as the original punched image. Each element in the feature map corresponds to the adjacency variation value of a pixel at the same location in the original image. In the original image, pixels in flat areas such as metal surfaces and the bottom of the hole generally have adjacency variation values ​​close to 0 or a very small value; while in edge areas such as the circumference of the hole, the adjacency variation values ​​of pixels are significantly higher. Therefore, by observing the adjacency variation values, the location of the hole edge can be determined.

[0022] In this embodiment, by sequentially performing grayscale and standardization processing on the original image, the influence of illumination fluctuations on image quality is effectively eliminated. Subsequently, a preset window is used to select the neighborhood of each pixel and calculate the mean grayscale difference to obtain the distribution of adjacent change values, thereby improving the distinguishability of edge features and effectively suppressing the interference of isolated noise points, providing high-quality input data for subsequent processing.

[0023] S20: Based on the adjacent change value distribution, perform a punching edge rate analysis to obtain the punching edge rate distribution and construct a punching edge set; Step S20 in the method provided in this application embodiment includes: Filter the adjacent change value with the largest adjacent change value within the adjacent change value distribution; Calculate the ratio of each adjacent change value to the maximum adjacent change value, and use it as the punching edge rate to obtain the punching edge probability distribution; A set of punched edges is constructed based on the probability distribution of punched edges and the punched image.

[0024] Specifically, firstly, the largest adjacent change value within the adjacent change value distribution feature map is selected from the adjacent change value distribution. The maximum value is usually located at the pixel point with the clearest edge and the strongest contrast at the hole. The largest adjacent change value selected will become the benchmark reference value for subsequent calculations.

[0025] Traverse the feature map of adjacent change values, comparing each adjacent change value: first compare point A and point B, retaining the larger adjacent change value B; then compare B with the next edge point, if an edge point is found to be greater than B, update the maximum value; continue comparing, and when the entire feature map has been traversed, output the maximum value.

[0026] Secondly, based on the changes in grayscale values ​​with neighboring pixels, the probability of each pixel being a punch edge is calculated. The ratio of each adjacent change value to the largest adjacent change value is used as the punch edge rate, resulting in the punch edge probability distribution. The larger the ratio, the closer the change intensity is to the strongest edge point globally, and the higher the probability that it belongs to a real edge; the smaller the ratio, the weaker the change intensity is compared to the strongest edge, and the higher the probability that it belongs to a flat area or noise.

[0027] Finally, based on the punch edge probability distribution and the punch image, a preset number of pixels with punch edge rates greater than a threshold are randomly selected and connected to form a preliminary fitted punch edge, resulting in a punch edge set. The pixels in the obtained punch edge set have a high punch edge probability.

[0028] In step S20 of the method provided in this application embodiment, a set of punched edges is constructed based on the punched edge probability distribution and the punched image, including: Based on the punched image detection data over a historical period, obtain the threshold values ​​for adjacent change values ​​in the punched and non-punched areas; Filter the pixels and punch edge probabilities corresponding to adjacent change values ​​that are greater than or equal to the adjacent change value threshold to obtain the set of suspected pixels and the set of suspected punch edge probabilities; Based on the punch image detection data from a historical period, obtain the preset number of pixels at the edge of the punch in a qualified punch image; Within the set of suspected pixels, a preset number of suspected pixels are randomly selected. Neighboring suspected pixels are connected one by one to form the punched edge. This selection and connection is repeated multiple times to obtain the punched edge set.

[0029] Specifically, firstly, due to errors such as lighting, there will be changes in grayscale values ​​in both the punched and non-punched areas. Therefore, it is necessary to set an adjacency change value threshold for judgment. Based on punched image detection data over a historical period, the minimum grayscale value difference between the punched and non-punched areas within that period is used as the adjacency change value threshold. If the adjacency change value of a pixel is greater than or equal to the threshold, it is more likely to be an edge point; if it is less than the threshold, it is more likely to be a background point or a point inside the hole.

[0030] Secondly, the pixels and punch edge probabilities corresponding to the adjacency change values ​​that are greater than or equal to the adjacency change value threshold are filtered to obtain the suspected pixel set and the suspected punch edge probability set. The suspected pixel set is a set of all pixels that satisfy the adjacency change value ≥ the threshold; the suspected punch edge probability set is a set of edge probability values ​​that correspond one-to-one with each pixel in the suspected pixel set.

[0031] The distribution of adjacent change values ​​is filtered. For each pixel, it is determined whether the adjacent change value is greater than or equal to the adjacent change value threshold. Pixels that meet the condition are designated as suspected pixels, and a set of suspected pixels is constructed. At the same time, the probability of the punching edge corresponding to the suspected pixels is recorded to form a set of suspected punching edge probabilities.

[0032] Secondly, based on the punch image detection data over a historical period, the preset number of pixels at the edge of the punch in the qualified punch image is obtained. The preset number of pixels is a reasonable number of pixels at the edge of the hole obtained by statistical analysis of historical data, which may be related to the actual physical size of the hole, the resolution of the camera, and the sharpness of the edge.

[0033] For example, by analyzing 10,000 qualified images from historical data, it was found that for a certain camera, at a resolution of 640×480, the complete edge of a hole is composed of an average of 198 pixels, with a standard deviation of 5 pixels. Therefore, the preset number of pixels can be set to 200.

[0034] Finally, a preset number of suspected pixels are randomly selected from the set of suspected pixels. Each randomly selected suspected pixel is used as a starting point to connect neighboring suspected pixels until the preset number of connected pixels is met, forming a punched edge. In order to cover as many reasonable edge shapes as possible, multiple selections and connections are performed. All successfully generated candidate edges are integrated to obtain a punched edge set.

[0035] In this embodiment, by normalizing the distribution of adjacency change values, errors caused by differences in light intensity or contrast between different images are eliminated; at the same time, by combining the adjacency change value threshold, high-probability suspected pixels are screened out, reducing the amount of data and complexity of subsequent processing; then, multiple candidate edges are constructed to form a punched edge set, improving the accuracy of edge extraction.

[0036] S30: Based on the punching edge rate distribution, configure the punching edge fitting parameters, use standard punching edges, fit the punching edge set one by one to obtain the edge fitting accuracy set, and filter to obtain the selected punching edge corresponding to the maximum edge fitting accuracy. In this embodiment, firstly, based on the distribution of the punching edge rate, the punching edge fitting parameters, i.e. the number of punches, are configured. The larger the punching edge rate, the more punches are set to improve the fitting degree. Then, standard punching edges are used to fit the punching edges constructed in the initial connection one by one to obtain the edge fitting accuracy set. The selected punching edge corresponding to the maximum edge fitting accuracy is then selected.

[0037] Step S30 in the method provided in this application embodiment includes: Obtain the probability of the suspected punch edge corresponding to all suspected pixels within each punch edge, and calculate the mean to obtain the punch edge confidence set; Obtain preset punch edge fitting parameters, wherein the preset punch edge fitting parameters include a preset number of fitting iterations; Calculate the ratio of the confidence level of each punch edge to the maximum value within the confidence level set of punch edges, adjust the calculation based on the preset number of fitting iterations, and obtain multiple punch edge fitting parameters; Based on multiple punching edge fitting parameters, using standard punching edges, the punching edge set is fitted one by one to obtain the edge fitting accuracy set; Select the punched edge corresponding to the highest edge fitting accuracy as the selected punched edge.

[0038] Specifically, firstly, since each edge is composed of several pixels, and each pixel contains a probability of being a suspected punch edge (i.e., the confidence level that the point belongs to the edge), the average of the probabilities of suspected punch edges across all points on an edge is used as the punch edge confidence level. The higher the average probability of suspected punch edges, the higher the punch edge confidence level; conversely, the lower the average probability of suspected punch edges, the more likely they are to pass through many low-probability noise points or background points, resulting in lower punch edge confidence. The punch edge confidence level set is obtained by calculating the probabilities of suspected punch edges for all suspected pixels within each punch edge.

[0039] Secondly, obtain the preset perforation edge fitting parameters, which include the preset fitting number, which represents the number of times the standard perforation edge is randomly placed. This number can be set by technicians based on the accuracy requirements of the actual application scenario and empirical experiments. The preset fitting number is used as the basis for adjustment calculation to obtain the fitting number for the actual scenario.

[0040] Next, for each edge, the ratio of the confidence level of each punched edge to the maximum value within the confidence level set of punched edges is calculated. This ratio is then adjusted based on the preset number of fitting iterations to obtain multiple punched edge fitting parameters. The closer the ratio is to 1, the better the quality of the punched edge. Subsequently, the ratio is multiplied by the preset number of fitting iterations to obtain the actual number of fitting iterations that should be performed for that edge. The highest quality edges will receive the most fitting iterations, while lower quality edges will receive fewer, thus achieving optimized allocation of computational resources.

[0041] For example, assume the maximum value of the confidence set for the punched edge is 0.92. With a preset fitting count of 1000, for a given punched edge, the confidence count is 0.78, the ratio = 0.78 / 0.92 = 0.848, and after adjustment, the fitting count is approximately 848.

[0042] Meanwhile, according to the actual number of fittings among the multiple punch edge fitting parameters, the standard punch edge is used to perform fitting on each edge in the punch edge set one by one. The standard punch edge is compared with the candidate edge to find the best matching position between the two. After its own number of fitting attempts, the best similarity score is reached, that is, the edge fitting accuracy. The higher the edge fitting accuracy, the more the edge matches the standard punch edge in shape.

[0043] Ultimately, the candidate edge that corresponds to the highest edge fitting accuracy is the one that is closest to the actual hole edge. This candidate edge has both high reliability and best matches the standard hole edge, and is therefore selected as the chosen hole edge.

[0044] In step S30 of the method provided in this application embodiment, according to multiple perforation edge fitting parameters, a standard perforation edge is used to fit the perforation edge set one by one to obtain an edge fitting accuracy set, including: Obtain standard punched edges; Based on the first punching edge fitting parameter among multiple punching edge fitting parameters, a standard punching edge is used to fit within the first punching edge to obtain the first edge fitting accuracy. Continuing with the other multiple punch edge fitting parameters, using standard punch edges, the punch edge set is fitted one by one to obtain the edge fitting accuracy set.

[0045] Specifically, firstly, the standard punched edge is defined by its geometric parameters, such as the position of the center, the radius, and the set of points on the edge. These are generally inherent settings on the punching machine. Since different models of products may have holes of different sizes, the corresponding standard punched edge needs to be obtained by measurement or reading of equipment parameters before fitting.

[0046] Secondly, when processing the set of punched edges one by one, the fitting number corresponding to the first punched edge among the multiple punched edge fitting parameters is used as the first punched edge fitting parameter. The standard punched edge is used as the benchmark, and the fitting is performed within the first punched edge according to the fitting number of the first punched edge fitting parameter. The first punched edge is the punched edge currently being processed.

[0047] Finally, using the same other multiple punch edge fitting parameters and standard punch edges, all punch edges in the punch edge set are fitted one by one to obtain the maximum edge fitting accuracy for each, and then integrated to obtain the edge fitting accuracy set.

[0048] In step S30 of the method provided in this application embodiment, according to the first drilling edge fitting parameter among multiple drilling edge fitting parameters, a standard drilling edge is used to fit within the first drilling edge to obtain the first edge fitting accuracy, including: Based on the pixel coordinates of the suspected pixels within the first punch edge, a first punch edge coordinate space is constructed. The standard punch edge is randomly input into the first punch edge coordinate space, and the similarity with the first punch edge is calculated as the edge fitting accuracy. Specifically, the coordinate similarity between each standard pixel within the standard punch edge and the nearest suspected pixel is calculated, and the mean value is calculated to obtain the similarity. Continue to randomly input standard punched edges until the first punched edge fitting parameters are met, and output the maximum edge fitting accuracy to obtain the first edge fitting accuracy.

[0049] Specifically, firstly, the coordinates of all suspected pixels on the first punch edge are extracted to establish a two-dimensional coordinate space. For example, the x-coordinate and y-coordinate values ​​of the leftmost and bottommost suspected pixels within the first punch edge are set to 0, and this is input into the coordinate system to form the coordinate space of the first punch edge. Then, based on the size of the standard punch, the x-coordinate and y-coordinate values ​​of the leftmost and bottommost suspected pixels are set to 0 to obtain the standard punch edge. After constructing the coordinate space of the first punch edge, a cyclical fitting process begins: each fitting iteration involves random placement, and during fitting, the similarity between the standard punch edge at the current position and the currently processed punch edge is calculated. For each pixel on the standard punch edge, the nearest pixel on the current punch edge is found, and the Euclidean distance between the two points is calculated. The square root of the square of the difference between the x-coordinates and the square of the difference between the y-coordinates is taken as the Euclidean distance between the two points. The nearest distances corresponding to all pixels on the first punch edge and the standard punch edge are calculated, and the average value is taken. The similarity is obtained by using 1 - average distance / maximum possible distance.

[0050] For example, there are N pixels. The first punch edge is compared with the standard punch edge, where the coordinates of a certain point K and K' are (33,25), (35,25), and (33-35), respectively. 2 +(25-25) 2 =4, the Euclidean distance is calculated to be 2. Similarly, the distances of the N pixels are calculated as follows: 4, 5, 3, 2, 3..., and the average value is (4+5+3+2+3+...) / N. Assuming the average value is 1.5 and the maximum distance is 10, the similarity is 1-(1.5 / 10)=0.85.

[0051] Secondly, similarly, the second edge is extracted from the set of punched edges, and the similarity is calculated repeatedly based on the number of fitting iterations until the fitting parameters of the first punched edge are met. After processing all edges, several edge fitting accuracy values ​​are obtained. Then, the maximum edge fitting accuracy is output to obtain the first edge fitting accuracy. For example, by comparison, the maximum edge fitting accuracy is found to be 0.98, and the first edge fitting accuracy = 0.98.

[0052] In this embodiment, a set of punch edge confidence is constructed to perform a preliminary quantitative assessment of the quality of each candidate edge. Subsequently, based on the punch edge confidence, the preset number of fitting iterations is dynamically adjusted, realizing dynamic allocation of computing resources and saving computing power. Then, standard punch edges are obtained, each candidate edge is fitted, and the similarity is calculated to accurately assess the degree of conformity between each candidate edge and the ideal circle. Finally, by selecting the edge with the highest edge fitting accuracy, the punch edge that is closest to the real hole edge is identified, improving the accuracy of edge positioning and enhancing the overall processing efficiency.

[0053] S40: Calculate the punch detection accuracy based on the maximum edge fitting accuracy and the punch edge set, and combine it with the selected punch edge as the detection result.

[0054] In this embodiment, the punching edge detection accuracy is analyzed based on the maximum edge fitting accuracy and the punching edge set, and punching quality detection is performed. At the same time, the final detection result is obtained by combining the selected punching edges.

[0055] Step S40 in the method provided in this application embodiment includes: Calculate the punch diameter of each punch edge within the punch edge set to obtain the punch diameter set; Calculate the discrete parameters of the punch diameter set, and calculate the ratio of the preset discrete parameters to the discrete parameters to obtain the discrete punch accuracy; The punch detection accuracy is calculated based on the maximum edge fitting accuracy and the discrete punch accuracy.

[0056] Specifically, firstly, the diameter of the punched edge reflects the stability of the overall hole edge size. For example, if the diameters of all punched edges are very close, it indicates that the actual hole edge is regular and the size is consistent; if the diameters of all punched edges vary greatly, it indicates that the hole may have deformation or burrs, resulting in large size fluctuations. Therefore, it is necessary to calculate the diameter value of each punched edge. For example, least-squares circle fitting can be performed on all pixels on each edge to obtain the diameter of the fitted circle, thereby constructing a set of punched diameters.

[0057] Secondly, based on the fitting accuracy, the discreteness of multiple punched edges is obtained, and the punched edge detection accuracy is analyzed to facilitate punched quality inspection. The discreteness parameter of the punched diameter set is calculated; for example, variance can be used to reflect the degree of deviation of all data points from the average value. A larger variance indicates that the punched diameter values ​​are more dispersed and the consistency of the hole edges is worse; a smaller variance indicates that the punched diameter values ​​are more concentrated and the hole edges are more regular. Subsequently, the ratio of the preset discreteness parameter to the discreteness parameter is calculated to obtain the discrete punched accuracy. The preset discreteness parameter can be the average discreteness parameter calculated from qualified punched inspection results over a historical period.

[0058] For example, for a certain punched edge, such as the punched diameters obtained as 100.5, 99.8, 99.6, 100.3..., we get (100.5-100.1)²+(99.8-100.1)²+(99.6-100.1)²+..., and the variance is 9.6 pixels. With the preset discreteness parameter = 9, the discrete punching accuracy is 9 / 9.6≈0.94.

[0059] Finally, the average of the maximum edge fitting accuracy and the discrete punching accuracy is calculated to obtain the punching detection accuracy.

[0060] For example, for a certain punched edge, the maximum edge fitting accuracy is 0.98, the discrete punching accuracy is 0.94, then the punching detection accuracy is (0.98+0.94) / 2=0.96.

[0061] In this embodiment, the drilling diameter is calculated for all candidate edges in the drilling edge set, and the discrete parameters are calculated and compared with the preset discrete parameters to obtain discrete drilling accuracy, thereby improving the stability of hole edges and the reliability of processing consistency. Then, the maximum edge fitting accuracy and discrete drilling accuracy are fused together to obtain comprehensive drilling detection accuracy, overcoming the limitations of drilling detection accuracy calculation, reflecting the integrity of the hole and process stability, improving the quality evaluation effect of edge detection, and enhancing the reliability of detection results.

[0062] The embodiments of this application, through the above specific implementation methods, achieve the following technical effects: In this embodiment, the original image is first subjected to grayscale and standardization processing in sequence, which effectively eliminates the impact of illumination fluctuations on image quality. Then, a preset window is used to select the neighborhood of each pixel and calculate the mean grayscale difference to obtain the distribution of adjacent change values, which improves the distinguishability of edge features and effectively suppresses the interference of isolated noise points, providing high-quality input data for subsequent processing.

[0063] Secondly, by normalizing the distribution of adjacency variation values, errors caused by differences in illumination intensity or contrast between different images are eliminated; at the same time, by combining the adjacency variation value threshold, high-probability suspected pixels are screened out, reducing the amount of data and complexity of subsequent processing; then, multiple candidate edges are constructed to form a punched edge set, improving the accuracy of edge extraction.

[0064] Next, a set of punch edge confidence is constructed to conduct a preliminary quantitative assessment of the quality of each candidate edge. Then, based on the punch edge confidence, the preset number of fittings is dynamically adjusted, realizing dynamic allocation of computing resources and saving computing power. Furthermore, standard punch edges are obtained, and each candidate edge is fitted to calculate the similarity, accurately assessing the degree of conformity between each candidate edge and the ideal circle. Finally, by selecting the edge with the highest edge fitting accuracy, the punch edge that is closest to the real hole edge is identified, improving the accuracy of edge positioning and enhancing the overall processing efficiency.

[0065] Finally, by calculating the drilling diameter of all candidate edges in the drilling edge set, calculating the discrete parameters and obtaining the ratio with the preset discrete parameters, the discrete drilling accuracy is obtained, which improves the stability of the hole edge and the reliability of the processing consistency. Then, the maximum edge fitting accuracy and the discrete drilling accuracy are fused together to obtain the comprehensive drilling detection accuracy, which overcomes the limitations of drilling detection accuracy calculation, and reflects the integrity of the hole and the stability of the process, thereby improving the quality evaluation effect of edge detection and enhancing the reliability of the detection results.

[0066] Example 2, as Figure 2 As shown, based on the same inventive concept as the online punch image detection method based on edge detection provided in Embodiment 1, this embodiment of the invention also provides an online punch image detection system based on edge detection, comprising: The image acquisition module 11 is used to acquire the image after the punching process and perform preprocessing to obtain the punched image, calculate the adjacency change value of each pixel, and obtain the adjacency change value distribution; The edge rate analysis module 12 is used to perform punching edge rate analysis based on the distribution of adjacent change values, obtain the punching edge rate distribution, and construct the punching edge set; The fitting accuracy filtering module 13 is used to configure the punching edge fitting parameters according to the punching edge rate distribution, use standard punching edges to fit the punching edge set one by one to obtain the edge fitting accuracy set, and filter to obtain the selected punching edge corresponding to the maximum edge fitting accuracy. The detection accuracy acquisition module 14 is used to calculate the punch detection accuracy based on the maximum edge fitting accuracy and the punch edge set, and combine it with the selected punch edge as the detection result. In one embodiment, the image acquisition module 11 is used for: The image after the punching process is acquired, and then subjected to grayscale and standardization processing to obtain the punched image. The grayscale value of each pixel in the punched image is calculated by the adjacent grayscale value change to obtain the adjacent change value distribution.

[0067] Specifically, the grayscale value of each pixel in the punched image is calculated by performing adjacent grayscale value changes to obtain the distribution of adjacent change values, including: Using a preset window, the neighboring pixels of each pixel in the punched image are selected to obtain the set of adjacent pixels; Extract the adjacent gray value set corresponding to the adjacent pixel set, and calculate the average difference between the gray value set and the corresponding pixel value to obtain the adjacent change value; Calculate the adjacency change value of all pixels to obtain the distribution of adjacency change values.

[0068] In one embodiment, the edge rate analysis module 12 is used for: Filter the adjacent change value with the largest adjacent change value within the adjacent change value distribution; Calculate the ratio of each adjacent change value to the maximum adjacent change value, and use it as the punching edge rate to obtain the punching edge probability distribution; A set of punched edges is constructed based on the probability distribution of punched edges and the punched image.

[0069] Specifically, based on the probability distribution of the punched edges and the punched image, a set of punched edges is constructed, including: Based on the punched image detection data over a historical period, obtain the threshold values ​​for adjacent change values ​​in the punched and non-punched areas; Filter the pixels and punch edge probabilities corresponding to adjacent change values ​​that are greater than or equal to the adjacent change value threshold to obtain the set of suspected pixels and the set of suspected punch edge probabilities; Based on the punch image detection data from a historical period, obtain the preset number of pixels at the edge of the punch in a qualified punch image; Within the set of suspected pixels, a preset number of suspected pixels are randomly selected. Neighboring suspected pixels are connected one by one to form the punched edge. This selection and connection is repeated multiple times to obtain the punched edge set.

[0070] In one embodiment, the fitting accuracy screening module 13 is used for: Obtain the probability of the suspected punch edge corresponding to all suspected pixels within each punch edge, and calculate the mean to obtain the punch edge confidence set; Obtain preset punch edge fitting parameters, wherein the preset punch edge fitting parameters include a preset number of fitting iterations; Calculate the ratio of the confidence level of each punch edge to the maximum value within the confidence level set of punch edges, adjust the calculation based on the preset number of fitting iterations, and obtain multiple punch edge fitting parameters; Based on multiple punching edge fitting parameters, using standard punching edges, the punching edge set is fitted one by one to obtain the edge fitting accuracy set; Select the punched edge corresponding to the highest edge fitting accuracy as the selected punched edge.

[0071] Specifically, based on multiple perforation edge fitting parameters, standard perforation edges are used to fit the perforation edge set one by one, resulting in an edge fitting accuracy set, including: Obtain standard punched edges; Based on the first punching edge fitting parameter among multiple punching edge fitting parameters, a standard punching edge is used to fit within the first punching edge to obtain the first edge fitting accuracy. Continuing with the other multiple punch edge fitting parameters, using standard punch edges, the punch edge set is fitted one by one to obtain the edge fitting accuracy set.

[0072] Specifically, based on the first punching edge fitting parameter among multiple punching edge fitting parameters, a standard punching edge is used to fit within the first punching edge to obtain the first edge fitting accuracy, including: Based on the pixel coordinates of the suspected pixels within the first punch edge, a first punch edge coordinate space is constructed. The standard punch edge is randomly input into the first punch edge coordinate space, and the similarity with the first punch edge is calculated as the edge fitting accuracy. Specifically, the coordinate similarity between each standard pixel within the standard punch edge and the nearest suspected pixel is calculated, and the mean value is calculated to obtain the similarity. Continue to randomly input standard punched edges until the first punched edge fitting parameters are met, and output the maximum edge fitting accuracy to obtain the first edge fitting accuracy.

[0073] In one embodiment, the detection accuracy acquisition module 14 is used for: Calculate the punch diameter of each punch edge within the punch edge set to obtain the punch diameter set; Calculate the discrete parameters of the punch diameter set, and calculate the ratio of the preset discrete parameters to the discrete parameters to obtain the discrete punch accuracy; The punch detection accuracy is calculated based on the maximum edge fitting accuracy and the discrete punch accuracy.

[0074] Compared with existing technologies, this application first performs grayscale and standardization processing on the original image in sequence, which effectively eliminates the impact of illumination fluctuations on image quality. Then, a preset window is used to select the neighborhood of each pixel and calculate the mean of grayscale difference to obtain the distribution of adjacent change values, which improves the distinguishability of edge features and effectively suppresses the interference of isolated noise points, providing high-quality input data for subsequent processing.

[0075] Secondly, by normalizing the distribution of adjacency variation values, errors caused by differences in illumination intensity or contrast between different images are eliminated; at the same time, by combining the adjacency variation value threshold, high-probability suspected pixels are screened out, reducing the amount of data and complexity of subsequent processing; then, multiple candidate edges are constructed to form a punched edge set, improving the accuracy of edge extraction.

[0076] Next, a set of punch edge confidence is constructed to conduct a preliminary quantitative assessment of the quality of each candidate edge. Then, based on the punch edge confidence, the preset number of fittings is dynamically adjusted, realizing dynamic allocation of computing resources and saving computing power. Furthermore, standard punch edges are obtained, and each candidate edge is fitted to calculate the similarity, accurately assessing the degree of conformity between each candidate edge and the ideal circle. Finally, by selecting the edge with the highest edge fitting accuracy, the punch edge that is closest to the real hole edge is identified, improving the accuracy of edge positioning and enhancing the overall processing efficiency.

[0077] Finally, by calculating the drilling diameter of all candidate edges in the drilling edge set, calculating the discrete parameters and obtaining the ratio with the preset discrete parameters, the discrete drilling accuracy is obtained, which improves the stability of the hole edge and the reliability of the processing consistency. Then, the maximum edge fitting accuracy and the discrete drilling accuracy are fused together to obtain the comprehensive drilling detection accuracy, which overcomes the limitations of drilling detection accuracy calculation, and reflects the integrity of the hole and the stability of the process, thereby improving the quality evaluation effect of edge detection and enhancing the reliability of the detection results.

Claims

1. An online method for detecting punched images based on edge detection, characterized in that, The method includes: The image after punching is acquired and preprocessed to obtain the punched image. The adjacency change value of each pixel is calculated to obtain the adjacency change value distribution. Based on the adjacent change value distribution, a punching edge rate analysis is performed to obtain the punching edge rate distribution, and a punching edge set is constructed. Based on the punching edge rate distribution, punching edge fitting parameters are configured, and standard punching edges are used to fit the punching edge set one by one to obtain the edge fitting accuracy set. The selected punching edge corresponding to the maximum edge fitting accuracy is then selected. The punch detection accuracy is calculated based on the maximum edge fitting accuracy and the punch edge set, and the selected punch edge is used as the detection result.

2. The online punch image detection method based on edge detection according to claim 1, characterized in that, The image after punching is acquired and preprocessed to obtain the punched image. The adjacency change value of each pixel is calculated to obtain the distribution of adjacency change values, including: The image after the punching process is acquired, and then subjected to grayscale and standardization processing to obtain the punched image. The grayscale value of each pixel in the punched image is calculated by the adjacent grayscale value change to obtain the adjacent change value distribution.

3. The online punch image detection method based on edge detection according to claim 2, characterized in that, The grayscale value of each pixel in the punched image is calculated by performing adjacent grayscale value changes to obtain the distribution of adjacent change values, including: Using a preset window, the neighboring pixels of each pixel in the punched image are selected to obtain the set of adjacent pixels; Extract the adjacent gray value set corresponding to the adjacent pixel set, and calculate the average difference between the gray value set and the corresponding pixel value to obtain the adjacent change value; Calculate the adjacency change value of all pixels to obtain the distribution of adjacency change values.

4. The online punch image detection method based on edge detection according to claim 1, characterized in that, Based on the adjacent change value distribution, a punching edge rate analysis is performed to obtain the punching edge probability distribution, and a punching edge set is constructed, including: Filter the adjacent change value with the largest adjacent change value within the distribution of the adjacent change values; Calculate the ratio of each adjacent change value to the maximum adjacent change value, and use it as the punching edge rate to obtain the punching edge probability distribution; Based on the probability distribution of the punched edges and the punched image, a set of punched edges is constructed.

5. The online punch image detection method based on edge detection according to claim 4, characterized in that, Based on the punch edge probability distribution and the punch image, a punch edge set is constructed, including: Based on the punched image detection data over a historical period, obtain the threshold values ​​for adjacent change values ​​in the punched and non-punched areas; Filter the pixels and punch edge probabilities corresponding to the adjacent change values ​​that are greater than or equal to the threshold value to obtain the set of suspected pixels and the set of suspected punch edge probabilities. Based on the punch image detection data from a historical period, obtain the preset number of pixels at the edge of the punch in a qualified punch image; Within the set of suspected pixels, a preset number of suspected pixels are randomly selected, and neighboring suspected pixels are connected one by one to form a punched edge. This selection and connection is repeated multiple times to obtain a set of punched edges.

6. The online punch image detection method based on edge detection according to claim 1, characterized in that, Based on the perforation edge rate distribution, perforation edge fitting parameters are configured. Using standard perforation edges, each perforation edge set is fitted to obtain an edge fitting accuracy set. The selected perforation edges corresponding to the highest edge fitting accuracy are then selected, including: Obtain the probability of the suspected punch edge corresponding to all suspected pixels within each punch edge, and calculate the mean to obtain the punch edge confidence set; Obtain preset punch edge fitting parameters, wherein the preset punch edge fitting parameters include a preset number of fitting iterations; Calculate the ratio of the confidence level of each punch edge to the maximum value within the set of confidence levels of punch edges, and adjust the calculation based on the preset number of fitting iterations to obtain multiple punch edge fitting parameters; Based on the multiple punching edge fitting parameters, the standard punching edge is used to fit the punching edge set one by one to obtain the edge fitting accuracy set. Select the punched edge corresponding to the highest edge fitting accuracy as the selected punched edge.

7. The online punch image detection method based on edge detection according to claim 6, characterized in that, Based on the multiple perforation edge fitting parameters, and using standard perforation edges, the perforation edge set is fitted one by one to obtain an edge fitting accuracy set, including: Obtain standard punched edges; Based on the first punching edge fitting parameter among multiple punching edge fitting parameters, a standard punching edge is used to fit within the first punching edge to obtain the first edge fitting accuracy. Continuing with the other multiple punch edge fitting parameters, using standard punch edges, the punch edge set is fitted one by one to obtain the edge fitting accuracy set.

8. The online punch image detection method based on edge detection according to claim 7, characterized in that, Based on the first punch edge fitting parameter among multiple punch edge fitting parameters, a standard punch edge is used to fit within the first punch edge to obtain the first edge fitting accuracy, including: Based on the pixel coordinates of the suspected pixels within the first punch edge, a first punch edge coordinate space is constructed. The standard punch edge is randomly input into the first punch edge coordinate space, and the similarity with the first punch edge is calculated as the edge fitting accuracy. Specifically, the coordinate similarity between each standard pixel within the standard punch edge and the nearest suspected pixel is calculated, and the mean value is calculated to obtain the similarity. Continue to randomly input standard punched edges until the first punched edge fitting parameters are met, and output the maximum edge fitting accuracy to obtain the first edge fitting accuracy.

9. The online punch image detection method based on edge detection according to claim 1, characterized in that, Based on the selected punched edge, the maximum edge fitting accuracy, and the punched edge set, the punch detection accuracy is calculated, including: Calculate the drilling diameter of each drilling edge within the drilling edge set to obtain the drilling diameter set; Calculate the discrete parameters of the hole diameter set, and calculate the ratio of the preset discrete parameters to the discrete parameters to obtain the discrete hole accuracy; The punch detection accuracy is calculated based on the maximum edge fitting accuracy and the discrete punch accuracy.

10. An online punch image detection system based on edge detection, characterized in that, For implementing the online punch image detection method based on edge detection as described in any one of claims 1-9, the system comprises: The image acquisition module is used to acquire images after the punching process and perform preprocessing to obtain punched images, calculate the adjacency change value of each pixel, and obtain the adjacency change value distribution; The edge rate analysis module is used to perform punching edge rate analysis based on the adjacent change value distribution, obtain the punching edge rate distribution, and construct the punching edge set; The fitting accuracy filtering module is used to configure the punching edge fitting parameters according to the punching edge rate distribution, use standard punching edges to fit the punching edge set one by one to obtain the edge fitting accuracy set, and filter to obtain the selected punching edge corresponding to the maximum edge fitting accuracy. The detection accuracy acquisition module is used to calculate the punch detection accuracy based on the maximum edge fitting accuracy and the punch edge set, and combine it with the selected punch edge as the detection result.