Industrial welding quality detection method based on machine vision
By adaptively acquiring structural elements and combining the connected domain features and texture features of welding images, the problem of insufficient enhancement of dark areas in welding quality inspection is solved, and the accuracy of welding defect detection is improved.
Patent Information
- Application Number
- CN202511293339.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-11
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-09-11
AI Technical Summary
In the prior art, the image processing effect in welding quality inspection is poor due to the optical environment and the reflective characteristics of the welded workpiece, especially the insufficient enhancement of dark areas, which affects the accuracy of welding defect detection.
By obtaining the grayscale value and grayscale histogram of the connected domain pixel points in the welding image, combining the area, edge features and texture features of the connected domain, adaptively obtaining the structural elements, and performing bottom-hat operation to enhance the welding defect area, thereby improving the detection accuracy.
The accuracy of welding defect detection is improved, the characteristic performance of dark areas is enhanced, and the effect of welding quality detection is improved.
Smart Images

Figure CN120765664A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data acquisition, in particular to an industrial welding quality detection method based on machine vision. BACKGROUND
[0002] At present, welding technology is applied in manufacturing, construction, automobile, shipbuilding, aerospace and other industries, and the quality of welding is directly related to the performance, safety and service life of the welding product in use, so machine vision technology is usually used to detect the quality of welding.
[0003] Due to the existence of optical environment and the reflection characteristics of the welded workpiece, the detection result is generally negatively affected, and in order to reduce the negative influence of optical environment and the reflection characteristics of the welded workpiece on the detection result, the collected image is usually subjected to bottom hat operation to improve the detection efficiency and accuracy, but in the prior art, a fixed size structure element is usually selected for bottom hat operation, and the determination of the size of such structure element will cause the problem of insufficient enhancement of dark areas, and insufficient enhancement of dark areas will result in low detection accuracy of welding defects, such as pores, cracks and other welding defects, which are usually represented as dark areas in the image, so how to adaptively obtain the size of the structure element and improve the accuracy of subsequent welding quality detection becomes a problem to be solved. SUMMARY
[0004] In order to solve the above problems, the present application provides an industrial welding quality detection method based on machine vision, and the technical solution is as follows: An embodiment of the present application provides an industrial welding quality detection method based on machine vision, comprising the following steps: Obtain a to-be-processed welding image of a welding workpiece and a to-be-analyzed connected domain on the to-be-processed welding image, wherein each point in the to-be-analyzed connected domain is referred to as a connected domain pixel point; According to the gray value of the connected domain pixel point and the gray histogram of the to-be-processed welding image, obtain a suspected abnormal feature value of the connected domain pixel point; According to the area of the to-be-analyzed connected domain containing the connected domain pixel point and the area of the minimum circumscribed ellipse, the curvature, gradient and normal direction of the edge pixel point on the to-be-analyzed connected domain containing the connected domain pixel point, and the local window corresponding to the connected domain pixel point, obtain a target defect feature value of the connected domain pixel point; According to the coordinates of the connected domain pixel points, the suspected abnormal characteristic value and the target defect characteristic value, a suspected welding defect clustering cluster is obtained, and according to the diameter of the minimum circumscribed circle of the suspected welding defect clustering cluster, a structure element of each pixel point in the to-be-processed welding image is obtained, bottom hat operation is performed on the to-be-processed welding image according to the structure element of the pixel point, and a target welding image is obtained. According to the target welding image, welding defect detection and identification of the welding workpiece are performed.
[0005] Beneficial effects: The present application firstly obtains a to-be-processed welding image of a welding workpiece and a to-be-analyzed connected domain on the to-be-processed welding image; then according to the gray value of the connected domain pixel points and the gray histogram of the to-be-processed welding image, a suspected abnormal characteristic value of the connected domain pixel points is obtained; then according to the area of the to-be-analyzed connected domain containing the connected domain pixel points and the area of the minimum circumscribed ellipse, the curvature, gradient and normal direction of the edge pixel points on the to-be-analyzed connected domain containing the connected domain pixel points and the local window corresponding to the connected domain pixel points, a target defect characteristic value of the connected domain pixel points is obtained; then according to the coordinates of the connected domain pixel points, the suspected abnormal characteristic value and the target defect characteristic value, a suspected welding defect clustering cluster is obtained, and according to the diameter of the minimum circumscribed circle of the suspected welding defect clustering cluster, a structure element of each pixel point in the to-be-processed welding image is obtained, bottom hat operation is performed on the to-be-processed welding image according to the structure element of the pixel point, and a target welding image is obtained; finally, according to the target welding image, welding defect detection and identification of the welding workpiece are performed. And the present application adaptively obtains the structure element according to the diameter of the minimum circumscribed circle of the suspected welding defect clustering cluster, can improve the effect of bottom hat operation, improve the enhancement effect on dark areas, and thus can improve the accuracy of detecting and identifying welding defects. BRIEF DESCRIPTION OF DRAWINGS
[0006] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, and the advantages thereof, a brief introduction will be given to the drawings needed in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0007] Figure 1 Flowchart of the present application, an industrial welding quality detection method based on machine vision. DETAILED DESCRIPTION
[0008] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by a person of ordinary skill in the art belong to the protection scope of the embodiments of the present application.
[0009] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
[0010] The embodiment provides a machine vision-based industrial welding quality detection method, and details are as follows: As shown in the figure, the machine vision-based industrial welding quality detection method comprises the following steps: Figure 1 As shown in the figure, the machine vision-based industrial welding quality detection method comprises the following steps: Step S001, acquiring a to-be-processed welding image of a welding workpiece and a to-be-analyzed connected domain on the to-be-processed welding image.
[0011] The main purpose of the embodiment is to improve the enhancement effect on the welding defect area by adaptively acquiring the size of the structure element when performing bottom hat operation on the collected welding image, so as to improve the accuracy of subsequent welding quality detection, and the structure element is the core of the bottom hat operation.
[0012] The embodiment first acquires any welding completed workpiece, and records it as a welding workpiece, then performs image acquisition on the surface of the welding workpiece, and records the acquired image as an initial welding image of the welding workpiece, performs gray scale processing on the initial welding image, records the image after the gray scale processing as a to-be-processed welding image of the welding workpiece, and the acquired image of the welding workpiece includes a welding area, and the device for performing image acquisition on the surface of the welding workpiece includes a high-definition camera and a light source, and the specific image acquisition process is known, for example, a collecting device capable of rotating the welding workpiece can be used to perform image acquisition on the surface of the welding workpiece, or the welding workpiece can also be placed on a transmission device for welding quality detection image acquisition, when the welding workpiece passes directly below the camera, the transmission belt stops, and the camera acquires the image of the welding workpiece.
[0013] Therefore, the embodiment can obtain the to-be-processed welding image of the welding workpiece through the above process. After obtaining the to-be-processed welding image, the connected domain on the to-be-processed welding image is obtained, and all the connected domains are recorded as to-be-analyzed connected domains. The pixel points in the to-be-analyzed connected domains are recorded as connected domain pixel points. Since the pixel points with welding defect features such as pores and cracks usually have connected domain features, that is, the pixel points with welding defect features such as pores and cracks are located in the connected domain, the embodiment mainly improves the accuracy of welding quality detection by improving the enhancement effect of the welding defect area. Therefore, the embodiment only analyzes the possibility of welding defects for the connected domain pixel points in the subsequent process, so as to reduce the calculation amount. That is, the purpose of obtaining the connected domain pixel points is to more conveniently and accurately analyze the possibility of the pixel points belonging to welding defects, so as to more accurately and effectively adjust the size of the structure element, improve the effect of the bottom hat operation, and improve the detection and recognition of the welding quality. In addition, in the embodiment, the specific process of obtaining the connected domain on the to-be-processed welding image is as follows: first, the edge of the to-be-processed welding image is extracted by using the canny edge detection algorithm to obtain all the edges in the to-be-processed welding image, and then the broken edges in the to-be-processed welding image are closed by morphological dilation or erosion. After that, the area contained by the closed edge is recorded as the connected domain.
[0014] In step S002, the suspected abnormal feature value of the connected domain pixel point is obtained according to the gray value of the connected domain pixel point and the gray histogram of the to-be-processed welding image.
[0015] Since the purpose of the bottom-hat operation on the welding image to be processed is to perform image enhancement, especially to enhance the features of the welding defect region, so that the features of the welding defect region are more obvious, and the subsequent identification and detection of the welding defect region are facilitated, and since the existing bottom-hat operation usually selects to use a fixed-size structure element, and the determination of the size of such a structure element will have the problem of insufficient enhancement of dark regions, and the welding defect region usually exhibits dark region features, thereby affecting the subsequent welding quality detection, if the structure element used is too large, the dark region details cannot be captured, resulting in poor enhancement effect on the dark region; and in order to improve the effect of the bottom-hat operation, the size of the structure element will be adaptively obtained based on the possibility of the connected domain pixel belonging to the welding defect next, that is, the size of the structure element will be adaptively obtained based on the suspected abnormality characteristic value and the target defect characteristic value of the connected domain pixel; therefore, it can be known that the suspected abnormality characteristic value of the connected domain pixel is analyzed and obtained next, and since the reflectivity of the metal material is generally good, it will also cause the welding defect regions such as pores and cracks to generally exhibit as regions with low gray value, that is, dark regions, resulting in a large difference between the welding defect region and the overall welding device, that is, the gray value of the pixel points in the dark region accounts for a small proportion relative to the overall image, and based on the above analysis, the specific process of obtaining the suspected abnormality characteristic value of each connected domain pixel in the connected domain to be analyzed on the welding image to be processed is: First, according to the frequency of each gray value in the to-be-processed welding image, a gray histogram of the to-be-processed welding image is constructed. The construction process of the gray histogram is known, and the implementer needs to set the gray level of the constructed gray histogram according to the actual situation. For example, an 8-level gray histogram or a 256-level gray histogram can be constructed. Each gray level on the 8-level gray histogram represents a gray value range. For example, the gray value range represented by the gray level 1 on the 8-level gray histogram is 0 to 31. For any connected domain pixel point b: on the gray histogram of the to-be-processed welding image, the gray level containing the gray value of the connected domain pixel point b is obtained, and is denoted as the gray level corresponding to the connected domain pixel point b. The pixel number corresponding to the gray level corresponding to the connected domain pixel point b is obtained, and is denoted as the pixel number characteristic value of the gray level corresponding to the connected domain pixel point b. The pixel number characteristic value of the gray level corresponding to the connected domain pixel point b refers to the number of pixel points belonging to the gray level corresponding to the connected domain pixel point b in the to-be-processed welding image. The maximum gray level on the gray histogram of the to-be-processed welding image is subtracted from the gray level corresponding to the connected domain pixel point b, and is denoted as the relative gray size characteristic value corresponding to the connected domain pixel point b. The pixel number characteristic value of the gray level corresponding to the connected domain pixel point b is negatively correlated, and the negative correlation mapping result of the pixel number characteristic value of the gray level corresponding to the connected domain pixel point b is multiplied by the relative gray size characteristic value corresponding to the connected domain pixel point b, to obtain the suspected abnormal characteristic value of the connected domain pixel point b. That is, the suspected abnormal characteristic value of the connected domain pixel point b is the product of the negative correlation mapping result of the pixel number characteristic value and the relative gray size characteristic value. The negative correlation mapping result of the pixel number characteristic value of the gray level corresponding to the connected domain pixel point b is the reciprocal of the pixel number characteristic value of the gray level corresponding to the connected domain pixel point b. The greater the suspected abnormal characteristic value of the connected domain pixel point b, the greater the possibility that the connected domain pixel point b belongs to a welding defect.
[0016] In the embodiment, the specific calculation expression of the suspected abnormal characteristic value of the connected domain pixel point b is: ; Wherein, is the suspected abnormal characteristic value of the connected domain pixel point b, is the maximum gray level on the gray histogram of the to-be-processed welding image, is the gray level corresponding to the connected domain pixel point b, is the pixel number characteristic value of the gray level corresponding to the connected domain pixel point b; and The greater the relative gray size characteristic value, the lower the gray value of the connected domain pixel point b relative to the image, and the more obvious the dark area feature represented, The smaller, the lower the proportion of the gray value of the connected domain pixel point b in the image, the more obvious the dark area feature represented, and the more likely it belongs to the welding defect area, and The larger, the more obvious the dark area feature represented by the connected domain pixel point b, the more likely it belongs to the welding defect area, and The smaller, the less obvious the dark area feature represented by the connected domain pixel point b, the less likely it belongs to the welding defect area. The larger, the more obvious the dark area feature represented by the connected domain pixel point b, the more likely it belongs to the welding defect area, and The larger, the more obvious the dark area feature represented by the connected domain pixel point b, the more likely it belongs to the welding defect area, and The smaller, the less obvious the dark area feature represented by the connected domain pixel point b, the less likely it belongs to the welding defect area.
[0017] Therefore, the embodiment can obtain the suspected abnormal representation value of each connected domain pixel point through the above process.
[0018] Step S003, obtaining the target defect representation value of the connected domain pixel point according to the area of the to-be-analyzed connected domain containing the connected domain pixel point and the minimum circumscribed ellipse, the curvature, gradient and normal direction of the edge pixel point on the to-be-analyzed connected domain containing the connected domain pixel point, and the local window corresponding to the connected domain pixel point.
[0019] Since the image has not only the characteristics of low gray value and being different from the normal part in the welding defect area, but also the noise generated by various external factors and the texture area of the welding workpiece itself may also have the characteristics of low gray value and being different from the normal part, only based on the above-mentioned suspected abnormal representation value to adaptively obtain the size of the structural element may cause excessive smoothing of some areas, loss of details or residual small noise, etc., resulting in poor effect of bottom hat operation or processing, affecting the detection result of subsequent welding quality, and in order to avoid the above-mentioned situation as much as possible, the embodiment needs to further analyze the connected domain pixel point to obtain the target defect representation value of the connected domain pixel point, and then further combine the target defect representation value of the connected domain pixel point to complete the adaptive acquisition of the size of the structural element, so the specific process of the target defect representation value of the connected domain pixel point is: Since the porosity welding defect is a welding quality problem caused by a process defect, and the noise is random interference caused by the external environment, the porosity will appear as an approximately circular or elliptical area with a relatively smooth boundary, while the noise will appear as irregular and small spots without a fixed shape. Since the gray level changes from the inside of the hole to the surrounding matrix are relatively steep, the gray level gradient of the porosity edge is large, and the boundary is clear and identifiable. The edge of the noise is blurred, and the gray level transition between pixels is relatively smooth without a clear boundary. Therefore, based on the differences between the characteristics of the porosity and the noise, that is, the shape of the connected domain pixel, the smoothness of the connected domain boundary, and the clarity, the first defect representation value of the connected domain pixel is first obtained. The first defect representation value of any connected domain pixel b is a key indicator for determining the target defect representation value of the connected domain pixel. The specific process for obtaining the first defect representation value of any connected domain pixel b is as follows: First, the connected domain to be analyzed containing the connected domain pixel b is obtained and denoted as connected domain A. The minimum circumscribed ellipse of connected domain A is obtained, and the curvature, gradient, and normal direction of each edge pixel in connected domain A are calculated. The process for obtaining the minimum circumscribed ellipse, the curvature, gradient, and normal direction of the pixel is known. Then, based on the area of connected domain A, the area of the minimum circumscribed ellipse of connected domain A, and the curvature, gradient, and normal direction of each edge pixel in connected domain A, the first defect representation value of connected domain pixel b is obtained. The specific process for obtaining the first defect representation value of connected domain pixel b based on the area of connected domain A, the area of the minimum circumscribed ellipse of connected domain A, and the curvature, gradient, and normal direction of each edge pixel in connected domain A is as follows: First, the area of the minimum circumscribed ellipse of connected domain A and the area of connected domain A are obtained, and the ratio of the area of the minimum circumscribed ellipse of connected domain A to the area of connected domain A is calculated and denoted as the first ratio. The absolute value of the difference between the constant 1 and the first ratio is calculated and denoted as the first difference. The result of negatively normalizing the first difference is denoted as the first index value of connected domain pixel b. The smaller the first difference, the larger the output result after negative normalization. The first difference is where S1 is the area of the minimum circumscribed ellipse of connected domain A, and S2 is the area of connected domain A. Generally, S1 is greater than or equal to S2, and the ratio of S1 to S2 is closer to 1, that is, The smaller the ratio or the larger the first index value, the more likely it is that connected domain A is an approximately circular or elliptical area, and the more it has the characteristics of the porosity welding defect. Therefore, connected domain pixel b also has the characteristics of the porosity welding defect.
[0020] In addition, the formula for negatively normalizing the first difference is where is the maximum value of the value range corresponding to the first difference, The minimum value of the value interval corresponding to the first difference value is taken as the first index value of the connected domain pixel point b, x is the first difference value, and the negative normalization method for other data is the same as that for the first difference value.
[0021] Then the standard deviation of the curvature of all edge pixel points on the connected domain A is calculated, and the result of the negative normalization of the standard deviation of the curvature of all edge pixel points on the connected domain A is recorded as the second index value of the connected domain pixel point b. The smaller the standard deviation of the curvature, the larger the output result after negative normalization. The larger the standard deviation of the curvature, the worse the smoothness of the edge of the connected domain A, and the less consistent with the characteristics of the pore defect. That is, the smaller the standard deviation of the curvature or the larger the second index value, the smoother the edge of the connected domain A or the more the connected domain A has the characteristics of the pore welding defect, and then the connected domain pixel point b also has the characteristics of the pore welding defect.
[0022] Then, taking each edge pixel point in the connected domain A as a starting point, a corresponding analysis window corresponding to the corresponding edge pixel point is constructed along the normal direction of the corresponding edge pixel point. The analysis window of the edge pixel point is located on the normal line of the edge pixel point, and in specific applications, the implementer needs to set the size of the analysis window according to the actual situation. For example, the size of the analysis window can be set to 1x4, that is, the number of pixel points that can be accommodated by the analysis window is 4. For example, for any edge pixel point, taking the edge pixel point as a starting point, traversing along the normal direction of the edge pixel point, and according to the traversal order, the window composed of the first three pixel points and the edge pixel point is recorded as the analysis window corresponding to the edge pixel point. Then the edge feature value of each edge pixel point in the connected domain A is obtained, and the specific calculation process of the edge feature value of any edge pixel point is as follows: the mean value of the gray values of all pixel points in the analysis window corresponding to the edge pixel point except the edge pixel point is calculated, and is recorded as the neighborhood mean value of the edge pixel point. The absolute value of the difference between the gray value of the edge pixel point and the neighborhood mean value of the edge pixel point is calculated, and is recorded as the gray neighborhood difference value of the edge pixel point. The addition result of the gray neighborhood difference value of the edge pixel point and the gradient value of the edge pixel point is calculated and taken as the edge feature value of the edge pixel point. The calculation expression of the edge feature value of the edge pixel point is D1 is the absolute value of the difference between the gray value of the edge pixel point and the neighborhood average value of the edge pixel point, and D2 is the gradient value of the edge pixel point; and the greater the gray neighborhood difference value of the edge pixel point and the gradient value of the edge pixel point, the clearer the edge of the connected domain A, the more consistent with the edge characteristics of the welding defect of the gas hole; then the mean value of the edge feature values of all edge pixel points in the connected domain A is calculated, and the result of normalizing the mean value of the edge feature values of all edge pixel points in the connected domain A is taken as the third index value of the connected domain pixel point b, and the greater the third index value, the clearer the edge of the connected domain A, the more consistent with the edge characteristics of the welding defect of the gas hole, and then the connected domain pixel point b also has the characteristics of the welding defect of the gas hole.
[0023] Finally, the product of the first index value, the second index value and the third index value of the connected domain pixel point b is calculated, and is taken as the first defect representation value of the connected domain pixel point b, that is, the calculation expression of the first defect representation value of the connected domain pixel point b is Where H1 is the first index value of the connected domain pixel point b, H2 is the second index value of the connected domain pixel point b, and H3 is the third index value of the connected domain pixel point b; the greater the first defect representation value of the connected domain pixel point b, the more the connected domain pixel point b has the characteristics of the welding defect of the gas hole, or the greater the probability that the connected domain pixel point b belongs to the welding defect area.
[0024] Since the crack welding defect is a linear fracture caused by welding stress or process defects, and the normal texture area is the organizational structure of the material itself, the crack will be a continuous fine line, without periodicity or repetition, while the normal texture is a fine granular, short linear or network structure, with regularity, such as the directionality of rolling texture, and the crack also has the characteristics of significant contrast with the surrounding matrix gray, clear boundary, obvious mutation of gray jump, etc. That is, the texture of the crack welding defect area is relatively uneven, and the gray feature of the neighborhood is relatively dissimilar, and the normal texture area has the characteristics of relatively flat gray change, low contrast with the adjacent area, and no obvious mutation of gray jump; therefore, the second defect representation value of the connected domain pixel point will be obtained by analyzing the texture characteristics and the gray jump characteristics in the following embodiment, and the second defect representation value of the connected domain pixel point is a key index for determining the target defect representation value of the connected domain pixel point, and the specific acquisition process of the second defect representation value of any connected domain pixel point b is as follows: With any pixel point as the center, a rectangular window corresponding to the pixel point is constructed and recorded as a local window corresponding to the pixel point, and in specific applications, the implementer needs to set the size of the rectangular window according to the actual situation, such as setting it to an empirical value, such as 7x7; then the gray level co-occurrence matrix and the gray level histogram of the local window corresponding to the connected domain pixel point b are constructed, and the eigenvalues of the gray level co-occurrence matrix of the local window corresponding to the connected domain pixel point are calculated; then according to the eigenvalues of the gray level co-occurrence matrix of the local window corresponding to the connected domain pixel point b, the gray level histogram of the local window corresponding to the connected domain pixel point b, and the similarity between the local window corresponding to the connected domain pixel point b and the local window corresponding to the neighborhood pixel point of the connected domain pixel point b, the second defect characteristic value of the connected domain pixel point b is obtained.
[0025] In this embodiment, the specific process of obtaining the second defect characteristic value of the connected domain pixel point b according to the eigenvalues of the gray level co-occurrence matrix of the local window corresponding to the connected domain pixel point b, the gray level histogram of the local window corresponding to the connected domain pixel point b, and the similarity between the local window corresponding to the connected domain pixel point b and the local window corresponding to the neighborhood pixel point of the connected domain pixel point b is as follows: First, according to the energy and uniformity of the gray level co-occurrence matrix of the local window corresponding to the connected domain pixel point b and the frequency difference of the same gray value appearing in the local window corresponding to the connected domain pixel point b and the local window corresponding to the neighborhood pixel point of the connected domain pixel point b, the target texture distribution characteristic value of the connected domain pixel point b is obtained; then, according to the gray level histogram of the local window corresponding to the connected domain pixel point b, the gray level jump degree of the connected domain pixel point b is obtained; finally, the product of the target texture distribution characteristic value and the gray level jump degree of the connected domain pixel point b is calculated, and is taken as the second defect characteristic value of the connected domain pixel point b. The greater the target texture distribution characteristic value of the connected domain pixel point b, the more uneven the local texture distribution of the connected domain pixel point b, the more similar the local gray distribution of adjacent pixels, the more the connected domain pixel point b has the characteristics of crack welding defects, the greater the gray level jump degree of the connected domain pixel point b, the greater the gray level span in the local window of the connected domain pixel point b, the more the connected domain pixel point b has the characteristics of crack welding defects, and the greater the target texture distribution characteristic value and the gray level jump degree of the connected domain pixel point b, the greater the second defect characteristic value of the connected domain pixel point b. Therefore, the greater the second defect characteristic value of the connected domain pixel point b, the more obvious the crack welding defect characteristics of the connected domain pixel point b, or the greater the probability that the connected domain pixel point b belongs to the welding defect area.
[0026] In this embodiment, the specific process of obtaining the target texture distribution characteristic value of the connected domain pixel point b is as follows: First, the product of the energy and uniformity of the grayscale co-occurrence matrix of the local window corresponding to the connected domain pixel point b is calculated, and the result of negative normalization of the product of energy and uniformity is recorded as the first texture distribution representation value of the connected domain pixel point b. The greater the energy and uniformity, the smaller the first texture distribution representation value, and the more uniform the local texture distribution of the connected domain pixel point b. Energy is also called the second-order angular moment, and uniformity is also called the inverse gap. Then, in the local window corresponding to the connected domain pixel point b, select any pixel point from all the pixels except the connected domain pixel point b as the neighboring pixel point of the connected domain pixel point b, and count all the grayscale value types that appear in the local window corresponding to the connected domain pixel point b and the local window corresponding to the neighboring pixel points of the connected domain pixel point b, and record the set constructed by all the grayscale value types that appear as a comprehensive set, and calculate the frequency difference corresponding to each grayscale value in the comprehensive set, and the frequency difference corresponding to any grayscale value a in the comprehensive set is the absolute value of the difference between the frequency of grayscale value a in the local window corresponding to the connected domain pixel point b and the frequency of grayscale value a in the local window corresponding to the neighboring pixel points of the connected domain pixel point b, that is, for the grayscale value 25 in the comprehensive set, , the frequency of the grayscale value 25 in the local window corresponding to the connected domain pixel point b is 5, and the frequency of the grayscale value 25 in the local window corresponding to the neighboring pixel points of the connected domain pixel point b is 1, then the frequency difference corresponding to the grayscale value 25 is 4; then the frequency differences corresponding to all the grayscale values in the comprehensive set are calculated and accumulated and then normalized, and recorded as the second texture distribution representation value of the connected domain pixel point b. The normalization here uses the normalization function Norm(); and the greater the difference in the frequency of a certain grayscale value in the local window corresponding to the connected domain pixel point b and in the local window corresponding to the neighboring pixel points of the connected domain pixel point b, that is, the larger the second texture distribution representation value, the more it indicates that the grayscale features of the connected domain pixel point b and the neighboring pixel points are more dissimilar. Finally, the average of the first texture distribution representation value and the second texture distribution representation value of the connected domain pixel point b is calculated and recorded as the target texture distribution representation value of the connected domain pixel point b; and since the larger the first texture distribution representation value and the second texture distribution representation value, the more uneven the local texture distribution of the connected domain pixel point b is and the less similar the grayscale features are to the neighboring pixels, the more uneven the local texture distribution of the connected domain pixel point b is and the less similar the grayscale features are to the neighboring pixels, the more obvious the crack welding defect features of the connected domain pixel point b are, or the greater the probability that the connected domain pixel point b belongs to the welding defect area.
[0027] In the embodiment, the specific acquisition process of the gray level jump degree of the connected domain pixel b is obtained according to the gray level histogram of the local window corresponding to the connected domain pixel b. The gray level histogram of the local window corresponding to the connected domain pixel b is denoted as an analysis histogram. The middle gray level on the analysis histogram is obtained. The middle gray level on the analysis histogram refers to the middle gray level between the maximum gray level and the minimum gray level on the analysis histogram, or the middle gray level on the analysis histogram refers to one half of the maximum gray level on the analysis histogram, and the vertical coordinates of the maximum gray level and the minimum gray level on the analysis histogram are not 0. In the embodiment, the middle gray level is required to be an integer. If one half of the maximum gray level is not an integer, the integer part of one half of the maximum gray level is taken as the middle gray level on the analysis histogram. The number of gray levels in the construction of the analysis histogram is set by the implementer according to experience. The maximum vertical coordinate value corresponding to the gray level on the left side of the middle gray level on the analysis histogram is obtained and denoted as a left representative gray level. The maximum vertical coordinate value corresponding to the gray level on the right side of the middle gray level on the analysis histogram is obtained and denoted as a right representative gray level. The acquisition process of the histogram is known. Finally, the absolute value of the difference between the left representative gray level and the right representative gray level is normalized and taken as the gray level jump degree of the connected domain pixel b. The normalization is also performed by using the normalization function Norm (). The greater the absolute value of the difference between the left representative gray level and the right representative gray level, the greater the degree of gray level jump in the local window of the connected domain pixel b, and the more the connected domain pixel b has the characteristics of the crack welding defect.
[0028] In the embodiment, the specific calculation expression of the second defect representation value of the connected domain pixel b is as follows: ; wherein, is the second defect representation value of the connected domain pixel b, EH is the first texture distribution representation value of the connected domain pixel b, Norm () is a normalization function, K is a comprehensive set, is the frequency difference value corresponding to the kth gray value in the comprehensive set, G1 is the left representative gray level, and G2 is the right representative gray level, is the second texture distribution representation value of the connected domain pixel b, is the target texture distribution representation value of the connected domain pixel b, is the gray level jump degree of the connected domain pixel b; and is greater, and is greater, is greater, and is greater, the welding defect characteristics of the connected domain pixel b are more obvious, the connected domain pixel b is more likely to belong to the welding defect, and vice versa The smaller the value of , the less obvious the welding defect feature of the connected domain pixel point b is, and the smaller the possibility that the connected domain pixel point b belongs to a welding defect is.
[0029] Since both the first defect characterization value and the second defect characterization value can reflect the possibility that the connected domain pixel point is a welding defect, this embodiment uses the average of the first defect characterization value and the second defect characterization value of each connected domain pixel point as the target defect characterization value of the corresponding connected domain pixel point, that is, the target defect characterization value of connected domain pixel point b is the average of the first defect characterization value of connected domain pixel point b and the second defect characterization value of connected domain pixel point b. The larger the target defect characterization value of connected domain pixel point b, the more obvious the welding defect characteristics of connected domain pixel point b, and the greater the possibility that it is a welding defect. Based on the above, it can be seen that the target defect characterization value of the connected domain pixel point is obtained based on the area of the connected domain to be analyzed and the area of the minimum circumscribed ellipse containing the connected domain pixel point, the curvature, gradient and normal direction of the edge pixels on the connected domain to be analyzed containing the connected domain pixel point, and the local window corresponding to the connected domain pixel point.
[0030] Step S004: obtain a suspected welding defect cluster based on the coordinates of the connected domain pixel points, the suspected abnormality characterization value and the target defect characterization value, and obtain the structural elements of each pixel point in the welding image to be processed based on the diameter of the minimum circumscribed circle of the suspected welding defect cluster. Based on the structural elements of the pixel points, perform a bottom hat operation on the welding image to be processed to obtain a target welding image; and perform welding defect detection and identification on the welding workpiece based on the target welding image.
[0031] Since the welding defect area is relatively small and the pixel points in the welding defect area are distributed more concentratedly, after obtaining the suspected abnormality representation value and the target defect representation value, this embodiment performs mean shift clustering on all connected domain pixel points based on the coordinates, suspected abnormality representation values and target defect representation values of each connected domain pixel point on the welding image to be processed to obtain various cluster clusters. When clustering, the distance measurement between the connected domain pixel points and the connected domain pixel points is the Euclidean distance between the feature vectors of the connected domain pixel points and the feature vectors of the connected domain pixel points. The feature vector of the connected domain pixel point is composed of the coordinates of the corresponding connected domain pixel point, the suspected abnormality representation value and the target defect representation value, and the process of mean shift clustering is well known.
[0032] After clustering is completed, suspected welding defect clusters are obtained based on the suspected abnormality representation values and target defect representation values of the connected domain pixels in each cluster and the density of the connected domain pixels in the cluster. Suspected welding defect clusters are the key to subsequently determining the structural element parameter values. The specific process of obtaining suspected welding defect clusters is as follows: For any cluster: obtain the total number of pixel points in the cluster and the area of the minimum circumscribed circle of the cluster, calculate the ratio of the total number of pixel points in the cluster to the area of the minimum circumscribed circle of the cluster, and record it as the characteristic ratio of the cluster. The characteristic ratio can reflect the density of connected domain pixel points in the cluster. The greater the characteristic ratio, the greater the density of connected domain pixel points in the cluster, and the more likely the cluster is a suspected welding defect cluster. Add the mean of the suspected abnormality feature values of all connected domain pixel points in the cluster to the mean of the target defect feature values of all connected domain pixel points in the cluster, and record the result as the comprehensive feature value of the cluster. The normalized result of multiplying the comprehensive feature value of the cluster by the characteristic ratio of the cluster is used as the target abnormality degree feature value of each connected domain pixel point in the cluster. The target abnormality degree feature values of each connected domain pixel point in the same cluster are the same, i.e. the target abnormality degree feature value of any connected domain pixel point in the cluster is the normalized result of multiplying the comprehensive feature value of the cluster by the characteristic ratio of the cluster. The comprehensive feature value of the cluster is the sum of the corresponding suspected abnormality mean and target defect mean. The corresponding suspected abnormality mean of the cluster is the mean of the suspected abnormality feature values of all connected domain pixel points in the corresponding cluster. The corresponding target defect mean of the cluster is the mean of the target defect feature values of all connected domain pixel points in the corresponding cluster. Here, the normalization function Norm() is used for normalization. Calculate the mean of the target abnormality degree feature values of all connected domain pixel points in the cluster, and use it as the abnormality degree judgment index value of the cluster. Since the target abnormality degree feature values of all connected domain pixel points in the cluster are consistent, the normalized result of multiplying the comprehensive feature value of the cluster by the characteristic ratio of the cluster can also be directly used as the abnormality degree judgment index value of the cluster. The greater the abnormality degree judgment index value of the cluster, the greater the density of suspected welding defect pixel points in the cluster, and the greater the probability that the cluster is a suspected welding defect cluster. Therefore, it is determined whether the abnormality degree judgment index value of the cluster is greater than a preset abnormality threshold. If yes, the cluster is determined to be a suspected welding defect cluster, i.e. the probability that the cluster belongs to a welding defect region is greater. However, it cannot be accurately stated that the cluster is a welding defect cluster, so the cluster is recorded as a suspected welding defect cluster. Otherwise, it is determined that the cluster is not a suspected welding defect cluster, but a normal region. In specific applications, the implementer needs to set the preset abnormality threshold according to the actual situation such as the rounding range of the abnormality degree judgment index value. In this embodiment, the preset abnormality threshold is set to 0.7.
[0033] After the suspected welding defect clustering cluster is obtained, the structural element parameter value is adaptively obtained based on the suspected welding defect clustering cluster, that is, after the suspected welding defect clustering cluster is obtained, the structural element of each pixel point on the welding image to be processed is obtained according to the diameter of the minimum circumscribed circle of the suspected welding defect clustering cluster. The specific acquisition process is as follows: For any pixel point in the welding image to be processed: if it is judged that the pixel point does not belong to the suspected welding defect clustering cluster, the preset structural element parameter value is taken as the structural element parameter value of the pixel point; if it is judged that the pixel point belongs to the suspected welding defect clustering cluster, the structural element parameter value of the pixel point is obtained according to the diameter of the minimum circumscribed circle of the clustering cluster to which the pixel point belongs, and the structural element parameter value is obtained according to the rule that the larger the diameter of the minimum circumscribed circle of the clustering cluster to which the pixel point belongs, the larger the structural element parameter value of the corresponding pixel point, that is, the structural element parameter value of the pixel point is taken as the structural element parameter value of the pixel point, c is an adjustment coefficient, c is set to an empirical value, for example, the adjustment coefficient is set to 1.5, r is the diameter of the minimum circumscribed circle of the clustering cluster to which the pixel point belongs, is a down rounding symbol; the structural element of the pixel point is VxV, and V is the structural element parameter value of the pixel point, that is, the size of the structural element of the pixel point is VxV. In addition, the way of determining the structural element of the pixel point in this embodiment can effectively enhance all welding defect regions as much as possible, that is, it can effectively enhance all welding defect regions as much as possible or can effectively avoid the problem of insufficient enhancement of welding defect regions.
[0034] It should be noted that when is an even number, the result of is added by a constant 1 to be taken as the structural element parameter value of the pixel point; in addition, in specific applications, the implementer needs to set the preset structural element parameter value according to the actual situation, for example, the preset structural element parameter value is set to an empirical value, for example, it is set to 5, that is, when the pixel point does not belong to the suspected welding defect clustering cluster, the size of the structural element of the pixel point is 5x5, and it is required that the set preset structural element parameter value can take into account noise suppression and detail preservation; as other implementation manners, the structural element of each pixel point on the welding image to be processed can also be obtained according to the side length of the minimum circumscribed rectangle of the suspected welding defect clustering cluster, and when the structural element of each pixel point on the welding image to be processed is obtained according to the side length of the minimum circumscribed rectangle of the suspected welding defect clustering cluster, r represents the side length of the minimum circumscribed rectangle.
[0035] After obtaining the structural elements of each pixel in the welding image to be processed, a bottom-hat operation is performed on the welding image to be processed according to the structural elements of each pixel, and the image after the bottom-hat operation is recorded as the target welding image. Under the premise that the structural element size of the pixel is known, the process of performing the bottom-hat operation on the welding image to be processed is well known; then, based on the target welding image and the welding defect network, welding defects are detected and identified on the welding workpiece, that is, a trained welding defect network is obtained, the target welding image is input into the trained welding defect network, and the welding defect area on the target welding image is output, that is, the welding defect network can mark the position of the welding defect area on the target welding image, and the use of the image after the bottom-hat operation can improve the accuracy and efficiency of defect area identification and detection; the welding defect network is a convolutional neural network (such as a CNN network) or a target detection model (such as a YOLO or Faster R-CNN model), and the training process of the welding defect network is a well-known technology, so it will not be described in detail in this embodiment.
[0036] At this point, this embodiment completes the detection and identification of welding defects on welding workpieces; that is, this embodiment adaptively obtains structural elements based on the diameter of the minimum circumscribed circle of the suspected welding defect cluster, which can make the bottom hat operation effect better and the dark area enhancement effect better, and the accuracy of welding defect detection and identification based on images with better dark area enhancement effect is higher.
[0037] To summarize, this embodiment first obtains a welding image to be processed of a welding workpiece and a connected domain to be analyzed on the welding image to be processed; then, based on the grayscale values of the pixels in the connected domain and the grayscale histogram of the welding image to be processed, the suspected abnormality representation values of the pixels in the connected domain are obtained; then, based on the area of the connected domain to be analyzed and the area of the minimum circumscribed ellipse containing the pixels in the connected domain, the curvature, gradient and normal direction of the edge pixels on the connected domain to be analyzed containing the pixels in the connected domain, and the local window corresponding to the pixels in the connected domain, the target defect representation values of the pixels in the connected domain are obtained; then, based on the coordinates of the pixels in the connected domain, the suspected abnormality representation values and the target defect representation values, suspected welding defect clusters are obtained, and based on the diameter of the minimum circumscribed circle of the suspected welding defect clusters, the structural elements of each pixel in the welding image to be processed are obtained, and based on the structural elements of the pixels, a bottom hat operation is performed on the welding image to be processed to obtain a target welding image; finally, based on the target welding image, welding defect detection and identification are performed on the welding workpiece. Moreover, this embodiment adaptively obtains structural elements based on the diameter of the minimum circumscribed circle of the suspected welding defect cluster, which can improve the effect of bottom hat operation and the enhancement effect of dark areas, thereby improving the accuracy of welding defect detection and identification.
[0038] The above-described embodiments are only used to illustrate the technical solutions of the present application, but not limit them; although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for industrial welding quality detection based on machine vision, characterized in that: The method comprises the following steps: Acquire a welding image to be processed of a welding workpiece and a connected domain to be analyzed on the welding image to be processed, where all points in the connected domain to be analyzed are called connected domain pixels; Obtaining suspected abnormality characterization values of the pixels in the connected domain according to the grayscale values of the pixels in the connected domain and the grayscale histogram of the welding image to be processed; Obtaining a target defect representation value of a pixel point in the connected domain according to the area of the connected domain to be analyzed and the area of the minimum circumscribed ellipse, the curvature, gradient, and normal direction of edge pixels on the connected domain to be analyzed and containing the pixel point in the connected domain, and the local window corresponding to the pixel point in the connected domain; Obtaining a suspected welding defect cluster based on the coordinates of the connected domain pixels, the suspected anomaly characterization value, and the target defect characterization value, and obtaining a structural element of each pixel in the welding image to be processed based on the diameter of the minimum circumscribed circle of the suspected welding defect cluster; performing a bottom-hat operation on the welding image to be processed based on the structural element of the pixel to obtain a target welding image; Welding defects are detected and identified on the welding workpiece according to the target welding image.
2. The industrial welding quality detection method based on machine vision according to claim 1, characterized in that: The method for obtaining the suspected abnormality representation value of the connected domain pixel point includes: For any connected domain pixel point, on the grayscale histogram of the welding image to be processed, the grayscale level containing the grayscale value of the connected domain pixel point and the number of pixels corresponding to the grayscale level containing the grayscale value of the connected domain pixel point are obtained, and are recorded as the grayscale level corresponding to the connected domain pixel point and the number of pixels corresponding to the grayscale level respectively. The result of subtracting the grayscale level corresponding to the connected domain pixel point from the maximum grayscale level on the grayscale histogram of the welding image to be processed is recorded as the relative grayscale size representation value, and the product of the relative grayscale size representation value and the result of the negative correlation mapping of the grayscale level corresponding to the connected domain pixel point is used as the suspected abnormality representation value of the connected domain pixel point.
3. The industrial welding quality detection method based on machine vision according to claim 1, characterized in that: The method for obtaining the target defect representation value of the connected domain pixel point includes: For any connected domain pixel point: the connected domain to be analyzed containing the connected domain pixel point is recorded as the connected domain A, and the first defect representation value of the connected domain pixel point is obtained according to the area of the connected domain A, the area of the minimum circumscribed ellipse of the connected domain A, and the curvature, gradient and normal direction of each edge pixel point in the connected domain A. The second defect representation value of the connected domain pixel point is obtained according to the eigenvalue of the grayscale co-occurrence matrix of the local window corresponding to the connected domain pixel point, the grayscale histogram of the local window corresponding to the connected domain pixel point, and the similarity between the local window corresponding to the connected domain pixel point and the local window corresponding to the neighboring pixel points of the connected domain pixel point. The local window corresponding to any pixel point is a rectangular window constructed with the corresponding pixel point as the center, and the average of the first defect representation value and the second defect representation value is the target defect representation value of the connected domain pixel point.
4. The method for detecting industrial welding quality based on machine vision according to claim 3, wherein: The method for obtaining the first defect representation value of the connected domain pixel point includes: Recording the ratio of the area of the minimum circumscribed ellipse of the connected domain A to the area of the connected domain A as a first ratio, and recording the result of negative normalization of the absolute value of the difference between a constant 1 and the first ratio as a first index value; The result of negative normalization of the standard deviation of the curvature of all edge pixels on the connected domain A is recorded as the second index value; Taking each edge pixel point in the connected domain A as a starting point, constructing a window to be analyzed corresponding to the corresponding edge pixel point along the normal direction of the corresponding edge pixel point, and obtaining a third index value based on the window to be analyzed corresponding to each edge pixel point in the connected domain A; The product of the first index value, the second index value and the third index value is used as the first defect representation value of the pixel point in the connected domain.
5. The method for industrial welding quality inspection based on machine vision according to claim 4, characterized in that: The method for obtaining the third indicator value includes: The grayscale mean of the remaining pixels in the window to be analyzed corresponding to the edge pixel point except the corresponding edge pixel point is recorded as the neighborhood mean of the corresponding edge pixel point, the absolute value of the difference between the grayscale value of each edge pixel point in the connected domain A and the neighborhood mean of the corresponding edge pixel point plus the gradient value of the corresponding edge pixel point is recorded as the edge eigenvalue of the corresponding edge pixel point, and the result of normalizing the mean of the edge eigenvalues of all edge pixels in the connected domain A is used as the third index value.
6. A signal data acquisition method for a battery central control mainboard according to claim 5, characterized in that: The method for obtaining the second defect representation value of the connected domain pixel point includes: According to the energy and uniformity of the grayscale co-occurrence matrix of the local window corresponding to the connected domain pixel point and the frequency difference between the occurrence of the same grayscale value in the local window corresponding to the connected domain pixel point and the local window corresponding to the neighboring pixel points of the connected domain pixel point, the target texture distribution representation value of the connected domain pixel point is obtained; according to the grayscale histogram of the local window corresponding to the connected domain pixel point, the grayscale jump degree of the connected domain pixel point is obtained; and the product of the target texture distribution representation value and the grayscale jump degree is used as the second defect representation value of the connected domain pixel point.
7. The method for detecting industrial welding quality based on machine vision according to claim 6, wherein: The method for obtaining the target texture distribution representation value of the connected domain pixel points includes: The result of negatively normalizing the product of the energy of the gray level co-occurrence matrix of the local window corresponding to the pixel point of the connected domain and the uniformity is recorded as the first texture distribution representation value; Record a set constructed by all grayscale value types appearing in the local window corresponding to the connected domain pixel point and the local window corresponding to the neighboring pixel points of the connected domain pixel point as a comprehensive set, and obtain the frequency difference corresponding to each grayscale value in the comprehensive set, the frequency difference corresponding to any grayscale value a in the comprehensive set is the absolute value of the difference between the frequency of occurrence of the grayscale value a in the local window corresponding to the connected domain pixel point and the frequency of occurrence of the grayscale value a in the local window corresponding to the neighboring pixel points of the connected domain pixel point, and record the result of accumulating the frequency differences corresponding to all grayscale values in the comprehensive set and then performing normalization processing as the second texture distribution representation value; The average of the first texture distribution representation value and the second texture distribution representation value is recorded as the target texture distribution representation value of the connected domain pixel point.
8. The method for industrial welding quality inspection based on machine vision according to claim 6, wherein: The method for obtaining the grayscale jump degree of the connected domain pixel points includes: The grayscale histogram of the local window corresponding to the connected domain pixel point is recorded as the histogram to be analyzed, the grayscale level corresponding to the maximum ordinate value on the left side of the middle grayscale level on the histogram to be analyzed is recorded as the left representative grayscale level, and the grayscale level corresponding to the maximum ordinate value on the right side of the middle grayscale level on the histogram to be analyzed is recorded as the right representative grayscale level. The result of normalizing the absolute value of the difference between the left representative grayscale level and the right representative grayscale level is taken as the grayscale jump degree of the connected domain pixel point.
9. The industrial welding quality detection method based on machine vision according to claim 1, characterized in that: The method for obtaining suspected welding defect clusters includes: Clustering all connected domain pixel points according to the coordinates of the connected domain pixel points, the suspected anomaly representation values, and the target defect representation values to obtain clusters; For any cluster, the ratio of the total number of pixels in the cluster to the area of the minimum circumscribed circle of the cluster is recorded as the characteristic ratio. The mean of the suspected abnormal characterization values of all connected domain pixels in the cluster is added to the mean of the target defect characterization values of all connected domain pixels in the cluster, and then the normalized result is multiplied by the characteristic ratio. It is used as the abnormality judgment index value of the cluster. If the abnormality judgment index value of the cluster is greater than the preset abnormality threshold, then the cluster is recorded as a suspected welding defect cluster.
10. The industrial welding quality detection method based on machine vision according to claim 1, characterized in that: The method for obtaining the structural elements of each pixel in the welding image to be processed includes: For any pixel point in the welding image to be processed, if the pixel point does not belong to the suspected welding defect cluster, the preset structural element parameter value is used as the structural element parameter value of the corresponding pixel point; if the pixel point belongs to the suspected welding defect cluster, the structural element parameter value of the pixel point is obtained according to the diameter of the minimum circumscribed circle of the cluster to which the pixel point belongs, and V×V is used as the structural element of the pixel point, where V is the structural element parameter value of the pixel point. The larger the diameter of the minimum circumscribed circle of the cluster to which the pixel point belongs, the larger the structural element parameter value of the pixel point.
Citation Information
Patent Citations
Segmentation method of weld defect images
CN109003275A
Fascia gun power supply driving board welding fault detection method based on artificial intelligence
CN115861307A
Aluminum composite plate defect detection method and system based on artificial intelligence
CN117611583A
Visual inspection method and system for welding robot
CN117689663A
Method for detecting welding quality of copper-aluminum dissimilar metal based on image processing
CN119205751A
Cited By
Vision-based accessory appearance defect detection method and system
CN121329969A