A method, equipment and medium for testing the corrosion resistance of gas pipelines
By obtaining the zinc bath temperature during hot-dip galvanizing of gas pipelines, screening samples, and performing image corrosion analysis, and dynamically setting thresholds to separate white rust from the background, the problem of low detection accuracy and detection rate in the corrosion resistance testing of gas pipelines was solved, achieving higher detection accuracy and a higher rate of finding defective products.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZUNYI SPECIAL EQUIPMENT INSPECTION INSTITUTE
- Filing Date
- 2025-08-07
- Publication Date
- 2026-05-26
AI Technical Summary
Existing corrosion resistance testing technologies for gas pipelines cannot accurately separate white rust from the background in salt spray tests, resulting in low testing accuracy and a low rate of defective products being detected.
By obtaining the zinc bath temperature during hot-dip galvanizing of gas pipelines, random samples are screened and images are collected for corrosion resistance testing and image corrosion analysis. Thresholds are dynamically set to separate white rust from the background. Combined with pixel cluster weighted average and neighboring pixel judgment, the detection accuracy and detection rate are improved.
The algorithm dynamically sets thresholds based on the surface characteristics of gas pipelines, accurately separates white rust from the background, improves detection accuracy and the detection rate of defective products, reduces the noise false judgment rate, and enhances the stability of the algorithm in various environments.
Smart Images

Figure CN121323533B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pipeline corrosion resistance testing technology, specifically to a method, equipment, and medium for testing the corrosion resistance of gas pipelines. Background Technology
[0002] Pipeline corrosion resistance testing technology refers to a technical system that uses a series of physical, chemical, electrochemical, or non-destructive testing methods to assess, monitor, and analyze the ability of pipelines to resist corrosion damage in specific environments. Its core objective is to quantify the corrosion resistance of pipeline materials and surface protective layers, identify potential corrosion risks, determine the degree of corrosion, and provide a scientific basis for pipeline design, maintenance, and replacement, so as to ensure the safe operation of pipeline systems and extend their service life.
[0003] Existing pipeline corrosion resistance testing technologies often rely on manual visual inspection or image analysis to detect the white rust area in salt spray tests of gas pipelines. Direct observation of the white rust coverage on the gas pipeline surface is limited by the visual sensitivity of the inspectors; different personnel may interpret the blurred boundaries of the white rust differently, leading to inconsistent results for the same sample and low detection accuracy. Image analysis methods often use manually set thresholds for binarization to separate the white rust from the background image. However, threshold settings require manual adjustment, and the parameters lack universality due to variations in coating gloss and white rust color depth among different samples, making accurate separation of white rust and background difficult. Furthermore, gas pipeline testing often employs random sampling, which fails to improve the detection rate of defective products and reduce the risk of missed detections. Therefore, existing pipeline corrosion resistance testing technologies cannot dynamically set thresholds based on the surface characteristics of gas pipelines to accurately separate the white rust from the background in the image, resulting in inaccurate white rust area measurements and a low detection rate of defective products. Summary of the Invention
[0004] This invention aims to at least partially solve one of the technical problems in the prior art. It obtains zinc bath temperature data during hot-dip galvanizing of gas pipelines and screens samples for inspection; acquires images of the inspected samples to obtain initial image data and performs corrosion resistance tests on the samples; acquires images of the inspected samples after testing to obtain test image data and performs image corrosion analysis to obtain corrosion image data; and obtains the corrosion area of the gas pipeline based on the corrosion image data to obtain the pipeline corrosion resistance test results. This addresses the problem that existing pipeline corrosion resistance testing technologies, when detecting white rust area in salt spray tests of gas pipelines, cannot dynamically set thresholds based on the surface characteristics of the gas pipeline to accurately separate white rust from the background in the image, resulting in inaccurate white rust area measurements and a low detection rate of defective products.
[0005] To achieve the above objectives, in a first aspect, this application provides a method for testing the corrosion resistance of gas pipelines, comprising the following steps:
[0006] The temperature of the zinc bath during hot-dip galvanizing of gas pipelines was obtained to acquire galvanizing temperature data, and samples were screened for inspection based on the galvanizing temperature data.
[0007] Images of the sampled specimens were collected to obtain initial image data, and corrosion resistance tests were performed on the sampled specimens.
[0008] Images of the sampled specimens after testing are obtained to acquire test image data. Based on the initial image data, image corrosion analysis is performed to obtain corrosion image data.
[0009] The corrosion area of the gas pipeline is obtained from the corrosion image data, and the corrosion resistance test results of the pipeline are obtained.
[0010] Furthermore, the zinc bath temperature during hot-dip galvanizing of the gas pipeline is obtained to acquire galvanizing temperature data. The selection of samples for inspection based on this galvanizing temperature data includes the following sub-steps:
[0011] For any batch of gas pipelines produced in the same batch, it shall be designated as the first batch of steel pipes, and any gas pipeline in the first batch of steel pipes shall be designated as the first steel pipe.
[0012] When the first steel pipe is hot-dip galvanized, the temperature of the zinc liquid is collected at a first time interval from the time the first steel pipe comes into contact with the zinc liquid until the first steel pipe is completely removed from the zinc liquid, and the time of collection is recorded as the hot-dip galvanizing temperature information of the first steel pipe.
[0013] Repeatedly obtain the hot-dip galvanizing temperature information of all gas pipelines in the first batch of steel pipes to obtain galvanizing temperature data.
[0014] Furthermore, obtaining the zinc bath temperature during hot-dip galvanizing of gas pipelines, acquiring galvanizing temperature data, and screening samples for inspection based on the galvanizing temperature data also includes the following sub-steps:
[0015] The theoretical optimal range of zinc bath temperature for hot-dip galvanizing is denoted as the optimal zinc bath temperature range [AT, BT].
[0016] For any one of the hot-dip galvanizing temperature data points for the first steel pipe, the zinc bath temperature is denoted as the first zinc bath temperature XTi. The temperature deviation of the first galvanizing temperature is calculated and denoted as PTi, where i represents the i-th data collection time.
[0017] Calculating the temperature deviation of the first galvanizing temperature includes: if XTi ∈ [AT, BT], then PTi = 0; if XTi < AT, then PTi = Qi * [AT - XTi], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(AT - XTi + 1) + 1], where k1 is the set maximum weight and k2 is the set change coefficient; if XTi > BT, then PTi = Qi * [XTi - BT], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(XTi - BT + 1) + 1];
[0018] Repeatedly calculate the temperature deviation of all zinc bath temperatures in the hot-dip temperature information of the first steel pipe and sum them, which is recorded as the galvanizing temperature anomaly index of the first steel pipe;
[0019] Repeatedly obtain the galvanizing temperature anomaly indexes of all gas pipelines in the first steel pipe batch and arrange them in descending order, which is recorded as the anomaly index sequence;
[0020] Obtain the number of non-zero galvanizing temperature anomaly indexes and the number of zero galvanizing temperature anomaly indexes in the anomaly index sequence, which are respectively recorded as AF and BF in order;
[0021] Select the largest and non-zero q1 * k3 galvanizing temperature anomaly indexes from the anomaly index sequence, and record the corresponding gas pipelines as the first sampled steel pipes, and randomly select (1 - q1) * k3 galvanizing temperature anomaly indexes equal to zero from the anomaly index sequence, and record the corresponding gas pipelines as the second sampled steel pipes; where k3 is the set number of samples and q1 is the proportionality coefficient;
[0022] Obtain test samples from the first sampled steel pipes and the second sampled steel pipes, which are respectively recorded as the first samples and the second samples, and both are marked as sampled samples.
[0023] Furthermore, collect images of the sampled samples to obtain initial image data, and conduct corrosion resistance tests on the sampled samples, including the following sub-steps:
[0024] For any sampled sample, recorded as the first initial sample, remove the stains on the surface of the first initial sample, use an image acquisition device, keep the distance between the image acquisition device and the first initial sample fixed, ensure that the shooting angle is perpendicular to the surface of the first initial sample, collect the image of the surface of the first initial sample, recorded as the initial sample image, and after completion, obtain the initial image data;
[0025] Next, place the first initial sample with the stain removed into the salt spray test chamber and conduct the salt spray test for k4 hours. After that, take out the first initial sample, remove the salt particles remaining on the surface of the first initial sample, and dry it thoroughly. After completion, the first initial sample is recorded as the first test sample, where k4 is the set time. Repeat the salt spray test on all sampled samples.
[0026] Further, images of the sampled specimens after testing are acquired to obtain experimental image data, and image corrosion analysis is performed based on the initial image data, including the following sub-steps:
[0027] For the first test sample, using an image acquisition device, keeping the environmental parameters and the device parameters of the image acquisition device the same as when acquiring the initial image data, an image of the surface of the first test sample is acquired and recorded as the test sample image. After completion, the test image data is obtained.
[0028] For initial sample images and test sample images acquired at the same location in the initial image data and test image data, they are respectively recorded as the first initial image and the first test image in sequence;
[0029] Set the grid size to a1*a1. Divide the first initial image and the first test image into multiple grid regions using the grid. For any grid region of the first initial image and the first test image, record them as the first initial grid and the first test grid respectively in sequence.
[0030] Furthermore, acquiring images of the sampled specimens after testing to obtain experimental image data, and performing image corrosion analysis based on the initial image data, also includes the following sub-steps:
[0031] Obtain the grayscale values of all pixels in the blue channel within the first initial grid and the first test grid, respectively;
[0032] For any pixel in the first initial grid, denoted as the first initial pixel, obtain the coordinates (x, y) of the first initial pixel in the first initial grid; calculate the horizontal gradient Gx and vertical gradient Gy of the first initial pixel using the Sobel operator, and calculate the local gradient magnitude AG = √(Gx / Gy) of the first initial pixel. 2 +Gy 2 );
[0033] The grayscale value of the first initial pixel in the blue channel is denoted as BG, and (AG, BG) is marked as the feature vector of the first initial pixel; the feature vectors of all pixels in the first initial grid are repeatedly obtained.
[0034] Randomly select k5 pixels from the first initial grid as center pixels, and denot them as center point 1-k5. Then, denot the pixel clusters represented by the center pixels as pixel clusters 1-k5, where k5 is the set number.
[0035] Based on the feature vectors of the first initial pixel and the center pixel, calculate the Euclidean distance between the feature vectors of the first initial pixel and each center pixel, and divide the first initial pixel into pixel clusters corresponding to the center pixels with the shortest Euclidean distance.
[0036] Repeat the process of dividing all pixels in the first initial grid and select the pixel cluster with the most pixels, which is denoted as the first pixel cluster.
[0037] Furthermore, acquiring images of the sampled specimens after testing to obtain experimental image data, and performing image corrosion analysis based on the initial image data, also includes the following sub-steps:
[0038] For any pixel in the first pixel cluster, denoted as the second initial pixel, the local gradient magnitude of the second initial pixel is denoted as AGj. The pixel weight TEj of the second initial pixel is calculated, TEj = 1 / (TEj+1). The weighted average of the gray values of all pixels in the first pixel cluster in the blue channel is calculated according to the first formula, denoted as the reference gray value WG. The first formula is as follows: Where n is the total number of pixels in the first pixel cluster;
[0039] For any pixel in the first test grid, it is denoted as the first test pixel. The gray value of the first test pixel in the blue channel is denoted as CG. The gray value deviation PG of the first test pixel is calculated, where PG = WG - CG. If PG > k6 * WG, then the first test pixel is marked as a candidate white rust point, where k6 is the scaling factor.
[0040] Repeat the labeling process for all pixels in the first test grid. For any candidate white rust point, if at least 3 of its corresponding 8 neighboring pixels are candidate white rust points, then mark it as the first white rust point; otherwise, mark it as a noise point.
[0041] Obtain the grayscale deviation of all first white rust spots, and obtain the grayscale values of the k7 first white rust spots with the smallest grayscale deviation in the blue channel, and calculate the average value, which is recorded as the grayscale threshold.
[0042] For all pixels in the first test grid, pixels with a gray value greater than the gray value threshold in the blue channel will be marked as white rust pixels;
[0043] Repeatedly acquire white rust pixels in all grid areas of the first test image to obtain the corresponding corrosion sample image. Then, repeatedly acquire corrosion sample images corresponding to all test sample images in the test image data to obtain corrosion image data.
[0044] Furthermore, the corrosion area of the gas pipeline is obtained based on the corrosion image data, and the pipeline corrosion resistance test results are obtained through the following sub-steps:
[0045] For any corrosion sample image in the corrosion image data, denoted as the first sample image, the actual area corresponding to all white rust pixels in the first sample image is obtained based on the actual area corresponding to each pixel in the first sample image.
[0046] Repeatedly acquire the actual area corresponding to the white rust pixels of all corrosion sample images in the corrosion image data to obtain the white rust area on the surface of the first test sample, and calculate the proportion of the white rust area to the total area, which is recorded as the white rust area ratio. Based on the white rust area ratio, obtain the corresponding corrosion resistance level and determine whether the corresponding sample is qualified.
[0047] Repeatedly obtain the corrosion resistance level and pass rate of all sampled products, and obtain the pass rate of the first sample and the second sample, which are recorded as AH and BH respectively in order; and calculate the pass rate CH of the corrosion resistance of the first batch of steel pipes, where CH=(AH*AF+BH*BF) / (AF+BF).
[0048] Secondly, this application provides an electronic device including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method described above are performed.
[0049] Thirdly, this application provides a storage medium on which a computer program is stored, which, when executed by a processor, performs the steps of the method described above.
[0050] The beneficial effects of this invention are as follows: This invention obtains zinc bath temperature data during hot-dip galvanizing of gas pipelines, and then selects samples for inspection based on the zinc bath temperature data; it acquires images of the samples to obtain initial image data, and performs corrosion resistance tests on the samples; it acquires images of the tested samples to obtain test image data, and performs image corrosion analysis based on the initial image data to obtain corrosion image data; it obtains the corrosion area of the gas pipeline based on the corrosion image data, and obtains the pipeline corrosion resistance test results; when detecting the white rust area of gas pipelines in salt spray tests, a threshold can be dynamically set according to the surface characteristics of the gas pipeline to accurately separate the white rust and background in the image, obtain the accurate white rust area, and improve the detection rate of defective products;
[0051] This invention, by real-time acquisition of the zinc bath temperature during hot-dip galvanizing and calculation of the galvanizing temperature anomaly index, can accurately identify pipes with large temperature control deviations as primary inspection targets, while retaining pipe sections with normal temperatures as control samples. This significantly improves the detection rate of potential serious defects and the detection rate of non-conforming products, avoiding resource waste. By extracting the local gradient amplitude of pixels and obtaining the baseline grayscale value through a clustering algorithm, the repeatability and consistency of results are ensured compared to the subjectivity of manual visual inspection. Based on the dynamic calculation of the grayscale threshold using a weighted average of pixel clusters, and combined with the judgment of white rust spots by neighboring pixels, it can adapt to different lighting conditions or sample background differences, effectively reducing the noise misjudgment rate and enhancing the stability of the algorithm in various field environments. Attached Figure Description
[0052] Figure 1 This is a flowchart of the steps of the method of the present invention;
[0053] Figure 2 This is a flowchart of the sample screening and sampling process of the present invention;
[0054] Figure 3 This is a flowchart of the image erosion analysis and processing of the present invention;
[0055] Figure 4 This is a schematic diagram of the electronic device of the present invention. Detailed Implementation
[0056] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] Example 1, please refer to Figure 1 As shown, this application provides a method for testing the corrosion resistance of gas pipelines, comprising the following steps:
[0058] Step S1 involves obtaining the zinc bath temperature during hot-dip galvanizing of the gas pipeline, acquiring galvanizing temperature data, and screening samples for inspection based on the galvanizing temperature data. Step S1 includes the following sub-steps:
[0059] Step S101: For any batch of gas pipelines produced in the same batch, record it as the first batch of steel pipes, and record any gas pipeline in the first batch of steel pipes as the first steel pipe.
[0060] Step S102, when hot-dip galvanizing the first steel pipe, from the moment the first steel pipe contacts the zinc bath until it completely leaves the zinc bath, collect the temperature of the zinc bath at a first time interval and record the collection time, denoted as the hot-dip temperature information of the first steel pipe; truly record the temperature fluctuations of each steel pipe during the immersion process to ensure that subsequent temperature anomaly analysis is based on a comprehensive temperature curve rather than discrete or small samples, improving data accuracy;
[0061] Step S103, repeatedly obtain the hot-dip temperature information of all gas pipelines in the first steel pipe batch to obtain galvanizing temperature data;
[0062] Step S104, obtain the theoretical optimal range of the zinc bath temperature during hot-dip galvanizing, denoted as the optimal zinc bath temperature range [AT, BT]; only by comparing the gap with the theoretical optimal range can the quality of temperature control be quantified; this range is the benchmark for subsequent deviation calculation and directly affects the accuracy of the anomaly index;
[0063] Step S105, please refer to Figure 2 As shown, for the zinc bath temperature at any collection time in the hot-dip temperature information of the first steel pipe, denoted as the first zinc bath temperature XTi, calculate the temperature deviation of the first galvanizing temperature, denoted as PTi, where i represents the i-th collection time.
[0064] Step S106, calculating the temperature deviation of the first galvanizing temperature includes: if XTi ∈ [AT, BT], then PTi = 0; if XTi < AT, then PTi = Qi * [AT - XTi], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(AT - XTi + 1) + 1], where k1 is the set maximum weight and k2 is the set change coefficient; if XTi > AT, then PTi = Qi * [XTi - BT], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(XTi - BT + 1) + 1]; ensure that temperature points within the process window do not contribute to outliers, and assign higher weights to points with larger deviations, controlled by coefficients such as k1 and k2, highlighting the impact of severe deviations on the overall evaluation and enhancing the sensitivity to major process out-of-control; in this embodiment, k1 is 3, that is, the weight range is 1 - 3, and the greater the temperature deviation, the higher the weight, k2 = 0.2, and the greater k2, the greater the change of the weight with the temperature deviation; for example, if AT - XTi = 20, then Qi = 1 + (3 - 1) * [1 - 1 / (0.2 * ln(20 + 1) + 1)] = 1.757.
[0065] Step S107, repeatedly calculate the temperature deviations of all zinc bath temperatures in the hot-dip temperature information of the first steel pipe and sum them, denoted as the galvanizing temperature anomaly index of the first steel pipe;
[0066] Step S108: Repeatedly obtain the galvanizing temperature anomaly index of all gas pipelines in the first batch of steel pipes, and arrange them in descending order, and record them as the anomaly index sequence.
[0067] Step S109: Obtain the number of non-zero galvanizing temperature anomaly indices and the number of zero galvanizing temperature anomaly indices in the anomaly index sequence, and record them as AF and BF respectively in order; AF and BF represent "potentially unqualified pipe fittings" and "potentially qualified pipe fittings" respectively, and are used for weighted evaluation in subsequent pass rate calculation.
[0068] Step S110: Select the largest non-zero galvanizing temperature anomaly index q1*k3 from the anomaly index sequence, and record the corresponding gas pipeline as the first sampled steel pipe. Randomly select (1-q1)*k3 galvanizing temperature anomaly indices equal to 0 from the anomaly index sequence, and record the corresponding gas pipeline as the second sampled steel pipe. Here, k3 is the set number of samples, and q1 is the proportional coefficient. In this embodiment, q1 = 0.7. A dual-track sampling strategy of "high-risk priority + random control" is adopted: focusing on the pipe fittings with the most serious potential problems to improve the efficiency of defect detection and the detection rate of non-conforming products; at the same time, process qualified control is retained to ensure the objectivity and representativeness of the overall evaluation and prevent bias.
[0069] Step S111: Obtain test samples from the first and second sampled steel pipes, and record them as the first sample and the second sample respectively, and mark them as sampled samples.
[0070] In practice, hot-dip galvanizing is a process in which steel pipes are immersed in molten zinc, allowing zinc to react with the base iron to form an alloy layer and a pure zinc layer, thereby giving the steel pipe corrosion resistance. The temperature of the zinc bath is a key parameter affecting the quality of the coating. If the temperature is too high or too low, it will directly affect the corrosion resistance of the steel pipe by changing the coating structure, thickness, and uniformity. If the zinc bath temperature is too high, the alloy layer will be too thick, brittle, and have more defects, reducing the integrity and adhesion of the coating. If the temperature is too low, the coating thickness will be uneven, there will be missed coatings, and the porosity will be high, weakening the protective barrier.
[0071] Step S2 involves acquiring images of the sampled specimens to obtain initial image data, and then conducting corrosion resistance tests on the specimens. Step S2 includes the following sub-steps:
[0072] Step S201: For any random sample, designated as the first initial sample, remove the stains from the surface of the first initial sample. Using an image acquisition device, keep the distance between the image acquisition device and the first initial sample fixed, and ensure that the shooting angle is perpendicular to the surface of the first initial sample. Acquire an image of the surface of the first initial sample, and record it as the initial sample image. After completion, the initial image data is obtained. Any stains adhering to the surface may affect the optical characteristics of subsequent images, resulting in image grayscale or texture distortion. At the same time, surface contamination may also interfere with the corrosion mechanism of the salt spray test, causing the test results to be distorted. Through thorough cleaning, ensure that all subsequent images and corrosion reactions only reflect the state of the substrate and coating itself.
[0073] Step S202: Place the first initial sample with the stain removed into a salt spray test chamber and conduct a salt spray test for 4 hours. Then, take out the first initial sample.
[0074] Step S203: Remove the residual salt particles on the surface of the first initial sample and dry it thoroughly. After completion, the first initial sample is recorded as the first test sample, where k4 is the set time. Repeat the salt spray test on all sampled samples. k4 can be set according to the actual application scenario. In this embodiment, k4 = 48 hours.
[0075] In the specific implementation process, the salt spray test creates a high-concentration salt spray environment in a closed test chamber, so that the surface of the gas pipeline is continuously exposed to salt spray, which accelerates the electrochemical corrosion process of the zinc layer. The zinc layer, as the anode, is preferentially corroded, forming white rust. If the zinc layer is penetrated, the base iron material will corrode and produce red rust. By observing the corrosion products on the sample surface over a certain period of time, the time and area of white rust and red rust appearance, as well as the zinc layer loss, the corrosion resistance of the galvanized layer is evaluated.
[0076] Step S3 involves acquiring images of the sampled specimens after testing to obtain experimental image data, and performing image corrosion analysis based on the initial image data to obtain corrosion image data. Step S3 includes the following sub-steps:
[0077] Step S301: For the first test sample, using an image acquisition device, while keeping the environmental parameters and the device parameters of the image acquisition device the same as when acquiring the initial image data, acquire an image of the surface of the first test sample, which is recorded as the test sample image. After completion, the test image data is obtained. Ensure that the initial image and the test image are strictly consistent in optical characteristics and shooting geometry to facilitate pixel-level comparison. Any deviation in lighting or angle will introduce additional deviations and affect the accurate identification of subsequent corrosion areas.
[0078] Step S302: For the initial sample image and the test sample image in the initial image data and the test image data that are collected at the same location, record them as the first initial image and the first test image in sequence; establish a one-to-one image comparison relationship to ensure that the state before and after the test can be accurately matched in subsequent processing;
[0079] Step S303: Set the grid size to a1*a1. Divide the first initial image and the first test image into multiple grid regions using the grid. Any grid region of the first initial image and the first test image is recorded as the first initial grid and the first test grid in sequence. In this embodiment, a1 is 24 pixels.
[0080] For step S304, please refer to... Figure 3 As shown, the grayscale values of all pixels in the first initial grid and the first experimental grid in the blue channel were obtained respectively. White rust is usually white under visible light and has a slight blue light reflection characteristic. The grayscale value of the blue channel has the highest contrast between the zinc substrate and the white rust. Using this channel as the basis for analysis can improve the distinction between the corroded area and the uncorroded area.
[0081] Step S305: For any pixel in the first initial grid, denoted as the first initial pixel, obtain the coordinates (x, y) of the first initial pixel in the first initial grid; calculate the horizontal gradient Gx and vertical gradient Gy of the first initial pixel using the Sobel operator, and calculate the local gradient magnitude AG = √(Gx / Gy) of the first initial pixel. 2 +Gy 2 The gradient magnitude reflects the intensity change of pixels at textures and edges, and combined with the grayscale value, it can distinguish between uncorroded areas and corroded areas.
[0082] Step S306: Denote the gray value of the first initial pixel in the blue channel as BG, and mark (AG, BG) as the feature vector of the first initial pixel; Repeat the acquisition of feature vectors of all pixels in the first initial grid.
[0083] Step S307: Randomly select k5 pixels from the first initial grid as center pixels, and record them as center points 1-k5 in sequence. Also record the pixel clusters represented by the center pixels as pixel clusters 1-k5 in sequence, where k5 is the set number; in this embodiment, k5 = 8.
[0084] Step S308: Based on the feature vectors of the first initial pixel and the center pixel, calculate the Euclidean distance between the feature vectors of the first initial pixel and each center pixel, and divide the first initial pixel into pixel clusters corresponding to the center pixels with the shortest Euclidean distance.
[0085] Step S309: Repeat the division of all pixels in the first initial grid and select the pixel cluster with the most pixels, which is denoted as the first pixel cluster. The largest cluster usually corresponds to the main distribution of the uncorroded background area, and its grayscale characteristics represent the typical grayscale level of a healthy coating. This cluster can be used as the benchmark for subsequent grayscale thresholds.
[0086] Step S310: For any pixel in the first pixel cluster, denoted as the second initial pixel, the local gradient magnitude of the second initial pixel is denoted as AGj. The pixel weight TEj of the second initial pixel is calculated, TEj = 1 / (TEj+1). The weighted average of the gray values of all pixels in the first pixel cluster in the blue channel is calculated according to the first formula and denoted as the reference gray value WG. The first formula is as follows: Where n is the total number of pixels in the first pixel cluster; pixels with smoother textures have higher weights, reinforcing the dominance of normal textures;
[0087] Step S311: For any pixel in the first test grid, denoted as the first test pixel, the gray value of the first test pixel in the blue channel is denoted as CG. The gray value deviation PG of the first test pixel is calculated, where PG = WG - CG. If PG > k6 * WG, the first test pixel is marked as a candidate white rust point, where k6 is a scaling factor. The larger the deviation, the brighter the pixel is relative to the healthy background, and the more likely it is a corrosion product. In this embodiment, k6 = 0.3.
[0088] Step S312: Repeat the marking of all pixels in the first test grid. For any candidate white rust point, if there are at least 3 candidate white rust points in the corresponding 8 neighboring pixels, it is marked as the first white rust point; otherwise, it is marked as a noise point. Spatial consistency is used to filter isolated noise to ensure that the real corrosion area is preserved while random scattered points are removed. Random scattered points may come from shooting noise, dust and reflection.
[0089] Step S313: Obtain the grayscale deviation of all first white rust spots, and obtain the grayscale values of the k7 first white rust spots with the smallest grayscale deviation in the blue channel, and calculate the average value, which is recorded as the grayscale threshold; in this embodiment, k7 = 3.
[0090] Step S314: For all pixels in the first test grid, pixels with gray values in the blue channel that are greater than the gray value threshold are marked as white rust pixels.
[0091] Step S315: Repeatedly acquire white rust pixels in all grid areas of the first test image. After completion, obtain the corresponding corrosion sample image. Repeatedly acquire corrosion sample images corresponding to all test sample images in the test image data. After completion, obtain corrosion image data. Calculate the threshold for each grid separately to avoid the problem of uniform threshold failure caused by uneven illumination and regional differences.
[0092] In practice, the surface of a normal galvanized layer is not a completely uniform solid color, but rather has subtle and continuous texture patterns, such as parallel fine lines formed during rolling and gradual changes in metallic luster. This texture has a high degree of consistency in local areas. However, abnormal points, scratches, and stains will disrupt this texture continuity. Therefore, by screening for texture consistency, most pixels with continuous texture in the grid can be found. Using the characteristics of these pixels as the reference grayscale value can improve the accuracy of white rust identification.
[0093] Step S4: Obtain the corrosion area of the gas pipeline based on the corrosion image data to obtain the pipeline corrosion resistance test result; Step S4 includes the following sub-steps:
[0094] Step S401: For any corrosion sample image in the corrosion image data, denoted as the first sample image, obtain the actual area corresponding to all white rust pixels in the first sample image based on the actual area corresponding to each pixel in the first sample image; determine the actual physical area corresponding to each pixel on the sample surface based on the calibration parameters of the imaging system, such as camera resolution, lens focal length, and shooting distance.
[0095] Step S402: Repeatedly acquire the actual area corresponding to the white rust pixels of all corrosion sample images in the corrosion image data to obtain the white rust area on the surface of the first test sample, and calculate the proportion of the white rust area to the total area, which is recorded as the white rust area ratio. Obtain the corresponding corrosion resistance level based on the white rust area ratio, and determine whether the corresponding sample is qualified. Obtain the corresponding corrosion resistance level according to the actual application scenario or relevant standards, and mark the samples that reach or exceed the qualified threshold as qualified, otherwise mark them as unqualified.
[0096] Step S403: Repeatedly obtain the corrosion resistance level and pass status of all sampled samples, and obtain the pass rate of the first sample and the second sample, which are recorded as AH and BH respectively in order; and calculate the pass rate CH of the corrosion resistance of the first steel pipe batch, where CH=(AH*AF+BH*BF) / (AF+BF).
[0097] In the specific implementation process, by weighted averaging the pass rates of the two types of samples, the risk of the pipe section most prone to defects is taken into account, while also including the overall performance of the control pipe section. The resulting pass rate can more accurately and comprehensively reflect the overall corrosion resistance reliability of the batch of pipes in actual use, and can specifically capture potential non-conforming products, thereby improving the detection rate of defective products.
[0098] Example 2, please refer to Figure 4 As shown, Figure 4 A schematic diagram of an electronic device is provided, which may include a processor, a communication interface, a memory, and a communication bus. The processor, communication interface, and memory communicate with each other via the communication bus. The memory stores computer-readable instructions, and the processor can call these instructions. When the processor executes a computer-readable instruction, it performs steps such as those in a method for detecting the corrosion resistance of a gas pipeline, to achieve the following functions: obtaining the temperature of the zinc bath during hot-dip galvanizing of the gas pipeline, obtaining galvanizing temperature data, and screening samples for inspection based on the galvanizing temperature data; acquiring images of the inspected samples, obtaining initial image data, and performing corrosion resistance testing on the inspected samples; acquiring images of the inspected samples after testing, obtaining test image data, and performing image corrosion analysis processing based on the initial image data to obtain corrosion image data; and obtaining the corrosion area of the gas pipeline based on the corrosion image data to obtain the pipeline corrosion resistance test result.
[0099] Furthermore, when the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0100] Example 3: This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it performs the steps of the above-described method for detecting the corrosion resistance of gas pipelines to achieve the following functions: obtaining the temperature of the zinc bath during hot-dip galvanizing of the gas pipeline, obtaining galvanizing temperature data, and screening samples for inspection based on the galvanizing temperature data; acquiring images of the samples for inspection, obtaining initial image data, and performing corrosion resistance tests on the samples; acquiring images of the tested samples, obtaining test image data, and performing image corrosion analysis processing based on the initial image data to obtain corrosion image data; obtaining the corrosion area of the gas pipeline based on the corrosion image data, and obtaining the pipeline corrosion resistance test result.
[0101] Based on the above description of the embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the technical solutions described above, or the parts that contribute to the prior art, can be embodied in the form of software products. These computer software products can be stored in computer-readable storage media, such as ROM / RAM, magnetic disks, optical disks, etc., and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or certain parts of the embodiments.
[0102] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces. The indirect coupling or communication connection between systems, modules, and units may be electrical, mechanical, or other forms.
[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for testing the corrosion resistance of gas pipelines, characterized in that, Includes the following steps: The temperature of the zinc bath during hot-dip galvanizing of gas pipelines was obtained to acquire galvanizing temperature data, and samples were screened for inspection based on the galvanizing temperature data. Images of the sampled specimens were collected to obtain initial image data, and corrosion resistance tests were performed on the sampled specimens. Images of the sampled specimens after testing are obtained to acquire test image data. Based on the initial image data, image corrosion analysis is performed to obtain corrosion image data. The corrosion area of the gas pipeline is obtained from the corrosion image data, and the corrosion resistance test results of the pipeline are obtained. The process of acquiring images of the sampled specimens after testing, obtaining experimental image data, and performing image corrosion analysis based on the initial image data includes the following sub-steps: For the first test sample, using an image acquisition device, keeping the environmental parameters and the device parameters of the image acquisition device the same as when acquiring the initial image data, an image of the surface of the first test sample is acquired and recorded as the test sample image. After completion, the test image data is obtained. For initial sample images and test sample images acquired at the same location in the initial image data and test image data, they are respectively recorded as the first initial image and the first test image in sequence; Set the grid size to a1*a1, where a1 is the number of pixels on one side of the grid. Divide the first initial image and the first test image into multiple grid regions using the grid. Any grid region of the first initial image and the first test image is recorded as the first initial grid and the first test grid in sequence. Obtain the grayscale values of all pixels in the blue channel within the first initial grid and the first test grid, respectively; For any pixel in the first initial grid, denoted as the first initial pixel, obtain the coordinates (x, y) of the first initial pixel in the first initial grid; calculate the horizontal gradient Gx and vertical gradient Gy of the first initial pixel using the Sobel operator, and calculate the local gradient magnitude AG = √(Gx / Gy) of the first initial pixel. 2 +Gy 2 ); Let BG be the gray value of the first initial pixel in the blue channel, and mark (AG, BG) as the feature vector of the first initial pixel; repeat to obtain the feature vectors of all pixels in the first initial grid. Randomly select k5 pixels from the first initial grid as center pixels, and denot them as center point 1-k5. Then, denot the pixel clusters represented by the center pixels as pixel clusters 1-k5, where k5 is the set number. Based on the feature vectors of the first initial pixel and the center pixel, calculate the Euclidean distance between the feature vectors of the first initial pixel and each center pixel, and assign the first initial pixel to the pixel cluster corresponding to the center pixel with the shortest Euclidean distance. Repeat the process of dividing all pixels in the first initial grid and select the pixel cluster with the most pixels, which is denoted as the first pixel cluster. For any pixel in the first pixel cluster, denoted as the second initial pixel, the local gradient magnitude of the second initial pixel is denoted as AGj. The pixel weight TEj of the second initial pixel is calculated, TEj = 1 / (AGj+1). The weighted average of the gray values of all pixels in the first pixel cluster in the blue channel is calculated according to the first formula, denoted as the reference gray value WG. The first formula is as follows: , where n is the total number of pixels in the first pixel cluster; For any pixel in the first test grid, it is denoted as the first test pixel. The gray value of the first test pixel in the blue channel is denoted as CG. The gray value deviation PG of the first test pixel is calculated, where PG = WG - CG. If PG > k6 * WG, the first test pixel is marked as a candidate white rust point, where k6 is the scaling factor. Repeat the labeling process for all pixels in the first test grid. For any candidate white rust point, if at least 3 of its corresponding 8 neighboring pixels are candidate white rust points, then mark it as the first white rust point; otherwise, mark it as a noise point. Obtain the gray-scale deviation degrees of all the first white rust points, and obtain the gray-scale values of the k7 first white rust points with the smallest gray-scale deviation degrees in the blue channel, and calculate the average value, which is denoted as the gray-scale threshold; For all pixel points in the first test grid, mark the pixel points with gray-scale values in the blue channel greater than the gray-scale threshold as white rust pixel points; Repeatedly obtain the white rust pixel points in all grid areas of the first test image. After completion, obtain the corresponding corroded sample image, and repeatedly obtain the corroded sample images corresponding to all test sample images in the test image data. After completion, obtain the corroded image data.
2. The method for testing the corrosion resistance of gas pipelines according to claim 1, characterized in that, Obtain the zinc bath temperature during hot-dip galvanizing of the gas pipeline to obtain the galvanizing temperature data, and screen the sampled samples according to the galvanizing temperature data, including the following sub-steps: For any batch of gas pipelines produced in the same batch, denoted as the first steel pipe batch, denote any one gas pipeline in the first steel pipe batch as the first steel pipe; During the hot-dip galvanizing of the first steel pipe, collect the temperature of the zinc bath at a first time interval from the moment when the first steel pipe contacts the zinc bath to the moment when the first steel pipe completely leaves the zinc bath, and record the collection time, which is denoted as the hot-dip galvanizing temperature information of the first steel pipe; Repeatedly obtain the hot-dip galvanizing temperature information of all gas pipelines in the first steel pipe batch to obtain the galvanizing temperature data.
3. The method for testing the corrosion resistance of gas pipelines according to claim 2, characterized in that, Obtain the zinc bath temperature during hot-dip galvanizing of the gas pipeline to obtain the galvanizing temperature data, and screening the sampled samples according to the galvanizing temperature data further includes the following sub-steps: Obtain the theoretical optimal range of the zinc bath temperature during hot-dip galvanizing, denoted as the optimal zinc bath temperature range [AT, BT]; Denote the zinc bath temperature at any collection time in the hot-dip galvanizing temperature information of the first steel pipe as the first zinc bath temperature XTi, and calculate the temperature deviation degree of the first galvanizing temperature, denoted as PTi, where i represents the i-th collection time; Calculating the temperature deviation degree of the first galvanizing temperature includes: if XTi ∈ [AT, BT], then PTi = 0; if XTi < AT, then PTi = Qi * [AT - XTi], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(AT - XTi + 1) + 1], where k1 is the set maximum weight and k2 is the set variation coefficient; if XTi > AT, then PTi = Qi * [XTi - BT], where Qi = 1 + (k1 - 1) * [1 - 1 / k2 * ln(XTi - BT + 1) + 1]; Repeatedly calculate the temperature deviation degrees of all the zinc bath temperatures in the hot-dip galvanizing temperature information of the first steel pipe and sum them, which is denoted as the galvanizing temperature anomaly index of the first steel pipe; Repeatedly obtain the galvanizing temperature anomaly indexes of all gas pipelines in the first steel pipe batch and arrange them in descending order, which is denoted as the anomaly index sequence; Obtain the number of non-zero galvanizing temperature anomaly indexes and the number of zero galvanizing temperature anomaly indexes in the anomaly index sequence, and denote them as AF and BF in sequence; Select the largest non-zero q1*k3 galvanized temperature anomaly indices from the anomaly index sequence and mark the corresponding gas pipelines as the first sampled steel pipes. Randomly select (1-q1)*k3 galvanized temperature anomaly indices equal to zero from the anomaly index sequence and mark the corresponding gas pipelines as the second sampled steel pipes. Here, k3 is the set number of samples and q1 is the proportional coefficient. Test samples were obtained from the first and second sampled steel pipes and were respectively recorded as the first sample and the second sample, and both were marked as sampled samples.
4. The method for testing the corrosion resistance of gas pipelines according to claim 3, characterized in that, Acquiring images of the sampled specimens to obtain initial image data, and conducting corrosion resistance tests on the sampled specimens, includes the following sub-steps: For any random sample, designated as the first initial sample, remove the stains from the surface of the first initial sample. Using an image acquisition device, keep the distance between the image acquisition device and the first initial sample fixed, and ensure that the shooting angle is perpendicular to the surface of the first initial sample. Acquire an image of the surface of the first initial sample, which is designated as the initial sample image. After completion, the initial image data is obtained. Next, place the first initial sample with the stain removed into the salt spray test chamber and conduct the salt spray test for k4 hours. After that, take out the first initial sample, remove the salt particles remaining on the surface of the first initial sample, and dry it thoroughly. After completion, the first initial sample is recorded as the first test sample, where k4 is the set time. Repeat the salt spray test on all sampled samples.
5. The method for testing the corrosion resistance of gas pipelines according to claim 4, characterized in that, Obtaining the corrosion area of the gas pipeline based on corrosion image data and obtaining the pipeline corrosion resistance test results includes the following sub-steps: For any corrosion sample image in the corrosion image data, denoted as the first sample image, the actual area corresponding to all white rust pixels in the first sample image is obtained based on the actual area corresponding to each pixel in the first sample image. Repeatedly acquire the actual area corresponding to the white rust pixels of all corrosion sample images in the corrosion image data to obtain the white rust area on the surface of the first test sample, and calculate the proportion of the white rust area to the total area, which is recorded as the white rust area ratio. Based on the white rust area ratio, obtain the corresponding corrosion resistance level and determine whether the corresponding sample is qualified. Repeatedly obtain the corrosion resistance level and pass rate of all sampled samples, and obtain the pass rate of the first sample and the second sample, which are recorded as AH and BH respectively in order; and calculate the pass rate CH of the corrosion resistance of the first batch of steel pipes, where CH=(AH*AF+BH*BF) / (AF+BF).
6. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-readable instructions that, when executed by the processor, perform the steps of the method as described in any one of claims 1-5.
7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it performs the steps of the method as described in any one of claims 1-5.