A high-frequency welded pipe defect detection method and system based on machine vision

Through the improved multi-scale Retinex algorithm and adaptive weight fusion technology, combined with deep learning CNN classifier, the problem of insufficient detection accuracy caused by uneven light in machine vision high-frequency welded pipe detection is solved, and high-precision and high-root welded pipe defect detection is achieved.

CN120107268BActive Publication Date: 2025-07-11XIAN JIAHE HUAHENG THERMAL SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510592872.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-07-11
Estimated Expiration
2045-05-09

AI Technical Summary

Technical Problem

The existing machine vision high-frequency welded pipe defect detection methods are difficult to accurately identify the tiny defects on the surface of the welded pipe under complex lighting conditions, especially in highlights and shaded areas, resulting in insufficient detection accuracy and reliability.

Method used

The improved multi-scale Retinex algorithm is used to combine adaptive weight calculations, and defect detection is performed by obtaining multi-scale images of the welded pipe surface, connecting domain analysis and adaptive weight fusion, combining grayscale symbiosis matrix and HU moment extraction features, and deep learning CNN classifiers are used for defect detection.

Benefits of technology

It significantly improves the accuracy and robustness of surface defect detection of welded pipes under complex lighting conditions, reduces the leakage detection rate and false alarm rate, and realizes high-precision automated detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120107268B_ABST
    Figure CN120107268B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing, and specifically relates to a method and system for detecting defects in high-frequency welded pipes based on machine vision. By using a camera to capture images of the welded pipes, the YOLOv5 algorithm is utilized to extract the detection area. An improved multi-scale Retinex algorithm is adopted to calculate the adaptive fusion weight according to the image characteristics for illumination equalization, effectively dealing with highlights and shadows. Subsequently, the defect area is located through Canny edge detection and connected component analysis, and its GLCM texture features and HU moment geometric features are extracted. The features and defect labels are used to train a CNN classification model. Finally, the trained CNN model is used to analyze the image of the detection area of the high-frequency welded pipe obtained in real time to determine whether there are surface defects and their severity. The present invention combines the improved MSR, object detection, feature extraction, and deep learning, significantly improving the detection efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular, to a method and system for detecting defects in high-frequency welded pipes based on machine vision. Background Art

[0002] High-frequency welded pipes are often used in many fields such as oil and gas transportation, building structures, and mechanical manufacturing due to their high production efficiency and relatively low cost. The quality of the welded pipes, especially the integrity of the weld seam and its nearby areas, is directly related to the safe and reliable operation of the pipeline system. During production and use, various defects such as cracks, pores, incomplete penetration, slag inclusions, scratches, and pits may appear on the surface of high-frequency welded pipes. If these defects are not detected and processed in time, they may lead to leakage, reduced strength, and even serious safety accidents and economic losses. Therefore, efficient and accurate surface defect detection of high-frequency welded pipes is of great significance for ensuring product quality and engineering safety.

[0003] Currently, the defect detection methods for high-frequency welded pipes mainly include manual visual inspection, eddy current testing, ultrasonic testing, and automatic detection based on machine vision. Manual inspection is inefficient, subjective, and prone to fatigue and missed detection; although eddy current and ultrasonic testing are sensitive to internal defects, their detection ability for surface micro-defects is limited, and the equipment cost is high and the operation is relatively complex. The detection method based on machine vision shows great potential in the surface defect detection of high-frequency welded pipes due to its non-contact, fast speed, and automation capabilities.

[0004] However, in practical applications, the defect detection of high-frequency welded pipes based on machine vision still faces challenges. The surface of the welded pipe usually has certain light reflection characteristics, and under industrial site lighting conditions, it is easy to form highly bright areas and shadow areas with significantly different brightness at different positions on the pipe wall. In addition, the weld seam itself may have irregular geometries and textures. These factors result in uneven contrast and blurred details in the captured images of the welded pipes, making the traditional image processing algorithms ineffective in segmenting and identifying defects. Especially in the highly bright areas, subtle defects may be submerged by strong light; while in the shadow areas, the defect features may be difficult to appear due to low brightness.

[0005] In the existing machine vision defect detection technologies, to eliminate the influence of complex lighting on the surface of the welded pipe, common image enhancement methods include histogram equalization, contrast stretching, and multi-scale Retinex algorithms. However, the original Retinex algorithm and some of its improvements (such as standard MSR) usually use a uniform weight assignment method to fuse image information at all scales. This processing method often fails to achieve an ideal lighting balance effect when facing the surface of the welded pipe with drastic lighting changes, strong specular reflection, or large-area shadows, and may lead to loss of image details, generation of artifacts, or over-enhancement, ultimately affecting the accuracy and reliability of defect detection. Summary of the Invention

[0006] In view of the problem that the above - mentioned uniform weight distribution method for fusing image information of all scales may lead to loss of image details, generation of artifacts, or over - enhancement, in a first aspect, the present invention proposes a high - frequency welded pipe defect detection method based on machine vision, including: obtaining an image of a detection area on the surface of a high - frequency welded pipe containing defects; using a multi - scale Retinex algorithm to process the detection area image to obtain an enhanced image, and extracting feature vectors of the defect area in the enhanced image; adding defect degree labels to each feature vector and then using them to train a classification model; obtaining a real - time image of the detection area of the high - frequency welded pipe, inputting the real - time image into the trained classification model to obtain the corresponding defect degree, and in response to the defect degree being greater than a set threshold, determining that the real - time image has surface defects; the multi - scale Retinex algorithm further includes: obtaining edge binary images of each scale image, performing connected - component analysis based on the edge binary images to obtain multiple connected components; performing single - scale Retinex processing on each connected component to obtain a connected - component reflection image, and every two connected - component reflection images form a pair of connected - component reflection images; calculating the mean square error of the reflection values in the pair of connected - component reflection images at the same scale to obtain a difference degree, and the sum of the difference degrees of all pairs of connected - component reflection images at the same scale constitutes the overall difference degree; taking the reciprocal of the mean square error of the luminance value of the illumination image and the reflection value of the reflection image at the same scale as the gain coefficient; the product of the gain coefficient and the overall difference degree constitutes an adaptive weight, and fusing each scale image according to the corresponding adaptive weight to obtain an enhanced image.

[0007] The present invention combines an improved adaptive - weight multi - scale Retinex image enhancement algorithm, refined feature extraction (texture and geometry), and a deep - learning - based CNN classifier to construct a complete high - frequency welded pipe surface defect detection process. Compared with the existing visual detection methods that use standard MSR or do not perform effective light processing, rely on simple features, or use traditional classifiers, the present invention significantly improves the processing ability of uneven illumination problems such as highlights and shadows commonly found on the surface of welded pipes by using adaptive weights, ensuring the effectiveness and accuracy of subsequent feature extraction, and finally realizing higher - precision and stronger - robustness automatic detection and degree judgment of welded pipe defects through the CNN model, effectively reducing the missed - detection rate and false - alarm rate.

[0008] Further, the specific calculation method of the adaptive weight is as follows:

[0009] ;

[0010] where M S represents the adaptive weight corresponding to the image at scale S; W S represents the gain coefficient at scale S; DS Represents the overall difference degree among all connected region reflection images at scale S; γ represents the tuning factor.

[0011] Furthermore, the specific calculation method of the overall difference degree is as follows:

[0012] ;

[0013] ;

[0014] where D S i,u represents the difference degree between connected regions R S i and R S u ; N represents the total number of pixels in the image at scale S; W and H respectively represent the width and height of the image at scale S; R S i (x, y) and R S u (x, y) respectively represent the reflection values at the coordinate (x, y) after single-scale Retinex processing for connected regions R S i and R S u ; and respectively represent the maximum reflection value and the minimum reflection value among all connected region reflection images at scale S; D S represents the overall difference degree among all connected region reflection images at scale S; n represents the number of connected regions at scale S.

[0015] The overall difference degree calculation method determined by the present invention provides a reliable index for evaluating the accuracy of illumination estimation at the same scale by quantitatively comparing the consistency of reflection images of different connected regions (representing different illumination regions) after single-scale Retinex processing. Compared with the method that does not consider the spatial consistency of reflection images, this calculation method can effectively identify and reduce the weights of those scales with inaccurate illumination estimation (resulting in large differences in reflection images), thereby avoiding the influence of errors introduced by these scales on the quality of the final fused image and improving the fidelity of the enhancement result.

[0016] Furthermore, the specific calculation method of the gain coefficient is as follows:

[0017] ;

[0018] where W S represents the gain coefficient at scale S; N represents the total number of pixels in the image at scale S; W and H respectively represent the width and height of the image at scale S; I Sill (x, y) represents the illumination image at scale S; I S ref (x, y) represents the reflection image at scale S; represents the parameter adjustment factor.

[0019] The calculation method of the gain coefficient quantifies the effectiveness of Retinex decomposition in separating the illumination and reflection components at a given scale by evaluating the reciprocal of the mean square error between the illumination image and the reflection image at the same scale. The smaller the difference, the larger the gain coefficient, indicating a better separation effect. Incorporating this gain coefficient into the adaptive weight calculation ensures that scales with clearer illumination / reflection separation receive higher weights, which compensates for the deficiency of relying solely on reflection consistency evaluation and further enhances the ability of the adaptive MSR algorithm to handle complex illumination scenarios, outperforming enhancement methods that do not consider the separation quality.

[0020] Further, obtaining the detection area image of the high-frequency welded pipe surface containing defects further includes: using an industrial CCD camera to capture the surface image of the high-frequency welded pipe; performing grayscale processing on the surface image to obtain a grayscale image; and extracting the detection area in the grayscale image based on the YOLOv5 object detection algorithm to obtain the detection area image.

[0021] Further, extracting the feature vector of the defect area in the enhanced image further includes: using the gray-level co-occurrence matrix to extract the texture features of the defect area in the enhanced image, including: energy, contrast, entropy, correlation, and homogeneity; using the HU moments to extract the geometric features of the defect area in the enhanced image, including 7 HU moments; the texture features and the geometric features together constitute the feature vector.

[0022] The present invention describes the defect area by jointly using the texture features extracted by the gray-level co-occurrence matrix (GLCM) and the geometric features extracted by the HU moments, and constructs a more comprehensive and robust defect feature vector. Compared with methods that only use a single type of feature (such as only texture or only shape) or simpler features, this multi-dimensional feature combination can more fully capture the diversity of defects (such as the linearity of cracks, the punctuality of pores, the texture changes of scratches, etc.), providing richer and more discriminative information for subsequent CNN classification, thereby improving the accuracy of defect recognition and classification.

[0023] Further, the classification model is a CNN model, and its training process includes: the model is selected as ResNet50; the learning rate is taken in the empirical value range [0.001, 0.002]; the batch size is taken as 32; the number of training epochs is set in the empirical value range [50, 70]; the loss function is set as the cross-entropy loss function; the optimizer is set as the Adam optimizer.

[0024] Further, the Canny edge detection algorithm is used to obtain the binary edge images of the respective scale images.

[0025] Further, it also includes performing morphological closing operation processing on each connected component.

[0026] When performing connected component analysis to determine the illumination area, a morphological closing operation processing step is added. This operation can effectively fill the holes inside the illumination area that may be caused by noise or small objects, and connect adjacent parts that belong to the same illumination area but are separated by small gaps. Compared with directly analyzing the connected components without this processing, the closing operation makes the identified illumination / shadow area more complete and smooth, more in line with the characteristics of actual large-scale illumination changes, thereby improving the accuracy and stability of subsequent calculation of the reflection image consistency.

[0027] In a second aspect, the present invention provides a high-frequency welded pipe defect detection system based on machine vision, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the high-frequency welded pipe defect detection method based on machine vision of the present invention is implemented.

[0028] The technical effects of the present invention are as follows:

[0029] The present invention proposes a set of adaptive weight calculation methods based on image content quality assessment. For each scale image decomposed by MSR, by analyzing the consistency of the reflection images of different regions inside it after single-scale Retinex processing, and the separation degree between the illumination image and the reflection image at this scale, the illumination estimation quality of this scale image is dynamically and quantitatively evaluated. Based on this evaluation result, the adaptive fusion weight of each scale is calculated, so that the scale that can estimate the illumination more accurately and can better reflect the true reflection attributes of the object plays a dominant role in the final image fusion. This adaptive enhancement strategy can significantly suppress the influence of uneven illumination, effectively improve the contrast between the defect area and the background, lay a solid foundation for subsequent extraction of texture (GLCM) and geometric (Hu moment) features and accurate classification of the CNN model, and finally achieve high precision and high robustness in the detection of high-frequency welded pipe surface defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] By referring to the accompanying drawings and reading the following detailed description, the above and other objects, features, and advantages of the exemplary embodiments of the present invention will become easily understood. In the drawings, several embodiments of the present invention are shown in an exemplary rather than restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0031] Figure 1 It is a flowchart showing the high-frequency welded pipe defect detection method based on machine vision in the embodiments of the present invention schematically;

[0032] Figure 2 is a schematic diagram showing the manufacturing process of high-frequency welded pipes in an embodiment of the present invention;

[0033] Figure 3 is a schematic diagram showing the surface grayscale of high-frequency welded pipes in an embodiment of the present invention;

[0034] Figure 4 is a block diagram showing the structure of a high-frequency welded pipe defect detection system based on machine vision in an embodiment of the present invention. Detailed implementation manners

[0035] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present invention.

[0036] Next, the detailed implementation manners of the present invention will be described in detail in conjunction with the accompanying drawings.

[0037] An embodiment of a high-frequency welded pipe defect detection method based on machine vision:

[0038] As Figure 1 shown, the high-frequency welded pipe defect detection method based on machine vision of the present invention includes:

[0039] S1. Obtain the surface image of the high-frequency welded pipe and use YOLOv5 to extract the image of the detection area.

[0040] The manufacturing process of the high-frequency welded pipe is as Figure 2 shown. First, the steel strip is formed into a circular pipe blank with a gap; then, a high-frequency current is generated by an induction coil surrounding the pipe blank, and the edges of the pipe seam are quickly heated to a molten or semi-molten state through the skin effect and proximity effect (the internal impedance helps to improve the heating efficiency). Immediately afterwards, a welding extrusion roller is used to apply pressure to the heated edges of the pipe seam to fuse them to form a firm weld seam, and finally a complete welded pipe is formed.

[0041] On the surface of the high-frequency welded pipe, especially in the weld seam and its adjacent areas, there may be defects such as cracks, pores, incomplete penetration, scratches, etc. These defects not only affect the appearance, but may also reduce the strength and sealing performance of the pipeline, and even cause serious safety accidents. In order to detect the defects on the surface of the welded pipe, it is necessary to obtain high-quality surface images. High-frequency welded pipes usually have the characteristics of continuous production, and the surface (especially the metal surface) may have reflections and shadows due to factors such as the lighting angle and surface curvature, which interfere with the defect detection.

[0042] First, a high-resolution (at least 1920×1080) industrial CCD camera can be used to capture the surface images of high-frequency welded pipes, especially the weld area, either online or offline. Then, a line array light source or an optimized ring / bar LED light strip can be used as the shooting light source to minimize overexposure and shadow areas and evenly illuminate the detection area. Finally, the average grayscale algorithm can be used to grayscale the captured color or original image to simplify subsequent calculations. For the online detection scenario, the camera is usually fixed, and the welded pipe moves through the field of view on the production line; or the camera system moves along the axial direction of the welded pipe for scanning shooting.

[0043] After obtaining the image of the welded pipe, since it may be necessary to focus on detecting specific areas (such as the weld and its heat-affected zone), or to locate the main body of the welded pipe from a wide-field image containing the background or other interferences, object detection algorithms can be used to extract the image of the detection area of interest from the original image to facilitate subsequent defect detection in this area. In one embodiment, the YOLOv5 algorithm is selected for object detection. The input of this algorithm is the original captured image, and the output is an image containing the surface area of the welded pipe to be detected (for example, a rectangular area centered on the weld); in another embodiment, the YOLOv5 algorithm is selected for object detection. The input of the algorithm is the original captured image, and the output is the complete surface image of the welded pipe with the background removed. The IOU threshold can be set to an empirical value of 0.5. The above YOLOv5 algorithm belongs to well-known technology, and the specific training process of the model will not be elaborated here.

[0044] S2. Obtain the reflection images of each scale image for connected component analysis to obtain multiple connected components; obtain the overall difference degree by obtaining the difference degree between the reflection images corresponding to each connected component; calculate the difference between the illumination image and the reflection image at each scale to obtain the gain coefficient; obtain the adaptive weight corresponding to each scale.

[0045] After obtaining the surface detection area image of the high-frequency welded pipe in step S1, it can be observed that there is a certain curvature on its surface. As Figure 3 shown, the reflection effect of the light source by different curvatures may vary at different positions, which is likely to form bright areas; at the same time, factors such as the protrusion or depression of the weld itself and the occlusion in the production environment may also cause the generation of shadow areas. Such uneven lighting conditions make it difficult to identify defects in the original image when the defect is located in a bright area, possibly due to signal saturation or insufficient contrast; if the defect is located in a shadow area, it may be ignored due to weak signals, resulting in poor detection effects.

[0046] Therefore, in this embodiment, the detection area image obtained in step S1 can be processed using multi-scale Retinex. The multi-scale Retinex algorithm (Multi-Scale Retinex, MSR) estimates the illumination component by combining several center-surround functions of different scales, so as to achieve good dynamic range compression and illumination equalization effects while maintaining details (such as defects), in order to improve the subsequent defect detection effect. It mainly includes the following key steps:

[0047] First, the original image is decomposed into multiple scale images through different Gaussian filters; then, Retinex processing is performed on each scale image. Specifically: the decomposed image is converted into the logarithmic space; the illumination image and the reflectance image are calculated; the illumination image and the reflectance image are subjected to exponential transformation to obtain the enhanced images of each scale. Finally, the enhanced images of each layer are weighted and fused to obtain the final enhanced image.

[0048] The above-mentioned illumination image represents the illumination component in the image, that is, the illumination intensity received by each point in the scene. It reflects the illumination effect projected by the light source in the image and is the change in image brightness caused by the changes in the direction, intensity, and position of the light source; while the reflectance image represents the light intensity reflected by the object surface, which reflects the inherent reflection attributes of the object itself in terms of color and material properties (in the high-frequency welded pipe scenario, mainly refers to the inherent reflection attributes of the welded pipe substrate and the weld area), and theoretically is not affected by illumination changes.

[0049] However, in the MSR algorithm, when performing Retinex processing on each scale image, the weights during the fusion of multiple scale images are equal, that is, the contribution of each layer of image to the final result is the same. Since images of different scales have different features and details, using equal weights will cause key information of some scales to be ignored. Especially when the illumination on the surface of the welded pipe changes greatly, it may ultimately lead to errors in the expression of the actual information of the welded pipe in the synthesized enhanced image, thereby reducing the accuracy of subsequent defect detection.

[0050] In this embodiment, the equal weights in the MSR algorithm are optimized, and the adaptive weights of each scale image are obtained for adaptive weighted fusion to obtain a more accurate reflectance image, thereby improving the accuracy of subsequent defect detection on the surface of the welded pipe. The specific implementation method is as follows:

[0051] Exemplary illustration. In this embodiment, it is set that the MSR algorithm has a total of 5 scales, and the standard deviation σ of the core parameter of the filter can be set to 0.8, 1.2, 2.0, 4.0, and 8.0 respectively. For any scale image, first use the Canny edge detection algorithm to distinguish different illumination regions. The input of this algorithm is the image after Gaussian filtering, and the output is the edge binary image. Then, the obtained edge binary image can be subjected to connected component analysis to identify continuous illumination regions and shadow regions in the image. The input of the connected component analysis is the edge binary image and the connection method. Here, the neighborhood type of the connection method can be set to 8-connectivity, and the output of the algorithm is an image containing connected component labels. Further, morphological closing operation can be used to fill the gaps inside the image and connect adjacent connected components. The input of this algorithm is the connected component label image, and the output of the algorithm is the optimized connected component label image. This operation can eliminate the surface defect regions in the image (assuming the defect size is relatively small) while retaining the normal uneven illumination regions, that is, the brighter or darker regions caused by the surface curvature or environmental illumination of the welded pipe. The main purpose of this step to eliminate the surface defect regions is:

[0052] Subsequently, single-scale Retinex processing needs to be performed on each connected component, and then the differences between the reflection images corresponding to each connected component are evaluated. Since the reflection image reflects the color and material characteristics of the object itself and is not affected by illumination changes, the reflection images corresponding to different connected components on the same surface of the welded pipe should also have high similarity. However, if the connected component contains defect regions (such as cracks, pores, etc.), which are different from the color and material characteristics of the welded pipe itself, it will affect the subsequent evaluation of the similarity of the reflection images corresponding to each connected component.

[0053] Finally, single-scale Retinex processing is performed on the image region corresponding to each connected component to obtain the reflection image of the corresponding image region. The input of this single-scale Retinex algorithm is the image region corresponding to each connected component, and the output is the illumination image and the reflection image. The above Canny edge detection algorithm, connected component analysis, morphological closing operation, and single-scale Retinex algorithm are well-known technologies, and the specific implementation methods will not be elaborated here.

[0054] Since the materials used on the surface of the same section of welded pipe are the same, the ideal reflection images of different sub-regions in the same detection region should be similar or meet a certain expectation. And since the reflection image is obtained by the difference between the logarithmic image and the illumination image. Based on this property, in this embodiment, the quality of the illumination image at this scale can be evaluated by comparing the differences between the reflection images of different regions at the same scale. Denote the i-th connected component in the image of the S-th scale as R S i, then for an image with a scale of S, its corresponding reflection image consists of multiple connected components R S 1, R S 1, …, R S n , where n represents the number of connected components at this scale. For each pair of connected components R S i and R S u , their difference index can be calculated using the mean square error (MSE). Then, at the same scale S, the reflection images of all connected components are compared to calculate the overall difference, specifically:

[0055] ;

[0056] ;

[0057] where D S i,u represents the difference between connected components R S i and R S u ; N represents the total number of pixels in the image at scale S; W and H represent the width and height of the image at scale S respectively; R S i (x, y) and R S u (x, y) represent the reflection values at the coordinate (x, y) after Retinex processing for connected components R S i and R S u respectively; and represent the maximum reflection value and the minimum reflection value in all reflection images at scale S respectively, that is, used for normalizing the difference; D S represents the overall difference between the reflection images corresponding to all connected components at scale S; n represents the number of connected components at scale S.

[0058] When the overall difference D S between the reflection images corresponding to each connected component at scale S is small, it indicates that the illumination image at this scale estimates the actual light component more accurately and the reflection images are more consistent. Then, a higher weight should be given to this scale during the final fusion. On the contrary, when the overall difference between the reflection images corresponding to each connected component at scale S is large, it indicates that the illumination image at this scale has a poor effect and may not accurately reflect the actual light distribution. At this time, the weight of this scale in the final image fusion should be reduced.

[0059] So far, the overall difference degree at each scale has been obtained. Since the number of scales is set to 5 in this embodiment, there are 5 overall difference degrees, denoted as D1, D2, D3, D4, and D5 respectively. And since the number of scales in the MSR algorithm is mostly set to empirical values such as 3 - 5, that is, the number of scales is relatively small, there may be a situation where the difference between the overall difference degrees corresponding to the images at each scale is small. Therefore, in this embodiment, the gain coefficient corresponding to the images at each scale is further calculated to adjust the amplification effect of the overall difference degree between different scales, so as to obtain the final adaptive weight.

[0060] At the same scale, since the illumination image is processed by Gaussian filtering, ideally, there should be a certain stable relationship between it and the reflection image (that is, illumination mainly reflects the slowly changing light, and reflection mainly reflects the inherent properties of objects). Excessive difference may indicate that there is a problem with the fitting of the illumination image to the luminance component and the illumination effect has not been well separated. Therefore, the quality of this scale can be evaluated by calculating the difference degree between the illumination image and the reflection image. If the difference between the two is too large, it means that the illumination estimation at this scale is inaccurate, and the gain coefficient should be smaller. Here, the illumination image at scale S is denoted as I S ill (x, y), and the reflection image at scale S is denoted as I S ref (x, y). The mean square error is used to calculate the difference degree between the illumination image and the reflection image to obtain the gain coefficient. The specific calculation method is as follows:

[0061] ;

[0062] Among them, W S represents the gain coefficient at scale S; N represents the total number of pixels in the image at scale S; W and H respectively represent the width and height of the image at scale S; I S ill (x, y) represents the illumination image at scale S; I S ref (x, y) represents the reflection image at scale S; represents the tuning parameter factor, which is used to avoid the situation where the denominator is 0. In this embodiment, it can be set to the empirical value 1e - 5.

[0063] When is larger, it indicates that the difference between the illumination image and the reflection image at this scale is larger, then the illumination estimation at this scale may be inaccurate, and the gain coefficient W S is smaller. The adaptive weight calculated for the image fusion at this scale subsequently should be smaller; when is smaller, it indicates that the difference between the illumination image and the reflection image at this scale is smaller, then the illumination estimation at this scale is more in line with the actual illumination effect, and the gain coefficient W SThe larger it is, the greater the adaptive weight should be when calculating image fusion at this scale subsequently.

[0064] Thus, the overall difference degree D corresponding to scale S is obtained. S And the gain coefficient W S Finally, the adaptive weight M corresponding to the image at scale S is calculated. S There is:

[0065] ;

[0066] Among them, M S represents the adaptive weight corresponding to the image at scale S; W S represents the gain coefficient at scale S; D S represents the overall difference degree between the reflection images corresponding to all connected regions at scale S; γ represents the tuning parameter to avoid the denominator being zero, and in this embodiment, it can be set to the empirical value 1e-6.

[0067] The steps of the multi-scale Retinex algorithm with the finally improved adaptive weight are as follows: First, decompose the original image into multiple scale images through different Gaussian filters; then calculate the adaptive weights of each scale image; then perform exponential transformation on the illumination image and the reflection image to obtain the enhanced images of each scale; finally, perform weighted fusion on the enhanced images of each scale according to the corresponding adaptive weights to obtain the final enhanced image.

[0068] S3. Obtain the detected region image obtained in step S1 and process it based on the improved adaptive weight MSR algorithm in step S2; perform defect detection on the processed image, extract defect features, and manually add labels for training the CNN classification model.

[0069] After obtaining the detected region image obtained in step S1, use the improved adaptive weight MSR algorithm as shown in step S2 for processing to obtain the detected region image of the surface of the welded pipe with brightness equalization. Further perform defect detection on the optimized image and extract defect features. The specific steps of defect detection are as follows:

[0070] First, perform Canny edge detection on the processed detected region image to extract edge information and obtain a binary edge image; then perform connected component analysis and morphological opening operation to eliminate noise regions. The brightness distribution of the image processed by the improved adaptive weight MSR algorithm is relatively balanced, and the edges of the defect regions, as well as the possible edges of the welds or other stable structure edges, can be detected more clearly during edge detection. Each independent region can be obtained through connected component analysis.

[0071] Finally, the regions representing defects need to be retained. Screening can be performed based on prior knowledge such as size and shape. For example, geometric parameters such as the area, perimeter, and aspect ratio of each connected component can be calculated. If defects usually appear as small spots or slender cracks, a threshold can be set to remove connected components with too large an area (which may correspond to the background region or large areas of normal weld regions), and retain the connected components whose sizes conform to the defect characteristics. The image corresponding to the remaining connected components of the defect region is the defect region image. The above Canny edge detection algorithm, connected component analysis, and morphological opening operation are all well-known technologies, and the specific implementation methods will not be elaborated here.

[0072] At this point, the defect regions on all the detected region images can be obtained, and the texture features and geometric features of the defects can be further extracted to generate feature vectors. In this embodiment, the gray-level co-occurrence matrix (GLCM) method can be used to extract texture features, including: energy, contrast, entropy, correlation, and homogeneity; then the HU moment algorithm is used to extract 7 moments. The above 5 texture features and 7 geometric features together constitute a feature vector, which can be denoted as E in this embodiment. After the defect feature extraction, manual labeling is also required to help the CNN model identify different types of defects or judge the severity of the defects. Relevant professional technicians label the defect severity labels for each defect region (for example, a value can be comprehensively evaluated according to the defect type, size, etc.), and denoted as Y, such as 0.05, 0.10, 0.15, …, 0.95, etc., then the q-th sample data can be denoted as [E q , Y q . After all the sample data are obtained, 70% of the sample data is used as training data, 15% of the sample data is used as validation data, and 15% of the sample data is used as test data, and all are input into the CNN classification model for model training.

[0073] In the present invention, the gray-level co-occurrence matrix and HU moments are used to extract the texture and geometric features of the image, making the defect features more obvious, and providing efficient and accurate training data for the CNN model, thereby improving the model classification ability and the accuracy of defect detection.

[0074] In this embodiment, the input for training the CNN classification model further includes: The model can select ResNet50; The learning rate can be set to the empirical value of 0.001. If the learning rate is too large, the gradient update will be too fast, and if it is too small, the convergence may be too slow; The batch size can be set to the empirical value of 32. This hyperparameter determines the number of samples used for each update; The number of training epochs can be set to 50 rounds; The loss function can select the cross-entropy loss function (Cross-Entropy Loss), which is applicable to multi-classification or regression (if the defect degree is a continuous value, other regression loss functions can be selected) problems; The optimizer can use the Adam optimizer, which can automatically adjust the learning rate according to the gradient of each parameter, avoiding the complexity of manual adjustment.

[0075] The output of the algorithm is the trained CNN model: It contains optimized network weights and can perform real-time defect detection on the surface of the welded pipe according to the input image features.

[0076] S4. Take a real-time image of the high-frequency welded pipe and obtain the image of the area to be detected, and input it into the trained CNN classification model in step S3 to implement the surface defect detection of the high-frequency welded pipe.

[0077] First, obtain the real-time image of the high-frequency welded pipe on the production line and perform grayscale processing. Then, based on the YOLOv5 object detection algorithm in step S1, obtain the image of the area to be detected. Next, input the data of the detected area image after enhancement in S2 and feature extraction in S3 into the trained CNN classification model in step S3 for defect detection. The model will analyze the image features, identify whether there are defects, and obtain the corresponding defect degree according to the training data.

[0078] Exemplary illustration: There is an image of the detection area on the surface of a welded pipe that contains two defect areas. After inputting it into the trained CNN classification model, the obtained defect degrees are 0.05 and 0.20 respectively, that is, the total (or maximum value, or other comprehensive indicators) of the defect degree of this detection area is 0.25. Compare this result with the set defect threshold (such as the empirical value of 0.05). If it is greater than the set threshold, it is determined at this time that there are surface defects in this section of the welded pipe and the defect degree is relatively high. The system can issue an alarm to notify relevant personnel to recheck or identify this section of the welded pipe, and analyze the specific reasons for the defects (such as abnormal welding parameters, raw material problems, etc.) to prevent unqualified products from flowing into the next link and avoid potential risks and economic losses. In addition to 0.05, the above defect threshold can also be set to 0.10, 0.15 or 0.20, etc. Specifically, it should be adjusted according to the production quality requirements and the sensitivity of the model to defects during training.

[0079] An embodiment of a high-frequency welded pipe defect detection system based on machine vision:

[0080] On the other hand, the present invention also provides a high-frequency welded pipe defect detection system based on machine vision. As Figure 4 shown, the high-frequency welded pipe defect detection system based on machine vision includes a processor and a memory, and the memory stores computer program instructions, which, when executed by the processor, implement a high-frequency welded pipe defect detection method according to the first aspect of the present invention.

[0081] The high-frequency welded pipe defect detection system based on machine vision further includes other components well known to those skilled in the art, such as a communication interface, and its settings and functions are known in the art, so they will not be described herein again.

[0082] In the present invention, the aforementioned memory can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. For example, the computer-readable storage medium can be any suitable magnetic storage medium or magneto-optical storage medium, such as, for example, resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc., or any other medium that can be used to store the required information and can be accessed by an application program, module, or both. Any such computer storage medium can be part of the device or accessible or connectable to the device. Any application or module described in the present invention can be implemented using computer-readable / executable instructions stored or otherwise held by such a computer-readable medium.

Claims

1. A high-frequency welded pipe defect detection method based on machine vision, characterized in that, The method includes: Obtaining an image of a detection area on the surface of a high-frequency welded pipe that contains defects; processing the image of the detection area using a multi-scale Retinex algorithm to obtain an enhanced image, and extracting feature vectors of the defect areas in the enhanced image; adding defect degree labels to each feature vector and then using them to train a classification model; Obtaining a real-time image of the detection area of the high-frequency welded pipe, inputting the real-time image into the trained classification model to obtain the corresponding defect degree, and in response to the defect degree being greater than a set threshold, determining that the real-time image has surface defects; The multi-scale Retinex algorithm further includes: Obtaining the edge binary images of each scale image, performing connected component analysis based on the edge binary images to obtain a plurality of connected components; performing single-scale Retinex processing on each connected component to obtain a connected component reflection image, and each pair of connected component reflection images forms a connected component reflection image pair; The difference degree is obtained by calculating the mean square error of the reflection values in the connected domain reflection image pairs at the same scale. The sum of the difference degrees of all connected domain reflection image pairs at the same scale constitutes the overall difference degree. The specific method is as follows: , , D S i,u represents the connected domain R S i and R S u The difference degree between them, N represents the total number of pixels in the image at scale S, W and H respectively represent the width and height of the image at scale S, R S i (x, y) and R S u (x, y) respectively represent the reflection values at the coordinate (x, y) after single-scale Retinex processing for the connected domain R S i and R S u ; and respectively represent the maximum reflection value and the minimum reflection value in all connected domain reflection images at scale S, D S represents the overall difference degree between all connected domain reflection images at scale S, and n represents the number of connected domains at scale S; Taking the reciprocal of the mean square error between the luminance value of the illuminance image and the reflection value of the reflection image at the same scale as the gain coefficient, the specific method is as follows: , W S represents the gain coefficient at scale S, and I S ill (x, y) represents the illuminance image at scale S, and I S ref (x, y) represents the reflection image at scale S, represents the tuning parameter factor; calculating the adaptive weight according to the gain coefficient and the overall difference degree, the specific method is as follows: , M S represents the adaptive weight corresponding to the image at scale S, and γ represents the tuning parameter factor; Fusing each scale image according to the corresponding adaptive weights to obtain an enhanced image.

2. The method for detecting defects of high-frequency welded pipes based on machine vision according to claim 1, wherein Obtaining an image of a detection area on the surface of a high-frequency welded pipe that contains defects, including: Using an industrial CCD camera to capture an image of the surface of the high-frequency welded pipe; Performing grayscale processing on the surface image to obtain a grayscale image; Extracting the detection area in the grayscale image based on the YOLOv5 object detection algorithm to obtain an image of the detection area.

3. A method for detecting defects in high-frequency welded pipes based on machine vision according to claim 1, characterized in that, Extracting the feature vectors of the defect areas in the enhanced image, including: Using a gray-level co-occurrence matrix to extract the texture features of the defect areas in the enhanced image, including: energy, contrast, entropy, correlation, and homogeneity; Using HU moments to extract the geometric features of the defect areas in the enhanced image, including 7 HU moments; The texture features and geometric features together constitute the feature vectors.

4. A method for detecting defects in high-frequency welded pipes based on machine vision according to claim 1, characterized in that, The classification model is a CNN model, and its training process includes: The model is selected as ResNet50; The learning rate value is in the empirical value range [0.001, 0.002]; The batch size value is 32; The number of training epochs is set in the empirical value range [50, 70]; The loss function is set as the cross-entropy loss function; The optimizer is set as the Adam optimizer.

5. A method for detecting defects in high-frequency welded pipes based on machine vision according to claim 1, characterized in that, Using the Canny edge detection algorithm to obtain the edge binary images of each scale image.

6. A method for detecting defects of high-frequency welded pipes based on machine vision according to claim 1, characterized in that, It also includes performing morphological closing operation processing on each connected component.

7. A high-frequency welded pipe defect detection system based on machine vision, characterized in that, It includes a processor and a memory, and the memory stores computer program instructions, and when the computer program instructions are executed by the processor, it implements a method for detecting defects of high-frequency welded pipes based on machine vision according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for analyzing and eliminating hidden defects of welded pipe

    CN110399694A

  • Welded pipe corrosion state detection method based on image processing

    CN117152137A