A profile weld seam detection method and system based on industrial vision

By using Gaussian filters and local polar coordinate system analysis in profile weld inspection, the weld seam image is dynamically captured. Combined with boundary continuity and internal gray level index, the problem of false detection and missed detection caused by the overlap of oxide scale patches and micro pores is solved, thus improving the accuracy and reliability of the inspection.

CN123141418APending Publication Date: 2026-11-20SHANDONG JITU INTELLIGENT EQUIPMENT CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611430453.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-15
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In existing profile weld inspection, the overlapping grayscale characteristics of oxide scale patches and micropores lead to false detections and missed detections, affecting the reliability of the inspection results.

Method used

By acquiring the original image data of the profile, Gaussian filters are used for smoothing and noise reduction. Combined with column pixel grayscale projection and first derivative extremum analysis, weld seam images are dynamically extracted. Local polar coordinate system is used to analyze boundary continuity and internal grayscale level index to determine the authenticity of potential hole areas.

Benefits of technology

It effectively identifies and removes surface oxide scale interference, significantly improves the accuracy and robustness of micropore detection, reduces the false negative rate, and ensures the reliability of welding defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123141418A_ABST
    Figure CN123141418A_ABST
Patent Text Reader

Abstract

The application relates to the profile weld detection technical field and provides a profile weld detection method and system based on industrial vision, which comprises the following steps: determining a welding seam image according to original image data and a welding precision index; determining potential hole regions in the welding seam image according to the welding seam image; determining a boundary closed continuity index of each potential hole region according to image data of each potential hole region in the welding seam image; determining an internal gray level index of each potential hole region according to the image data of each potential hole region in the welding seam image; and judging whether each potential hole region is a real hole region according to the boundary closed continuity index and the internal gray level index of the potential hole region. Through the scheme, the efficiency of profile weld detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of profile weld inspection technology, and in particular to a profile weld inspection method and system based on industrial vision. Background Technology

[0002] In the inspection of weld defects in profiles of intelligent manufacturing equipment, an automated system based on industrial vision is usually used. This system uses a high-angle ring light source to illuminate the weld and acquire grayscale images. Candidate regions are extracted by grayscale threshold segmentation, and micro-porosity defects are screened by combining morphological criteria such as roundness.

[0003] However, in actual production, the heat-affected zone of the weld is affected by oxidation, and irregular oxide scale often peels off the surface. These dark patches formed by the oxide scale peeling often overlap with the actual micropores in terms of grayscale features, making it impossible for grayscale thresholding to effectively separate the two, thus leading to the incorrect extraction of oxide scale patches. Existing image processing logic, lacking multi-dimensional distinguishing features, often misclassifies near-circular oxide scale patches as pores, resulting in serious false detection problems. Furthermore, increasing morphological strictness to suppress false alarms can lead to the missed detection of some slightly irregularly shaped actual pores, severely affecting the reliability of weld defect detection results. Summary of the Invention

[0004] This application provides a method and system for inspecting profile welds based on industrial vision, aiming to solve the problems of false detection and missed detection caused by the overlap of grayscale features of oxide scale patches and micropores in the prior art.

[0005] The technical solution of this application is as follows: In a first aspect, this application discloses a method for inspecting profile welds based on industrial vision, comprising: acquiring original image data and welding accuracy index of the profile to be inspected; determining a weld image based on the original image data and welding accuracy index; determining potential hole regions in the weld image based on the weld image; determining the boundary closure continuity index of each potential hole region based on the image data of each potential hole region in the weld image; determining the internal grayscale level index of each potential hole region based on the image data of each potential hole region in the weld image; and determining whether a potential hole region is a real hole region for each potential hole region based on the boundary closure continuity index and the internal grayscale level index.

[0006] Optionally, determining the weld seam image based on the original image data and the welding accuracy index includes: smoothing and denoising the original image data using a Gaussian filter to obtain intermediate image data; identifying the edge of the weld seam in the intermediate image data based on column pixel grayscale projection and first derivative extremum analysis; using the product of a first value and a first preset pixel distance as the target pixel distance; the first value being the difference between 1 and the welding accuracy index; extending the target pixel distance from the edge of the weld seam towards the target direction to obtain the target edge; the target direction being perpendicular to the edge of the weld seam and the target direction being the direction away from the weld seam; and using the area enclosed by the target edge as the weld seam image.

[0007] Optionally, determining the potential hole region in the weld seam image based on the weld seam image includes: for each pixel in the weld seam image, determining the mean gray value and standard deviation of the gray value of the pixel and its neighboring pixels; determining whether the gray value of the pixel is less than a target gray value; the target gray value is the difference between the mean gray value of the pixel and a second value; the second value is the product of a preset gray coefficient and the standard deviation of the gray value; when the gray value of the pixel is less than the target gray value, the pixel is determined to be a potential hole pixel; when the gray value of the pixel is greater than or equal to the target gray value, the pixel is determined not to be a potential hole pixel; and determining the potential hole region in the weld seam image based on the potential hole pixels in the weld seam image.

[0008] Optionally, determining the potential hole region in the weld seam image based on the potential hole pixels in the weld seam image includes: merging spatially adjacent potential hole pixels in the weld seam image into connected components based on a connected component labeling algorithm; for each connected component, determining whether the total number of pixels within the connected component is within a preset hole number range; when the total number of pixels within the connected component is within the preset hole number range, determining the corresponding connected component as a potential hole region; when the total number of pixels within the connected component is outside the preset hole number range, determining the corresponding connected component as not a potential hole region.

[0009] Optionally, based on the image data of each potential hole region in the weld seam image, the boundary closure continuity index of each potential hole region is determined, including: establishing a local polar coordinate system for each potential hole region with the centroid of each potential hole region as the pole; starting from the pole of the local polar coordinate system of each potential hole region, determining multiple line segments of each potential hole region with a preset angular step size; the length of the line segment is a second preset pixel distance; for each potential hole region, calculating the gray-level gradient magnitude between adjacent pixels on each line segment of the potential hole region based on the Sobel operator; for each line segment of the potential hole region, determining whether there is a gray-level gradient magnitude greater than a preset value. Define the target adjacent pixels with a grayscale gradient magnitude threshold. When there are target adjacent pixels on the line segment with a grayscale gradient magnitude greater than the preset threshold, select the pixel closest to the extremum among the target adjacent pixels as the candidate boundary pixel of the line segment. When there are no target adjacent pixels on the line segment with a grayscale gradient magnitude greater than the preset threshold, determine that there are no candidate boundary pixels on the line segment. For each candidate boundary pixel in each potential hole region, determine the actual gradient direction vector of the candidate boundary pixel. Determine the boundary closure continuity index of each potential hole region based on the actual gradient direction vector of the candidate boundary pixels in each potential hole region.

[0010] Optionally, the boundary closure continuity index of each potential hole region is determined based on the actual gradient direction vector of the candidate boundary pixels of each potential hole region, including: for each candidate boundary pixel of each potential hole region, the cosine of the angle between the actual gradient direction vector of the candidate boundary pixel and the target gradient direction vector of the candidate boundary pixel is used as the sub-boundary closure continuity index of the candidate boundary pixel; the target gradient direction vector of the candidate boundary pixel is the direction vector of the candidate boundary pixel pointing to the pole; the ratio of the sum of the sub-boundary closure continuity indices of all candidate boundary pixels of each potential hole region to the total number of all line segments corresponding to each potential hole region is used as the boundary closure continuity index of each potential hole region.

[0011] Optionally, based on the image data of each potential hole region in the weld seam image, the internal grayscale level index of each potential hole region is determined, including: determining the Euclidean distance between each pixel in each potential hole region and the nearest candidate boundary pixel; defining the region formed by pixels with an Euclidean distance less than a first preset Euclidean distance as the outer ring region of each potential hole region; defining the region formed by pixels with an Euclidean distance greater than a second preset Euclidean distance as the inner ring region of each potential hole region; the second preset Euclidean distance is greater than the first preset Euclidean distance; defining the region formed by pixels with an Euclidean distance less than or equal to the second preset Euclidean distance and an Euclidean distance greater than or equal to the first preset Euclidean distance as the middle ring region of each potential hole region; and determining the internal grayscale level index of each potential hole region based on the image data of the middle ring region, the outer ring region, and the inner ring region of each potential hole region.

[0012] Optionally, based on the image data of the middle ring area, outer ring area, and inner ring area of ​​each potential hole area, the internal grayscale level index of each potential hole area is determined, including: determining the mean grayscale value of the middle ring area image data of each potential hole area based on the middle ring area image data of each potential hole area; determining the mean grayscale value of the inner ring area image data of each potential hole area based on the inner ring area image data of each potential hole area; and determining the mean grayscale value of the outer ring area image data of each potential hole area based on the outer ring area image data of each potential hole area. For each potential hole region, the difference between the mean gray value of the outer ring area image data and the mean gray value of the middle ring area image data is taken as the first gray value difference of the potential hole region; the difference between the mean gray value of the middle ring area image data and the mean gray value of the inner ring area image data is taken as the second gray value difference of the potential hole region; and the sum of the first gray value difference and the second gray value difference of each potential hole region is taken as the internal gray level index of the potential hole region.

[0013] Optionally, determining whether a potential hole region is a real hole region based on its boundary closure continuity index and internal grayscale level index includes: for each potential hole region, determining whether the boundary closure continuity index of the potential hole region is greater than a preset boundary closure continuity index threshold; if the boundary closure continuity index of the potential hole region is less than or equal to the preset boundary closure continuity index threshold, determining that the potential hole region is not a real hole region; if the boundary closure continuity index of the potential hole region is greater than the preset boundary closure continuity index threshold, determining whether the internal grayscale level index of the potential hole region is greater than a preset internal grayscale level index threshold; if the internal grayscale level index of the potential hole region is greater than the preset internal grayscale level index threshold, determining that the potential hole region is a real hole region; if the internal grayscale level index of the potential hole region is less than or equal to the preset internal grayscale level index threshold, determining that the potential hole region is not a real hole region.

[0014] Secondly, this application also discloses a profile weld inspection system based on industrial vision, comprising: an acquisition device and a processing device; the acquisition device is used to acquire the original image data and welding accuracy index of the profile to be inspected; the processing device is used to determine the weld image based on the original image data and welding accuracy index; the processing device is also used to determine potential hole regions in the weld image based on the weld image; the processing device is also used to determine the boundary closure continuity index of each potential hole region based on the image data of each potential hole region in the weld image; the processing device is also used to determine the internal grayscale level index of each potential hole region based on the image data of each potential hole region in the weld image; the processing device is also used to determine whether a potential hole region is a real hole region for each potential hole region based on the boundary closure continuity index and the internal grayscale level index of the potential hole region.

[0015] Beneficial effects

[0016] The method provided in this application acquires the original image of the profile to be inspected and dynamically extracts the weld seam image. After determining the potential pore area, it achieves in-depth mining of defect features by calculating the boundary closure continuity index and the internal grayscale level index. Compared with existing technologies that rely solely on grayscale thresholds and roundness for discrimination, this scheme analyzes the continuity of the boundary contour by constructing a local polar coordinate system and combines the grayscale difference between the inner and outer ring areas to reflect the physical concavity characteristics of the pores, effectively identifying and eliminating interference such as surface oxide scale. This multi-dimensional and multi-stage discrimination logic completely solves the problem caused by the overlap between oxide scale patches and real pore features, significantly reducing the false negative rate while greatly improving the accuracy and robustness of micropore detection, ensuring the reliability of the welding defect detection system. Attached Figure Description

[0017] Figure 1 A flowchart illustrating a profile weld inspection method based on industrial vision provided in this application; Figure 2 A flowchart illustrating another industrial vision-based method for inspecting profile welds provided in this application; Figure 3 This is a schematic diagram of the architecture of a profile weld inspection system based on industrial vision, provided in this application. Detailed Implementation

[0018] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following drawings indicate similar items; therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0019] like Figure 1 As shown, the technical solution disclosed in this embodiment is as follows: S101. Obtain the original image data and welding accuracy index of the profile to be inspected.

[0020] S102. Determine the weld seam image based on the original image data and welding accuracy index.

[0021] S103. Determine the potential void areas in the weld seam image based on the weld seam image.

[0022] S104. Based on the image data of each potential hole region in the weld seam image, determine the boundary closure continuity index of each potential hole region.

[0023] S105. Based on the image data of each potential hole area in the weld seam image, determine the internal gray level index of each potential hole area.

[0024] S106. For each potential hole region, determine whether the potential hole region is a real hole region based on the boundary closure continuity index and the internal gray level index of the potential hole region.

[0025] The following will combine Figure 2 The proposed solution will be explained in detail.

[0026] In the operational logic of the above overall technical solution, the system first acquires basic images and process parameters. Specifically, as shown in the example below, it receives raw image data of the profile to be inspected in real time from an industrial camera via a gigabit Ethernet interface, and simultaneously reads the welding accuracy index of the current batch of profiles from a programmable logic controller (PLC) via an industrial communication protocol. To ensure that the image data and welding accuracy index correspond in time, the system generates the same batch identifier each time a profile enters the inspection station, and writes this batch identifier to both the image cache record and the process parameter record. In this way, during subsequent processing, the system can bind the raw image data corresponding to the same profile with the welding accuracy index, avoiding mismatches where the image comes from a previous profile but the process parameters come from a subsequent profile.

[0027] After acquiring the basic data, it is necessary to determine the weld seam image. In one possible example, the original image data can be cropped using a pre-defined fixed coordinate frame to directly extract the image region at a fixed position as the weld seam image. This method is suitable for scenarios where the weld seam's position in the camera's field of view is relatively stable, the profile specifications change little, and the conveying posture fluctuations are weak.

[0028] Subsequently, potential void regions need to be extracted from the weld seam image. In some implementations, a globally fixed grayscale threshold segmentation method can be used. For example, a batch of representative weld seam images can be pre-selected, and the approximate differences in grayscale distribution between real pores, oxide scale patches, and normal weld seam background can be statistically analyzed. Based on this, a global grayscale threshold T can be set. The system traverses the weld seam image, extracts pixels with grayscale values ​​lower than T, and connects adjacent pixels through morphological closing operations to form several potential void regions. Here, the morphological closing operation is mainly used to fill in small discontinuities in local dark areas, reconnecting pixels that originally belonged to the same dark spot but were slightly broken due to noise or reflection into a complete region.

[0029] After extracting the potential pore areas, the system needs to further extract multidimensional features for differentiation, as these areas contain a mixture of real micropores and oxide scale flakes. Real pores, being three-dimensional physical pores, typically exhibit continuous shadow transitions at their edges under ring light illumination, and their interiors display distinct grayscale levels due to varying depths, generally appearing brighter near the edges and gradually darkening towards the center. In contrast, oxide scale flakes are two-dimensional peelings, often with jagged or discontinuous edges, and may also be accompanied by flaky tearing marks. Their internal grayscale is relatively uniform, lacking the stable sense of depth inherent in spatial layers.

[0030] Therefore, the system calculates the boundary closure continuity index and the internal grayscale level index for each potential hole region. Finally, it combines these two indices to classify each potential hole region and determine whether it is a real hole region. More specifically, the boundary closure continuity index can be determined based on whether the outer contour of the region is complete, whether the contour direction is smooth, and whether the edge grayscale changes are continuous. The internal grayscale level index can be determined based on whether there are multi-level grayscale bands that gradually darken from the outside to the inside of the region, and whether there is a relatively stable progressive relationship between different levels. If a potential hole region exhibits both good boundary closure continuity and obvious internal grayscale levels, it is more likely to be classified as a real hole region; if the boundary is broken and the internal grayscale is flat or chaotic, it is more likely to be classified as an oxide scale patch.

[0031] The aforementioned overall technical solution breaks through the limitations of traditional methods that rely solely on a single grayscale threshold and two-dimensional circularity for judgment. By utilizing the boundary continuity and internal grayscale gradation characteristics mapped from the three-dimensional physical structure of real pores in a two-dimensional image, a boundary closure continuity index and an internal grayscale level index are constructed. These two dimensions of features can accurately characterize the essential differences between pores and oxide scale patches in optical imaging. Therefore, even when dark patches formed by localized oxide scale peeling overlap with real micropores on the grayscale histogram, these two objects can still be stably separated. This effectively solves the problem of simultaneous false and false detections of pores, significantly improving the reliability of weld defect detection results. This is because grayscale values ​​and two-dimensional shapes can only reflect the brightness and contour approximation of a region on a single plane, while the boundary closure continuity index further introduces information about whether the edge imaging conforms to the light-receiving laws of the pores, and the internal grayscale level index further introduces information about whether the region has depth mapping characteristics. In other words, even if an oxide scale patch happens to have a similar low grayscale value to a real pore at a certain moment, and even if its outer contour is approximately circular, it will still differ from a real pore in these two indices as long as its edges have a strong sense of breakage and its interior lacks a hierarchical structure that gradually darkens from the edge to the center. It is precisely because the classification criteria have expanded from a single dimension to complementary multi-dimensional dimensions that the system has the ability to simultaneously suppress false detections and false negatives in complex contexts.

[0032] To extract weld images containing the complete heat-affected zone more accurately, in some preferred embodiments, the weld image is determined based on the original image data and the welding accuracy index, including: smoothing and denoising the original image data using a Gaussian filter to obtain intermediate image data; identifying the edge of the weld in the intermediate image data based on column pixel grayscale projection and first derivative extremum analysis; using the product of a first value and a first preset pixel distance as the target pixel distance; the first value is the difference between 1 and the welding accuracy index; extending the target pixel distance from the edge of the weld towards the target direction to obtain the target edge; the target direction is perpendicular to the edge of the weld and is the direction away from the weld; and using the area enclosed by the target edge as the weld image.

[0033] More specifically, the system first uses a Gaussian filter to perform convolution operations on the original image data to eliminate fine reflective noise on the metal surface, resulting in smooth intermediate image data. The purpose of using the Gaussian filter here is not to significantly blur the weld boundary, but to suppress isolated bright spots, fine reflective textures, and sensor noise, making the subsequent grayscale projection curve smoother and avoiding interference from local spikes in derivative analysis. The window size and filtering intensity of the Gaussian filter can be pre-tuned and determined based on image resolution, weld width, and surface reflectivity. If the filter is too weak, noise suppression will be insufficient; if the filter is too strong, it may weaken the true grayscale changes at the weld edge. Therefore, filter parameters that can suppress fine noise while preserving the overall weld boundary transition are usually selected. Next, the two-dimensional intermediate image data is accumulated along the column direction to obtain a one-dimensional column pixel grayscale projection curve. "Accumulating grayscale along the column direction" can be understood as summarizing the pixel grayscale values ​​in each column, compressing the originally two-dimensional grayscale information into a one-dimensional curve reflecting lateral positional changes. Because the weld area differs from the base material areas on both sides in terms of surface texture, reflectivity, and heat-affected zone distribution, the column pixel grayscale projection curve typically shows significant changes when the scanning position moves from the base material into the weld and then from the weld to the other base material. Subsequently, performing first-order derivative extremum analysis on this projection curve to find the location of the most drastic grayscale change allows for the localization of the weld edge.

[0034] Subsequently, an adaptive expansion was implemented using a welding accuracy index. The welding accuracy index reflects the stability of the current weld formation and can therefore serve as a basis for adjusting the expansion range of the heat-affected zone. A higher welding accuracy index indicates a more concentrated weld formation and smaller boundary fluctuations, typically eliminating the need for excessive outward expansion. Conversely, a lower welding accuracy index suggests that weld edge undulations, heat-affected zone diffusion, and oxide scale peeling are more likely to extend outwards, requiring an appropriate increase in the envelope distance from the weld edge.

[0035] In practice, the system first calculates a first value based on the welding accuracy index, then combines this first value with a first preset pixel distance to obtain the target pixel distance. The first preset pixel distance can be obtained through prior sample statistics. Specifically, it can be achieved by acquiring multiple profile images under different welding conditions, manually marking the approximate distance from the weld edge to the outer edge of the heat-affected zone, statistically analyzing the range of distances that cover most oxide scale peeling areas and actual porosity distribution areas, and then selecting the pixel distance suitable as the base extension amount as the first preset pixel distance. With this setting, the lower the welding accuracy index, the larger the target pixel distance; the higher the welding accuracy index, the smaller the target pixel distance, thus achieving adaptive trimming that matches the process state. Next, the system extends the target pixel distance from the identified weld edge towards the target direction to obtain the target edge. The target direction here is perpendicular to the weld edge and points away from the weld center. Its purpose is to include the heat-affected zone and the peripheral areas where oxide scale peeling and micro-porosity may exist, rather than repeatedly extending into the weld interior. If both sides of the weld need to be preserved, the corresponding distance can be extended outward from each side edge, ultimately forming the weld image together with the two target edges and the weld length boundary. If the weld in the original image is slightly tilted, the target direction can be determined according to the local edge normal direction to ensure that the extended area always conforms to the actual weld direction, rather than simply mechanically extending along the horizontal or vertical direction of the image.

[0036] This specific implementation scheme achieves adaptive dynamic extraction of the region of interest (ROI) in the weld by combining low-level image features (grayscale projection and derivative extrema) with prior process parameters (welding accuracy index). It not only accurately locates the weld body but also dynamically adjusts the envelope of the heat-affected zone based on welding quality, ensuring that areas potentially containing oxide scale patches and porosity are fully preserved under various process fluctuations, providing a high-quality data foundation for subsequent accurate inspection.

[0037] Optionally, determining the potential hole region in the weld seam image based on the weld seam image includes: for each pixel in the weld seam image, determining the mean gray value and standard deviation of the gray value of the pixel and its neighboring pixels; determining whether the gray value of the pixel is less than a target gray value; the target gray value is the difference between the mean gray value of the pixel and a second value; the second value is the product of a preset gray coefficient and the standard deviation of the gray value; when the gray value of the pixel is less than the target gray value, the pixel is determined to be a potential hole pixel; when the gray value of the pixel is greater than or equal to the target gray value, the pixel is determined not to be a potential hole pixel; and determining the potential hole region in the weld seam image based on the potential hole pixels in the weld seam image.

[0038] In practical implementation, the system traverses the weld seam image and selects a local window as the neighborhood for each central pixel. The size of this local window can be preset based on the image resolution, the expected minimum porosity, and the surface texture density of the weld seam. If the window is too small, the local statistical results are easily affected by a single noise point; if the window is too large, it may mix different lighting areas together, weakening the local adaptive capability. Therefore, a window size that can cover a small local background around the target pixel without crossing areas with excessive brightness changes is usually selected. For pixels located near the image edge, if the neighborhood window exceeds the image boundary, boundary padding, mirror extension, or reducing the edge window can be used to handle this, as long as the pixel still obtains the corresponding local statistical results. Next, the system calculates the mean and standard deviation of the gray values ​​of all pixels in the neighborhood. The mean reflects the basic illumination of the local area, and the standard deviation reflects the texture complexity and gray-level dispersion of the local area. If a region is generally bright, its mean is higher; if a region has more texture undulations, reflective variations, or edge transitions, its standard deviation is relatively larger. Subsequently, the system dynamically calculates the target grayscale value.

[0039] This specific implementation scheme utilizes local statistical characteristics to construct an adaptive dynamic threshold segmentation logic. By introducing the mean and standard deviation of the neighborhood grayscale, the threshold can be adjusted in real time to follow the illumination fluctuations and texture changes on the weld surface. This approach effectively overcomes the problem of uneven global illumination caused by high-angle ring light sources, and can completely and accurately extract real pores hidden in darker backgrounds, as well as oxide scale patches with similar grayscale to pores, as potential hole pixels, greatly reducing the probability of missing tiny pores in the initial screening stage.

[0040] Further analysis reveals that under a globally fixed threshold method, the same threshold is shared between bright and dark areas in the image, often resulting in a contradiction: the threshold for bright areas is too wide, while the threshold for dark areas is too strict. Bright areas easily misinterpret normal shadows as defects, while dark areas easily miss real micropores. In this implementation scheme, each pixel is judged using its own neighborhood as a reference. The comparison is actually based on whether "the pixel is significantly darker than its surrounding local background," rather than whether "the pixel is below the uniform standard of the entire image." In this way, even if there are overall brightness differences in different locations of the weld image, as long as real pores still exhibit relatively prominent darkening characteristics within their local area, they can be stably extracted. Simultaneously, ordinary background shadows that only darken with the overall illumination and do not significantly deviate from their neighborhood statistical characteristics are less likely to be mislabeled. Therefore, this scheme can maintain good integrity in the extraction of potential hole regions even under complex lighting conditions, laying a reliable foundation for subsequent fine classification based on boundary closure continuity index and internal grayscale level index.

[0041] To acquire these potential hole pixels, weld seam images can be captured first using an industrial camera. The industrial camera can be mounted above or diagonally above the weld seam inspection station, and a ring light source or strip lighting source can be used to provide stable illumination to the weld seam area, reducing the impact of ambient light fluctuations on grayscale judgment. The acquired weld seam images can be processed by grayscale conversion, brightness normalization, and cropping of the main weld seam area. Then, potential hole pixels are extracted based on pre-set grayscale filtering conditions. An "isolated dark pixel" refers to a single pixel or a very small set of pixels that lacks sufficient adjacent dark pixels in space and is only scattered. The direct representation of the "volume characteristics of physical pores" in the image is that the dark area usually forms a continuous small closed region, rather than appearing as just one or two discrete pixels. For example, in a cropped partial image of the weld seam, if a dark area consists of only a small number of non-adjacent pixels, it is usually noise; if a dark area consists of a continuous area of ​​dark pixels, it is more likely to correspond to a real surface defect area. By first filtering spatial morphology before proceeding to subsequent feature analysis, we can avoid retaining interference items that clearly lack spatial entity morphology, thereby reducing the probability of misjudgment from the data source.

[0042] In some preferred embodiments, determining the potential hole region in the weld seam image based on the potential hole pixels in the weld seam image includes: merging spatially adjacent potential hole pixels in the weld seam image into connected components based on a connected component labeling algorithm; for each connected component, determining whether the total number of pixels within the connected component is within a preset hole number range; when the total number of pixels within the connected component is within the preset hole number range, determining the corresponding connected component as a potential hole region; when the total number of pixels within the connected component is outside the preset hole number range, determining the corresponding connected component as not a potential hole region.

[0043] In practice, the connected component labeling algorithm scans the image and assigns the same label to potentially hole pixels that are directly adjacent in spatial location (such as 8-neighborhood or 4-neighborhood), thereby aggregating scattered pixels into independent connected components. Here, "4-neighborhood" can be understood as the current pixel establishing an adjacency relationship only with pixels in its four directions: up, down, left, and right; "8-neighborhood" further includes pixels in the four diagonal directions (upper left, upper right, lower left, and lower right) in the adjacency relationship. In weld seam images, the edges of potential holes are often not regular square boundaries, but rather exhibit slanted connections, rounded edges, or locally jagged transitions. Therefore, the 8-neighborhood labeling method is preferred to avoid the same dark area being incorrectly split into multiple small regions due to unrecognized diagonal connections.

[0044] Next, the total number of pixels contained in each connected region is counted. This number directly reflects the size of the dark area. Here, "total number of pixels" refers to all pixels marked as belonging to the same connected region; its physical meaning is the projected area of ​​that region on the image plane. Real-world micropores in images are typically neither so small as to consist of only a few pixels nor so large as to cover an area significantly exceeding the expected size. The preset range of pore counts is set based on the range of micropore sizes of interest in actual production. To obtain this range, a calibration piece or plate of known size can be placed at the inspection station. An industrial camera is used to acquire calibration images under the same installation height, focal length, and lighting conditions as the actual inspection. Then, the correspondence between millimeter dimensions and pixel counts is established. After calibration, the pore diameter range required by the production standard can be converted into the corresponding pixel count range, and this is used to determine the preset pore count range.

[0045] The information processing can be performed as follows: Scan the weld seam image line by line, after extracting potential hole pixels. When an unmarked potential hole pixel is detected, it is used as a new seed point, and the system continues to check its neighborhood for other potential hole pixels. If any exist, they are assigned to the same label, and the process continues to expand outwards until no more adjacent potential hole pixels are found in the area. At this point, a connected component is marked. This process is repeated until all potential hole pixels are assigned to their respective connected components. After marking, the total number of pixels in each connected component is counted and compared with a preset range of hole counts. Connected components within the range are retained, while those outside the range are deleted. This processing flow transforms the judgment of "whether it is likely a real micropore" into a judgment of spatial continuity and the reasonableness of the area range, significantly improving the effectiveness of subsequent analysis.

[0046] The reason this technique can produce a good filtering effect is that random noise, dust reflections and shadows, and minor scratches and dark lines commonly found in welding sites, although similar to potential hole pixels at the individual pixel grayscale level, usually do not have a stable, continuous, and compact small region shape in space. Connected component labeling first uses spatial adjacency to aggregate homogeneous pixels, and then uses the total number of pixels to limit the range. This is equivalent to introducing two constraints at the same time: "connected patches" and "reasonable patch size." Therefore, it can effectively eliminate interference items that are similar in grayscale but have obviously abnormal shapes.

[0047] This specific implementation scheme effectively addresses the impact of isolated noise and large-area non-pore interference on subsequent detection by introducing connected component labeling and area filtering mechanisms. By aggregating pixels based on spatial adjacency and then using pixel count for hard filtering, the number of regions requiring complex feature analysis can be significantly reduced without losing real micropores. This not only significantly improves the efficiency of the detection algorithm but also eliminates interference items that clearly do not conform to pore characteristics in terms of morphology, providing cleaner data input for subsequent fine classification based on boundaries and internal grayscale.

[0048] In a preferred embodiment of this application, determining the boundary closure continuity index of each potential hole region based on image data of each potential hole region in the weld seam image includes: establishing a local polar coordinate system for each potential hole region with the centroid of each potential hole region as the pole; determining multiple line segments of each potential hole region from the pole of the local polar coordinate system of each potential hole region with a preset angular step size; the length of the line segment is a second preset pixel distance; for each potential hole region, calculating the gray-level gradient magnitude between adjacent pixels on each line segment of the potential hole region based on the Sobel operator; and for each line segment of the potential hole region, determining whether a gray-level gradient exists on the line segment. Target adjacent pixels with a gray-level gradient magnitude greater than a preset gray-level gradient magnitude threshold are identified. When there are target adjacent pixels with a gray-level gradient magnitude greater than the preset gray-level gradient magnitude threshold on the line segment, the pixel closest to the extremum among the target adjacent pixels is selected as the candidate boundary pixel of the line segment. When there are no target adjacent pixels with a gray-level gradient magnitude greater than the preset gray-level gradient magnitude threshold on the line segment, it is determined that there are no candidate boundary pixels on the line segment. For each candidate boundary pixel in each potential hole region, the actual gradient direction vector of the candidate boundary pixel is determined. The boundary closure continuity index of each potential hole region is determined based on the actual gradient direction vector of the candidate boundary pixels in each potential hole region.

[0049] In practice, the geometric centroid of each potential hole region is first calculated, and this centroid is used as the pole to establish a local polar coordinate system. Here, the "centroid" refers to the central position of all pixels in the region in terms of spatial distribution, which can be understood as the central reference point of the potential hole region. The reason for using the centroid as the pole is that the position, size, and shape of different potential hole regions in the weld seam image may be different. If a unified coordinate system is used for the entire image, the correspondence between the boundary detection direction and the region's own structure is not direct enough. However, after establishing a local polar coordinate system with the center of the region itself, each outward-radiating line segment naturally corresponds to a search direction "from the inside to the edge", which is more suitable for analyzing closed targets.

[0050] Next, starting from the pole, rays are emitted outward according to a preset angular step size, intercepting line segments with a length equal to the second preset pixel distance. The "preset angular step size" refers to the angular interval between two adjacent line segments; a smaller angular step size results in denser coverage and more precise boundary detection, but also increases processing time. The "second preset pixel distance" refers to the search length of each line segment extending outward from the pole. This length should be sufficient to penetrate the edge of the potential hole area and enter the surrounding background to a certain distance; otherwise, the search may terminate before reaching the boundary in some directions. This parameter can be determined during the equipment debugging phase based on the largest target pore sample of known size. Specifically, the pixel range of the maximum radius of the target pore in the image is first calculated, and then the second preset pixel distance is set to a value slightly larger than this range, thus ensuring sufficient margin for boundary search.

[0051] Subsequently, the Sobel operator is used to calculate the gray-level gradient magnitude between adjacent pixels on these line segments. The Sobel operator is a commonly used edge enhancement technique, which highlights locations in the image where gray-level changes are significant. In this embodiment, instead of performing indiscriminate edge extraction on the entire image, it is preferable to extract local gradient information only along the pixel paths traversed by each line segment. This reduces computational load and avoids including a large number of background edges unrelated to the current potential hole region in the analysis. A preset gray-level gradient magnitude threshold is used to filter out minor gray-level fluctuations, such as small fluctuations caused by rough textures on metal surfaces, slight uneven lighting, or imaging quantization errors, retaining only significant gradient changes sufficient to represent boundary transitions.

[0052] In specific processing, the following steps can be taken: First, generate multiple line segments evenly distributed in different directions based on the centroid position; then, sequentially read the pixel grayscale values ​​along each line segment and determine whether there are obvious grayscale abrupt changes between adjacent positions; once the gradient magnitude at a certain position exceeds the preset grayscale gradient magnitude threshold, it is considered that this position may be the transition point between the dark area edge and the background. If multiple positions meeting the conditions appear on the same line segment, the position closest to the pole is selected as the candidate boundary pixel. The reason for this selection is that the true boundary is usually the first significant grayscale transition position encountered when searching from the inside of the region outward, while significant gradients further away may often come from background texture, adjacent weld seam structure, or other unrelated structures. If no position exceeding the preset grayscale gradient magnitude threshold appears on the entire line segment, it means that the edge in that direction either does not have a clear closed boundary or the edge transition is too blurry, so this direction is recorded as having no candidate boundary pixels.

[0053] Finally, the actual gradient direction vector of each candidate boundary pixel is calculated, indicating the direction of the fastest grayscale change at that point. Since real pores in images are typically darker in the center and brighter at the periphery, the direction of the fastest grayscale change at their edges usually points from the inside of the pore to the bright background outside, or forms a stable correspondence with the ideal direction pointing to the center. By retaining the candidate boundary pixels and their actual gradient direction vectors in each direction, a direct basis is provided for subsequently determining whether the boundary of the region is continuously closed along the circumference.

[0054] The effectiveness of this technique stems from a combination of two aspects: First, the local polar coordinate system and ray-based search ensure that boundary detection always revolves around the single potential hole region, preventing the inclusion of distant background edges during global contour extraction. Second, selecting the most significant gradient point closest to the pole along the line segment allows for boundary localization that more closely approximates the actual defect edge, rather than being misled by complex textures in the background. Therefore, this method is particularly suitable for industrial imaging scenarios such as the heat-affected zone of welds, where the background is complex and edges are prone to adhesion.

[0055] This specific implementation scheme cleverly transforms the two-dimensional edge extraction problem into a gradient extremum search problem on a one-dimensional line segment by establishing a local polar coordinate system and employing ray detection. This proactive probing method from the center outwards not only effectively avoids interference from complex external background textures but also intuitively reflects the edge integrity of the region in various directions. By finding the point of significant gradient change closest to the extremum, the true physical boundary of potential holes can be accurately located. This method effectively overcomes the shortcomings of traditional global edge detection, which is prone to breakage and false extraction in complex weld backgrounds, providing extremely reliable geometric and gradient information for subsequent quantification of boundary closure continuity.

[0056] Optionally, the boundary closure continuity index of each potential hole region is determined based on the actual gradient direction vector of the candidate boundary pixels of each potential hole region, including: for each candidate boundary pixel of each potential hole region, the cosine of the angle between the actual gradient direction vector of the candidate boundary pixel and the target gradient direction vector of the candidate boundary pixel is used as the sub-boundary closure continuity index of the candidate boundary pixel; the target gradient direction vector of the candidate boundary pixel is the direction vector of the candidate boundary pixel pointing to the pole; the ratio of the sum of the sub-boundary closure continuity indices of all candidate boundary pixels of each potential hole region to the total number of all line segments corresponding to each potential hole region is used as the boundary closure continuity index of each potential hole region.

[0057] In practice, the target gradient direction vector is defined as a vector pointing directly from the candidate boundary pixel to the extremum (i.e., the centroid of the region). For an ideal circular hole, the grayscale gradient direction at any point on its edge should be highly consistent with the direction pointing from that point to the center of the circle. Therefore, using the cosine of the angle between the actual gradient direction vector of the candidate boundary pixel and the target gradient direction vector can directly describe the degree of directional matching of the candidate boundary pixel. The reason for using the cosine of the angle is that: when the two directions are highly consistent, the value is close to 1; when the two directions deviate significantly, the value decreases; when the two directions are significantly opposite, the value will be low or even negative. Thus, the directional consistency of a single candidate boundary pixel can be compressed into an intuitive and easily comparable sub-boundary closure continuity index.

[0058] In specific processing, the following steps can be taken: First, for a potential hole region, read the identified candidate boundary pixels on each line segment one by one; then, based on the positional relationship between the candidate boundary pixels and the poles, obtain the target gradient direction vector pointing from the candidate boundary pixel to the pole; simultaneously, based on the calculation results of the Sobel operator near the candidate boundary pixel, obtain the actual gradient direction vector of that point; then, determine the degree of consistency between these two directions and record this degree of consistency as the sub-boundary closure continuity index of the candidate boundary pixel. For directions on line segments where no candidate boundary pixels exist, no corresponding sub-boundary closure continuity index is generated, and its contribution to the sum is treated as 0.

[0059] Subsequently, the sub-boundary closure continuity indices of all candidate boundary pixels are accumulated and divided by the total number of line segments corresponding to that region. The use of the "total number of line segments" as the normalization benchmark, rather than solely based on the number of line segments that find candidate boundary pixels, has clear technical significance: if candidate boundary pixels cannot be found in certain directions, it indicates that the boundary of that region is missing, blurred, or has not formed a stable closure in those directions, and this situation should be included in the adverse impact on the boundary closure continuity index. Through this processing method, the system examines both "whether the direction of the found boundary is correct" and "in how many directions the boundary can actually be found," thus ensuring that the final index simultaneously incorporates information on both boundary direction consistency and boundary integrity.

[0060] Once the preset angle step size, the second preset pixel distance, and the preset grayscale gradient magnitude threshold are determined, the calculation process for the boundary closure continuity index can be executed consistently. If it is necessary to set subsequent judgment thresholds, these can be obtained through sample annotation: first, collect a batch of weld seam image samples that have been confirmed to be real pores and oxide scale patches; for each potential hole area, calculate the boundary closure continuity index according to the above steps; then, statistically analyze the index distribution range of the two types of samples; and select the threshold that can better distinguish between the two types of samples as the basis for subsequent classification. The threshold obtained in this way has clear data support, rather than being subjectively set.

[0061] The technical effectiveness of this method can be derived from two aspects. First, the edges of real pores naturally surround the center, resulting in high directional consistency and a large sum of accumulated sub-boundary closure continuity indices. Second, the edges of real pores usually exist in most directions, thus rarely encountering situations where "a line segment has no candidate boundary pixels." In contrast, oxide patches not only have chaotic orientations but also often lack boundaries. Since the final index is affected by both "whether the orientation is aligned with the center" and "whether the boundary exists in all directions," the two types of targets will naturally differ in this index.

[0062] This specific implementation scheme utilizes the cosine of the vector angle to combine the geometry of the edge with the depth of the gray-level gradient direction, constructing a highly sensitive evaluation index for closure continuity. The design cleverly divides the sum of the sub-indices by the total number of all line segments, rather than just by the number of line segments that find candidate boundary pixels. This not only penalizes cluttered edge gradient directions but also severely penalizes missing edges (i.e., no candidate boundary pixels can be found). Through this dual-penalty mechanism, real pores and oxide patches are significantly differentiated in the boundary closure continuity index, enabling the system to accurately distinguish between them based on the microscopic physical features of the edges, even with extremely similar gray-level performance.

[0063] In practical applications, based on the image data of each potential hole region in the weld seam image, the internal grayscale level index of each potential hole region is determined, including: determining the Euclidean distance between each pixel in each potential hole region and the nearest candidate boundary pixel; defining the region formed by pixels with an Euclidean distance less than a first preset Euclidean distance as the outer ring region of each potential hole region; defining the region formed by pixels with an Euclidean distance greater than a second preset Euclidean distance as the inner ring region of each potential hole region; defining the region formed by pixels with an Euclidean distance less than or equal to the second preset Euclidean distance and greater than or equal to the first preset Euclidean distance as the middle ring region of each potential hole region; and determining the internal grayscale level index of each potential hole region based on the image data of the middle ring region, the outer ring region, and the inner ring region.

[0064] In practice, to accurately reflect the relative depth of pixels within the hole, the Euclidean distance from each pixel within the region to its nearest candidate boundary pixel is calculated. This Euclidean distance can be understood as the actual straight-line distance between two points on the image plane. The reason for choosing "distance to the nearest candidate boundary pixel" as the layering criterion is that the candidate boundary pixels have approximated the true outer edge of the potential hole region. The farther any point within the region is from the outer edge, the closer it is usually to the center of the region, and the more likely it is to correspond to a deeper physical hole.

[0065] Based on this distance metric, using the first and second preset Euclidean distances, the internal space of the potential hole region is strictly divided into three concentric ring-shaped regions: the outer ring region, the middle ring region, and the inner ring region. The "outer ring region" corresponds to the pixel set near the boundary transition zone; the "middle ring region" corresponds to the middle layer pixel set transitioning from the edge to the center; and the "inner ring region" corresponds to the pixel set farthest from the boundary and closest to the region center. The term "concentric ring-shaped region" does not require them to be geometrically perfect circles, but rather refers to these regions forming a hierarchical enclosure around the center of the potential hole region. Even if the potential hole region is slightly elliptical or has minor irregularities, as long as the division is based on the "distance to the nearest candidate boundary pixel," a hierarchical structure that adapts to the actual boundary of the target can still be formed.

[0066] The first and second preset Euclidean distances are preset technical methods, and their acquisition method can be determined during the sample debugging stage. Specifically, a batch of confirmed real pore samples can be selected, and the pixel distance range from their boundaries to the center can be statistically analyzed. Then, the first and second preset Euclidean distances can be set according to the proportion of the average radius of the target pores, so that the three layers have sufficient pixel coverage, neither too narrow nor too overlapping. If sufficient samples are lacking under certain imaging conditions, the first preset Euclidean distance can be set as the lower limit value A, and the second preset Euclidean distance can be set as the upper limit value B, where B is greater than A, and can be corrected in subsequent debugging based on the sample layering effect.

[0067] In the specific processing, the following steps can be taken: For a potential hole region, first collect all internal pixels and all candidate boundary pixels of the region; then, for each internal pixel, sequentially determine its distance from each candidate boundary pixel, and select the smallest distance as the boundary proximity of the internal pixel; next, based on the first preset Euclidean distance and the second preset Euclidean distance, classify all internal pixels into the outer ring region, middle ring region, or inner ring region respectively. After the division is completed, read the grayscale data of the three regions respectively, for example, to statistically analyze the average grayscale, grayscale distribution concentration, or grayscale trend of each region, and determine the internal grayscale level index accordingly.

[0068] This implementation method is able to reflect the depth characteristics of real pores because the darkness variation of real pores in imaging is usually related to their spatial depth: the closer to the center, the more obvious the occlusion and reflection loss, and the darker the grayscale; the closer to the edge, the more easily affected by external illumination, and the relatively brighter the grayscale. By using the distance to the boundary for layering, it is possible to distinguish the internal positions "near the edge" and "near the center", so the grayscale differences extracted subsequently have more physical meaning.

[0069] This specific implementation scheme successfully reconstructs the depth topology of three-dimensional holes in a two-dimensional image by calculating the Euclidean distance from each pixel to the boundary and performing threshold segmentation. This distance-based ring region segmentation method does not depend on the absolute size or regular shape of the region. Even for slightly elliptical or irregular real pores, it can still accurately separate the outer, middle, and inner depth levels. This provides a solid spatial structural foundation for subsequent comparison of grayscale differences between different levels and quantification of internal grayscale level indices. It enables the system to delve deeper into the key features reflecting physical depth through the grayscale appearance of the two-dimensional plane, thereby completely solving the problem of misjudgment of oxide scale patches due to the lack of depth features.

[0070] Furthermore, this implementation scheme does not rely on the absolute size of the region because the layering is not based on a fixed graphic template, but rather on the relative positional relationship between each pixel and the nearest candidate boundary pixel. For larger potential hole regions, the inner ring region naturally extends towards the center; for smaller potential hole regions, the three-layer region shrinks accordingly; for regions that are slightly stretched or have irregular edges, the distance layering adapts adaptively along the actual boundary, rather than forcibly applying a circular template. Because of this, the method can stably extract grayscale levels "from the boundary to the center" even when there are certain differences in shape.

[0071] In a preferred embodiment of this application, determining the internal grayscale level index of each potential hole region based on the image data of the middle ring area, outer ring area, and inner ring area of ​​each potential hole region includes: determining the average grayscale value of the middle ring area image data of each potential hole region based on the middle ring area image data of each potential hole region; determining the average grayscale value of the inner ring area image data of each potential hole region based on the inner ring area image data of each potential hole region; and determining the average grayscale value of the outer ring area image data of each potential hole region based on the outer ring area image data of each potential hole region. Mean grayscale value; for each potential hole region, the difference between the mean grayscale value of the outer ring area image data and the mean grayscale value of the middle ring area image data of the potential hole region is taken as the first grayscale value difference of the potential hole region; the difference between the mean grayscale value of the middle ring area image data and the mean grayscale value of the inner ring area image data of the potential hole region is taken as the second grayscale value difference of the potential hole region; the sum of the first grayscale value difference and the second grayscale value difference of each potential hole region is taken as the internal grayscale level index of the potential hole region.

[0072] In practice, the system calculates the average grayscale value of all pixels in the outer, middle, and inner ring regions. The average grayscale value is used instead of extreme values ​​or the median because it smooths out minor local reflection noise or sensor noise, more stably reflecting the overall brightness level of that layer. Next, the system calculates the grayscale difference between adjacent layers. The first grayscale difference represents the degree of brightness decrease when transitioning from the outer to the middle ring region; the second grayscale difference represents the degree of brightness decrease when transitioning from the middle to the inner ring region. For tiny pores with true physical depth, due to light blocking and multiple reflections, the opening (outer ring region) is relatively bright, the sidewalls (middle ring region) are darker, and the bottom (inner ring region) is the darkest. Therefore, the first and second grayscale differences of a real pore are usually significantly positive.

[0073] Subsequently, the difference between the first and second grayscale values ​​is added together to obtain the internal grayscale level index. This summation operation is actually a comprehensive quantification of the entire "continuous darkening from the outside to the inside" trend. If a potential porous area is an oxide patch, its internal grayscale often fluctuates randomly. For example, the outer ring area may be darker than the middle ring area (the first grayscale value difference is negative), or the middle ring area may be darker than the inner ring area, but the brightness of the outer and middle ring areas is similar. In this case, there are often negative or extremely small values ​​in the first and second grayscale value differences, which will cancel each other out or remain at a low level after summation, resulting in a significantly low final internal grayscale level index.

[0074] This specific implementation scheme cleverly transforms the depth mapping characteristics of three-dimensional pores into a one-dimensional numerical index by calculating and summing the mean grayscale differences between adjacent depth levels. This calculation method not only amplifies the continuous and progressive grayscale changes within real pores but also naturally suppresses the irregular grayscale fluctuations within oxide scale patches. Its technical effect is that even if the overall average grayscale of oxide scale patches is extremely similar to that of real pores, as long as they lack a stable, stepped darkening structure within, they will show a significant difference in internal grayscale level indices compared to real pores, thus providing a highly distinguishable key feature for subsequent accurate classification.

[0075] After obtaining the boundary closure continuity index and the internal grayscale level index, the system has comprehensively characterized the potential hole region from two dimensions: external contour structure and internal depth representation. Next, the features from these two dimensions need to be integrated to complete the final defect determination. To this end, this application further proposes a method for determining whether a potential hole region is a real hole region based on its boundary closure continuity index and internal grayscale level index. This method includes: for each potential hole region, determining whether the boundary closure continuity index of the potential hole region is greater than a preset boundary closure continuity index threshold; if the boundary closure continuity index of the potential hole region is less than or equal to the preset boundary closure continuity index threshold, determining that the potential hole region is not a real hole region; if the boundary closure continuity index of the potential hole region is greater than the preset boundary closure continuity index threshold, determining whether the internal grayscale level index of the potential hole region is greater than a preset internal grayscale level index threshold; if the internal grayscale level index of the potential hole region is greater than the preset internal grayscale level index threshold, determining that the potential hole region is a real hole region; and if the internal grayscale level index of the potential hole region is less than or equal to the preset internal grayscale level index threshold, determining that the potential hole region is not a real hole region.

[0076] In practice, the system employs a cascaded judgment logic to screen potential hole regions. First, the boundary closure continuity index of the potential hole region is compared with a preset boundary closure continuity index threshold. This threshold is obtained through statistical analysis of a large number of known samples, selecting a critical value that effectively distinguishes between closed and broken edges. If the boundary closure continuity index is less than or equal to this threshold, it indicates that the edge of the region has obvious gaps, breaks, or disordered orientations, failing to meet the geometric characteristics of a physical hole. The system directly classifies it as a non-real hole region (such as oxide scale patches or background shadows) and terminates further judgment on that region.

[0077] Only when the boundary closure continuity index is greater than a preset boundary closure continuity index threshold, indicating that the region already possesses a closed contour similar to a pore on the two-dimensional plane, will the system further examine its internal three-dimensional depth features. At this point, the internal grayscale level index is compared with a preset internal grayscale level index threshold. Similarly, the preset internal grayscale level index threshold is also set based on sample statistics and is used to distinguish between regions with obvious grayscale progression and regions with flat grayscale. If the internal grayscale level index is greater than this threshold, it indicates that the region not only has closed edges but also possesses a depth mapping feature that continuously darkens from the outside in, and the system ultimately confirms it as a real hole region; conversely, if the internal grayscale level index is less than or equal to this threshold, it indicates that although the region's edges appear closed, it lacks internal depth features and is most likely an oxide scale patch with a shape that is approximately circular, and the system also excludes it.

[0078] This implementation scheme employs a cascaded judgment strategy that first determines the boundary and then the internal grayscale, resulting in significant technical advantages. On one hand, the calculation and judgment of boundary features are relatively intuitive, quickly filtering out a large number of interference items with obviously irregular edges. This avoids complex internal grayscale level analysis for all candidate regions, effectively saving system computational resources and improving overall detection efficiency. On the other hand, by setting dual strict thresholds, requiring the target to simultaneously meet both the conditions of "closed external contour" and "internal depth," it completely breaks through the misjudgment dilemma easily caused by traditional single grayscale thresholds. This multi-dimensional feature joint verification mechanism enables the system to reliably and accurately separate real micropores from a massive number of similar interference objects when facing complex and ever-changing weld surface conditions, achieving a perfect balance between high detection rate and low false alarm rate.

[0079] like Figure 3 As shown, based on the same inventive concept of the above method embodiments, this application also proposes a profile weld inspection system based on industrial vision, including: an acquisition device and a processing device; the acquisition device is used to acquire the original image data and welding accuracy index of the profile to be inspected; the processing device is used to determine the weld image based on the original image data and welding accuracy index; the processing device is further used to determine potential hole regions in the weld image based on the weld image; the processing device is further used to determine the boundary closure continuity index of each potential hole region based on the image data of each potential hole region in the weld image; the processing device is further used to determine the internal grayscale level index of each potential hole region based on the image data of each potential hole region in the weld image; the processing device is further used to determine whether the potential hole region is a real hole region for each potential hole region based on the boundary closure continuity index and the internal grayscale level index of the potential hole region.

[0080] In practical industrial deployments, the acquisition device may include a high-resolution industrial camera mounted above the inspection station, a matching high-angle ring light source, and an industrial Ethernet interface for communication with a programmable logic controller (PLC) or a host computer. The industrial camera is responsible for acquiring raw image data of the profile surface in real time, while the communication interface synchronously receives the welding accuracy index of the current batch. The processing device can be a computing platform consisting of a high-performance industrial computer, an edge computing server, or a dedicated image processing chip. After receiving the data transmitted by the acquisition device, the built-in inspection software or algorithm module will sequentially perform adaptive image cropping, local dynamic threshold segmentation, connected component morphological filtering, boundary detection in local polar coordinates, and internal grayscale analysis based on distance layering, ultimately outputting accurate defect judgment results.

[0081] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method for inspecting profile welds based on industrial vision, characterized in that, include: Obtain the original image data and welding accuracy index of the profile to be inspected; The weld seam image is determined based on the original image data and welding accuracy index; Identify potential void regions in weld seam images based on weld seam images; Based on the image data of each potential void region in the weld seam image, determine the boundary closure continuity index of each potential void region; Based on the image data of each potential hole area in the weld seam image, determine the internal gray level index of each potential hole area; For each potential hole region, determine whether the potential hole region is a real hole region based on the boundary closure continuity index and the internal gray level index of the potential hole region.

2. The method for inspecting profile welds based on industrial vision according to claim 1, characterized in that, Weld seam images are determined based on the original image data and welding accuracy index, including: The original image data is smoothed and denoised using a Gaussian filter to obtain intermediate image data. Based on column pixel grayscale projection and first derivative extremum analysis, the edge of the weld seam in the intermediate image data is identified. The product of the first value and the first preset pixel distance is used as the target pixel distance; the first value is the difference between 1 and the welding precision index; The target edge is obtained by extending the target pixel distance from the edge of the weld seam towards the target direction; the target direction is perpendicular to the edge of the weld seam and is the direction away from the weld seam. The area enclosed by the edge of the target is used as the weld seam image.

3. The method for inspecting profile welds based on industrial vision according to claim 1, characterized in that, Identify potential void regions in weld seam images based on weld seam images, including: For each pixel in the weld seam image, determine the mean and standard deviation of the gray value of the pixel and its neighboring pixels. Determine whether the grayscale value of a pixel is less than the target grayscale value; the target grayscale value is the difference between the mean grayscale value of the pixel and the second value; the second value is the product of the preset grayscale coefficient and the standard deviation of the grayscale value. When the gray value of a pixel is less than the target gray value, the pixel is identified as a potential hole pixel. When the gray value of a pixel is greater than or equal to the target gray value, the pixel is determined not to be a potential hole pixel. The potential hole region in the weld seam image is determined based on the potential hole pixels in the weld seam image.

4. The method for inspecting profile welds based on industrial vision according to claim 3, characterized in that, Identifying potential hole regions in weld seam images based on potential hole pixels includes: Based on the connected component labeling algorithm, spatially adjacent potential hole pixels in the weld seam image are merged into connected components; For each connected component, determine whether the total number of pixels within the connected component is within the preset range of hole counts. When the total number of pixels in a connected region is within a preset range of the number of holes, the corresponding connected region is determined to be a potential hole region. When the total number of pixels within a connected region is outside the preset range of hole counts, the corresponding connected region is determined not to be a potential hole region.

5. The method for inspecting profile welds based on industrial vision according to claim 1, characterized in that, Based on the image data of each potential void region in the weld seam image, the boundary closure continuity index of each potential void region is determined, including: Establish a local polar coordinate system for each potential cavity region, with the centroid of each potential cavity region as the pole; Starting from the pole of the local polar coordinate system of each potential hole region, multiple line segments of each potential hole region are determined with a preset angle step size; the length of the line segment is the second preset pixel distance. For each potential hole region, the gray-level gradient magnitude between adjacent pixels on each line segment of the potential hole region is calculated based on the Sobel operator; For each line segment in the potential hole region, determine whether there are target adjacent pixels on the line segment whose gray-scale gradient magnitude is greater than a preset gray-scale gradient magnitude threshold; When there are target neighboring pixels on a line segment whose gray-level gradient magnitude is greater than a preset gray-level gradient magnitude threshold, the pixel closest to the pole among the target neighboring pixels is taken as the candidate boundary pixel of the line segment. If there are no target adjacent pixels on the line segment whose gray-level gradient magnitude is greater than the preset gray-level gradient magnitude threshold, it is determined that there are no candidate boundary pixels on the line segment. For each candidate boundary pixel in each potential hole region, determine the actual gradient direction vector of the candidate boundary pixel; The boundary closure continuity index of each potential hole region is determined based on the actual gradient direction vector of the candidate boundary pixels of each potential hole region.

6. The method for inspecting profile welds based on industrial vision according to claim 5, characterized in that, The boundary closure continuity index of each potential hole region is determined based on the actual gradient direction vector of the candidate boundary pixels of each potential hole region, including: For each candidate boundary pixel in each potential hole region, the cosine of the angle between the actual gradient direction vector of the candidate boundary pixel and the target gradient direction vector of the candidate boundary pixel is used as the sub-boundary closure continuity index of the candidate boundary pixel; the target gradient direction vector of the candidate boundary pixel is the direction vector of the candidate boundary pixel pointing to the pole. The ratio of the sum of the sub-boundary closure continuity indices of all candidate boundary pixels in each potential hole region to the total number of all line segments corresponding to each potential hole region is used as the boundary closure continuity index of each potential hole region.

7. The method for inspecting profile welds based on industrial vision according to claim 5, characterized in that, Based on the image data of each potential void region in the weld seam image, the internal grayscale level index of each potential void region is determined, including: Determine the Euclidean distance between each pixel within each potential hole region and the nearest candidate boundary pixel; The region formed by pixels whose Euclidean distance is less than the first preset Euclidean distance is taken as the outer ring region of each potential hole region. The region formed by pixels whose Euclidean distance is greater than the second preset Euclidean distance is taken as the inner ring region of each potential hole region; the second preset Euclidean distance is greater than the first preset Euclidean distance. The region formed by pixels whose Euclidean distance is less than or equal to the second preset Euclidean distance and whose Euclidean distance is greater than or equal to the first preset Euclidean distance is taken as the middle ring region of each potential hole region. Based on the image data of the middle ring area, outer ring area, and inner ring area of ​​each potential hole area, the internal gray level index of each potential hole area is determined.

8. The method for inspecting profile welds based on industrial vision according to claim 7, characterized in that, Based on the image data of the middle ring area, outer ring area, and inner ring area of ​​each potential hole region, the internal grayscale level index of each potential hole region is determined, including: The mean grayscale value of the middle ring area image data of each potential hole area is determined based on the middle ring area image data of each potential hole area; The mean grayscale value of the inner ring area image data of each potential hole area is determined based on the inner ring area image data of each potential hole area. The mean grayscale value of the outer ring area image data of each potential hole area is determined based on the outer ring area image data of each potential hole area. For each potential hole region, the difference between the mean gray value of the outer ring area image data of the potential hole region and the mean gray value of the middle ring area image data of the potential hole region is taken as the first gray value difference of the potential hole region. The difference between the mean gray value of the middle ring area image data of the potential hole region and the mean gray value of the inner ring area image data of the potential hole region is taken as the second gray value difference of the potential hole region. The sum of the first grayscale value difference and the second grayscale value difference of each potential hole region is used as the internal grayscale level index of the potential hole region.

9. The method for inspecting profile welds based on industrial vision according to claim 1, characterized in that, Based on the boundary closure continuity index and internal gray level index of the potential cavity region, it is determined whether the potential cavity region is a real cavity region, including: For each potential hole region, determine whether the boundary closure continuity index of the potential hole region is greater than the preset boundary closure continuity index threshold. When the boundary closure continuity index of a potential hole region is less than or equal to a preset boundary closure continuity index threshold, the potential hole region is determined not to be a real hole region. When the boundary closure continuity index of the potential hole region is greater than the preset boundary closure continuity index threshold, determine whether the internal gray level index of the potential hole region is greater than the preset internal gray level index threshold. When the internal gray level index of a potential hole region is greater than the preset internal gray level index threshold, the potential hole region is determined to be a real hole region. If the internal grayscale index of a potential hole region is less than or equal to a preset internal grayscale index threshold, the potential hole region is determined not to be a real hole region.

10. A profile weld inspection system based on industrial vision, characterized in that, include: Acquisition device and processing device; Acquisition device, used to acquire raw image data and welding accuracy index of the profile to be inspected; Processing device for determining weld seam images based on raw image data and welding accuracy index; The processing device is also used to determine potential void regions in the weld seam image based on the weld seam image; The processing device is also used to determine the boundary closure continuity index of each potential hole region based on the image data of each potential hole region in the weld seam image; The processing device is also used to determine the internal grayscale level index of each potential hole area based on the image data of each potential hole area in the weld seam image; The processing device is also used to determine whether a potential hole region is a real hole region based on the boundary closure continuity index and the internal gray level index of each potential hole region.