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

Through the improved adaptive weight multi-scale Retinex algorithm, the problem of poor lighting equalization effect in high-frequency welded pipe defect detection under complex lighting conditions is solved, and high-precision and robustness detection of surface defects of welded pipes is achieved, reducing the missed detection and false alarm rates.

CN120107268AActive Publication Date: 2025-06-06XIAN JIAHE HUAHENG THERMAL SYST CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

The existing high-frequency welded pipe defect detection method based on machine vision is difficult to achieve an ideal light equalization effect when facing complex lighting conditions, which may lead to image details loss, artifact generation or excessive enhancement, affecting the accuracy and reliability of defect detection.

Method used

The improved adaptive weight multi-scale Retinex image enhancement algorithm is adopted to obtain edge binary images of images of each scale for communication domain analysis, calculate the difference between reflected image pairs, dynamically evaluate the light estimation quality, calculate the adaptive weight for image fusion, and improve the lighting processing capability.

Benefits of technology

Significantly suppress the impact of uneven light, improve the contrast between the defect area and the background, ensure the effectiveness and accuracy of feature extraction, realize high-precision and robust automatic detection and degree judgment of high-frequency welded pipe defects, and reduce the leakage detection rate and false alarm rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120107268A_ABST
    Figure CN120107268A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image processing, in particular to a high-frequency welded pipe defect detection method and system based on machine vision, a welded pipe image is shot through a camera, a detection area is extracted by utilizing a YOLOv5 algorithm, an improved multi-scale Retinex algorithm is adopted, an adaptive fusion weight is calculated according to image characteristics, illumination equalization is carried out, and highlight and shadow are effectively processed. Then, a defect area is positioned through Canny edge detection and connected domain analysis, and GLCM texture features and HU moment geometric features of the defect area are extracted; the features and defect labels are used for training a CNN classification model, finally, the trained CNN model is used for analyzing a high-frequency welded pipe detection area image obtained in real time, and whether surface defects exist or not and the degree of the surface defects are judged. According to the method, improved MSR, target detection, feature extraction and deep learning are fused, and the detection efficiency and accuracy are remarkably improved.
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 high-frequency welded pipe defect detection method and system based on machine vision. Background Art

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

[0003] At present, the defect detection methods of high-frequency welded pipes mainly include manual visual inspection, eddy current inspection, ultrasonic inspection, and automatic inspection based on machine vision. Manual inspection is inefficient, highly subjective, and prone to fatigue and missed inspections; although eddy current and ultrasonic inspections are sensitive to internal defects, their ability to detect tiny surface defects is limited, and the equipment cost is high and the operation is relatively complex. The inspection method based on machine vision has shown great potential in the surface defect detection of high-frequency welded pipes due to its advantages such as non-contact, fast speed, and automation.

[0004] However, in practical applications, high-frequency welded pipe defect detection based on machine vision still faces challenges. The surface of welded pipes usually has certain reflective properties. Under industrial lighting conditions, it is easy to form highlight areas and shadow areas with significant brightness differences at different positions on the pipe wall. In addition, the weld itself may have irregular geometric shapes and textures. These factors lead to uneven contrast and blurred details in the collected welded pipe images, making traditional image processing algorithms ineffective in segmenting and identifying defects. Especially in highlight areas, subtle defects may be submerged by strong light; while in shadow areas, defect features may be difficult to show due to low brightness.

[0005] In the existing machine vision defect detection technology, in order to eliminate the influence of complex lighting on the welded pipe surface, commonly used image enhancement methods include histogram equalization, contrast stretching, and multi-scale Retinex algorithm. However, the original Retinex algorithm and some of its improvements (such as standard MSR) usually use a uniform weight distribution method to fuse image information of all scales. This processing method is often difficult to achieve the ideal lighting balance effect when facing the welded pipe surface with drastic lighting changes, strong reflections or large shadows, which may lead to loss of image details, artifacts or over-enhancement, and ultimately affect the accuracy and reliability of defect detection. Summary of the invention

[0006] In view of the problem that the above-mentioned use of a uniform weight distribution method to fuse 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, comprising: obtaining an image of a detection area containing defects on the surface of a high-frequency welded pipe; using a multi-scale Retinex algorithm to process the image of the detection area to obtain an enhanced image, and extracting a feature vector of the defect area in the enhanced image; adding a defect degree label to each feature vector for training a classification model; obtaining a real-time image of the high-frequency welded pipe detection area, inputting the real-time image into the trained classification model to obtain a corresponding defect degree, and in response to the defect degree being greater than a set threshold, determining that the real-time image has a defect degree. surface defects; the multi-scale Retinex algorithm also includes: obtaining edge binary images of images of each scale, performing connected domain analysis based on the edge binary images to obtain multiple connected domains; performing single-scale Retinex processing on each connected domain to obtain a connected domain reflection image, and every two connected domain reflection images constitute a connected domain reflection image pair; calculating the mean square error of the reflection values ​​in the connected domain reflection image pair at the same scale to obtain the difference, and the sum of the differences of all connected domain reflection image pairs at the same scale constitutes the overall difference; taking the inverse of the mean square error of the brightness 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 constitutes an adaptive weight, and the images of each scale are fused according to the corresponding adaptive weights 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 CNN classifier based on deep learning to construct a complete high-frequency welded pipe surface defect detection process. Compared with the visual detection method in the prior art that uses standard MSR or does not perform effective illumination processing and relies on simple features or traditional classifiers, the present invention uses adaptive weights to significantly improve the ability to handle uneven illumination problems such as highlights and shadows on the surface of welded pipes, ensuring the effectiveness and accuracy of subsequent feature extraction. Finally, the CNN model is used to achieve higher-precision and more robust automatic detection and degree judgment of welded pipe defects, effectively reducing the missed detection rate and false alarm rate.

[0008] Furthermore, the calculation method of the adaptive weight is specifically as follows: ; Among them, M S represents the adaptive weight corresponding to the image at scale S; W S represents the gain coefficient under scale S; D SIt represents the overall difference between the reflection images of all connected domains at scale S; γ represents the parameter adjustment factor.

[0009] Furthermore, the calculation method of the overall difference is specifically as follows: ; ; Where D S i,u Represents the connected domain R S i With R S u The difference between them; 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 connected domain R S i With R S u The reflection value at the coordinate (x,y) after single-scale Retinex processing; and They represent the maximum and minimum reflection values ​​in the reflection images of all connected domains under scale S respectively; D S represents the overall difference between the reflection images of all connected domains at scale S; n represents the number of connected domains at scale S.

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

[0011] Furthermore, the calculation method of the gain coefficient is specifically as follows: ; Where W S represents the gain coefficient at scale S; N represents the total number of pixels of the image at scale S; W and H represent the width and height of the image at scale S respectively; 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 factor.

[0012] The gain coefficient calculation method quantifies the effectiveness of Retinex decomposition in separating illumination and reflection components at the same scale by evaluating the inverse 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 those scales with clearer illumination / reflection separation can obtain higher weights, which supplements the shortcomings of relying solely on reflection consistency evaluation and further improves the ability of the adaptive MSR algorithm to cope with complex lighting scenes, which is better than enhancement methods that do not consider the separation quality.

[0013] Furthermore, obtaining an image of a detection area containing defects on the surface of the high-frequency welded pipe also includes: using an industrial CCD camera to capture the surface image of the high-frequency welded pipe; gray-scaling the surface image to obtain a gray-scale image; and extracting the detection area in the gray-scale image based on the YOLOv5 target detection algorithm to obtain the detection area image.

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

[0015] The present invention constructs a more comprehensive and robust defect feature vector by combining texture features extracted by gray-level co-occurrence matrix (GLCM) and geometric features extracted by HU moment to describe the defect area. Compared with the method of using only 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 point shape 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.

[0016] Furthermore, the classification model is a CNN model, and its training process includes: the model is selected as ResNet50; the learning rate is taken as the empirical value range [0.001, 0.002]; the batch size is taken as 32; the training rounds are set to the empirical value range [50, 70]; the loss function is set to the cross entropy loss function; and the optimizer is set to the Adam optimizer.

[0017] Furthermore, the Canny edge detection algorithm is used to obtain edge binary images of the images of each scale.

[0018] Furthermore, the method further includes performing morphological closing operations on each connected domain.

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

[0020] In a second aspect, the present invention provides a high-frequency welded pipe defect detection system based on machine vision, comprising a processor and a memory, wherein 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.

[0021] The technical effects of the present invention are: The present invention proposes a set of adaptive weight calculation methods based on image content quality assessment. This method dynamically and quantitatively evaluates the illumination estimation quality of each scale image decomposed by MSR by analyzing the consistency of the reflection image after single-scale Retinex processing in different regions inside it, as well as the degree of separation between the illumination image and the reflection image at this scale. Based on this evaluation result, the adaptive fusion weight of each scale is calculated, so that the scale with more accurate illumination estimation and better reflection of the real reflection property of the object occupies a dominant position in the final image fusion. This adaptive enhancement strategy can significantly suppress the influence of uneven illumination and effectively improve the contrast between the defective area and the background, laying a solid foundation for the subsequent extraction of texture (GLCM) and geometric (Hu moment) features and the accurate classification of the CNN model, and finally achieving high-precision and high robustness of surface defect detection of high-frequency welded pipes. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 is a flowchart schematically showing a method for detecting defects in a high-frequency welded pipe based on machine vision according to an embodiment of the present invention; Figure 2 It is a schematic diagram schematically showing the high-frequency welded pipe manufacturing process of an embodiment of the present invention; Figure 3 Schematic diagram of the grayscale of the surface of the high-frequency welded pipe in the embodiment of the present invention; Figure 4 The figure schematically shows the structure block diagram of the high-frequency welded pipe defect detection system based on machine vision according to an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0024] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0025] An embodiment of a high-frequency welded pipe defect detection method based on machine vision: like Figure 1 As shown, the high-frequency welded pipe defect detection method based on machine vision of the present invention includes: S1. Obtain the surface image of the high-frequency welded pipe and use YOLOv5 to extract the detection area image.

[0026] The production process of high frequency welded pipe is as follows Figure 2 As shown in the figure, the steel strip is first formed into a round tube with a gap; then, a high-frequency current is generated by an induction coil surrounding the outside of the tube, and the edge of the tube seam is quickly heated to a molten or semi-molten state through the skin effect and proximity effect (the internal resistor helps to improve the heating efficiency). Next, the welding squeeze roller applies pressure to the heated edge of the tube seam to fuse it to form a strong weld, and finally form a complete welded pipe.

[0027] The surface of high-frequency welded pipes, especially the welds and their vicinity, may have defects such as cracks, pores, incomplete penetration, scratches, etc. These defects not only affect the appearance, but may also reduce the strength and sealing of the pipes, and even lead to serious safety accidents. In order to detect defects on the surface of welded pipes, high-quality surface images need to be obtained. High-frequency welded pipes are usually produced continuously, and the surface (especially the metal surface) may produce reflections and shadows due to factors such as lighting angle and surface curvature, which interfere with defect detection.

[0028] First, a high-resolution (at least 1920×1080) industrial CCD camera can be used to capture the surface image of the high-frequency welded pipe online or offline, especially the weld area. Then, a linear array light source or an optimized ring / strip LED light strip can be used as the shooting light source to minimize overexposure and shadow areas and evenly illuminate the inspection area. Finally, the average grayscale algorithm can be used to grayscale the captured color or original image to simplify subsequent calculations. For online inspection scenarios, 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.

[0029] After acquiring the image of the welded pipe, since it may be necessary to focus on detecting only specific areas (such as the weld and its heat-affected zone), or it may be necessary to locate the welded pipe body from a wide-field image containing background or other interference, a target detection algorithm can be used to extract the detection area image of interest from the original image to facilitate subsequent defect detection of the area. In one embodiment, the YOLOv5 algorithm is selected for target detection, the input of the 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 target detection, the input of the algorithm is the original captured image, and the output is a complete welded pipe surface image with the background removed. The IOU threshold can be set to an empirical value of 0.5. The above YOLOv5 algorithm belongs to a well-known technology, and the specific training process of the model will not be repeated here.

[0030] S2. Obtain the reflection images of images at each scale and perform connected domain analysis to obtain multiple connected domains; obtain the difference between the reflection images corresponding to each connected domain to obtain the overall difference; 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.

[0031] After obtaining the surface inspection area image of the high-frequency welded pipe in step S1, it can be found that there is a certain curvature on the surface, such as Figure 3 As shown in the figure, the reflection effect of different curvatures on the light source may be different at different locations, which is easy to form a highlight area; at the same time, the convexity or concaveness of the weld itself, as well as the occlusion in the production environment and other factors, may also lead to the generation of shadow areas. This uneven lighting condition makes it difficult to identify defects in the highlight area due to signal saturation or insufficient contrast when performing defect detection based on the original image; if the defect is in the shadow area, it may be ignored due to weak signals, resulting in poor detection results.

[0032] Therefore, in this embodiment, the detection area image obtained in step S1 can be processed using multi-scale Retinex. The multi-scale Retinex algorithm (MSR) estimates the illumination component by combining center-surround functions of several different scales, thereby achieving good dynamic range compression and illumination balance effects while maintaining details (such as defects), so as to improve the subsequent defect detection effect. It mainly includes the following key steps: First, the original image is decomposed into multiple scale images through different Gaussian filters; then the image of each scale is retinexed, specifically: the decomposed image is converted into logarithmic space; the illumination image and the reflection image are calculated; the illumination image and the reflection image are exponentially transformed to obtain the enhanced images of each scale. Finally, the enhanced images of each layer are weighted fused to obtain the final enhanced image.

[0033] 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 changes in the direction, intensity and position of the light source; while the reflection image represents the intensity of light reflected from the surface of the object, which reflects the color and material properties of the object itself (in the high-frequency welded pipe scene, it mainly refers to the inherent reflection properties of the welded pipe base material and weld area), and is theoretically not affected by changes in illumination.

[0034] However, in the MSR algorithm, when performing Retinex processing on images of different scales, the weights of images of multiple scales are equal when they are fused, that is, the image of each layer contributes equally to the final result. Since images of different scales have different features and details, using equal weights will cause key information of certain scales to be ignored, especially when the illumination of the welded pipe surface changes greatly, which may eventually cause errors in the actual information description of the welded pipe after synthesis, thereby reducing the accuracy of subsequent defect detection.

[0035] In this embodiment, the equal weight in the MSR algorithm is optimized, and the adaptive weights of the images of each scale are obtained for adaptive weighted fusion to obtain a more accurate reflection image, thereby improving the accuracy of subsequent welded pipe surface defect detection. The specific implementation method is as follows: As an example, in this embodiment, the MSR algorithm is set to have 5 scales, where the core parameter standard deviation σ of the filter can be set to 0.8, 1.2, 2.0, 4.0 and 8.0 respectively. For any scale image, the Canny edge detection algorithm is first used to distinguish different illumination areas. The input of the algorithm is the image after Gaussian filtering, and the output is an edge binary image; then the acquired edge binary image can be subjected to a connected domain analysis to identify continuous illumination areas and shadow areas in the image. The input of the connected domain analysis is the edge binary image and the connectivity mode. Here, the neighborhood type of the connectivity mode can be set to 8-connected, and the output of the algorithm is an image containing connected domain labels; further, the morphological closing operation can be used to fill the gaps inside the image and connect adjacent connected domains. The input of the algorithm is a connected domain label image, and the output of the algorithm is an optimized connected domain label image. This operation can eliminate the surface defect area in the image (assuming that the defect size is relatively small) and retain the normal illumination unevenness area, that is, the brighter or darker area of ​​the welded pipe due to the surface curvature or ambient light. The main purpose of this step to eliminate the surface defect area is: Subsequently, it is necessary to perform single-scale Retinex processing on each connected domain to evaluate the differences between the reflection images corresponding to each connected domain. Since the reflection image reflects the color and material properties of the object itself and is not affected by changes in illumination, the reflection images corresponding to different connected domains on the same welded pipe surface should also have a high degree of similarity. However, if the connected domain contains defective areas (such as cracks, pores, etc.), which are different from the color and material properties of the welded pipe itself, it will affect the subsequent similarity evaluation of the reflection images corresponding to each connected domain.

[0036] Finally, a single-scale Retinex process is performed on the image area corresponding to each connected domain to obtain a reflection image of the corresponding image area. The input of the single-scale Retinex algorithm is the image area corresponding to each connected domain, and the output is an illumination image and a reflection image. The above-mentioned Canny edge detection algorithm, connected domain analysis, morphological closing operation and single-scale Retinex algorithm belong to well-known technologies, and the specific implementation methods will not be repeated here.

[0037] Since the same material is used on the surface of the same section of welded pipe, the ideal reflection images of different sub-areas in the same inspection area should be similar or meet certain expectations. 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 of the scale can be evaluated by comparing the difference in reflection images of different areas at the same scale. The i-th connected domain in the image of the S-th scale is denoted as R S i , then for an image of scale S, its corresponding reflection image consists of multiple connected domains RS 1 ,R S 1 ,…,R S n where n represents the number of connected domains at this scale. For each pair of connected domains R S i With R S u , the difference index can be calculated using the mean square error (MSE), and then the overall difference is calculated by comparing the reflection images of all connected domains at the same scale S, specifically: ; ; Where D S i,u Represents the connected domain R S i With R S u The difference between them; 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 connected domain R S i With R S u The reflection value at the coordinate (x,y) after Retinex processing; and They represent the maximum and minimum reflection values ​​of all reflection images under scale S, which are used to standardize the difference; D S represents the overall difference between the reflection images corresponding to all connected domains at scale S; n represents the number of connected domains at scale S.

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

[0039] 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 differences, which are respectively recorded as D 1 , D 2 , D3 , D 4 and D 5 However, since the number of scales in the MSR algorithm is mostly set to an empirical value of 3-5, that is, the number of scales is relatively small, there may be a situation where the overall difference corresponding to the images of each scale is small. Therefore, in this embodiment, the gain coefficient corresponding to the image of each scale is further calculated to adjust the amplification effect of the overall difference between different scales to obtain the final adaptive weight.

[0040] 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 (i.e., illumination mainly reflects slowly changing light, and reflection mainly reflects the inherent properties of the object). Too large a difference may indicate that there is a problem with the illumination image fitting the brightness component, and the illumination effect is not well separated. Therefore, the quality of the scale can be evaluated by calculating the difference between the illumination image and the reflection image. If the difference between the two is too large, it means that the illumination estimation at the scale is inaccurate and the gain coefficient should be small. Here, the illumination image at scale S is denoted as I S ill (x, y), the reflected image at scale S is recorded as I S ref (x, y), use the mean square error to calculate the difference between the illumination image and the reflection image to obtain the gain coefficient, and the specific calculation method is: ; Where W S represents the gain coefficient at scale S; N represents the total number of pixels of the image at scale S; W and H represent the width and height of the image at scale S respectively; 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 a parameter adjustment factor, which is used to avoid the situation where the denominator is 0. In this embodiment, it can be set to an empirical value of 1e-5.

[0041] when When the value is larger, it means that the difference between the illumination image and the reflection image at this scale is large, and the illumination estimation at this scale may be inaccurate. S The smaller it is, the smaller the adaptive weight of the image fusion calculated at this scale should be; when The smaller the value, the smaller the difference between the illumination image and the reflection image at this scale, and the illumination estimation at this scale is more consistent with the actual illumination effect, so the gain coefficient W S The larger it is, the larger the adaptive weight should be when the image fusion is calculated at this scale.

[0042] So far, the overall difference D corresponding to the scale S is obtained S And the gain factor W S Finally, the adaptive weight M corresponding to the image at scale S is calculated S ,have: ; Among them, M S represents the adaptive weight corresponding to the image at scale S; W S represents the gain coefficient under scale S; D S represents the overall difference between the reflection images corresponding to all connected domains at scale S; γ represents the parameter adjustment factor to avoid the situation where the denominator is 0, and in this embodiment, it can be set to an empirical value of 1e-6.

[0043] The steps of the multi-scale Retinex algorithm after the final improvement of adaptive weights are: first, the original image is decomposed into multiple scale images through different Gaussian filters; then the adaptive weights of each scale image are calculated; then the illumination image and the reflectance image are exponentially transformed to obtain the enhanced images of each scale; finally, the enhanced images of each scale are weightedly fused according to the corresponding adaptive weights to obtain the final enhanced image.

[0044] S3, obtaining the detection area image obtained in step S1 and processing it based on the improved adaptive weight MSR algorithm in step S2; performing defect detection on the processed image, extracting defect features and manually adding labels for training the CNN classification model.

[0045] After obtaining the inspection area image obtained in step S1, the improved adaptive weight MSR algorithm shown in step S2 is used for processing to obtain the inspection area image of the welded pipe surface after brightness equalization. The optimized image is further subjected to defect detection and defect features are extracted. The specific defect detection steps are as follows: First, the processed detection area image is subjected to Canny edge detection to extract edge information and obtain a binary edge image; then connected domain analysis and morphological opening operation are performed to eliminate noise areas. The brightness distribution of the image processed by the improved adaptive weight MSR algorithm is relatively balanced, and the edge of the defect area and possible weld edges or other stable structure edges can be more clearly detected during edge detection. Each independent area can be obtained through connected domain analysis.

[0046] Finally, the area representing the defect needs to be retained. It can be screened based on prior knowledge such as size and shape. For example, the geometric parameters such as the area, perimeter, aspect ratio, etc. of each connected domain can be calculated. If the defect usually appears as a small spot or a long and thin crack, a threshold can be set to remove the connected domain with an area that is too large (which may correspond to the background area or a large area of ​​normal weld seam), and retain the connected domain whose size meets the defect characteristics. The image corresponding to the remaining connected domain of the defective area is the defective area image. The above-mentioned Canny edge detection algorithm, connected domain analysis, and morphological opening operation are all well-known technologies, and the specific implementation methods will not be repeated here.

[0047] At this point, the defect areas on the images of all detection areas 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 recorded as E in this embodiment. After the defect features are extracted, manual labels are required to help the CNN model identify different types of defects or judge the severity of defects. Relevant professional and technical personnel shall label each defect area with a defect degree label (for example, a numerical value can be comprehensively evaluated based on the defect type, size, etc.), and record it as Y, such as 0.05, 0.10, 0.15,…, 0.95, etc., then the qth sample data can be recorded as [E q ,Y q ]. After obtaining all the sample data, 70% of the sample data is used as training data, 15% of the sample data is used as verification data, and 15% of the sample data is used as test data, and all of them are input into the CNN classification model for model training.

[0048] The gray level co-occurrence matrix and HU moment are used in the present invention 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.

[0049] In this embodiment, the input of CNN classification model training also includes: the model can be selected as ResNet50; the learning rate can be set to an empirical value of 0.001. If the learning rate is too large, the gradient will be updated too quickly, and if it is too small, the convergence may be too slow; the batch size can be set to an empirical value of 32. This hyperparameter determines the number of samples used in each update; the training epochs can be set to 50; the loss function can select the cross-entropy loss function, which is suitable for 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.

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

[0051] S4, taking a real-time image of the high-frequency welded pipe and obtaining an image of the area to be detected, and inputting the image into the CNN classification model trained in step S3 to realize surface defect detection of the high-frequency welded pipe.

[0052] First, the real-time image of the high-frequency welded pipe on the production line is obtained and grayed. Then, the image of the area to be detected is obtained based on the YOLOv5 target detection algorithm in step S1. Then, the image of the detection area is enhanced in S2 and the feature is extracted in S3. The data is input into the CNN classification model trained in step S3 for defect detection. The model will analyze the image features, identify whether there are defects, and obtain the corresponding defect degree based on the training data.

[0053] Exemplary explanation: There is an image of the surface inspection area of ​​a welded pipe containing two defective areas. After inputting them into the trained CNN classification model, the defect levels are 0.05 and 0.20 respectively, that is, the total defect level (or maximum value, or other comprehensive index) of the inspection area is 0.25. Compare this result with the set defect threshold (for example, the empirical value of 0.05). If it is greater than the set threshold, it is determined that the section of welded pipe has surface defects and the degree of defects is high. The system can issue an alarm to notify relevant personnel to review or mark the section of welded pipe and analyze the specific causes of 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-mentioned defect threshold can also be set by the implementer to 0.10, 0.15 or 0.20, etc., which should be adjusted according to the production quality requirements and the sensitivity of the model to defects during training.

[0054] An embodiment of a high-frequency welded pipe defect detection system based on machine vision: On the other hand, the present invention also provides a high-frequency welded pipe defect detection system based on machine vision. Figure 4 As shown, the high-frequency welded pipe defect detection system based on machine vision includes a processor and a memory, wherein the memory stores computer program instructions. When the computer program instructions are executed by the processor, a high-frequency welded pipe defect detection method based on machine vision according to the first aspect of the present invention is implemented.

[0055] The high-frequency welded pipe defect detection system based on machine vision also includes other components familiar to those skilled in the art, such as a communication interface, whose settings and functions are known in the art and will not be described in detail here.

[0056] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in the present invention may be implemented using computer-readable / executable instructions stored or otherwise maintained 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 comprises: Obtain an image of a detection area containing defects on the surface of a high-frequency welded pipe; use a multi-scale Retinex algorithm to process the image of the detection area to obtain an enhanced image, and extract a feature vector of the defect area in the enhanced image; add a defect degree label to each feature vector for training a classification model; A real-time image of the high-frequency welded pipe inspection area is obtained, and the real-time image is input into a trained classification model to obtain a corresponding defect degree. In response to the defect degree being greater than a set threshold, it is determined that the real-time image has a surface defect; the multi-scale Retinex algorithm also includes: Obtain edge binary images of images at each scale, perform connected domain analysis based on the edge binary images to obtain multiple connected domains; perform single-scale Retinex processing on each connected domain to obtain a connected domain reflection image, and every two connected domain reflection images constitute a connected domain reflection image pair; The mean square error of the reflection values ​​in the connected domain reflection image pairs at the same scale is calculated to obtain the difference, and the sum of the difference of all connected domain reflection image pairs at the same scale constitutes the overall difference; The inverse of the mean square error of the brightness value of the illumination image and the reflectance value of the reflectance image at the same scale is taken as the gain coefficient; the product of the gain coefficient and the overall difference constitutes an adaptive weight, and the images of each scale are fused according to the corresponding adaptive weight to obtain an enhanced image.

2. The high-frequency welded pipe defect detection method based on machine vision according to claim 1 is characterized in that: The calculation method of the adaptive weight is specifically as follows: ; Among them, M S represents the adaptive weight corresponding to the image at scale S; W S represents the gain coefficient under scale S; D S It represents the overall difference between the reflection images of all connected domains at scale S; γ represents the parameter adjustment factor.

3. The high-frequency welded pipe defect detection method based on machine vision according to claim 2 is characterized in that: The calculation method of the overall difference is specifically as follows: ; ; Where D S i,u Represents the connected domain R S i With R S u The difference between them; 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 connected domain R S i With R S u The reflection value at the coordinate (x,y) after single-scale Retinex processing; and They represent the maximum reflection value and the minimum reflection value in all connected domain reflection images at scale S respectively; D S represents the overall difference between the reflection images of all connected domains at scale S; n represents the number of connected domains at scale S.

4. The high-frequency welded pipe defect detection method based on machine vision according to claim 2 is characterized in that: The calculation method of the gain coefficient is specifically as follows: ; Where W S represents the gain coefficient at scale S; N represents the total number of pixels of the image at scale S; W and H represent the width and height of the image at scale S respectively; 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 factor.

5. The high-frequency welded pipe defect detection method based on machine vision according to claim 1 is characterized in that: Obtain images of the inspection area containing defects on the surface of high-frequency welded pipes, including: Use 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; Based on the YOLOv5 target detection algorithm, the detection area in the grayscale image is extracted to obtain the detection area image.

6. The high-frequency welded pipe defect detection method based on machine vision according to claim 1 is characterized in that: Extracting a feature vector of a defect area in the enhanced image includes: Extracting texture features of the defective area in the enhanced image using a gray level co-occurrence matrix, including: energy, contrast, entropy, correlation, and homogeneity; Extracting geometric features of the defect area in the enhanced image using HU moments, including 7 HU moments; The texture features and geometric features together constitute a feature vector.

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

8. The high-frequency welded pipe defect detection method based on machine vision according to claim 1 is characterized in that: The Canny edge detection algorithm is used to obtain the edge binary images of the images of each scale.

9. The high-frequency welded pipe defect detection method based on machine vision according to claim 1 is characterized in that: It also includes morphological closing operations on each connected domain.

10. A high-frequency welded pipe defect detection system based on machine vision, characterized in that: It comprises a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a high-frequency welded pipe defect detection method based on machine vision as described in any one of claims 1 to 9 is implemented.

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

  • Test paper color change quantitative identification method based on improved MSRCR and random forest

    CN119274001A

  • Automated data extraction from scatter plot images

    US20170351708A1

  • Deep perceptual image enhancement

    WO2022133194A1

Cited By

  • Method for monitoring glue melting state of nozzle of injection molding machine based on machine vision

    CN120747083A

  • Injection molding machine nozzle melt state monitoring method based on machine vision

    CN120747083B

  • Image data enhancement method and system based on monitoring video

    CN121685351A