A pipe wall image defect detection method and device based on numerical analysis

Through numerical analysis, the pipe wall boundary of the pump pipe is detected directly, and the inner diameter and outer diameter length are solved, which solves the problems of low accuracy and sensitivity to light changes in the traditional method, and achieves efficient and stable pipe wall image defect detection.

CN118691614BActive Publication Date: 2025-01-07XIDIAN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411176151.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2025-01-07
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

Traditional methods have low accuracy, slow efficiency when detecting pump tube sizes, and are sensitive to light changes and noise, resulting in unstable detection results.

Method used

Using the tube wall image defect detection method based on numerical analysis, the pixel matrix is ​​constructed by acquiring images and preprocessing them into grayscale images, numerical analysis is carried out to detect the tube wall boundary coordinates, determine the inner diameter and outer diameter length, and directly obtain the defect detection result. Filter and threshold processing are omitted.

Benefits of technology

It improves detection accuracy and speed, reduces calculation costs, reduces the impact of light and noise on the results, and achieves more stable detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118691614B_ABST
    Figure CN118691614B_ABST
Patent Text Reader

Abstract

The present invention discloses a pipe wall image defect detection method and device based on numerical analysis, the method comprising: obtaining an image of a pipe to be detected; preprocessing the image to obtain a grayscale image; constructing a pixel matrix matching the size of the grayscale image; the pixel matrix stores the pixel values ​​and coordinates of each pixel point in the grayscale image; by numerically analyzing the pixel matrix, detecting the pipe wall boundary coordinates of the pipe to be detected to obtain multiple sets of pipe wall boundary coordinates; determining a set of length values ​​according to each set of pipe wall boundary coordinates; a set of length values ​​includes: an inner diameter length value and an outer diameter length value; determining the defect detection result of the pipe to be detected based on multiple sets of length values ​​corresponding to multiple sets of pipe wall boundary coordinates. The present invention can improve the detection accuracy and detection speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of intelligent detection, and in particular relates to a method and device for detecting pipe wall image defects based on numerical analysis. Background Art

[0002] With the development of artificial intelligence technology, the research on machine vision inspection technology has made great progress. The information of the image is collected by image acquisition devices such as cameras, and effective information is extracted by image processing technology, which replaces the human eye to make various inspections and judgments, thereby greatly improving the efficiency and automation level of inspection. Related research has also been widely used in the medical field. In the medical system, the accuracy of infusion is determined by the equipment used for infusion, and the quality of the pump tube is a key factor affecting the accuracy, pressure and life of the infusion. Among them, the dimensional accuracy of the pump tube is one of the key factors determining the quality of the pump tube. Detecting possible dimensional defects in the pump tube is crucial to improving the efficiency of infusion and the operation efficiency of the medical system. Traditional calipers or contact measurement methods cannot accurately measure the size of the pump tube, resulting in time-consuming and labor-intensive measurement of the pump tube size and low efficiency. Summary of the invention

[0003] In order to solve the above problems existing in the prior art, the present invention provides a method and device for detecting pipe wall image defects based on numerical analysis.

[0004] The technical problem to be solved by the present invention is achieved through the following technical solutions:

[0005] The present invention provides a pipe wall image defect detection method based on numerical analysis, comprising:

[0006] Acquire an image of the pipe to be inspected;

[0007] Preprocessing the image to obtain a grayscale image;

[0008] Constructing a pixel matrix matching the size of the grayscale image; the pixel matrix stores the pixel value and coordinates of each pixel point in the grayscale image;

[0009] By performing numerical analysis on the pixel matrix, the pipe wall boundary coordinates of the pipe to be detected are detected to obtain multiple sets of pipe wall boundary coordinates;

[0010] Determine a set of length values ​​according to each set of pipe wall boundary coordinates; wherein the set of length values ​​includes: an inner diameter length value and an outer diameter length value;

[0011] Based on the multiple groups of length values ​​that correspond one to one to the multiple groups of pipe wall boundary coordinates, the defect detection result of the pipe to be detected is determined.

[0012] The present invention also provides a pipe wall image defect detection device based on numerical analysis, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of the pipe wall image defect detection method based on numerical analysis when executing the program stored in the memory.

[0013] Compared with the prior art, the present invention has the following beneficial effects:

[0014] The present invention constructs a pixel matrix that matches the size of the grayscale image of the pipe fitting and stores the pixel values ​​of each pixel point in the grayscale image of the pipe fitting, and performs numerical analysis on the pixel matrix to detect the pipe wall boundary coordinates of the pipe fitting, thereby obtaining multiple sets of pipe wall boundary coordinates, and determining the inner diameter length and outer diameter length of the pipe fitting according to each set of pipe wall boundary coordinates. Thereafter, the defect detection result of the pipe fitting to be detected is determined according to the multiple sets of inner diameter lengths and outer diameter lengths that correspond one to one to the multiple sets of pipe wall boundary coordinates. Compared with the traditional method of measuring the pipe diameter using a measuring tool, not only the detection accuracy is improved, but also the detection speed is improved. Moreover, the present invention uses a numerical analysis method, omitting the steps of filter and threshold processing, thereby greatly saving the calculation cost. At the same time, the pixel-based numerical analysis method proposed by the present invention also solves the problem that the traditional method (for example, using a filter for boundary detection, using a threshold segmentation method for threshold detection, etc.) is sensitive to light, so that the change of light will not affect the analysis result of the present invention, and also solves the problem that the noise in the image affects the analysis result, so that the noise in the image will not affect the analysis result of the present invention.

[0015] The present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a flow chart of a method for detecting pipe wall image defects based on numerical analysis provided by an embodiment of the present invention;

[0017] Figure 2 It is a schematic diagram of a group of pipe wall boundary points of a pipe to be inspected provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.

[0019] Traditional edge detection methods in the field of image recognition usually have the following disadvantages:

[0020] 1) High computational cost: Traditional methods usually use a series of filters to calculate the gradient or edge response of the image. These filters need to perform convolution operations on the image, involving a large number of multiplication and addition operations. For large-sized images, the filter operation requires a lot of computing resources and time. When performing edge detection, the entire image needs to be traversed to calculate the edge response of each pixel. This means that corresponding operations need to be performed on each pixel, resulting in a linear relationship between the amount of calculation and the size of the image. For high-resolution images, the computational cost of the traversal operation will increase significantly. Traditional edge detection algorithms have high computational costs in terms of filter operations, image traversal, threshold processing, and edge connection, especially when processing large-sized images or real-time applications.

[0021] 2) Instability caused by multiple factors: Sensitive to illumination changes. When the illumination conditions of the image change, the edge detection results may be inconsistent. The strength and position of the edge may be affected by illumination changes; sensitive to noise in the image. Noise may cause the edge detection results to have wrong edges or produce too many false edges. Even if noise suppression methods are used in the preprocessing step, traditional methods still cannot completely eliminate the impact of noise; parameters need to be set manually, such as filter size, threshold, etc. Different parameter selections may lead to different edge detection results, so parameter selection is critical for stable edge detection results. However, due to the complexity and diversity of images, selecting appropriate parameters is not a simple task.

[0022] The pipe wall image defect detection method based on numerical analysis provided by the present invention uses numerical analysis to omit steps such as filters and threshold processing, thereby greatly saving computing costs. At the same time, the pixel-based numerical analysis method proposed by the present invention also solves the problem of traditional methods (for example, using filters for boundary detection, using threshold segmentation for threshold detection, etc.) being sensitive to light, so that changes in light will not affect the analysis results of the present invention. It also solves the problem of noise in the image affecting the analysis results, so that noise in the image will not affect the analysis results of the present invention, ultimately improving the detection accuracy of the pipe to be detected.

[0023] Figure 1 FIG. 1 is a flow chart of a method for detecting pipe wall image defects based on numerical analysis provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0024] S101, obtaining an image of a pipe to be inspected.

[0025] Here, the pipe to be inspected may be any pipe, for example, a hose, a hard pipe, etc., and the present invention is not limited to this.

[0026] In some embodiments, the image of the pipe to be inspected may be a global image of the pipe. In some embodiments, the image of the pipe to be inspected may also be multiple local images of the pipe, and the multiple local images are spliced ​​along the axial direction of the pipe to form a global image of the pipe. When the image of the pipe to be inspected is multiple local images of the pipe, the following S102 to S106 are the processing of each of the multiple local images.

[0027] Exemplarily, when the image of the pipe to be inspected is multiple local images of the pipe, these multiple local images can be obtained by the following method: the camera is mounted on a stepper motor, the stepper motor is fixed on a straight axis, the pipe to be inspected is placed under the camera, and the extension directions of both ends of the pipe to be inspected are parallel to the axis; the camera starts to collect local photos of the pipe to be inspected from one end of the pipe to be inspected, and the camera moves forward 2 cm for each local photo until all positions of the pipe to be inspected are captured, thereby obtaining multiple local images of the pipe to be inspected.

[0028] S102: Preprocess the image to obtain a grayscale image.

[0029] Here, the image can be Gaussian filtered first, and then the Gaussian filtered image can be converted into a grayscale image. Through Gaussian filtering, the noise generated during the acquisition or transmission of the image can be reduced, and the details and texture in the image can also be reduced to achieve a blurring effect, making the image smoother. Gaussian filtering is a commonly used linear smoothing filtering method that reduces noise and details in the image by weighted averaging the image. The filter used in Gaussian filtering is based on the Gaussian function, and a two-dimensional Gaussian kernel is used to perform a convolution operation on the image. The core idea of ​​Gaussian filtering is to replace the value of each pixel with the weighted average of its surrounding pixels, where the weight is determined by the value of the Gaussian function. The Gaussian function is a bell-shaped curve with two parameters: the center point and the standard deviation (variance). The larger the standard deviation, the flatter the Gaussian function and the wider the weight distribution. The main advantage of the Gaussian filter is that it can maintain the overall structure and edge information of the image while smoothing the image.

[0030] S103, constructing a pixel matrix that matches the size of the grayscale image; the pixel matrix stores the pixel value and coordinates of each pixel point in the grayscale image.

[0031] Here, the size of the grayscale image is the resolution of the grayscale image. For example, when the resolution of the grayscale image is 256 512, the constructed pixel matrix is ​​a two-dimensional matrix of 256 rows and 512 columns, and an element in the pixel matrix is ​​the pixel value of a pixel in the image, and the number of rows and columns of the pixel value in the pixel matrix constitute the coordinates of the pixel corresponding to the pixel value in the grayscale image, where the number of rows is the horizontal coordinate and the number of columns is the vertical coordinate. It should be noted that the coordinates of the pixel are the coordinates of the pixel in the grayscale image.

[0032] Specifically, first according to the resolution p of the grayscale image q, create an empty two-dimensional pixel matrix with p rows and q columns, then traverse each pixel of the grayscale image, and store the grayscale value of each pixel in the corresponding matrix position from left to right. After traversal and storage operations, a complete pixel matrix will be obtained, which contains the pixel values ​​of the original grayscale image and the coordinates of each pixel value.

[0033] S104 , detecting the pipe wall boundary coordinates of the pipe to be detected by numerically analyzing the pixel matrix, and obtaining multiple sets of pipe wall boundary coordinates.

[0034] S105. Determine a set of length values ​​according to each set of pipe wall boundary coordinates; wherein the set of length values ​​includes: an inner diameter length value and an outer diameter length value.

[0035] S106. Determine defect detection results of the pipe to be detected based on the multiple groups of length values ​​corresponding to the multiple groups of pipe wall boundary coordinates.

[0036] In some embodiments, the above S104 is implemented by the following steps:

[0037] S1041. During the i-th detection, obtain the i-1th row number, and determine the i-th target row number based on the i-1th row number and the preset interval value; the i-1th row number is the label of the row in the pixel matrix where a group of pixel values ​​corresponding to the i-1th group of tube wall boundary coordinates obtained in the i-1th detection are located; wherein i is a positive integer greater than 0, and when i is 1, the i-1th row number is the preset interval value.

[0038] Here, "determining the target row number for the i-th time according to the i-1th row number and the preset interval value" in S1041 specifically includes: taking the sum of the i-1th row number and the preset interval value as the target row number for the i-th time. Here, the preset interval value is a positive integer, and the preset interval value can be set according to actual needs, for example, the preset interval value can be 200.

[0039] S1042. When the i-th target row number is less than the total number of rows of the pixel matrix, a set of horizontal coordinate screening results is determined based on the i-th target row number and the pixel matrix, and the i-th group of tube wall boundary coordinates and the i-th row number are determined based on the set of horizontal coordinate screening results and a set of preset boundary coordinate ranges, and this cycle is iterated until multiple sets of tube wall boundary coordinates are obtained.

[0040] The above-mentioned “determining a set of horizontal coordinate screening results based on the target row number and pixel matrix for the i-th time” in S1042 is implemented by the following steps:

[0041] S10, taking the four smallest grayscale values ​​in the pixel values ​​of the target row number of the pixel matrix as four initial peaks; the horizontal coordinates corresponding to the four initial peaks increase in sequence.

[0042] Here, the magnitude relationship of the abscissas of the four initial peaks is: the fourth initial peak>the third initial peak>the second initial peak>the first initial peak.

[0043] S11. Determine a horizontal coordinate search range according to the horizontal coordinate of each initial peak and a preset radius, and obtain four horizontal coordinate search ranges corresponding to the four initial peaks.

[0044] Here, the preset radius is a preset positive integer L, and the value of L can be set according to actual needs, which is not limited in the present invention.

[0045] Here, for the first initial peak, the difference between the horizontal coordinate of the first initial peak and the preset radius is used as the lower limit value of a horizontal coordinate search range corresponding to the first initial peak, and the horizontal coordinate of the first initial peak is used as the upper limit value of a horizontal coordinate search range corresponding to the first initial peak; for example, when the horizontal coordinate of the first initial peak is start1, and the preset radius is L, then the horizontal coordinate search range corresponding to the first initial peak is (start1-L, start1). For the second initial peak, the sum of the horizontal coordinate of the second initial peak and the preset radius is used as the upper limit value of a horizontal coordinate search range corresponding to the second initial peak, and the horizontal coordinate of the second initial peak is used as the lower limit value of a horizontal coordinate search range corresponding to the second initial peak; for example, when the horizontal coordinate of the second initial peak is start2, and the preset radius is L, then the horizontal coordinate search range corresponding to the second initial peak is (start2, start2+L). For the third initial peak, the difference between the abscissa of the third initial peak and the preset radius is used as the lower limit value of a abscissa search range corresponding to the third initial peak, and the abscissa of the third initial peak is used as the upper limit value of a abscissa search range corresponding to the third initial peak; for example, when the abscissa of the third initial peak is start3, and the preset radius is L, then the abscissa search range corresponding to the third initial peak is (start3-L, start3). For the fourth initial peak, the sum of the abscissa of the fourth initial peak and the preset radius is used as the upper limit value of a abscissa search range corresponding to the fourth initial peak, and the abscissa of the fourth initial peak is used as the lower limit value of a abscissa search range corresponding to the fourth initial peak; for example, when the abscissa of the fourth initial peak is start4, and the preset radius is L, then the abscissa search range corresponding to the fourth initial peak is (start4, start4+L).

[0046] S12. Filter the horizontal coordinates from each horizontal coordinate search range according to the four score functions and the pixel matrix to obtain four horizontal coordinate filtering results corresponding to the four horizontal coordinate search ranges; the four horizontal coordinate filtering results are a group of horizontal coordinate filtering results.

[0047] In the present invention, the first score function among the four score functions is used to calculate the common score value of three consecutive horizontal coordinates within the first horizontal coordinate search range corresponding to the first initial peak. Exemplarily, the expression of the first score function is: ,in, Indicates the first of three consecutive horizontal coordinates. Indicates the second horizontal coordinate of three consecutive horizontal coordinates. Indicates the third horizontal coordinate of three consecutive horizontal coordinates. represents the first score function, Indicates taking the absolute value.

[0048] The second score function among the four score functions is used to calculate the common score value of three consecutive horizontal coordinates within the second horizontal coordinate search range corresponding to the second initial peak. Exemplarily, the expression of the second score function is: , represents the second score function.

[0049] The third score function among the four score functions is used to calculate the common score value of three consecutive horizontal coordinates within the third horizontal coordinate search range corresponding to the third initial peak. Exemplarily, the expression of the third score function is: , represents the third scoring function.

[0050] The fourth score function among the four score functions is used to calculate the common score value of three consecutive horizontal coordinates within the fourth horizontal coordinate search range corresponding to the fourth initial peak. Exemplarily, the expression of the fourth score function is: , Represents the fourth scoring function.

[0051] Specifically, S12 is implemented by the following steps:

[0052] S121. For the nth horizontal coordinate retrieval range corresponding to the nth initial peak, when the jth score is calculated, in the nth horizontal coordinate retrieval range, starting with the third horizontal coordinate selected when the j-1th score is calculated, three consecutive horizontal coordinates are selected after a horizontal interval of m horizontal coordinates; n is a positive integer, and the value of n is 1 to 4; j is a positive integer greater than 0; m is a preset integer.

[0053] Here, the value of m can be set according to actual needs, for example, m can be 10, which is not limited in the present invention. For example, when a horizontal coordinate search range has 200 rows, each row has 100 horizontal coordinates, m is 10, and the third horizontal coordinate selected in the j-1th score calculation is the third horizontal coordinate of the second row in the horizontal coordinate search range, then the three consecutive horizontal coordinates selected in the jth score calculation are the 14th, 15th and 16th horizontal coordinates of the second row in the horizontal coordinate search range.

[0054] S122. Substitute the selected three horizontal coordinates into the nth score function corresponding to the nth initial peak to obtain the jth score value, and then continue the j+1th score calculation, and iterate until the last three consecutive horizontal coordinates are taken from the nth horizontal coordinate retrieval range, and J score values ​​are obtained; wherein each score value corresponds to 3 consecutive horizontal coordinates.

[0055] For example, for the first initial peak, substitute the three selected horizontal coordinates into the first score function Calculate the common score of these three horizontal coordinates; for the second initial peak, substitute the selected three horizontal coordinates into the second score function The common score of these three horizontal axes is calculated.

[0056] Here, after obtaining the j-th score value, return to the above S121, and continue to iterate according to the steps described in S121~S122 until the last three consecutive horizontal coordinates are taken from the n-th horizontal coordinate search range, and J score values ​​are obtained.

[0057] S123. Use the second horizontal coordinate of the three consecutive horizontal coordinates corresponding to the largest score value among the J score values ​​as a horizontal coordinate screening result.

[0058] In the present invention, the four horizontal coordinate screening results correspond to the four boundary coordinate ranges. Each boundary coordinate range can be determined based on a preset reference value and a preset boundary range value k. The reference value can be an empirical value obtained by pre-analyzing the images of other pipes to be inspected. For example, for the first boundary coordinate range corresponding to the first horizontal coordinate screening result, the first boundary coordinate range can be determined based on the empirical value s1 and the preset boundary range value k. Exemplarily, the first boundary coordinate range corresponding to the first horizontal coordinate screening result is (s1-k, s1+k); for the second boundary coordinate range corresponding to the second horizontal coordinate screening result, the second boundary coordinate range can be determined based on the empirical value s2 and the preset boundary range value k. Exemplarily, the second boundary coordinate range corresponding to the second horizontal coordinate screening result is (s2-k, s2+k); for the third boundary coordinate range corresponding to the third horizontal coordinate screening result, the third boundary coordinate range can be determined based on the empirical value s3 and the preset boundary range value k. Exemplarily, the third boundary coordinate range corresponding to the third horizontal coordinate screening result is (s3-k, s3+k); for the fourth boundary coordinate range corresponding to the fourth horizontal coordinate screening result, the fourth boundary coordinate range can be determined based on the empirical value s4 and the preset boundary range value k. Exemplarily, the fourth boundary coordinate range corresponding to the fourth horizontal coordinate screening result is (s4-k, s4+k).

[0059] The above-mentioned step of “determining the i-th group of pipe wall boundary coordinates and the i-th row number based on a set of horizontal coordinate screening results and a set of preset boundary coordinate ranges” in S1042 is implemented by the following steps:

[0060] S20. When each horizontal coordinate screening result belongs to a corresponding boundary coordinate range, the target row number of the i-th time is taken as the i-th row number, and the vertical coordinates of the four horizontal coordinate screening results are found out from the pixel matrix, and four coordinates are obtained according to the four horizontal coordinate screening results and the vertical coordinates of the four horizontal coordinate screening results, and the four coordinates are taken as the i-th group of tube wall boundary coordinates.

[0061] Here, a horizontal coordinate screening result and the vertical coordinate of the horizontal coordinate screening result form a coordinate. Among the four coordinates obtained, the horizontal coordinate of the first coordinate is the smallest, the horizontal coordinate of the fourth coordinate is the largest, the horizontal coordinate of the second coordinate is greater than the horizontal coordinate of the first coordinate, and the horizontal coordinate of the third coordinate is greater than the horizontal coordinate of the second coordinate. Therefore, if Figure 2 As shown in FIG. 1 , the portion enclosed by the dotted line is the region where the pipe to be detected is located in the image of the pipe to be detected. When the i-th row number is the 2000th row, Figure 2 The four black dots in are the four boundary points corresponding to the four coordinates obtained. From left to right, the first black dot corresponding to the first coordinate and the fourth black dot corresponding to the fourth coordinate are the two boundary points of the outer wall of the pipe to be tested. In addition, the first black dot is the left boundary point of the outer wall of the pipe to be tested, and the fourth black dot is the right boundary point of the outer wall of the pipe to be tested. The distance between the left boundary point and the right boundary point of the outer wall is the outer diameter. Figure 2 As shown, the second black dot corresponding to the second coordinate and the third black dot corresponding to the third coordinate are two boundary points of the inner wall of the pipe to be inspected, and the second black dot is the left boundary point of the inner wall of the pipe to be inspected, and the third black dot is the right boundary point of the inner wall of the pipe to be inspected, and the distance between the left boundary point and the right boundary point of the inner wall is the inner diameter.

[0062] S21. When at least one horizontal coordinate screening result does not belong to a corresponding boundary coordinate range, the i-th target row number is increased by 1 to obtain an updated i-th target row number. When the updated i-th target row number is less than the total number of rows of the pixel matrix, a group of horizontal coordinate screening results is re-determined based on the updated i-th target row number and the pixel matrix, and it is continuously determined whether each re-determined horizontal coordinate screening result belongs to a corresponding boundary coordinate range, and this cycle is iterated until the i-th row number and the i-th group of tube wall boundary coordinates are obtained.

[0063] Here, when a horizontal coordinate screening result does not belong to a corresponding boundary coordinate range, the i-th target row number is increased by 1 to obtain an updated i-th target row number. Then, a set of horizontal coordinate screening results is re-determined according to the principles described in S10~S12. Then, the execution is continued according to the principles described in S20~S21, and the cycle is iterated until the i-th row number and the i-th group of tube wall boundary coordinates are obtained. Exemplarily, when i is 200, when one of the four horizontal coordinate screening results determined according to the elements of the 200th row does not fall within a corresponding boundary coordinate range, the four horizontal coordinate screening results are continued to be determined according to the elements of the 201st row, and when one of the determined four horizontal coordinate screening results does not fall within a corresponding boundary coordinate range, the four horizontal coordinate screening results are continued to be determined according to the elements of the 202nd row, and so on, until the four horizontal coordinate screening results determined according to the elements of a certain row all fall within a corresponding boundary coordinate range, the row number of the row is taken as the i-th row number, and the i-th group of tube wall boundary coordinates is obtained based on the four horizontal coordinate screening results.

[0064] In some embodiments, the above S105 is implemented by the following steps:

[0065] S1051. Use the first coordinate and the fourth coordinate of the four coordinates as the two boundary coordinates of the outer wall of the pipe to be inspected, and use the second coordinate and the third coordinate of the four coordinates as the two boundary coordinates of the inner wall of the pipe to be inspected; wherein, from the first coordinate to the fourth coordinate, the horizontal coordinates of the four coordinates increase successively.

[0066] S1052. Subtract the horizontal coordinates of the two boundary coordinates of the outer wall of the pipe to be inspected to obtain an outer diameter length.

[0067] S1053. Subtract the horizontal coordinates of the two boundary coordinates of the inner wall of the pipe to be inspected to obtain an inner diameter length.

[0068] In some embodiments, the above S106 is implemented by the following steps:

[0069] S1061. Calculate the mean and standard deviation of the inner diameter length values ​​in the multiple groups of length values ​​corresponding to the multiple groups of pipe wall boundary coordinates, and obtain a first mean and a first standard deviation.

[0070] Here, the mean of the inner diameter length values ​​among the multiple groups of length values ​​corresponding to the multiple groups of tube wall boundary coordinates is calculated, and the obtained mean is recorded as the first mean, and the standard deviation of the inner diameter length values ​​among the multiple groups of length values ​​corresponding to the multiple groups of tube wall boundary coordinates is calculated, and the obtained standard deviation is recorded as the first standard deviation.

[0071] S1062. Calculate the mean and standard deviation of the outer diameter length values ​​in the multiple groups of length values ​​to obtain a second mean and a second standard deviation.

[0072] Here, the mean of the outer diameter length values ​​among the multiple groups of length values ​​corresponding to the multiple groups of tube wall boundary coordinates is calculated, and the obtained mean is recorded as the second mean, and the standard deviation of the outer diameter length values ​​among the multiple groups of length values ​​corresponding to the multiple groups of tube wall boundary coordinates is calculated, and the obtained standard deviation is recorded as the second standard deviation.

[0073] S1063. When the first mean satisfies the first preset condition, the second mean satisfies the second preset condition, the first standard deviation satisfies the third preset condition, and the second standard deviation satisfies the fourth preset condition, a defect detection result is obtained, indicating that the pipe diameter size of the pipe to be detected is free of defects.

[0074] S1064. When at least one of the first mean, the first standard deviation, the second mean, and the second standard deviation does not satisfy a corresponding preset condition, a defect detection result is obtained, indicating that the pipe diameter size of the pipe to be detected is defective.

[0075] Here, the first preset condition, the second preset condition, the third preset condition and the fourth preset condition can be set according to actual needs, and the present invention is not limited to this.

[0076] In some embodiments, the first preset condition is a preset first mean threshold, the second preset condition is a preset second mean threshold, the third preset condition is a preset first standard deviation threshold, and the fourth preset condition is a preset second standard deviation threshold. Accordingly, when the first mean is less than or equal to the preset first mean threshold, the second mean is less than or equal to the preset second mean threshold, the first standard deviation is less than or equal to the preset first standard deviation threshold, and the second standard deviation is less than or equal to the preset second standard deviation threshold, a defect detection result is obtained that characterizes that the pipe diameter size of the pipe to be inspected is free of defects; otherwise, a defect detection result is obtained that characterizes that the pipe diameter size of the pipe to be inspected is defective.

[0077] In some embodiments, the first preset condition is a preset first numerical range, the second preset condition is a preset second numerical range, the third preset condition is a preset third numerical range, and the fourth preset condition is a preset fourth numerical range. Accordingly, when the first mean belongs to the preset first numerical range, the second mean belongs to the preset second numerical range, the first standard deviation belongs to the preset third numerical range, and the second standard deviation belongs to the preset fourth numerical range, a defect detection result is obtained that characterizes that the pipe diameter size of the pipe to be inspected is free of defects; otherwise, a defect detection result is obtained that characterizes that the pipe diameter size of the pipe to be inspected is defective.

[0078] In the boundary recognition part of the image, the present invention has stronger adaptability to pictures taken under different lighting conditions, gradually expands from the local optimal solution to the global optimal solution, and ensures the accuracy and continuity of the boundary.

[0079] Compared with the existing methods, the present invention has the following advantages:

[0080] 1. Threshold segmentation is sensitive to changes in illumination in the image. If the illumination of the image is uneven or there are shadows, threshold segmentation may not accurately identify the boundaries of the image. In different areas of the image, the illumination conditions may cause differences in the grayscale values ​​of pixels, which will interfere with the results of threshold segmentation. However, the present invention is based on numerical analysis, and different illumination only changes the grayscale value of the image, which will not affect the analysis results of the present invention. The present invention can still better identify the boundary position of the image.

[0081] 2. Threshold segmentation faces challenges when processing images containing multiple targets. If there are multiple targets in the image and their grayscale values ​​are similar near the threshold, for example, when the grayscale values ​​near the tube wall are relatively close, using a single threshold for segmentation cannot accurately separate them. The present invention obtains boundary information based on numerical analysis, and then screens the coordinates based on the preset boundary information, which can more accurately find the boundary location.

[0082] 3. Determining the appropriate threshold is a key step in threshold segmentation. Selecting an appropriate threshold is usually a subjective process and needs to be adjusted according to the specific application. Different images may require different threshold selection methods, which increases the difficulty of threshold segmentation. An unreasonable threshold cannot distinguish the tube wall from the shadow part. The present invention does not require the selection of a threshold, thus avoiding the subjective errors caused by manual threshold determination.

[0083] The present invention also provides a pipe wall image defect detection device based on numerical analysis, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of the above-mentioned pipe wall image defect detection method based on numerical analysis when executing the program stored in the memory.

[0084] It should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0085] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification.

[0086] In the specification, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality of components. Certain measures are recorded in different embodiments, but this does not mean that these measures cannot be combined to produce good effects.

[0087] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.

Claims

1. A method for detecting pipe wall defects based on numerical analysis, characterized in that: include: Acquire an image of the pipe to be inspected; Preprocessing the image to obtain a grayscale image; Constructing a pixel matrix matching the size of the grayscale image; The pixel matrix stores the pixel value and coordinates of each pixel point in the grayscale image; the coordinates of each pixel point include: a horizontal coordinate and a vertical coordinate; In the i-th detection, the i-1th row number is obtained, and the i-th target row number is determined according to the i-1th row number and the preset interval value; the i-1th row number is the number of the row in the pixel matrix where a group of pixel values ​​corresponding to the i-1th group of tube wall boundary coordinates obtained in the i-1th detection are located; wherein i is a positive integer greater than 0, and when i is 1, the i-1th row number is the preset interval value; When the target row number of the i-th time is less than the total number of rows of the pixel matrix, four smallest grayscale values ​​among the pixel values ​​of the target row number of the pixel matrix are used as four initial peaks; the horizontal coordinates corresponding to the four initial peaks increase in sequence; Determine a horizontal coordinate search range according to the horizontal coordinate of each initial peak and a preset radius, and obtain four horizontal coordinate search ranges corresponding to the four initial peaks one by one; According to the four score functions and the pixel matrix, a horizontal coordinate is screened from each horizontal coordinate search range to obtain four horizontal coordinate screening results corresponding to the four horizontal coordinate search ranges, wherein the four horizontal coordinate screening results form a group of horizontal coordinate screening results; Based on the set of horizontal coordinate screening results and a set of preset boundary coordinate ranges, determine the i-th set of tube wall boundary coordinates and the i-th row number, and repeat the process in this way until multiple sets of tube wall boundary coordinates are obtained; Determine a set of length values ​​according to each set of pipe wall boundary coordinates; wherein the set of length values ​​includes: an inner diameter length value and an outer diameter length value; Based on the multiple groups of length values ​​that correspond one to one to the multiple groups of pipe wall boundary coordinates, the defect detection result of the pipe to be detected is determined.

2. The method for detecting pipe wall defects based on numerical analysis according to claim 1, characterized in that: The first score function among the four score functions is used to calculate the common score value of three consecutive horizontal coordinates within the first horizontal coordinate search range corresponding to the first initial peak, and the first horizontal coordinate search range is a horizontal coordinate range with the horizontal coordinate of the first initial peak as the upper limit value and the difference between the horizontal coordinate of the first initial peak and the preset radius as the lower limit value; The second score function is used to calculate the common score value of three consecutive horizontal coordinates within the second horizontal coordinate search range corresponding to the second initial peak, wherein the second horizontal coordinate search range is a horizontal coordinate range with the horizontal coordinate of the second initial peak as the lower limit value and the sum of the horizontal coordinate of the second initial peak and the preset radius as the upper limit value; The third score function is used to calculate the common score value of three consecutive horizontal coordinates within the third horizontal coordinate search range corresponding to the third initial peak, wherein the third horizontal coordinate search range is a horizontal coordinate range with the horizontal coordinate of the third initial peak as the upper limit and the difference between the horizontal coordinate of the third initial peak and the preset radius as the lower limit; The fourth scoring function is used to calculate the common score value of three consecutive horizontal coordinates within the fourth horizontal coordinate retrieval range corresponding to the fourth initial peak, and the fourth horizontal coordinate retrieval range is a horizontal coordinate range with the horizontal coordinate of the fourth initial peak as the lower limit value and the sum of the horizontal coordinate of the fourth initial peak and the preset radius as the upper limit value.

3. The method for detecting pipe wall defects based on numerical analysis according to claim 1, characterized in that: The method of screening abscissas from each abscissa search range according to the four score functions and the pixel matrix to obtain four abscissa screening results corresponding to the four abscissa search ranges includes: For the nth horizontal coordinate search range corresponding to the nth initial peak, when the jth score is calculated, in the nth horizontal coordinate search range, starting from the third horizontal coordinate selected when the j-1th score is calculated, 3 consecutive horizontal coordinates are selected after a horizontal interval of m horizontal coordinates; n is a positive integer, and the value of n is 1 to 4; j is a positive integer greater than 0; m is a preset integer; Substituting the selected three horizontal coordinates into the nth score function corresponding to the nth initial peak value, obtaining the jth score value, and then continuing the j+1th score calculation, and iterating in this way until the last three consecutive horizontal coordinates are taken from the nth horizontal coordinate search range, and J score values ​​are obtained; wherein each score value corresponds to three consecutive horizontal coordinates; The second horizontal coordinate of the three consecutive horizontal coordinates corresponding to the largest score value among the J score values ​​is used as a horizontal coordinate screening result.

4. The method for detecting pipe wall defects based on numerical analysis according to claim 2, characterized in that: The calculation formulas of the four score functions are as follows: Among them, x1 represents the first horizontal coordinate of the three consecutive horizontal coordinates, x2 represents the second horizontal coordinate of the three consecutive horizontal coordinates, x3 represents the third horizontal coordinate of the three consecutive horizontal coordinates, S1(x) represents the first scoring function, S2(x) represents the second scoring function, S3(x) represents the third scoring function, S4(x) represents the fourth scoring function, and |.| represents taking the absolute value.

5. The method for detecting pipe wall defects based on numerical analysis according to claim 1, characterized in that: The set of preset boundary coordinate ranges includes: four boundary coordinate ranges, and the four horizontal coordinate screening results correspond to the four boundary coordinate ranges one by one; the determining the i-th group of pipe wall boundary coordinates and the i-th row number based on the set of horizontal coordinate screening results and the set of preset boundary coordinate ranges includes: When each horizontal coordinate screening result belongs to a corresponding boundary coordinate range, the target row number of the i-th time is used as the i-th row number, and the vertical coordinates of the four horizontal coordinate screening results are found from the pixel matrix, and four coordinates are obtained according to the four horizontal coordinate screening results and the vertical coordinates of the four horizontal coordinate screening results, and the four coordinates are used as the i-th group of tube wall boundary coordinates; When at least one horizontal coordinate screening result does not fall within a corresponding boundary coordinate range, the i-th target row number is increased by 1 to obtain an updated i-th target row number. When the updated i-th target row number is less than the total number of rows of the pixel matrix, a group of horizontal coordinate screening results is re-determined based on the updated i-th target row number and the pixel matrix, and it is continuously determined whether each re-determined horizontal coordinate screening result falls within a corresponding boundary coordinate range. This cycle is iterated until the i-th row number and the i-th group of tube wall boundary coordinates are obtained.

6. The method for detecting pipe wall defects based on numerical analysis according to claim 1, characterized in that: Each set of pipe wall boundary coordinates includes: four coordinates, and each coordinate includes: a horizontal coordinate and a vertical coordinate; according to each set of pipe wall boundary coordinates, a set of length values ​​is determined, including: The first coordinate and the fourth coordinate of the four coordinates are used as two boundary coordinates of the outer wall of the pipe to be detected, and the second coordinate and the third coordinate of the four coordinates are used as two boundary coordinates of the inner wall of the pipe to be detected; wherein, from the first coordinate to the fourth coordinate, the horizontal coordinates of the four coordinates increase in sequence; Subtracting the horizontal coordinates of two boundary coordinates of the outer wall of the pipe to be inspected to obtain an outer diameter length; The horizontal coordinates of the two boundary coordinates of the inner wall of the pipe to be inspected are subtracted to obtain an inner diameter length.

7. The method for detecting pipe wall defects based on numerical analysis according to claim 1, characterized in that: The step of determining the defect detection result of the pipe to be inspected based on the multiple groups of length values ​​corresponding to the multiple groups of pipe wall boundary coordinates in a one-to-one manner comprises: Calculating the mean and standard deviation of the inner diameter length values ​​in the multiple groups of length values ​​corresponding to the multiple groups of tube wall boundary coordinates one by one, to obtain a first mean and a first standard deviation; Calculating the mean and standard deviation of the outer diameter length values ​​in the plurality of groups of length values ​​to obtain a second mean and a second standard deviation; When the first mean satisfies a first preset condition, the second mean satisfies a second preset condition, the first standard deviation satisfies a third preset condition, and the second standard deviation satisfies a fourth preset condition, a defect detection result is obtained indicating that the pipe diameter size of the pipe to be detected is free of defects; When at least one of the first mean, the first standard deviation, the second mean and the second standard deviation does not satisfy a corresponding preset condition, a defect detection result indicating that the pipe diameter size of the pipe to be detected is defective is obtained.

8. A pipe wall image defect detection device based on numerical analysis, comprising a processor, a communication interface, a memory and a communication bus, characterized in that: The processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the method steps described in any one of claims 1-7 when executing the program stored in the memory.