Defective image determination method, device and electronic equipment

Through image acquisition and quality assessment algorithms, the signal-to-noise ratio and structural similarity are calculated, and defect images that meet the standards are output, which solves the problems of low manual identification efficiency and unstable accuracy in pipeline inspection, and improves the quality and detection efficiency of defect images. .

CN118505711BActive Publication Date: 2024-10-18POWERCHINA HUADONG ENG CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410979007.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-10-18
Estimated Expiration
2044-07-22

AI Technical Summary

Technical Problem

The existing technology relies on manual identification in pipeline defect detection, which is affected by subjective judgment, low efficiency, unstable accuracy, and lacks unified standards and automated tools, resulting in poor defect image quality and low extraction efficiency.

Method used

Collect pipeline images through image acquisition equipment, perform preprocessing, grayscale processing and segmentation. Based on preset parameters and quality assessment algorithms, calculate signal-to-noise ratio, structural similarity and information entropy, and evaluate image quality through convolution operations and Euclidean distance. , output defect images that meet the standards.

Benefits of technology

It improves the quality and extraction efficiency of defect images, reduces interference from human factors, improves detection accuracy and efficiency, and meets the needs of modern industrial detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118505711B_ABST
    Figure CN118505711B_ABST
Patent Text Reader

Abstract

The present invention provides a defect image determination method, device and electronic device, including: collecting defective pipeline images and non-defective pipeline images; graying the above images to obtain a first image and a second image; segmenting the first image and the second image, and marking them to obtain a marked image; subtracting the grayscale value of the marked image and the grayscale value of the second target image at the center of the marked image and the grayscale value of the second sub-image corresponding to the marked image to obtain a difference; weighted averaging the difference to obtain an average deviation; and calculating the deviation of the marked image; calculating the distance between the deviation of the marked image and the average deviation to obtain multiple distances; determining the first target defect image of the marked image according to the multiple distances; evaluating the image quality of the first target defect image, and outputting the second target defect image that meets the preset standard in the first target defect image. The method can improve the quality of defect images and extraction efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a defective image determination method, device and electronic equipment. Background Art

[0002] In the current field of image processing technology, especially in industrial inspection such as drainage pipe defect inspection, the level of automation and intelligence still needs to be improved. Existing pipeline defect detection methods mainly rely on manual operation, which involves remotely controlling robots to move inside the pipeline, collect pipeline images, and transmit these images to ground staff in real time. Subsequently, the staff needs to manually screen the images to identify and extract the defective parts in the pipeline.

[0003] However, this method that relies on manual screening has several limitations. First, manual identification of defect images is susceptible to subjective judgment, which may lead to unstable quality of defect images and affect the accuracy of subsequent analysis and processing. Second, the manual screening process is time-consuming and labor-intensive, with low efficiency, and it is difficult to meet large-scale or emergency inspection needs. In addition, due to the lack of unified standards and automated tools, there may be significant differences in the accuracy and consistency of defect identification between different operators.

[0004] Although some automated image processing algorithms have been proposed to address these issues, they still face challenges in practical applications, such as the generalization ability of the algorithm, adaptability to complex backgrounds, and the need for real-time processing. Therefore, developing an automated method that can improve the quality and extraction efficiency of defect images is of great significance for improving the accuracy and efficiency of pipeline inspection.

[0005] The present invention aims to solve the above-mentioned problems in the prior art and provide an automated defect image determination method, device and electronic equipment to reduce the interference of human factors, improve the accuracy and processing speed of defect detection, and meet the needs of modern industrial detection. Summary of the invention

[0006] The purpose of the present invention is to provide a defect image determination method, device and electronic device to alleviate the technical problems of poor defect image quality and low efficiency in the prior art and to improve the defect image quality and extraction efficiency.

[0007] In a first aspect, an embodiment of the present invention provides a defect image determination method, comprising: acquiring an initial defective pipe image of a first preset position of a defective pipe and an initial non-defective pipe image of a second preset position of a normal pipe at a preset image acquisition angle through an image acquisition device; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipe and the normal pipe are the same type of pipe; preprocessing the initial defective pipe image and the initial non-defective pipe image to obtain a defective pipe image and a non-defective pipe image; graying the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image; segmenting the first grayscale image and the second grayscale image based on preset parameters to obtain a plurality of first sub-images and a plurality of first sub-images. a second sub-image; marking the first target sub-image of the above-mentioned multiple first sub-images that meets the preset first defect parameter to obtain a marked image; subtracting the above-mentioned marked image and the first grayscale value of the center position of the above-mentioned marked image and the second grayscale value of the second target image at the center position of the above-mentioned second sub-image corresponding to the above-mentioned marked image to obtain multiple differences; weighted averaging the above-mentioned multiple differences to obtain an average deviation; and calculating the deviation of each of the above-mentioned marked images; calculating the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distance degrees; determining the first target defect image of the above-mentioned marked image based on the above-mentioned multiple distance degrees; based on the preset quality assessment algorithm, assessing the image quality of the above-mentioned first target defect image, and outputting the second target defect image that meets the preset standard in the above-mentioned first target defect image.

[0008] In a preferred embodiment of the present invention, based on a preset quality assessment algorithm, the step of assessing the image quality of the first target defect image includes: dividing the first target defect image into a plurality of sub-images based on preset parameters; calculating the signal-to-noise ratio, structural similarity and information entropy of each sub-image to obtain a signal-to-noise ratio matrix, a structural similarity matrix and an information entropy matrix; based on a preset convolution kernel size, performing convolution calculations on the signal-to-noise ratio matrix, the structural similarity matrix and the information entropy matrix, respectively, to obtain a first convolution matrix, a second convolution matrix and a third convolution matrix; and assessing the image quality of the first target defect image based on the first convolution matrix, the second convolution matrix and the third convolution matrix.

[0009] In a preferred embodiment of the present invention, the step of calculating the information entropy of each subgraph to obtain the above-mentioned information entropy matrix includes: calculating the information entropy of each of the above-mentioned subgraphs based on the following formula: Among them, H is the information entropy of each sub-image, pi is the frequency of occurrence of the grayscale value of each sub-image pixel; n is the total number of different pixel grayscale values ​​in the sub-image; the grayscale value range is [0,255].

[0010] In a preferred embodiment of the present invention, the step of calculating the signal-to-noise ratio of each sub-image to obtain the above-mentioned signal-to-noise ratio matrix includes: calculating the signal-to-noise ratio of each of the above-mentioned sub-images based on the following formula: μ is the average grayscale value of each sub-image. is the variance of the grayscale values ​​of the pixels in the above sub-image; N is the total number of pixels in the above sub-image; f(x, y) represents the grayscale value of any sub-image.

[0011] In a preferred embodiment of the present invention, the step of calculating the structural similarity of each sub-image to obtain the above-mentioned structural similarity matrix includes: extracting the brightness information, contrast information, grayscale mean information and grayscale variance information of the above-mentioned sub-image; inputting the above-mentioned brightness information, the above-mentioned contrast information, the above-mentioned grayscale mean information and the above-mentioned grayscale variance information into a preset structural similarity calculation formula to obtain the above-mentioned structural similarity matrix; the above-mentioned structural similarity calculation formula is: SSIM(x,y)=L(x,y)×D(x,y)×S(x,y); Among them, WSSIM(x,y) represents the structural similarity calculation formula of the above sub-image, L(x,y) represents the brightness information, D(x,y) represents the contrast information, S(x,y) represents the structural information of the above sub-image, SSIM(x,y) represents the similarity of the above sub-image, SSIM(x j ,y j ) represents the similarity of the jth image in the above sub-image, W(x,y) represents the gray value of the above sub-image, W j (x j ,y j ) represents the grayscale value of the jth image in the above sub-image, μ x represents the first grayscale mean in the grayscale mean information, μ y represents the second grayscale mean in the above grayscale mean information, δ x represents the first grayscale variance in the above grayscale variance information, δ y represents the second grayscale variance in the above grayscale variance information, δ xy represents the covariance in the above-mentioned grayscale variance information, c1 represents a first preset constant greater than zero, c2 represents a second preset constant greater than zero, c3 represents a third preset constant greater than zero, x and y both represent the grayscale values ​​of the pixels of the above-mentioned sub-image, (x, y)∈[0,255], and N is the number of the above-mentioned sub-images.

[0012] In a preferred embodiment of the present invention, the step of evaluating the image quality of the first target defect image according to the first convolution matrix, the second convolution matrix and the third convolution matrix includes: multiplying the first convolution matrix, the second convolution matrix and the third convolution matrix to obtain a total matrix; calculating the Euclidean distance between any two elements in the total matrix to obtain a plurality of Euclidean distance values; accumulating the plurality of Euclidean distance values ​​to obtain a Euclidean distance sum; the step of outputting the second target defect image that meets the preset standard in the first target defect image includes: outputting the second target defect image whose Euclidean distance sum is less than a preset threshold; after the step of outputting the second target defect image that meets the preset standard in the first target defect image, the method further includes: outputting the third target defect image whose Euclidean distance sum is greater than or equal to the preset threshold.

[0013] By calculating the signal-to-noise ratio, structural similarity and information entropy of the image and constructing the corresponding matrix, it is equivalent to "extracting" the features of the defect image and the normal image from different levels in advance, and then constructing a multiplication matrix and performing a convolution operation. The result of the convolution matrix calculation is then used to calculate the Euclidean distance to obtain the difference point. Therefore, through the above operations and setting the preset threshold, the corresponding target defect image can be output according to actual needs.

[0014] In a preferred embodiment of the present invention, after the step of outputting the third target defect image whose Euclidean distance and value are greater than or equal to the preset threshold, the method comprises: adaptively enhancing the brightness vector, contrast vector and saturation vector of the third target defect image to obtain a first enhanced image; wherein the contrast vector of the third target defect image is adaptively enhanced by the following formula: Wherein, BH is the saturation of the third target defect image, FS 1is the saturation of the first enhanced image, max(R, G, B) is the maximum value of the pixel corresponding to the third target defect image, min(R, G, B) is the minimum value of the pixel corresponding to the third target defect image; μ(R, G, B) is the average value of the pixel corresponding to the third target defect image; the high-frequency component in the brightness vector is subjected to denoising to obtain the first high-frequency component, and the low-frequency component in the brightness vector is subjected to adaptive gamma correction to obtain the first low-frequency component; the first high-frequency component and the first low-frequency component are subjected to wavelet reconstruction to obtain the second enhanced image, the HSV space of the second enhanced image is converted to the RGB space, and finally enhanced by the unsharp masking technology to obtain the third enhanced image; wherein, the step of enhancing by the unsharp masking technology to obtain the third enhanced image includes: performing convolution calculation on the third target defect image and the Gaussian function to obtain a fuzzy function; the expression of the fuzzy function is: Among them, M(x, y, z) is the above fuzzy function, G g (x, y, z) is the above-mentioned Gaussian function, and Y(x, y, z) is the above-mentioned third target defect image; the third target defect image is subjected to difference operation with the fuzzy function to obtain a high-frequency image; the expression of the above-mentioned high-frequency image is: GP(x, y, z) = Y(x, y, z) - M(x, y, z), wherein GP(x, y, z) is the above-mentioned high-frequency image. The above-mentioned high-frequency image is enhanced to obtain the above-mentioned third enhanced image; wherein, the calculation formula for enhancing the above-mentioned high-frequency image to obtain the above-mentioned third enhanced image is: E(x, y, z) = Y(x, y, z) + χGP(x, y, z); wherein χ represents the enhancement coefficient of the high-frequency image, and (x, y, z) represents the three pixels of the R, G, and B color channels, and the value range is [0, 255].

[0015] In a preferred embodiment of the present invention, after the step of enhancing the high-frequency image to obtain the third enhanced image, the method further includes: based on the quality assessment algorithm, evaluating the image quality of the third enhanced image, and outputting the fourth target defect image in the third enhanced image that meets the preset standard.

[0016] In a second aspect, an embodiment of the present invention provides a defect image extraction device, including: an image acquisition and processing module, used to acquire an initial defective pipe image of a first preset position of a defective pipe and an initial non-defective pipe image of a second preset position of a normal pipe at a preset image acquisition angle through an image acquisition device; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipe and the normal pipe are the same type of pipe; pre-processing the initial defective pipe image and the initial non-defective pipe image to obtain a defective pipe image and a non-defective pipe image; gray-scaling the defective pipe image and the non-defective pipe image to obtain a first gray-scale image and a second gray-scale image; segmenting the first gray-scale image and the second gray-scale image based on preset parameters to obtain a plurality of first sub-images and a plurality of first sub-images. a second sub-image; marking the first target sub-image of the above multiple first sub-images that meets the preset first defect parameter to obtain a marked image; subtracting the above marked image and the first grayscale value at the center position of the above marked image and the second grayscale value of the second target image at the center position of the above second sub-image corresponding to the above marked image to obtain multiple differences; weighted averaging the above multiple differences to obtain an average deviation; and calculating the deviation of each of the above marked images; calculating the distance between the deviation of each of the above marked images and the above average deviation to obtain multiple distances; determining the first target defect image of the above marked image according to the above multiple distances; a quality assessment module, used to assess the image quality of the above first target defect image based on a preset quality assessment algorithm, and output the second target defect image that meets the preset standard in the above first target defect image.

[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable content that can be executed by the processor, and the processor executes the computer executable content to implement the defective image determination method.

[0018] The embodiments of the present invention have the following beneficial technical effects:

[0019] The embodiments of the present invention provide a defect image determination method, device and electronic device, comprising: acquiring an initial defective pipe image of a first preset position of a defective pipe and an initial non-defective pipe image of a second preset position of a normal pipe at a preset image acquisition angle by an image acquisition device; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipe and the normal pipe are the same type of pipe; preprocessing the initial defective pipe image and the initial non-defective pipe image to obtain a defective pipe image and a non-defective pipe image; graying the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image; segmenting the first grayscale image and the second grayscale image based on preset parameters to obtain a plurality of first sub-images and a plurality of first sub-images. second sub-images; mark the first target sub-images of the above multiple first sub-images that meet the preset first defect parameters to obtain a marked image; subtract the first grayscale value of the marked image and the center position of the marked image and the second grayscale value of the second target image at the center position of the second sub-image corresponding to the marked image to obtain multiple differences; perform weighted average on the above multiple differences to obtain an average deviation degree; and calculate the deviation degree of each of the above marked images; calculate the distance between the deviation degree of each of the above marked images and the average deviation degree to obtain multiple distance degrees; determine the first target defect image of the above marked image based on the above multiple distance degrees; based on the preset quality evaluation algorithm, evaluate the image quality of the above first target defect image, and output the second target defect image that meets the preset standard in the above first target defect image. The method can extract defect images in an image and output defect images that meet the image quality, thereby improving the quality of defect images and extraction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 A schematic diagram of a flow chart of a defect image determination method provided by an embodiment of the present invention;

[0022] Figure 2 A schematic diagram of a first sub-image provided by an embodiment of the present invention;

[0023] Figure 3 A schematic diagram of a second sub-image provided by an embodiment of the present invention;

[0024] Figure 4 A schematic diagram of a marking image provided by an embodiment of the present invention;

[0025] Figure 5 A structural schematic diagram of a defect image determination device provided by an embodiment of the present invention;

[0026] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

[0027] Icons: 21 - image acquisition and processing module; 22 - quality assessment module; 41 - processor; 42 - memory; 43 - bus; 44 - communication interface. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0029] At present, manual extraction of defect images has the problem of poor quality of defect images due to subjective influence, and the efficiency of the above methods is also low.

[0030] Based on this, the embodiments of the present invention provide a defect image determination method, device and electronic device, which can extract defect images in an image and output defect images that meet the image quality, thereby improving the defect image quality and extraction efficiency. For ease of understanding, the defect image determination method is first described in detail.

[0031] Example 1

[0032] In this embodiment, Figure 1 A schematic flow chart of a defect image determination method provided by an embodiment of the present invention.

[0033] Depend on Figure 1 As can be seen, the method includes:

[0034] Step S101: an initial defective pipe image of a first preset position of a defective pipe and an initial non-defective pipe image of a second preset position of a normal pipe are captured by an image capture device at a preset image capture angle; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipe and the normal pipe are of the same type of pipe.

[0035] Step S102: preprocessing the initial defective pipeline image and the initial non-defective pipeline image to obtain a defective pipeline image and a non-defective pipeline image.

[0036] Step S103: grayscale processing is performed on the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image.

[0037] Step S104: segmenting the first grayscale image and the second grayscale image based on preset parameters to obtain a plurality of first sub-images and a plurality of second sub-images.

[0038] For ease of understanding, Figure 2 A schematic diagram of a first sub-image provided by an embodiment of the present invention; Figure 3 A schematic diagram of a second sub-image provided by an embodiment of the present invention.

[0039] Depend on Figure 2 As can be seen, the first sub-image is divided into 36 small images, numbered as X1, X2, X3...X36. Figure 3 As can be seen, the second sub-image is cumulatively divided into 36 small images, which are numbered as: Y1, Y2, Y3...Y36.

[0040] Step S105: marking the first target sub-image of the plurality of first sub-images that meets the preset first defect parameter to obtain a marked image.

[0041] For ease of understanding, Figure 4 A schematic diagram of a marked image provided by an embodiment of the present invention.

[0042] like Figure 4 visible, Figure 3 X8, X9, X10, X14, X15, X16, X17, X20, X22, X26, X27, and X29 have defects and are thus marked as marked images.

[0043] Step S106: Subtract the marked image and the first grayscale value at the center of the marked image from the second grayscale value of the second target image at the center of the second sub-image corresponding to the marked image to obtain a plurality of difference values.

[0044] In actual operation, the first grayscale values ​​of the center positions of multiple first sub-images are: 156, 168, 179, 167, 176, 167, 201, 188, 102, 167, 172, 171; the second grayscale values ​​of multiple second sub-images are: 99, 109, 89, 111, 123, 112, 112, 102, 190, 108, 89, 112; subtracting the above-mentioned first grayscale values ​​from the second grayscale values ​​can obtain multiple difference values ​​ΔΨ, which are: 57, 59, 90, 56, 53, 55, 89, 86, 88, 59, 83, 59.

[0045] Step S107: performing weighted averaging on the above-mentioned multiple differences to obtain an average deviation degree; and calculating the deviation degree of each of the above-mentioned marked images.

[0046] According to the average deviation calculation formula

[0047] Where ΔΨ represents the difference, Z1, Z2, Z3…Z m Representing the grayscale value of the marked image, the average deviation can be obtained as =71.56.

[0048] Step S108: Calculate the distance between the deviation degree of each of the above-mentioned marked images and the above-mentioned average deviation degree to obtain multiple distance degrees.

[0049] In actual operation, the distances of small images numbered X8, X9, X10, X14, X15, X16, X17, X20, X22, X26, X27, and X29 are 12.53, 10.53, 20.47, 13.53, 16.53, 14.53, 19.47, 16.47, 18.47, 10.53, 13.47, and 10.53 respectively.

[0050] Step S109: determining a first target defect image of the marked image according to the multiple distances.

[0051] Step S1010: Based on a preset quality assessment algorithm, the image quality of the first target defect image is assessed, and a second target defect image that meets a preset standard in the first target defect image is output.

[0052] In one embodiment, based on a preset quality assessment algorithm, the step of evaluating the image quality of the first target defect image includes: dividing the first target defect image into multiple sub-images based on preset parameters; calculating the signal-to-noise ratio, structural similarity and information entropy of each sub-image to obtain a signal-to-noise ratio matrix, a structural similarity matrix and an information entropy matrix; based on a preset convolution kernel size, performing convolution calculations on the signal-to-noise ratio matrix, the structural similarity matrix and the information entropy matrix respectively to obtain a first convolution matrix, a second convolution matrix and a third convolution matrix; and evaluating the image quality of the first target defect image according to the first convolution matrix, the second convolution matrix and the third convolution matrix.

[0053] In this embodiment, the step of calculating the information entropy of each subgraph to obtain the above information entropy matrix includes: calculating the information entropy of each subgraph based on the following formula: Among them, H is the information entropy of each sub-image, pi is the frequency of occurrence of the grayscale value of each sub-image pixel; n is the total number of different pixel grayscale values ​​in the sub-image; the grayscale value range is [0,255].

[0054] Here, taking a sub-image A as an example, it can be obtained that the pixel values ​​of sub-image A are 50, 100, 150, and 200, as shown in the figure Assume that p 50 =0.20, p 100 =0.30, p 150 =0.15, p 200 =0.35, and substituting it into the formula for calculation, we can get H=-(0.20log2(0.20)+0.30log2(0.30)+0.15log2(0.15)+0.35log2(0.35))=1.9119.

[0055] Similarly, in this embodiment, the image information entropy matrix F1 can be obtained as:

[0056]

[0057] Furthermore, the step of calculating the signal-to-noise ratio of each sub-graph to obtain the above-mentioned signal-to-noise ratio matrix includes: calculating the signal-to-noise ratio of each of the above-mentioned sub-graphs based on the following formula: Among them, μ is the average grayscale value of each sub-image. is the variance of the grayscale values ​​of the pixels in the above sub-image; N is the total number of pixels in the above sub-image; f(x, y) represents the grayscale value of any sub-image.

[0058] Calculate the signal-to-noise ratio of a sub-image A and the average gray value. The variance of the sub-image pixel grayscale value is 1458.33, and we can finally get:

[0059] PSNR=10.7.

[0060] Similarly, in this implementation, the signal-to-noise ratio matrix F2 can be obtained as:

[0061]

[0062] Furthermore, the step of calculating the structural similarity of each sub-image to obtain the above structural similarity matrix includes: extracting the brightness information, contrast information, grayscale mean information and grayscale variance information of the above sub-image; inputting the above brightness information, the above contrast information, the above grayscale mean information and the above grayscale variance information into a preset structural similarity calculation formula to obtain the above structural similarity matrix; the above structural similarity calculation formula is:

[0063]

[0064] SSIM(x,y)=L(x,y)×D(x,y)×S(x,y);

[0065]

[0066] Among them, WSSIM(x,y) represents the structural similarity calculation formula of the above sub-image, L(x,y) represents the brightness information, D(x,y) represents the contrast information, S(x,y) represents the structural information of the above sub-image, SSIM(x,y) represents the similarity of the above sub-image, SSIM(x j ,y j ) represents the similarity of the jth image in the above sub-image, W(x,y) represents the gray value of the above sub-image, W j (x j ,y j ) represents the grayscale value of the jth image in the above sub-image, μ x represents the first grayscale mean in the grayscale mean information, μ y represents the second grayscale mean in the above grayscale mean information, δ x represents the first grayscale variance in the above grayscale variance information, δ y represents the second grayscale variance in the above grayscale variance information, δ xy represents the covariance in the above-mentioned grayscale variance information, c1 represents a first preset constant greater than zero, c2 represents a second preset constant greater than zero, c3 represents a third preset constant greater than zero, x and y both represent the grayscale values ​​of the pixels of the above-mentioned sub-image, (x, y)∈[0,255], and N is the number of the above-mentioned sub-images.

[0067] In this implementation, the first grayscale value and the second grayscale value of sub-image A are 125 and 130 respectively, the covariance is 0.2, the first grayscale variance is 0.78, and the second grayscale variance is 0.65;

[0068] c1=(0.01×255) 2 =6.5625

[0069] c2=(0.03×255) 2 =21.023

[0070] c3=(0.025×255) 2 =40.641

[0071] W(x,y)=0.782+0.652+21.0225=22.053;

[0072]

[0073] SSIM(x,y)=L(x,y)×D(x,y)×S(x,y)=1.018×0.999×0.997=1.014

[0074]

[0075] Similarly, according to the above formula, the structural similarity matrix F3 can be obtained in this implementation,

[0076]

[0077] The step of evaluating the image quality of the first target defect image according to the first convolution matrix, the second convolution matrix and the third convolution matrix comprises: multiplying the first convolution matrix, the second convolution matrix and the third convolution matrix to obtain a total matrix;

[0078] Design three different convolution kernels, Gaussian blur kernel J1, sharpening kernel J2, edge detection kernel J3, the three convolution kernels are as follows:

[0079]

[0080] The convolution calculation step size in this embodiment is 1, F1 is convolved with J1 to obtain G1, F2 is convolved with J2 to obtain G2, and F3 is convolved with J3 to obtain G3;

[0081] The first convolution matrix G1 can be obtained

[0082]

[0083] The second convolution matrix G2

[0084]

[0085] The third convolution matrix G3

[0086]

[0087] By multiplying the first convolution matrix, the second convolution matrix, and the third convolution matrix, we can get the total matrix, which is represented by G Z :

[0088]

[0089] The step of calculating the Euclidean distance between any two elements in the total matrix to obtain a plurality of Euclidean distance values; accumulating the plurality of Euclidean distance values ​​to obtain a Euclidean distance sum; outputting the second target defect image that meets the preset standard in the first target defect image comprises: outputting the second target defect image whose Euclidean distance sum is less than a preset threshold; after the step of outputting the second target defect image that meets the preset standard in the first target defect image, the method further comprises: outputting the third target defect image whose Euclidean distance sum is greater than or equal to the preset threshold.

[0090] In this embodiment, the Euclidean distance is calculated by the following formula:

[0091]

[0092] Among them, dijrs is the Euclidean distance, a im with a rm For any two elements in each row of the above total matrix, a jn with a sn represents any two elements in each column of the above total matrix, where i≠r or j≠s. m and n represent the number of rows and columns of the above total matrix respectively, and N represents the total number of rows or columns of the above total matrix.

[0093] Furthermore, after the step of outputting the third target defect image whose Euclidean distance and value are greater than or equal to the preset threshold, the method includes: adaptively enhancing the brightness vector, contrast vector and saturation vector of the third target defect image to obtain a first enhanced image; wherein the contrast vector of the third target defect image is adaptively enhanced by the following formula:

[0094]

[0095] Wherein, BH is the saturation of the third target defect image, FS 1 is the saturation of the first enhanced image, max(R, G, B) is the maximum value of the pixel points corresponding to the third target defect image, min(R, G, B) is the minimum value of the pixel points corresponding to the third target defect image; μ(R, G, B) is the average value of the pixel points corresponding to the third target defect image.

[0096] is the average value of the corresponding pixel points of the third target defect image; the high-frequency component in the brightness vector is subjected to denoising to obtain the first high-frequency component, and the low-frequency component in the brightness vector is subjected to adaptive gamma correction to obtain the first low-frequency component; the first high-frequency component and the first low-frequency component are subjected to wavelet reconstruction to obtain the second enhanced image, the HSV space of the second enhanced image is converted to the RGB space, and finally enhanced by the unsharp masking technology to obtain the third enhanced image; wherein, the step of enhancing by the unsharp masking technology to obtain the third enhanced image includes: performing convolution calculation on the third target defect image and the Gaussian function to obtain a fuzzy function; the expression of the fuzzy function is: Among them, M(x, y, z) is the above fuzzy function, G g (x, y, z) is the above-mentioned Gaussian function, and Y(x, y, z) is the above-mentioned third target defect image; the third target defect image is subjected to difference operation with the fuzzy function to obtain a high-frequency image; the expression of the above-mentioned high-frequency image is: GP(x, y, z) = Y(x, y, z) - M(x, y, z); wherein GP(x, y, z) is the above-mentioned high-frequency image; the above-mentioned high-frequency image is enhanced to obtain the above-mentioned third enhanced image; wherein, the calculation formula for enhancing the above-mentioned high-frequency image to obtain the above-mentioned third enhanced image is: E(x, y, z) = Y(x, y, z) + χGP(x, y, z); wherein χ represents the enhancement coefficient of the high-frequency image, and (x, y, z) represents three pixel points of the R, G, and B color channels, with a value range of [0, 255].

[0097] Furthermore, after the step of enhancing the high-frequency image to obtain the third enhanced image, the method further includes: based on the quality assessment algorithm, evaluating the image quality of the third enhanced image, and outputting the fourth target defect image in the third enhanced image that meets the preset standard.

[0098] The present invention provides a defect image determination method, comprising: acquiring an initial defective pipeline image of a first preset position of a defective pipeline and an initial non-defective pipeline image of a second preset position of a normal pipeline at a preset image acquisition angle through an image acquisition device; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipeline and the normal pipeline are the same type of pipe; pre-processing the initial defective pipeline image and the initial non-defective pipeline image to obtain a defective pipeline image and a non-defective pipeline image; gray-scaling the defective pipeline image and the non-defective pipeline image to obtain a first gray-scale image and a second gray-scale image; segmenting the first gray-scale image and the second gray-scale image based on preset parameters to obtain a plurality of first sub-images and a plurality of second sub-images image; mark the first target sub-image of the above multiple first sub-images that meets the preset first defect parameter to obtain a marked image; subtract the first grayscale value of the marked image and the center position of the marked image and the second grayscale value of the second target image at the center position of the second sub-image corresponding to the marked image to obtain multiple differences; weighted average the above multiple differences to obtain an average deviation degree; and calculate the deviation degree of each of the above marked images; calculate the distance between the deviation degree of each of the above marked images and the average deviation degree to obtain multiple distance degrees; determine the first target defect image of the above marked image based on the above multiple distance degrees; based on the preset quality evaluation algorithm, evaluate the image quality of the above first target defect image, and output the second target defect image that meets the preset standard in the above first target defect image. This method can extract defect images in images and output defect images that meet the image quality, thereby improving the quality of defect images and extraction efficiency.

[0099] Example 2

[0100] In this embodiment, Figure 5 A schematic structural diagram of a defect image determination device provided by an embodiment of the present invention.

[0101] Depend on Figure 5 As can be seen, the device includes:

[0102] The image acquisition and processing module 21 is used to acquire an initial defective pipe image at a first preset position of a defective pipe and an initial non-defective pipe image at a second preset position of a normal pipe through an image acquisition device at a preset image acquisition angle; the distance between the first preset position and the second preset position is less than a preset distance threshold; the defective pipe and the normal pipe are the same type of pipe; pre-process the initial defective pipe image and the initial non-defective pipe image to obtain a defective pipe image and a non-defective pipe image; grayscale the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image; and convert the first grayscale image and the second grayscale image into a grayscale image based on preset parameters. The method comprises the steps of: segmenting two grayscale images to obtain a plurality of first sub-images and a plurality of second sub-images; marking a first target sub-image of the plurality of first sub-images that meets a preset first defect parameter to obtain a marked image; subtracting the first grayscale value of the marked image and the center position of the marked image from the second grayscale value of the second target image at the center position of the second sub-image corresponding to the marked image to obtain a plurality of difference values; weighted averaging the plurality of difference values ​​to obtain an average deviation degree; and calculating the deviation degree of each of the marked images; calculating the distance between the deviation degree of each of the marked images and the average deviation degree to obtain a plurality of distance degrees; and determining the first target defect image of the marked image according to the plurality of distance degrees.

[0103] The quality assessment module 22 is used to assess the image quality of the first target defect image based on a preset quality assessment algorithm, and output the second target defect image that meets the preset standard in the first target defect image.

[0104] The image acquisition and processing module 21 and the quality assessment module 22 are connected.

[0105] The defect image determination device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned defect image determination method embodiment. For the sake of brief description, for parts not mentioned in the embodiment of the above-mentioned defect image determination device, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0106] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 41 and a memory 42, the memory 42 stores machine executable instructions that can be executed by the processor 41, and the processor 41 executes the machine executable instructions to implement the above-mentioned defect image determination method.

[0107] exist Figure 6In the illustrated embodiment, the electronic device further includes a bus 43 and a communication interface 44 , wherein the processor 41 , the communication interface 44 and the memory 42 are connected via the bus.

[0108] The memory 42 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 44 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus may be an ISA bus, a PCI bus, or an EISA bus, etc. The above-mentioned bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0109] Among them, the processor 41 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 41 or the instruction in the form of software. The above processor 41 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, register, or other mature storage media in the art. The storage medium is located in the memory, and the processor 41 reads the information in the memory 42 and completes the steps of the defect image determination method of the above embodiment in combination with its hardware.

[0110] An embodiment of the present invention also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned defective image determination method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.

[0111] The defect image determination method, defect image determination device and computer program product of the electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the above program code can be used to execute the above defect image determination method in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here.

[0112] Unless otherwise specifically stated, the relative steps, numerical expressions and numerical values ​​of the components and steps described in these embodiments do not limit the scope of the present invention. If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the above methods of various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.

Claims

1. A defect image determination method, characterized in that: include: An initial defective pipe image of a first preset position of a defective pipe and an initial non-defective pipe image of a second preset position of a normal pipe are captured by an image capture device at a preset image capture angle; the distance between the first preset position and the second preset position is less than a preset distance threshold; The defective pipe and the normal pipe are made of the same type of pipe; Preprocessing the initial defective pipeline image and the initial non-defective pipeline image to obtain a defective pipeline image and a non-defective pipeline image; grayscale the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image; Segmenting the first grayscale image and the second grayscale image based on preset parameters to obtain a plurality of first sub-images and a plurality of second sub-images; Marking a first target sub-image of the plurality of first sub-images that meets a preset first defect parameter to obtain a marked image; Subtracting the marked image and a first grayscale value at a center position of the marked image from a second grayscale value of a second target image at a center position of the second sub-image corresponding to the marked image to obtain a plurality of difference values; Performing weighted averaging on the multiple differences to obtain an average deviation degree; and calculating the degree of deviation of each of the marked images; Calculating the distance between the deviation degree of each of the marked images and the average deviation degree to obtain a plurality of distance degrees; determining a first target defect image of the marked image according to the multiple distance degrees; Based on a preset quality assessment algorithm, the image quality of the first target defect image is assessed, and a second target defect image that meets a preset standard in the first target defect image is output.

2. The defect image determination method according to claim 1, characterized in that: The step of evaluating the image quality of the first target defect image based on a preset quality evaluation algorithm comprises: Dividing the first target defect image into a plurality of sub-images based on preset parameters; Calculate the signal-to-noise ratio, structural similarity, and information entropy of each subgraph to obtain the signal-to-noise ratio matrix, structural similarity matrix, and information entropy matrix; Based on a preset convolution kernel size, convolution calculations are performed on the signal-to-noise ratio matrix, the structural similarity matrix, and the information entropy matrix to obtain a first convolution matrix, a second convolution matrix, and a third convolution matrix; The image quality of the first target defect image is evaluated according to the first convolution matrix, the second convolution matrix and the third convolution matrix.

3. The defect image determination method according to claim 2, characterized in that: The step of calculating the information entropy of each subgraph to obtain the information entropy matrix includes: The information entropy of each subgraph is calculated based on the following formula: Among them, H is the information entropy of each sub-image, pi is the frequency of occurrence of the grayscale value of each sub-image pixel; n is the total number of different pixel grayscale values ​​in the sub-image; the grayscale value range is [0,255].

4. The defect image determination method according to claim 2, characterized in that: The step of calculating the signal-to-noise ratio of each sub-graph to obtain the signal-to-noise ratio matrix comprises: The signal-to-noise ratio of each sub-image is calculated based on the following formula: μ is the average grayscale value of each sub-image. is the variance of the grayscale values ​​of the sub-image pixels; N is the total number of pixels in the sub-image; f(x, y) represents the grayscale value of any sub-image.

5. The defect image determination method according to claim 2, characterized in that: The step of calculating the structural similarity of each subgraph to obtain the structural similarity matrix includes: Extracting brightness information, contrast information, grayscale mean information and grayscale variance information of the sub-image; Inputting the brightness information, the contrast information, the grayscale mean information and the grayscale variance information into a preset structural similarity calculation formula to obtain the structural similarity matrix; The structural similarity calculation formula is: SSIM(x,y)=L(x,y)×D(x,y)×S(x,y); Wherein, WSSIM(x,y) represents the structural similarity calculation formula of the sub-image, L(x,y) represents the brightness information, D(x,y) represents the contrast information, S(x,y) represents the structural information of the sub-image, SSIM(x,y) represents the similarity of the sub-image, SSIM(x j ,y j ) represents the similarity of the jth image in the sub-image, W(x,y) represents the gray value of the sub-image, W j (x j ,y j ) represents the grayscale value of the jth image in the sub-image, μ x represents the first grayscale mean in the grayscale mean information, μ y represents the second grayscale mean in the grayscale mean information, δ x represents the first grayscale variance in the grayscale variance information, δ y represents the second grayscale variance in the grayscale variance information, δ xy represents the covariance in the grayscale variance information, c1 represents a first preset constant greater than zero, c2 represents a second preset constant greater than zero, c3 represents a third preset constant greater than zero, x and y both represent the grayscale values ​​of the pixels of the sub-image, (x, y)∈[0,255], and N is the number of the sub-images.

6. The defect image determination method according to claim 2, characterized in that: The step of evaluating the image quality of the first target defect image according to the first convolution matrix, the second convolution matrix and the third convolution matrix comprises: Multiplying the first convolution matrix, the second convolution matrix and the third convolution matrix to obtain a total matrix; Calculating the Euclidean distance between any two elements in the total matrix to obtain a plurality of Euclidean distance values; Accumulate the multiple Euclidean distance values ​​to obtain a Euclidean distance sum; The step of outputting a second target defect image that meets a preset standard in the first target defect image comprises: Outputting the second target defect image whose Euclidean distance and value are less than a preset threshold; After the step of outputting a second target defect image that meets a preset standard in the first target defect image, the method further includes: The third target defect image whose Euclidean distance is greater than or equal to the preset threshold is output.

7. The defect image determination method according to claim 6, characterized in that: After the step of outputting the third target defect image whose Euclidean distance is greater than or equal to the preset threshold, the method includes: The third target defect image is adaptively enhanced in terms of brightness vector, contrast vector and saturation vector respectively to obtain a first enhanced image; wherein the third target defect image is adaptively enhanced in terms of contrast vector respectively by the following formula: Wherein, BH is the saturation of the third target defect image, FS 1 is the saturation of the first enhanced image, max(R, G, B) is the maximum value of the pixel points corresponding to the third target defect image, min(R, G, B) is the minimum value of the pixel points corresponding to the third target defect image; μ(R, G, B) is the average value of the pixel points corresponding to the third target defect image; Performing denoising on the high-frequency component in the brightness vector to obtain a first high-frequency component, and performing adaptive gamma correction on the low-frequency component in the brightness vector to obtain a first low-frequency component; reconstructing the first high-frequency component and the first low-frequency component through wavelet to obtain a second enhanced image, converting the HSV space of the second enhanced image into the RGB space, and finally enhancing the image through the unsharp masking technology to obtain a third enhanced image; The step of performing enhancement by using an unsharp masking technique to obtain a third enhanced image includes: The third target defect image is convolved with the Gaussian function to obtain a fuzzy function; the expression of the fuzzy function is: Wherein, M(x, y, z) is the fuzzy function, Gg(x, y, z) is the Gaussian function, and Y(x, y, z) is the third target defect image; By performing a difference operation between the third target defect image and the fuzzy function, a high-frequency image can be obtained; the expression of the high-frequency image is: GP(x,y,z)=Y(x,y,z)-M(x,y,z); Wherein, GP(x,y,z) is the high-frequency image; enhancing the high-frequency image to obtain the third enhanced image; The high-frequency image is enhanced to obtain the third enhanced image by the following calculation formula: E(x, y, z) = Y(x, y, z) + χGP(x, y, z); Among them, χ represents the enhancement coefficient of the high-frequency image, (x, y, z) represents the three pixels of the R, G, and B color channels, and the value range is [0, 255].

8. The defect image determination method according to claim 7, characterized in that: After the step of enhancing the high-frequency image to obtain the third enhanced image, the method further includes: Based on the quality assessment algorithm, the image quality of the third enhanced image is assessed, and a fourth target defect image in the third enhanced image that meets the preset standard is output.

9. A defect image extraction device, characterized in that: include: An image acquisition and processing module, used to acquire an initial defective pipe image at a first preset position of a defective pipe and an initial non-defective pipe image at a second preset position of a normal pipe through an image acquisition device at a preset image acquisition angle; the distance between the first preset position and the second preset position is less than a preset distance threshold; The defective pipe and the normal pipe are of the same type of pipe; the initial defective pipe image and the initial non-defective pipe image are preprocessed to obtain a defective pipe image and a non-defective pipe image; grayscale the defective pipe image and the non-defective pipe image to obtain a first grayscale image and a second grayscale image; Segmenting the first grayscale image and the second grayscale image based on preset parameters to obtain a plurality of first sub-images and a plurality of second sub-images; Marking a first target sub-image of the plurality of first sub-images that meets a preset first defect parameter to obtain a marked image; subtracting the marked image and a first grayscale value at a center position of the marked image from a second grayscale value of a second target image at a center position of the second sub-image corresponding to the marked image to obtain a plurality of difference values; and performing weighted averaging on the plurality of differences to obtain an average deviation degree; and calculating the degree of deviation of each of the marked images; Calculating the distance between the deviation degree of each of the marked images and the average deviation degree to obtain a plurality of distance degrees; determining the first target defect image of the marked image according to the plurality of distance degrees; The quality assessment module is used to assess the image quality of the first target defect image based on a preset quality assessment algorithm, and output a second target defect image that meets a preset standard in the first target defect image.

10. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a computer executable program that can be executed by the processor, and the processor executes the computer executable program to implement the defective image determination method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Machine vision detection device and method for steel rail surface discrete defects

    CN107618533A

  • Mechanical component defect detection method based on image processing

    CN115018853A