Gas pipe network leakage detection method and detection system based on defect image processing

By graying, enhancing and filtering the real-time image of gas pipelines, the problem of low efficiency and poor accuracy in leak detection in gas pipelines is solved, and early and accurate detection and positioning of leaks in gas pipelines is achieved.

CN120387976APending Publication Date: 2025-07-29STATE GRID XIONGAN SIJI DIGITAL TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510289373.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-12
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

The existing gas pipeline leakage detection technology has problems of low detection efficiency and poor accuracy, especially when the image quality is affected by noise, uneven light and weather conditions, resulting in poor detection results.

Method used

By grayscale processing of multiple continuous real-time images of the gas pipeline, grayscale images are acquired, defective images are initially diagnosed, and image enhancement and filtering are performed to improve image quality and feature extraction.

Benefits of technology

It significantly improves the accuracy and efficiency of gas pipeline leakage detection, can detect small leaks in the early stage, reduce safety accidents and economic losses, adapt to different environmental conditions, and improve patrol efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120387976A_ABST
    Figure CN120387976A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a gas pipe network leakage detection method and system based on defect image processing, and belongs to the technical field of gas pipe network leakage detection. The gas pipe network leakage detection method comprises the following steps: acquiring a plurality of continuous real-time images of a gas pipeline; performing graying processing on the plurality of continuous real-time images to obtain corresponding grayscale images; performing preliminary diagnosis on the gas pipeline according to the plurality of gray images to obtain a defect image; performing image enhancement processing on the defect image; and carrying out filtering processing on the defect image, and outputting a filtered image. According to the method, the defect image is preliminarily diagnosed by adopting the grayscale image, and the defect image is further subjected to enhanced filtering, so that the accuracy and the detection efficiency of gas pipeline leakage detection can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of gas pipeline leakage detection, and particularly to a gas pipeline leakage detection method and detection system based on defect image processing. Background Art

[0002] As an important infrastructure for urban energy supply, the safe operation of gas pipelines is directly related to the safety of public life and property and the stable development of social economy. Once a gas leak occurs, it may trigger serious accidents such as explosions and fires, causing huge casualties and property losses. Therefore, it is crucial to detect gas pipeline leaks in a timely and accurate manner.

[0003] With the development of computer vision and image processing technologies, using image recognition technology for gas pipeline leakage detection has gradually become a research hotspot. Image recognition technology can indirectly detect gas leaks by analyzing the image information of the pipeline surrounding environment, such as infrared thermal imaging images, visible light images, etc. This method has the advantages of non-contact, wide detection range, high visualization degree, etc., and is expected to overcome some limitations of traditional detection methods.

[0004] In practical applications, the gas pipeline images collected may be of poor quality due to various factors. For example, infrared thermal imaging images may be affected by noise interference, resulting in inaccurate temperature information; visible light images may be affected by uneven illumination and weather conditions (such as fog, rain, snow, etc.), making the features of the pipeline and its surrounding environment blurred. These low-quality images directly affect the subsequent leakage detection accuracy and detection efficiency.

[0005] The inventors of the present application found in the process of implementing the present invention that the above-mentioned solutions of the prior art have the defects of low leakage detection efficiency and poor accuracy. Summary of the Invention

[0006] The purpose of the embodiments of the present invention is to provide a gas pipeline leakage detection method and detection system based on defect image processing, and the gas pipeline leakage detection method and detection system based on defect image processing have the functions of high leakage detection efficiency and high accuracy.

[0007] To achieve the above purpose, on the one hand, the embodiments of the present invention provide a gas pipeline leakage detection method based on defect image processing, including:

[0008] Obtain a plurality of consecutive real-time images of the gas pipeline;

[0009] Perform grayscale processing on the plurality of consecutive real-time images to obtain corresponding grayscale images;

[0010] Based on the plurality of grayscale images, perform a preliminary diagnosis on the gas pipeline to obtain defect images;

[0011] Perform image enhancement processing on the defective image;

[0012] Perform filtering processing on the defective image and output the filtered image.

[0013] Optionally, performing grayscale processing on multiple consecutive real-time images includes:

[0014] Perform grayscale processing on the real-time image according to formula (1),

[0015] Gray(i,j) = 0.299×R(i,j) + 0.578×G(i,j) + 0.114×B(i,j), (1)

[0016] where Gray(i,j) is the grayscale value of the real-time image after grayscale processing at the coordinate point (i,j), and R(i,j), G(i,j), and B(i,j) are the luminance values of the three color components of the real-time image at the coordinate point (i,j), respectively.

[0017] Optionally, performing a preliminary diagnosis on the gas pipeline based on multiple grayscale images includes:

[0018] Obtain a standard image of the gas pipeline during normal operation and an abnormal image of the gas pipeline during leakage;

[0019] Obtain the minimum pixel grayscale difference value and the minimum number of pixels based on the standard image and the abnormal image;

[0020] Obtain the grayscale image to be diagnosed and its adjacent grayscale images;

[0021] Obtain the corresponding pixel grayscale difference value and the number of pixels based on the grayscale image to be diagnosed and its adjacent grayscale images;

[0022] Obtain a defective image based on the minimum number of pixels and the number of pixels for the grayscale image to be diagnosed and its adjacent grayscale images.

[0023] Optionally, obtaining the minimum pixel grayscale difference value and the minimum number of pixels based on the standard image and the abnormal image includes:

[0024] Obtain the minimum pixel grayscale difference value according to formula (2),

[0025] Δ , , , , min , , 1(i,j) ,

[0020] ,

[0019] ,

[0025] ,

[0024] ,

[0023] , 1(i,j) ,

[0022] , 2(i,j) ,

[0021] , min , ,

[0026] , , = min|a 1(i,j) - a 2(i,j) |, (2)

[0026] where Δ min is the minimum pixel grayscale difference value, and a 1(i,j)is the grayscale value of the coordinate point (i, j) in the standard image, a 2(i,j) is the grayscale value of the coordinate point (i, j) in the abnormal image;

[0027] Obtain the minimum number of pixels in the abnormal image whose pixel grayscale difference from the standard image is greater than or equal to the minimum pixel grayscale difference value.

[0028] Optionally, obtaining the corresponding pixel grayscale difference value and the number of pixels according to the grayscale image to be diagnosed and its adjacent grayscale images includes:

[0029] Obtain the pixel grayscale difference value according to formula (3),

[0030] Δ t = |a x·k - a y·k |, (3)

[0031] where, Δ t is the pixel grayscale difference value between the grayscale image to be diagnosed and its adjacent grayscale image, a x·k is the pixel value of the k-th coordinate on the grayscale image to be diagnosed, a y·k is the pixel value of the k-th coordinate on the grayscale image adjacent to the grayscale image to be diagnosed, and k is an integer number;

[0032] Obtain the number of pixels in the grayscale image to be diagnosed and its adjacent grayscale images whose pixel grayscale difference is greater than or equal to the minimum pixel grayscale difference value.

[0033] Optionally, obtaining the defective image according to the minimum number of pixels and the number of pixels for the grayscale image to be diagnosed and its adjacent grayscale images includes:

[0034] Judge whether the number of pixels is greater than or equal to the minimum number of pixels;

[0035] In the case where it is judged that the number of pixels is greater than or equal to the minimum number of pixels, determine that the grayscale image to be diagnosed is a defective image;

[0036] In the case where it is judged that the number of pixels is less than the minimum number of pixels, determine that the grayscale image to be diagnosed is not a defective image.

[0037] Optionally, performing image enhancement processing on the defective image includes:

[0038] Obtain the histogram of the defective image;

[0039] Obtain the frequency of occurrence of each grayscale value in the defective image according to formula (4),

[0040]

[0041] where p r (r k ) is the probability of the gray value at the k-th level in the defect image, r k is the gray value at the k-th level, n k is the number of pixels with the gray value r k in the defect image, N is the total number of pixels in the defect image, and k is an integer number;

[0042] Obtain the cumulative histogram of each gray value according to formula (5),

[0043]

[0044] where s k is the cumulative histogram at the k-th level in the defect image, p r (r j ) is the probability of the gray value at the j-th level in the defect image, and j is an integer number;

[0045] Obtain the mapped gray level corresponding to the original gray level according to formula (6),

[0046] M k = int[(max(r k )) - min(r k )) * s k + 0.5], (6)

[0047] where M k is the mapped gray level corresponding to the k-th gray level, max(r k ) is the maximum gray value, and min(r k ) is the minimum gray value;

[0048] Output the equalized image according to the mapped gray level.

[0049] Optionally, the filtering process for the defect image includes:

[0050] Obtain an initial filtering window;

[0051] Sort the gray values of the pixels within the filtering window from smallest to largest;

[0052] Determine whether the minimum gray value within the filtering window is less than the median and whether the median is less than the maximum gray value;

[0053] In the case where it is determined that the minimum gray value within the filtering window is less than the median and the median is less than the maximum gray value, obtain the gray value of the current pixel;

[0054] Determine whether the grayscale value of the current pixel is greater than the minimum grayscale value and less than the maximum grayscale value;

[0055] In the case where it is determined that the grayscale value of the current pixel is greater than the minimum grayscale value and less than the maximum grayscale value, output the grayscale value of the current pixel;

[0056] In the case where it is determined that the grayscale value of the current pixel is not greater than the minimum grayscale value and less than the maximum grayscale value, output the median value;

[0057] In the case where it is determined that the minimum grayscale value within the filtering window is not less than the median value and the median value is less than the maximum grayscale value, increase the filtering window;

[0058] Determine whether the current filtering window is less than or equal to the maximum window size;

[0059] In the case where it is determined that the current filtering window is less than or equal to the maximum window size, return to the step of sorting the grayscale values of the pixels within the filtering window from smallest to largest;

[0060] In the case where it is determined that the current filtering window is greater than the maximum window size, output the grayscale value of the current pixel.

[0061] On the other hand, the present invention also provides a gas pipeline network leakage detection system based on defect image processing, including:

[0062] An infrared thermal imaging camera, arranged near the gas pipeline, for performing real-time shooting on the gas pipeline;

[0063] A controller, connected to the infrared thermal imaging camera, for executing any one of the above-mentioned gas pipeline network leakage detection methods.

[0064] On yet another aspect, the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores instructions, and the instructions are used to be read by a machine so that the machine executes any one of the above-mentioned gas pipeline network leakage detection methods.

[0065] Through the above technical solutions, the present invention provides a gas pipeline network leakage detection method and detection system based on defect image processing. By performing grayscale processing on a plurality of consecutive real-time images of the gas pipeline, corresponding grayscale images are obtained, and the gas pipeline is preliminarily diagnosed based on adjacent grayscale images to obtain a defect image; the defect image is sequentially subjected to image enhancement processing and filtering processing, and finally an image with clear features is output, that is, an image that can effectively display the leakage position and leakage degree of the gas pipeline, so as to accurately locate and detect the leakage position and leakage degree of the gas pipeline; by using a grayscale image to preliminarily diagnose a defect image and further enhancing and filtering the defect image, the accuracy and detection efficiency of gas pipeline leakage detection can be effectively improved.

[0066] Other features and advantages of the embodiments of the present invention will be described in detail in the following specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention, and constitute a part of the specification. Together with the following specific implementation, they are used to explain the embodiments of the present invention, but do not constitute a limitation to the embodiments of the present invention. In the accompanying drawings:

[0068] Figure 1 is a flowchart of a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0069] Figure 2 is a flowchart of obtaining a defect image in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0070] Figure 3 is a flowchart of obtaining the minimum number of pixels in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0071] Figure 4 is a flowchart of obtaining the number of pixels in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0072] Figure 5 is a flowchart of diagnosing a defect image in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0073] Figure 6 is a flowchart of image equalization processing in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0074] Figure 7 is a schematic diagram of histogram equalization principle in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention;

[0075] Figure 8 is a flowchart of image filtering in a gas pipeline network leakage detection method based on defect image processing according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0076] The following will describe in detail the specific implementation of the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the embodiments of the present invention, and is not used to limit the embodiments of the present invention.

[0077] It should be noted that the acquisition, transmission, storage, use, processing, etc. of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations. In the embodiments of this application, certain existing solutions in the industry such as software, components, models, etc. may be mentioned. They should be regarded as exemplary. The purpose is only to illustrate the feasibility in the implementation of the technical solution of this application, but it does not mean that the applicant has already or necessarily used this solution.

[0078] Figure 1 is a flowchart of a gas pipeline leakage detection method based on defect image processing according to an embodiment of the present invention. In Figure 1 this method, the gas pipeline leakage detection method may include:

[0079] In step S10, a plurality of consecutive real-time images of the gas pipeline are acquired. Among them, the acquisition of real-time images of the gas pipeline may include an infrared thermal imaging camera, etc. The installation of the infrared sensor is a fixed installation and can effectively monitor the gas pipeline stably. At the same time, considering that when the gas pipeline leaks, the infrared thermal imaging camera, etc. will capture it in time. Therefore, consecutive infrared thermal imaging images of the gas pipeline can be acquired according to a preset detection frequency to achieve effective monitoring of the gas pipeline.

[0080] In step S11, the plurality of consecutive real-time images are grayscale processed to obtain corresponding grayscale images. Among them, infrared thermal imaging images are generally color images, but the complexity of color images is relatively high, and there is a large complexity and computing power when performing pixel comparison. Therefore, the color images can be grayscale processed, and the pixels after grayscaling can be processed and diagnosed.

[0081] In step S12, based on the plurality of grayscale images, a preliminary diagnosis of the gas pipeline is performed to obtain defect images. Among them, for adjacent grayscale images, the change of the gas pipeline at adjacent moments can be determined by comparing the pixel grayscale values. If the change is large, it indicates that there may be a leakage situation, that is, the corresponding defect images can be determined.

[0082] In step S13, image enhancement processing is performed on the defect images. Among them, after determining and obtaining the defect images, it is also necessary to further determine the defect / leakage position. Therefore, the defect images can be further subjected to image enhancement processing to distinguish the background and features of the images as much as possible.

[0083] In step S14, the defective image is filtered and the filtered image is output. During the process of image acquisition, more or less noise interference will occur. Therefore, it is necessary to filter the defective image. After filtering, a clearer image of the gas pipeline can be obtained. This image can further determine the defect / leakage location and leakage degree of the gas pipeline to achieve defect localization, and then output the filtered image.

[0084] In steps S10 to S14, first, a plurality of consecutive real-time images of the gas pipeline are obtained, and then the real-time images are grayscaled to obtain the corresponding grayscale images. By comparing the pixel grayscale values of the consecutive grayscale images, a defective image can be preliminarily diagnosed. After obtaining the defective image, image enhancement processing and filtering processing are performed on the defective image to strengthen the image features and remove noise, so as to locate and diagnose the defects in the defective image, significantly improving the accuracy of gas pipeline network leakage detection. And due to the effective extraction and optimization of image features in the present invention, it can capture tiny leakage signs more sensitively. For example, for early leakage features such as tiny temperature changes or extremely subtle deformations on the pipeline surface, they can be more clearly recognized by the detection algorithm after preprocessing. This helps to detect problems at the early stage of leakage, take timely measures for repair, avoid the further expansion of leakage and cause serious accidents, and reduce safety risks and economic losses. In addition, the optimized image preprocessing process can quickly process a large amount of image data and reduce the processing time. For example, by using efficient parallel computing technology or optimized algorithm structures, the image processing speed can be increased without reducing the processing quality. This enables more rapid completion of image acquisition and analysis during large-area inspection of the gas pipeline network, timely discovery of potential leakage points, improvement of inspection efficiency, and saving of labor and time costs.

[0085] Traditional gas pipeline network images may be affected by various factors and have poor quality, making the features of the pipeline and the surrounding environment blurred. These low-quality images directly affect the accuracy and efficiency of subsequent leakage detection. In this embodiment of the present invention, by using grayscale images to preliminarily diagnose defective images and further enhancing and filtering the defective images, the accuracy and efficiency of gas pipeline leakage detection can be effectively improved. At the same time, it overcomes the limitations of traditional detection technologies, improves the image quality, enhances the feature extraction effect, so as to achieve early and accurate detection of gas pipeline network leakage, ensure the safe operation of the gas pipeline network, and reduce safety accidents and economic losses caused by leakage.

[0086] In this embodiment of the present invention, in order to facilitate the comparison of real-time images, it is necessary to grayscale the real-time images. Specifically, the processing steps may include:

[0087] Perform grayscale processing on the real-time image according to formula (1).

[0088] Gray(i,j) = 0.299×R(i,j) + 0.578×G(i,j) + 0.114×B(i,j), (1)

[0089] Among them, Gray(i,j) is the grayscale value of the real-time image after grayscale processing at the coordinate point (i,j), and R(i,j), G(i,j), and B(i,j) are the luminance values of the three color components of the real-time image at the coordinate point (i,j) respectively. The color value corresponding to each pixel point in a black-and-white image is called grayscale, and there are 256 gray levels in total. The maximum grayscale value is 255, representing white; the minimum grayscale value is 0, representing black. A color image contains three colors: red, green, and blue. In images with different shades of color, the proportion of each color is also different. However, in the grayscale image, one pixel point represents one color. At this time, the color change in the image is between black and white. The darker the color, the closer it is to black, and the darker it appears visually. On the contrary, the lighter the color, the closer it is to white, and the brighter it appears visually. The formula (1) of the present invention performs grayscale processing on the defective image through the weighted average method. Weighting means assigning different weights to the three components. The weights are assigned according to the acceptance degree of the human eye for colors. The acceptance degree of the eye for colors is different. Surveys show that the acceptance degree for green is the highest, so the weight assigned will also be higher when allocating weights, while the acceptance degree for blue is the lowest among the three components, so the weight assigned will be relatively lower when allocating weights.

[0090] In this embodiment of the present invention, after obtaining the grayscale image of the gas pipeline, the grayscale values of the grayscale image can be compared with the adjacent grayscale images to preliminarily determine whether there is a leakage in the current gas pipeline. Specifically, the comparison steps can be as Figure 2 shown. Specifically, in Figure 2 it, the gas pipeline leakage detection method may further include:

[0091] In step S120, obtain the standard image when the gas pipeline is operating normally and the abnormal image when the gas pipeline leaks. Among them, the standard image when the gas pipeline is operating normally and the abnormal image when it leaks can be obtained according to historical data. Specifically, since there are various forms of leakage and their manifestations on the image are also different, therefore, in order to improve the detection accuracy of the gas pipeline when it leaks, the abnormal image with the smallest change area of the abnormal part relative to the standard image can be used as the image to be compared. Specifically, the standard image and the abnormal image are the content at the same position, that is, the coordinates in the two images correspond one by one. Therefore, the present invention sets that the grayscale values of the remaining areas are equal except for the leakage area where the grayscale values change.

[0092] In step S121, the minimum pixel gray value difference and the minimum number of pixels are obtained based on the standard image and the abnormal image. Among them, when obtaining the gray images of the standard image and the abnormal image, the pixel points corresponding to the standard image and the abnormal image can be compared in terms of gray values, and the pixel points with changed gray values are selected to calculate the difference value, and then the minimum difference value and the number of difference pixels corresponding to the minimum difference value, that is, the minimum number of pixels, can be obtained.

[0093] In step S122, the gray image to be diagnosed and its adjacent gray image are obtained. Among them, the adjacent gray image of the gray image to be diagnosed can be understood as the gray image at the next moment of the gray image to be diagnosed.

[0094] In step S123, the corresponding pixel gray value difference and the number of pixels are obtained based on the gray image to be diagnosed and its adjacent gray image. Among them, by comparing the gray values of the gray image to be diagnosed and its adjacent gray image, the pixel gray value difference and the number of pixels with gray value differences can be obtained. Specifically, only the pixel region with different gray values is considered here, and the pixel gray value difference and the number of pixels in this region are obtained.

[0095] In step S124, a defect image is obtained for the gray image to be diagnosed and its adjacent gray image according to the minimum number of pixels and the number of pixels. Among them, after obtaining the number of difference pixels between the current gray image and the adjacent gray image, comparing it with the minimum number of pixels can determine whether there is a leak in the current gas pipeline.

[0096] In steps S120 to S124, first, the standard image and the abnormal image when the gas pipeline is operating normally are obtained. After obtaining the gray images of the two, the gray value difference is calculated to obtain the minimum pixel gray value difference and the minimum number of pixels. Similarly, the gray value difference of the current gray image to be diagnosed and its adjacent gray image is calculated to obtain the pixel gray value difference and the number of pixels of the current gray image to be diagnosed. Finally, by comparing the number of pixels of the current gray image to be diagnosed with the minimum number of pixels, it can be determined whether there is a leakage defect in the current gray image to be diagnosed, that is, a defect image can be obtained.

[0097] In a gas pipeline network, the proportion of images with defects is very small. To reduce the workload and improve the detection efficiency, the present invention first preliminarily determines which images contain defects, and then performs subsequent segmentation and recognition on the selected suspected defects. For an image with a defect, its gray value distribution will be uneven, while the gray value distribution of a pipeline image without a defect is relatively uniform. When taking consecutive photos, the gray value distributions of two adjacent images should be at the same level or very similar. Therefore, to quickly screen out images with defects, it is only necessary to compare the gray distribution of the image to be judged with the two adjacent images. Because the gray distributions of images taken under the same conditions are uniform, if there is an obvious change in the gray value of the image, there may be a defect.

[0098] In this embodiment of the present invention, after obtaining the standard image and the abnormal image, the minimum difference value of the pixel gray values in the abnormal area and the corresponding minimum number of pixels can be obtained. The specific obtaining steps can be as Figure 3 shown. Specifically, in Figure 3 , this gas pipeline network leakage detection method may further include:

[0099] In step S1210, the minimum difference value of the pixel gray values is obtained according to formula (2),

[0100] Δ min =min|a 1(i,j) -a 2(i,j) |, (2)

[0101] where, Δ min is the minimum difference value of the pixel gray values, a 1(i,j) is the gray value of the coordinate point (i, j) in the standard image, and a 2(i,j) is the gray value of the coordinate point (i, j) in the abnormal image. Specifically, for pixel gray values that are the same, it is not considered that there is a difference between the two, that is, the calculated gray difference value here refers to the calculation of the gray values with differences. The same applies hereinafter.

[0102] In step S1211, the minimum number of pixels in the abnormal image whose pixel gray difference from the standard image is greater than or equal to the minimum difference value of the pixel gray values is obtained. Among them, the abnormal area formed by the leakage defect is generally relatively concentrated, that is, concentrated at the leakage position.

[0103] In this embodiment of the present invention, for the preliminary diagnosis of gas pipeline defects, it can also be obtained by calculating the gray difference between the gray image of the current gas pipeline and the adjacent gray images. The specific steps can be as Figure 4 shown. Specifically, in Figure 4 , this gas pipeline network leakage detection method may further include:

[0104] In step S1230, the pixel gray - level difference value is obtained according to formula (3).

[0105] Δ t =|a x·k -a y·k |, (3)

[0106] Where, Δ t is the pixel gray - level difference value between the gray - level image to be diagnosed and its adjacent gray - level image, a x·k is the pixel value of the k - th coordinate on the gray - level image to be diagnosed, a y·k is the pixel value of the k - th coordinate on the gray - level image adjacent to the gray - level image to be diagnosed, and k is an integer number. Specifically, for the calculation of the pixel gray - level difference value, the above - mentioned calculation of the gray - level value of a single pixel point can be used, or the average gray - level difference of two images can be obtained according to formula (7).

[0107]

[0108] Where, Δ var is the average gray - level difference of two images, S n is the number of pixel points with different gray - level values or the total number of pixel points in two images, and n is the total number of pixel points in the image. Specifically, the above - mentioned mean - value calculation method can effectively determine the abnormal area of two images, that is, if the average pixel gray - level difference of two images is large, it can be determined that there are defective images in the two images, otherwise they are all normal images.

[0109] In step S1231, the number of pixels whose pixel gray - level difference between the gray - level image to be diagnosed and its adjacent gray - level image is greater than or equal to the minimum pixel gray - level difference value is obtained.

[0110] In this embodiment of the present invention, after obtaining the minimum number of pixels and the number of pixels, preliminary defect diagnosis can be performed on the two currently adjacent images. The specific steps can be as Figure 5 shown. Specifically, in Figure 5 , this gas pipeline leakage detection method may further include:

[0111] In step S1240, it is judged whether the number of pixels is greater than or equal to the minimum number of pixels.

[0112] In step S1241, when it is determined that the number of pixels is greater than or equal to the minimum number of pixels, the grayscale image to be diagnosed is determined to be a defective image. Among them, for the determination of a defective image, it is also based on the sequential relationship between the grayscale image to be diagnosed and its adjacent grayscale images. Generally, the grayscale image to be diagnosed is set in the front, and the adjacent grayscale image is set in the back to maintain the order of sequential diagnosis. Therefore, if the current number of pixels is greater than or equal to the minimum number of pixels, it can be determined that the grayscale image to be diagnosed is a defective image.

[0113] In step S1242, when it is determined that the number of pixels is less than the minimum number of pixels, the grayscale image to be diagnosed is determined not to be a defective image. Among them, if the number of pixels is less than the minimum number of pixels, it indicates that there is local interference, the gas pipeline is operating normally, and there is no leakage.

[0114] In this embodiment of the present invention, after determining the defective image, it is necessary to accurately determine the defective / leakage position and the defective / leakage degree in the defective image. Therefore, it is also necessary to perform further enhancement processing on the defective image. The purpose of image enhancement is to improve the recognizable degree of the image, distinguish the background and features of the image as much as possible, and fundamentally improve the recognition accuracy rate of the gas pipeline image. When the detection system collects the original image, due to the movement of the collection device, the captured image may be blurred or the captured image may have uneven illumination. The specific enhancement steps can be as Figure 6 shown. Specifically, in Figure 6 it, the gas pipeline network leakage detection method may include:

[0115] In step S130, obtain the histogram of the defective image. Among them,

[0116] In step S131, according to formula (4), obtain the frequency of occurrence of each gray level value in the defective image,

[0117]

[0118] where p r (r k ) is the probability of the gray level value of the k-th level in the defective image, r k is the gray level value of the k-th level, n k is the number of pixels with the gray level value r k in the defective image, N is the total number of pixels in the defective image, and k is the integer number.

[0119] In step S132, according to formula (5), obtain the cumulative histogram of each gray level value,

[0120]

[0121] where s kis the cumulative histogram of the k-th level in the defect image, p r (r j ) is the probability of the gray value of the j-th level in the defect image, and j is an integer number.

[0122] In step S133, the mapped gray level corresponding to the original gray level is obtained according to formula (6),

[0123] M k =int[(max(r k ) - min(r k )) * s k + 0.5], (6)

[0124] where M k is the mapped gray level corresponding to the k-th gray level, max(r k ) is the maximum gray value of the gray value, and min(r k ) is the minimum gray value.

[0125] In step S134, the equalized image is output according to the mapped gray level.

[0126] In steps S130 to S134, the histogram of the image plays an important role in representing the information hidden in the image and truly reflects the gray value of each pixel point in the image. According to the light and dark changes reflected by the histogram, the gray value of each pixel point is re-"shuffled" by using the equalization processing method, reducing the gray value of overexposed pixel points and pulling the pixel points with lower gray values closer to the average gray value, so that the frequency of each gray value appearing in the image is equal. Specifically, the schematic diagram of histogram equalization can be as Figure 7 shown.

[0127] In this embodiment of the present invention, during the process of collecting images, more or less noise interference will occur, so filtering operations need to be performed. The filtering operations must strictly abide by two rules: First, the edge information of the contour must be completely preserved and not be blurred or lost; Second, the quality of the original image should be improved and the image quality should not be reduced. Through the image filtering operation, not only can the redundant noise in the image be eliminated, but also the features of the image can be extracted, laying a good foundation for feature extraction. Specifically, the filtering steps can be as Figure 8 shown. In Figure 8 , this gas pipeline network leakage detection method may further include:

[0128] In step S140, an initial filtering window is obtained.

[0129] In step S141, the gray values of the pixels in the filtering window are sorted from small to large.

[0130] In step S142, it is judged whether the minimum gray value within the filtering window is less than the median value and whether the median value is less than the maximum gray value.

[0131] In step S143, when it is judged that the minimum gray value within the filtering window is less than the median value and the median value is less than the maximum gray value, the gray value of the current pixel is obtained.

[0132] In step S144, it is judged whether the gray value of the current pixel is greater than the minimum gray value and less than the maximum gray value.

[0133] In step S145, when it is judged that the gray value of the current pixel is greater than the minimum gray value and less than the maximum gray value, the gray value of the current pixel is output.

[0134] In step S146, when it is judged that the gray value of the current pixel is not greater than the minimum gray value and less than the maximum gray value, the median value is output.

[0135] In step S147, when it is judged that the minimum gray value within the filtering window is not less than the median value and the median value is less than the maximum gray value, the filtering window is increased.

[0136] In step S148, it is judged whether the current filtering window is less than or equal to the maximum window size.

[0137] In step S149, when it is judged that the current filtering window is less than or equal to the maximum window size, return to the step of sorting the gray values of the pixels within the filtering window from small to large.

[0138] In step S150, when it is judged that the current filtering window is greater than the maximum window size, the gray value of the current pixel is output.

[0139] In steps S140 to S150, first set the initial window size. Generally, a 5×5 template is selected, and the pixel gray values within the initial template are arranged in a regular order. Use the median of the pixel gray values to replace the central value of the entire template area to obtain a new window template, and traverse all areas of the image with this. Different sizes of the window template result in different filtering effects on the image. If the window size is small, although some detail information in the pipeline image can be well protected, the filtering effect is not achieved. If the window size is too large, although the filtering effect is good, the edge information in the pipeline image will be blurred and become unclear. Therefore, the above adaptive method can actively change the size of the window template according to the gray values of the noise pixels and signal pixels within the window, so that the entire image has multiple different thresholds, realizing noise removal while maintaining the gray values of the original pixel points unchanged. Through precise image denoising and enhancement algorithms, the present invention makes the edges of potential leakage areas clearer, temperature anomalies more obvious, etc., enabling subsequent image analysis and recognition algorithms to more accurately judge whether there is a leakage and the location and degree of the leakage, thus significantly improving the accuracy of gas pipeline network leakage detection. In addition, this method can adapt to different environmental conditions, such as different weather (sunny, rainy, foggy, etc.), different light intensities (strong light during the day, weak light at night, etc.) and complex backgrounds around the pipeline network (such as interference from buildings, vegetation, etc.).

[0140] On the other hand, the present invention also provides a gas pipeline network leakage detection system based on defect image processing. Specifically, the gas pipeline network leakage detection system may include an infrared thermal imaging camera and a controller. Specifically, the infrared thermal imaging camera is set near the gas pipeline for real-time shooting of the gas pipeline, and the controller is connected to the infrared thermal imaging camera and is used to execute any one of the above gas pipeline network leakage detection methods.

[0141] On yet another aspect, the present invention also provides a computer-readable storage medium. The computer-readable storage medium stores instructions that are used to be read by a machine so that the machine executes any one of the above gas pipeline network leakage detection methods.

[0142] Through the above technical solution, the present invention provides a gas pipeline leakage detection method and detection system based on defect image processing. By performing grayscale processing on a plurality of consecutive real-time images of the gas pipeline, corresponding grayscale images are obtained. Based on adjacent grayscale images, a preliminary diagnosis of the gas pipeline is carried out to obtain defect images. The defect images are sequentially subjected to image enhancement processing and filtering processing, and finally an image with clear features is output, that is, an image that can effectively display the leakage position and leakage degree of the gas pipeline, so as to accurately locate and detect the leakage position and leakage degree of the gas pipeline. By using grayscale images to preliminarily diagnose defect images and further enhancing and filtering the defect images, the accuracy and detection efficiency of gas pipeline leakage detection can be effectively improved.

[0143] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0144] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0145] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means realizes the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, causing a series of operational steps to be performed on the computer or other programmable apparatus to generate a computer-implemented process, so that the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one process Figure 1 one process or a plurality of processes and / or blocks Figure 1 or steps for implementing the functions specified in a block or a plurality of blocks.

[0147] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0148] The memory may include non-permanent memory in the computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.

[0149] Computer-readable media includes both permanent and non-permanent, removable and non-removable media implemented by any method or technology for storing information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0150] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.

[0151] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A method for detecting gas pipeline network leakage based on defect image processing, characterized in that, Including: Obtaining a plurality of consecutive real-time images of a gas pipeline; Performing grayscale processing on the plurality of consecutive real-time images to obtain corresponding grayscale images; Performing preliminary diagnosis on the gas pipeline based on the plurality of grayscale images to obtain defect images; Performing image enhancement processing on the defect images; Performing filtering processing on the defect images and outputting the filtered images.

2. The gas pipeline network leakage detection method according to claim 1, characterized in that Performing grayscale processing on the plurality of consecutive real-time images includes: Performing grayscale processing on the real-time images according to formula (1), Gray(i,j) = 0.299×R(i,j) + 0.578×G(i,j) + 0.114×B(i,j), (1) where Gray(i,j) is the grayscale value after grayscale processing of the real-time image at the coordinate point (i,j), and R(i,j), G(i,j), and B(i,j) are the luminance values of the three color components of the real-time image at the coordinate point (i,j) respectively.

3. The gas pipeline network leakage detection method according to claim 1, characterized in that, Performing preliminary diagnosis on the gas pipeline based on the plurality of grayscale images includes: Obtaining a standard image when the gas pipeline operates normally and an abnormal image when the gas pipeline leaks; Obtaining the minimum pixel grayscale difference value and the minimum number of pixels according to the standard image and the abnormal image; Obtaining the grayscale image to be diagnosed and its adjacent grayscale images; Obtaining the corresponding pixel grayscale difference value and the number of pixels according to the grayscale image to be diagnosed and its adjacent grayscale images; Obtaining defect images according to the minimum number of pixels and the number of pixels for the grayscale image to be diagnosed and its adjacent grayscale images.

4. The gas pipeline network leakage detection method according to claim 3, wherein Obtaining the minimum pixel grayscale difference value and the minimum number of pixels according to the standard image and the abnormal image includes: Obtaining the minimum pixel grayscale difference value according to formula (2), Δ min = min|a 1(i,j) - a 2(i,j) |, (2) Among them, Δ min is the minimum difference value of pixel grayscale, a 1(i,j) is the grayscale value of the coordinate point (i, j) in the standard image, and a 2(i,j) is the grayscale value of the coordinate point (i, j) in the abnormal image; Obtaining the minimum number of pixels in the abnormal image whose pixel grayscale difference from the standard image is greater than or equal to the minimum pixel grayscale difference value.

5. The gas pipeline network leakage detection method according to claim 3, characterized in that Obtaining the corresponding pixel grayscale difference value and the number of pixels according to the grayscale image to be diagnosed and its adjacent grayscale images includes: Obtaining the pixel grayscale difference value according to formula (3), Δ t = |a x·k - a y·k |, (3) where, Δ t is the pixel gray level difference value between the gray scale image to be diagnosed and its adjacent gray scale images, a x·k is the pixel value at the k-th coordinate on the gray scale image to be diagnosed, a y·k is the pixel value at the k-th coordinate on the gray scale image adjacent to the gray scale image to be diagnosed, and k is an integer number; Obtaining the number of pixels in the grayscale image to be diagnosed and its adjacent grayscale images whose pixel grayscale difference is greater than or equal to the minimum pixel grayscale difference value.

6. The gas pipeline network leakage detection method according to claim 3, wherein Obtaining defect images according to the minimum number of pixels and the number of pixels for the grayscale image to be diagnosed and its adjacent grayscale images includes: Judging whether the number of pixels is greater than or equal to the minimum number of pixels; When judging that the number of pixels is greater than or equal to the minimum number of pixels, determining that the grayscale image to be diagnosed is a defect image; When judging that the number of pixels is less than the minimum number of pixels, determining that the grayscale image to be diagnosed is not a defect image.

7. The gas pipeline network leakage detection method according to claim 1, characterized in that, Performing image enhancement processing on the defect images includes: Obtaining the histogram of the defect image; Obtaining the frequency of occurrence of each grayscale value in the defect image according to formula (4), where p r (r k ) is the probability of the gray value at the k-th level in the defect image, r k is the gray value at the k-th level, n k is the number of pixels with the gray value r k in the defect image, N is the total number of pixels in the defect image, and k is an integer number; Obtaining the cumulative histogram of each grayscale value according to formula (5), where s k is the cumulative histogram of the k-th level in the defective image, and p r (r j ) is the probability of the gray value of the j-th level in the defective image, where j is an integer number; Obtaining the mapped grayscale level corresponding to the original grayscale level according to formula (6), M k = int[(max(r k ) - min(r k )) * s k + 0.5], (6) Among them, M k is the mapped gray level corresponding to the k-th gray level, max(r k ) is the maximum gray value of the gray value, min(r k ) is the minimum gray value; Outputting the equalized image according to the mapped grayscale level.

8. The gas pipeline network leakage detection method according to claim 1, characterized in that Filtering the defective image includes: Obtaining an initial filtering window; Sorting the gray values of the pixels within the filtering window from smallest to largest; Judging whether the minimum gray value within the filtering window is less than the median and whether the median is less than the maximum gray value; When it is judged that the minimum gray value within the filtering window is less than the median and the median is less than the maximum gray value, obtaining the gray value of the current pixel; Judging whether the gray value of the current pixel is greater than the minimum gray value and less than the maximum gray value; When it is judged that the gray value of the current pixel is greater than the minimum gray value and less than the maximum gray value, outputting the gray value of the current pixel; When it is judged that the gray value of the current pixel is not greater than the minimum gray value and less than the maximum gray value, outputting the median; When it is judged that the minimum gray value within the filtering window is not less than the median and the median is less than the maximum gray value, increasing the filtering window; Judging whether the current filtering window is less than or equal to the maximum window size; When it is judged that the current filtering window is less than or equal to the maximum window size, returning to the step of sorting the gray values of the pixels within the filtering window from smallest to largest; When it is judged that the current filtering window is greater than the maximum window size, outputting the gray value of the current pixel.

9. A gas pipeline network leakage detection system based on defect image processing, characterized in that, Including: An infrared thermal imaging camera, arranged near the gas pipeline, for performing real-time shooting on the gas pipeline; A controller, connected to the infrared thermal imaging camera, for executing the gas pipeline network leakage detection method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions, and the instructions are used to be read by a machine so that the machine executes the gas pipeline network leakage detection method according to any one of claims 1-8.