A machine vision-based intelligent detection method for weld defects
By constructing a distance metric function for local grayscale profile deviation degree and local gradient structure disorder degree, and combining it with the DBSCAN algorithm, the problem of distinguishing between benign heterogeneous points and malignant defect points in existing weld inspection is solved, and high-precision weld defect identification is achieved.
Patent Information
- Application Number
- CN202511663681.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-11-13
AI Technical Summary
In existing weld defect detection methods, Euclidean distance cannot effectively distinguish between benign heterogeneous points and malignant defect points, resulting in a high rate of missed detection and making it difficult to meet the needs of efficient, safe and automated weld inspection.
By constructing distance metric functions for local grayscale profile deviation and local gradient structure disorder, and combining them with the DBSCAN algorithm, weld defects can be identified.
It significantly improves the accuracy of weld defect detection, reduces misjudgments and missed detections, and enhances the stability and reliability of the detection system under complex process conditions.
Smart Images

Figure CN121095262B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and in particular to a welding seam defect intelligent detection method based on machine vision. BACKGROUND
[0002] In modern manufacturing, welding as a key process to realize the connection of metal materials is widely used in high-end equipment manufacturing fields such as aerospace, rail transit, automobile manufacturing and pressure vessels. The stability and reliability of the welding quality are directly related to the safety and service life of the product structure, so the detection and evaluation of the welding quality are indispensable in industrial production. The traditional welding seam detection methods mainly include manual visual detection, radiographic testing (RT) and ultrasonic testing (UT) and other methods. These methods can find defects inside or on the surface of the welding seam to some extent, but they have low detection efficiency, high cost, and the detection results depend on manual experience and have poor repeatability. In addition, radiographic testing also has radiation safety hazards, which is difficult to meet the needs of intelligent production lines for efficient, safe and automated welding seam detection.
[0003] With the rapid development of machine vision and image processing technology, the welding seam defect automatic detection method based on image recognition has become the mainstream direction of research and application. This kind of method usually uses an industrial camera to collect the welding seam surface image, analyzes the image gray, texture and topographic features through an algorithm, and realizes the automatic identification of welding seam defects. Among them, the detection technology based on unsupervised clustering has good universality and automation characteristics because it does not need manual annotation. The basic principle is to input the gray value and spatial position of each pixel point as features into the clustering algorithm, and judge the similarity between pixels through distance measurement. However, the existing methods generally use traditional Euclidean distance as the similarity measurement between pixels, which only considers the difference between pixel gray and coordinates, and cannot reflect the structural continuity of the gray distribution and the order of the gradient direction on the welding seam surface. Because the welding process will form micro-texture and welding wave structure caused by normal process, these areas show benign heterogeneous points with significant gray changes on the image, while real defects (such as pores, slag or cracks) also show gray mutation characteristics, making it difficult for the clustering algorithm to distinguish between the two, resulting in problems such as the characteristics of defects being submerged by normal welding seam texture, high missing detection rate and the like. Therefore, how to construct a distance measurement model with structure perception ability in the welding seam image clustering process to improve the separability of welding seam defects and normal texture areas has become a technical problem that needs to be solved in the current field of intelligent detection of welding seam images. SUMMARY
[0004] Therefore, the present application aims to provide a welding seam defect intelligent detection method based on machine vision to solve the problem that the Euclidean distance cannot distinguish between benign heterogeneous points and malignant defect points in the existing welding seam defect detection, resulting in missed detection.
[0005] In order to achieve the above object, the technical scheme of the present application is as follows:
[0006] A welding seam defect intelligent detection method based on machine vision, the method comprising:
[0007] Step S1: acquiring pixel point basic gray feature data set by image acquisition and feature preparation of the welding seam area;
[0008] Step S2: acquiring local gray profile deviation by trend prediction comparison of the local gray profile of the pixel point;
[0009] Step S3: acquiring local gradient structure disorder degree by unit vector aggregation analysis of the gradient direction of the neighborhood of the pixel point;
[0010] Step S4: acquiring structure-aware distance metric function by multiplicative modulation of the local gray profile deviation and the local gradient structure disorder degree;
[0011] Step S5: acquiring welding seam defect recognition result by cluster analysis of the structure-aware distance metric function.
[0012] Further, the pixel point basic gray feature data set acquired by image acquisition and feature preparation of the welding seam area comprises:
[0013] acquiring at least one high-resolution digital gray image by vertical image acquisition process of the welding seam area of the workpiece to be detected by the industrial area array camera installed on the production line; fixed light source is used in the vertical image acquisition process; after the acquired gray image is preprocessed, the basic gray feature data of each pixel point is extracted from the image; the basic gray feature data includes the two-dimensional position coordinates of the pixel point in the image and the corresponding gray value, and the two-dimensional position coordinates and the gray value of all pixel points constitute the pixel point basic gray feature data set.
[0014] Further, the local gray profile deviation acquired by trend prediction comparison of the local gray profile of the pixel point comprises:
[0015] acquiring inner ring and outer ring gray feature parameters by hierarchical statistical processing of the neighborhood gray data of the pixel point; acquiring local gray profile deviation factor by trend prediction and deviation calculation processing of the gray feature parameters.
[0016] Further, the inner ring and outer ring gray feature parameters acquired by hierarchical statistical processing of the neighborhood gray data of the pixel point comprise:
[0017] For any target pixel in the basic grayscale feature dataset, define the inner ring neighborhood range and the outer ring neighborhood range, divide the neighborhood range of the target pixel according to the inner ring neighborhood range and the outer ring neighborhood range, and obtain the inner ring neighborhood and outer ring neighborhood of the target pixel.
[0018] The average gray value of the pixels in the inner ring neighborhood of the target pixel is used as the inner ring gray value feature parameter of the target pixel; the average gray value of the pixels in the outer ring neighborhood of the target pixel is used as the outer ring gray value feature parameter of the target pixel.
[0019] Furthermore, the step of obtaining the local grayscale profile deviation by performing trend prediction and deviation calculation on grayscale feature parameters includes:
[0020] For any target pixel in the pixel base grayscale feature dataset, the calculation result of the inner ring grayscale feature parameter of the target pixel being twice the outer ring grayscale feature parameter of the target pixel is taken as the theoretical environment predicted grayscale value of the target pixel; the absolute value of the calculation result of subtracting the grayscale value of the target pixel from the theoretical environment predicted grayscale value of the target pixel is taken as the local grayscale profile deviation of the target pixel.
[0021] Furthermore, the step of obtaining the local gradient structure disorder by performing unit vector aggregation analysis on the gradient directions of the pixel's neighborhood includes:
[0022] By performing gradient calculation on the grayscale data of the weld image, a pixel gradient vector dataset is obtained. Then, by normalizing the gradient vector dataset, unit direction vector data of the pixels is obtained. Finally, by aggregating and summing the neighborhood unit direction vector data, the disorder factor of the local gradient structure is obtained.
[0023] Furthermore, the step of performing gradient calculation processing on the grayscale data of the weld image to obtain a pixel gradient vector dataset, and then performing direction normalization processing on the gradient vector dataset to obtain pixel unit direction vector data, includes:
[0024] For any target pixel in the pixel basic grayscale feature dataset, the horizontal gradient component and vertical gradient component of the target pixel are obtained by calculating the grayscale change rate of the target pixel in the horizontal and vertical directions, respectively.
[0025] The horizontal and vertical gradient components of the target pixel are combined to obtain the gradient vector of the target pixel, and the magnitude of the gradient vector of the target pixel is calculated.
[0026] Divide the gradient vector of the target pixel point by the module length of the gradient vector to obtain the unit direction vector of the target pixel point, and define the range direction vector of the target pixel point as a zero vector when the module length of the gradient vector is zero.
[0027] Further, the local gradient structure disorder degree is obtained by aggregating and summing the neighborhood unit direction vector data, comprising:
[0028] A square neighborhood radius is set; for any target pixel point in the pixel point basic gray feature data set, the unit direction vector data of all pixel points in the neighborhood range is extracted with the target pixel point as the center according to the square neighborhood radius; the unit direction vectors of all pixel points in the neighborhood range are summed, and the module length of the vector sum result is calculated, and the module length is normalized with the number of pixel points in the neighborhood to obtain a neighborhood gradient direction consistency ratio; the calculation result of subtracting the neighborhood gradient direction consistency ratio from a constant 1 is taken as the local gradient structure disorder degree of the target pixel point.
[0029] Further, the structure-aware distance metric function is obtained by multiplying the local gray profile deviation and the local gradient structure disorder degree, comprising:
[0030] For any two target pixel points in the pixel point basic gray feature data set, the Euclidean distance is calculated based on the gray values and two-dimensional position coordinates of the two target pixel points to obtain the original distance metric value of the two target pixel points.
[0031] The difference values of the local gray profile deviation and the local gradient structure disorder degree of the two target pixel points are calculated respectively, and the calculation results of adding the absolute values of the two difference values to a constant 1 are taken as the modulation terms of the two types of structure attributes.
[0032] The original distance metric value is multiplied by the modulation terms of the two types of structure attributes in turn to obtain the structure-aware distance metric function value of the two target pixel points.
[0033] Further, the welding defect recognition result is obtained by clustering analysis on the structure-aware distance metric function, comprising:
[0034] The neighborhood radius parameter and the minimum neighborhood sample number parameter of the clustering algorithm are set, and the structure-aware distance metric function is taken as the distance calculation standard of the clustering algorithm; the density reachability of all pixel points in the pixel point basic gray feature data set is analyzed, and the pixel points meeting the density reachability condition are clustered and connected to form multiple pixel point clusters; the pixel point number of the clusters is filtered in size, and the clusters with a pixel number less than the minimum neighborhood sample number parameter are removed as noise clusters; the clusters remaining after the size filtering are output as welding defect regions to obtain the welding defect recognition result.
[0035] Compared with the prior art, the present application has the following advantages:
[0036] The intelligent welding seam defect detection method based on machine vision provided by the present application introduces a local gray profile divergence factor and a local gradient structure disorder degree factor, and performs structural improvement on the traditional welding seam image clustering measurement based on Euclidean distance, so that the distance calculation not only reflects the difference between pixel gray and spatial position, but also reflects the local gray continuity and gradient direction consistency features of the welding seam surface. Through this structural perception distance measurement method, the algorithm can naturally enlarge the distance between the real defect points and the normal welding seam texture points in the feature space, thereby enhancing the clustering separation degree and realizing high-precision identification of small pores, slag inclusion, cracks and other defects on the welding seam surface. In actual industrial detection scenarios, the present application can significantly reduce the misjudgment and missed detection problems caused by normal welding waves, solidification textures and other benign gray heterogeneous points, so that the welding seam defect detection system still has stable recognition ability under complex process background. This method does not need to additionally increase hardware sensors, and only needs to model and adaptively modulate the gray structure and gradient direction at the algorithm level, so as to balance the detection accuracy and real-time performance, and provides a high-reliability image analysis solution for online monitoring and intelligent evaluation of welding quality. BRIEF DESCRIPTION OF DRAWINGS
[0037] The accompanying drawings, which form a part of the present application, are intended to provide further understanding of the present application, and the illustrative embodiments thereof and their descriptions serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings:
[0038] Figure 1 The method flowchart of the intelligent welding seam defect detection method based on machine vision provided by the present application embodiment. DETAILED DESCRIPTION
[0039] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments.
[0040] Reference Figure 1 The method flowchart of the intelligent welding seam defect detection method based on machine vision provided by the present application embodiment one is shown in Figure 1 The intelligent welding seam defect detection method based on machine vision can include:
[0041] Step S1, acquiring pixel point basic gray feature data set by collecting and preparing features of the welding seam area image.
[0042] The step is to obtain basic data for subsequent analysis. First, a vertical image acquisition process is performed on the weld area of the workpiece to be detected by an industrial area array camera installed on the production line to obtain at least one high-resolution digital gray image. A fixed light source is used for illumination during the vertical image acquisition process. After preprocessing the collected gray image, the basic gray feature data of each pixel point in the image is extracted. The basic gray feature data includes the two-dimensional position coordinates of the pixel point in the image and the corresponding gray value, and the two-dimensional position coordinates and the gray value of all pixel points form the pixel point basic gray feature data set.
[0043] At this point, the pixel point basic gray feature data set is obtained by collecting and preparing the image of the weld area.
[0044] Step S2, the local gray profile deviation degree is obtained by comparing the trend prediction of the local gray profile of the pixel point.
[0045] In the prior art problem of weld defect detection, the essence is that the algorithm cannot distinguish whether a gray abnormal point belongs to a normal weld texture (benign heterogeneous point) or a real defect (malignant defect point). The attribute of a pixel point should not be determined only by its own gray value, but should be defined by its structural relationship with the surrounding local environment. Specifically, a benign heterogeneous point, even if its gray value forms a peak or valley in the local area, it is still part of the continuous and smooth evolution of the gray profile in the region where it is located. On the contrary, a malignant defect point is a structural singularity that destroys the continuity of the local gray profile. It is necessary to quantify the degree to which the gray value of any pixel point conforms to the gray change trend of its local environment. This step achieves this purpose by constructing a gray prediction model based on the local environment: first, analyze the gray distribution law of the environment around a pixel point, and predict the theoretical gray value of the pixel point under the condition of no defect based on this law; Then, by comparing the difference between the actual gray value and the theoretical gray value of the pixel point, an index quantifying the abnormality of the pixel point can be obtained. The smaller the index value, the more the point conforms to the local structure law, and the higher the possibility of being a benign point; the larger the index value, the more the point destroys the local structure law, and the greater the suspicion of being a malignant defect point.
[0046] In summary, this invention first performs hierarchical statistical processing on the grayscale data of the pixel neighborhood to obtain inner and outer ring grayscale feature parameters. Specifically, for any target pixel in the basic grayscale feature dataset, an inner ring neighborhood range and an outer ring neighborhood range are defined. In this embodiment, the inner ring neighborhood range is defined as the range within a radius of 2 pixels of the target pixel, and the outer ring neighborhood range is defined as the range 3 to 4 pixels away from the target pixel. The neighborhood range of the target pixel is divided according to the inner and outer ring neighborhood ranges to obtain the inner and outer ring neighborhoods of the target pixel. The average grayscale value of the pixels in the inner ring neighborhood of the target pixel is used as the inner ring grayscale feature parameter of the target pixel; the average grayscale value of the pixels in the outer ring neighborhood of the target pixel is used as the outer ring grayscale feature parameter of the target pixel.
[0047] After obtaining the outer ring grayscale feature parameters of the target pixel, the local grayscale profile deviation factor is obtained by performing trend prediction and deviation calculation on the grayscale feature parameters. Specifically, for any target pixel in the basic grayscale feature dataset, the calculation result of twice the inner ring grayscale feature parameters of the target pixel and the outer ring grayscale feature parameters of the target pixel is used as the theoretical environment predicted grayscale value of the target pixel; the absolute value of the calculation result of subtracting the theoretical environment predicted grayscale value of the target pixel from its grayscale value is used as the local grayscale profile deviation of the target pixel.
[0048] In one implementation, assume the first The inner ring grayscale feature parameters of each pixel are: ;No. The outer ring grayscale feature parameters of each pixel are: ;No. The grayscale value of each pixel is Then the first The expression for calculating the local grayscale profile divergence of a pixel is:
[0049]
[0050] in, Indicates the first Local grayscale profile divergence of individual pixels; Indicates the first The grayscale value of each pixel; Indicates the first Inner ring grayscale feature parameters of each pixel; Indicates the first Outer ring grayscale feature parameters of each pixel; This indicates absolute value calculation.
[0051] It should be noted that the calculation of local grayscale profile deviation is achieved by defining inner and outer ring neighborhood ranges to collect contextual information around the target pixel. On the actual weld surface, whether it's a smooth weld area or an undulating area with a fish-scale pattern, the surface morphology should be a continuous transition at the microscale. This physical continuity is directly reflected in the image as a smooth change in the grayscale profile. The inner and outer ring grayscale feature parameters capture the average grayscale level at two levels from the target pixel, from far to near. The difference between the two quantifies the rate of grayscale change as it approaches the center from the periphery, i.e., the trend of the local grayscale profile. For example, on the slope of a weld wave, this difference will be a stable small value; while when crossing the edge of a bright weld wave, this difference will be a large positive value. Secondly, the core expression of the formula... Mathematically equivalent to Assuming the weld surface structure is continuous, the grayscale value of the target pixel should be the grayscale level of its nearest neighbor (represented by the inner ring), superimposed with the variation trend carried over from the outermost environment (from the outer ring to the inner ring). .therefore, This constitutes the theoretical environmental prediction value for the grayscale value of the target pixel. This prediction value reflects the grayscale that the target pixel should exhibit under conditions of no structural abrupt changes or defects. Finally, by calculating the absolute difference between the actual grayscale value and this environmental prediction value, the formula yields the local grayscale profile deviation of the pixel. For a benign heterogeneous point produced by a normal welding process, such as a tiny protrusion on a weld bead, although its grayscale value may be higher than the surrounding area, it is still part of the smooth transition of the entire weld bead surface, so its grayscale value will be very close to the environmental prediction value, and the calculated local grayscale profile deviation value will be very small. However, for a malignant defect point, such as a tiny black pore, it is a break in the physical structure on the originally continuous weld surface. Its extremely low grayscale value differs from the higher theoretical value predicted by the surrounding bright and normal weld area, which will result in a large local grayscale profile deviation value.
[0052] Thus, the process of obtaining the local grayscale profile deviation by trend prediction and comparison of local grayscale profiles of pixels is completed.
[0053] Step S3: Obtain the disorder of the local gradient structure by performing unit vector aggregation analysis on the gradient directions of the neighborhood of the pixel.
[0054] The local gray scale profile deviation degree constructed in step S2 effectively identifies the pixel points with the gray scale value deviating from the local profile trend. However, the local gray scale profile deviation degree has a deeper problem in the process of solving the problem, that is, it cannot effectively distinguish between ordered gray scale mutations and unordered gray scale mutations. In the actual weld image, some structures formed by normal processes, such as clear junction lines between weld waves, will have pixel points on the structures with high profile deviation degree values because of the sharp change in gray scale, which is similar to the profile deviation degree values of unordered abnormal points (such as pores and slag inclusions) caused by defects. However, the two types of points have essential differences in physical structure: the local structure of the former (such as the edge of the weld wave) is regular and directional; and the local structure of the latter (such as the pore) is chaotic. Therefore, in order to completely solve the problem of distinguishing between benign and malignant heterogeneous points, a second judgment standard must be introduced to quantify the chaos degree of the microstructure in the neighborhood of the pixel point. Because the image gradient field of an ordered structure region is regular, the directions of the gradient vectors are consistent or smoothly transitioned; on the contrary, a structureless defect region will disturb the gradient field around it, so that the direction of the gradient vector becomes chaotic. This step aims to design an index that can accurately measure the consistency of the direction distribution of the local gradient field.
[0055] In summary, the present application first obtains a pixel gradient vector data set by performing gradient calculation and processing on the gray scale data of the weld image, and obtains a pixel unit direction vector data set by performing direction normalization processing on the gradient vector data set. Specifically, for any target pixel point in the pixel basic gray scale feature data set, the horizontal gradient component and the vertical gradient component of the target pixel point are obtained by calculating the gray scale change rate of the target pixel point in the horizontal direction and the vertical direction, respectively; the horizontal gradient component and the vertical gradient component of the target pixel point are combined to obtain the gradient vector of the target pixel point, and the length of the gradient vector of the target pixel point is calculated; the gradient vector of the target pixel point is divided by the length of the gradient vector to obtain the unit direction vector of the target pixel point, and when the length of the gradient vector is zero, the range direction vector of the target pixel point is defined as a zero vector.
[0056] After obtaining the pixel point unit direction vector data, continue to aggregate and sum the neighborhood unit direction vector data to obtain the local gradient structure disorder degree. Specifically, a square neighborhood radius is set, which is 5 in the embodiment of the present application, and the square neighborhood radius value can be adjusted according to the actual scene, without any requirement. For any target pixel point in the pixel point basic gray feature data set, taking the target pixel point as the center, the unit direction vector data of all the pixel points in the neighborhood range is extracted according to the square neighborhood radius; the unit direction vectors of all the pixel points in the neighborhood range are vector summed, and the module length of the vector sum result is calculated, and the module length is normalized with the number of pixel points in the neighborhood to obtain the neighborhood gradient direction consistency ratio; the calculation result of subtracting the constant 1 from the neighborhood gradient direction consistency ratio is taken as the local gradient structure disorder degree of the target pixel point.
[0057] In an embodiment, it is assumed that the unit direction vector of the i-th pixel point is , the square neighborhood pixel point set of the i-th pixel point is , and the neighborhood radius of the square neighborhood is , then the calculation expression of the local gradient structure disorder degree of the i-th pixel point is:
[0058]
[0059] wherein, di represents the local gradient structure disorder degree of the i-th pixel point; ui represents the unit direction vector of the i-th pixel point; Ni represents the square neighborhood pixel point set of the i-th pixel point; and r represents the neighborhood radius of the square neighborhood.
[0060] It should be noted that the formula calculates the unit gradient vector of all the pixels in the square neighborhood of the target pixel point The focus of the analysis is shifted from the magnitude of the gradient to the direction of the gradient. In a weld image, the direction of the gradient directly reflects the direction of the most drastic change in gray level, which is closely related to the micro-geometric trend of the weld surface. By normalizing the gradient vector, the influence of the gradient amplitude variation caused by uneven illumination or contrast difference is eliminated, so that this factor can more purely focus on the order of the structure itself. Secondly, the core part of the formula is to perform vector summation on all unit gradient vectors in the neighborhood. If the structure of a region is highly ordered, such as a regular straight weld wave edge, the gradient directions of all pixels in its neighborhood will be basically consistent, all perpendicular to the edge line. At this time, all unit vectors are almost the same, and the modulus of their vector sum will tend to the sum of the modulus of all unit vectors, i.e. the total number of pixels in the neighborhood. Finally, the formula normalizes the modulus of the vector sum to the interval of 0 to 1 through This ratio quantifies the overall consistency of the gradient direction, and the closer the value is to 1, the more consistent the direction is. On this basis, through the operation of , the local gradient structure disorder degree evaluation is obtained. Such design makes the local gradient structure disorder degree evaluation value positively related to the degree of disorder of the structure. For the ordered abnormal points mentioned above (such as weld wave edges), since the gradient direction is highly consistent, the ratio is close to 1, and the finally calculated local gradient structure disorder degree evaluation value will tend to 0. However, for an unordered abnormal point (such as a pore), the gradient vectors in its neighborhood will point to the center of the pore from all directions, and these different direction unit vectors will largely cancel each other out when performing vector summation, resulting in a modulus of the vector sum much smaller than , the ratio is close to 0, and the finally calculated local gradient structure disorder degree evaluation value will tend to 1. In this way, the local gradient structure disorder degree evaluation successfully provides a decisive basis for distinguishing the two types of local gray profile deviation degree high value points that cannot be distinguished in step S2, and accurately quantifies the order of the local structure of the pixel point.
[0061] At this point, the local gradient structure disorder degree is obtained by analyzing the unit vector aggregation of the gradient direction in the neighborhood of the pixel point.
[0062] Step S4, obtain the structure-aware distance metric function by multiplying the local gray profile deviation degree and the local gradient structure disorder degree.
[0063] Two key optimization factors have been calculated for each pixel in the image through step S2 and step S3. Now it is necessary to effectively integrate the two factors into the traditional Euclidean distance metric function, so that it can comprehensively consider the spatial position, original gray difference and newly constructed structural attribute difference between two pixel points when calculating the distance between them. When two pixel points show great difference in any structural attribute, the possibility of them belonging to the same class (especially the defect class) is very low, so the calculated distance between them should be significantly enlarged; on the contrary, when two pixel points are highly similar in structural attributes, their original distance is not punished to be enlarged, so as to maintain their closeness in relative sense. Through such differentiated distance modulation, the distance between malignant defect points and all benign points in the feature space can be effectively enlarged, thereby enhancing their separability in subsequent clustering.
[0064] In summary, after obtaining the local gray profile deviation degree and the local gradient structure disorder degree, for any two target pixel points in the pixel point basic gray feature data set, the Euclidean distance is calculated based on the gray value and the two-dimensional position coordinates of the two target pixel points, to obtain the original distance metric value of the two target pixel points. The difference values of the local gray profile deviation degree and the local gradient structure disorder degree of the two target pixel points are calculated respectively, and the calculation results of adding the absolute values of the two difference values to constant 1 are taken as the modulation items of the two structural attributes. The structural perception distance metric function value of the two target pixel points is obtained by multiplying the original distance metric value by the modulation items of the two structural attributes in turn.
[0065] At this point, the structural perception distance metric function is obtained by multiplying the local gray profile deviation degree and the local gradient structure disorder degree.
[0066] Step S5, the welding defect recognition result is obtained by clustering analysis on the structural perception distance metric function.
[0067] In the present embodiment, the DBSCAN algorithm mentioned in the background section is used to cluster the pixel points. First, two core parameters of the algorithm need to be set: the neighborhood radius and the minimum number of neighborhood samples for a core point. The minimum number of neighborhood samples can be set according to the minimum effective size of the defect to be detected. For example, if a small defect composed of at least 10 pixels is to be detected, the minimum number of neighborhood samples can be set to 10. The neighborhood radius parameter is selected based on the numerical characteristics of the distance metric in step S4. As previously analyzed, the design of the structure-aware distance metric makes the calculated distance between adjacent pixel points of the same physical origin (e.g., two adjacent points belonging to the same defect) much smaller in value than the calculated distance between pixel points of different physical origins (e.g., a malignant defect point and a benign heterogeneous point). In the numerical simulation of the present embodiment, the structure-aware distance metric value of adjacent defect points of the same type is usually in the order of tens, while the structure-aware distance metric value between different types of points is in the order of thousands. Therefore, the neighborhood radius parameter can be set as a threshold value that can effectively distinguish the two types of distances. In the present embodiment, the neighborhood radius is set to 500.
[0068] After setting the neighborhood radius parameter and the minimum number of neighborhood samples parameter of the clustering algorithm, the structure-aware distance metric function is used as the distance calculation standard of the clustering algorithm. The density reachability of all pixel points in the pixel point-based gray feature data set is analyzed, and the pixel points that meet the density reachability condition are clustered and connected to form multiple pixel point clustering clusters.
[0069] After the clustering process is completed, all pixel point clustering clusters output by the algorithm are analyzed for post-processing to complete the final determination of defects. Through the structure-aware distance metric, the real malignant defect points have been specifically aggregated in the feature space. Therefore, only a size filter based on the minimum defect size needs to be applied to all pixel clusters generated by the DBSCAN algorithm. Any cluster with a pixel number less than the preset minimum number of neighborhood samples is considered to be caused by random noise and is not considered. For the remaining clusters that pass the size filtering, the design of the present application ensures that only clusters composed of real malignant defect points will be stably formed, because in the design of step S4, the structure-aware distance metric between all benign points (whether smooth points or ordered abnormal points) and malignant defect points is systematically amplified, resulting in their inability to meet the density reachability condition of the DBSCAN algorithm and being grouped into the same core cluster. Therefore, any independent cluster that remains after size filtering can be directly determined as a defect region.
[0070] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for intelligent detection of weld defects based on machine vision, characterized in that, The method comprises: Step S1: obtaining pixel point basic gray feature data set by image acquisition and feature preparation of the weld area image; Step S2: obtaining local gray profile deviation degree by trend prediction comparison of the pixel point local gray profile; Step S3: obtaining local gradient structure disorder degree by unit vector aggregation analysis of the pixel point neighborhood gradient direction; Step S4: obtaining structure perception distance measurement function by multiplicative modulation of the local gray profile deviation degree and the local gradient structure disorder degree; Step S5: obtaining the weld defect recognition result by cluster analysis of the structure perception distance measurement function; The calculation expression of the local gray profile deviation degree is: ; wherein, represents a local gray profile deviation of the th pixel point; represents a gray value of the th pixel point; represents an inner ring gray feature parameter of the th pixel point, wherein an average gray value of the pixel points in the inner ring neighborhood of the target pixel point is taken as the inner ring gray feature parameter of the target pixel point; represents an outer ring gray feature parameter of the th pixel point, wherein an average gray value of the pixel points in the outer ring neighborhood of the target pixel point is taken as the outer ring gray feature parameter of the target pixel point; represents an absolute value calculation; The calculation expression of the local gradient structure disorder degree is: ; wherein, denotes the local gradient structure disorder of the pixel point; denotes the unit directional vector of the pixel point; denotes the square neighborhood pixel point set of the pixel point; denotes the neighborhood radius of the square neighborhood. The structure perception distance measurement function obtained by multiplicative modulation of the local gray profile deviation degree and the local gradient structure disorder degree comprises: for any two target pixel points in the pixel point basic gray feature data set, calculating the Euclidean distance based on the gray values and two-dimensional position coordinates of the two target pixel points to obtain the original distance measurement value of the two target pixel points; calculating the local gray profile deviation degree difference value and the local gradient structure disorder degree difference value of the two target pixel points respectively, and taking the absolute values of the local gray profile deviation degree difference value and the local gradient structure disorder degree difference value as the modulation items of the two types of structure attributes; multiplying the original distance measurement value by the modulation items of the two types of structure attributes in sequence to obtain the structure perception distance measurement function value of the two target pixel points.
2. The method of claim 1, wherein the method further comprises: The pixel point basic gray feature data set obtained by image acquisition and feature preparation of the weld area image comprises: acquiring at least one high-resolution digital gray image through a vertical image acquisition process of the weld area of the workpiece to be detected by an industrial area array camera installed on the production line; fixed light source illumination is adopted in the vertical image acquisition process; after preprocessing the acquired gray image, the basic gray feature data of each pixel point is extracted from the image; the basic gray feature data comprises two-dimensional position coordinates and corresponding gray values of the pixel point in the image, and the two-dimensional position coordinates and the gray values of all pixel points form the pixel point basic gray feature data set. 3.The method of claim 1, wherein The inner ring gray feature parameter and the outer ring gray feature parameter of the pixel point comprise: for any target pixel point in the pixel point basic gray feature data set, the inner ring neighborhood range and the outer ring neighborhood range are set, the neighborhood range of the target pixel point is divided according to the inner ring neighborhood range and the outer ring neighborhood range, and the inner ring neighborhood and the outer ring neighborhood of the target pixel point are obtained.
4. The method of claim 1, wherein the method further comprises: The unit direction vector of the pixel point comprises: for any target pixel point in the pixel point basic gray feature data set, the horizontal gradient component and the vertical gradient component of the target pixel point are obtained by calculating the gray change rate of the target pixel point in the horizontal direction and the vertical direction respectively; the horizontal gradient component and the vertical gradient component of the target pixel point are combined to obtain the gradient vector of the target pixel point, and the length of the gradient vector of the target pixel point is calculated. The gradient vector of the target pixel point is divided by the module length of the gradient vector to obtain a unit direction vector of the target pixel point, and when the module length of the gradient vector is zero, the range direction vector of the target pixel point is defined as a zero vector.
5. The method of claim 1, wherein the method further comprises: The welding defect recognition result is obtained by performing clustering analysis on the structure-aware distance metric function, and the welding defect recognition result comprises: The neighborhood radius parameter and the minimum neighborhood sample quantity parameter of the clustering algorithm are set, and the structure-aware distance metric function is taken as the distance calculation standard of the clustering algorithm; density reachability analysis is performed on all pixel points in the pixel point basic gray feature data set, pixel points satisfying the density reachability condition are clustered and connected, and a plurality of pixel point clustering clusters are formed; the pixel point quantity of the clustering cluster is subjected to size filtering processing, and the clustering cluster with a pixel quantity less than the minimum neighborhood sample quantity parameter is removed as a noise cluster; the clustering cluster remaining after the size filtering is output as a welding defect area, and a welding defect recognition result is obtained.
Citation Information
Patent Citations
Steel die welding defect detection method and system based on machine vision
CN115100171A
Construction engineering steel structure welding quality detection method
CN117635604A