Defect image extraction method, device and electronic equipment
By collecting and preprocessing pipeline images, calculating differences and deviations, adjusting threshold intervals, and using cluster analysis technology, the problems of low image extraction efficiency and poor accuracy in the existing technology are solved, and efficient identification of drainage pipeline defects is achieved. .
Patent Information
- Application Number
- CN202410979008.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-22
AI Technical Summary
In the existing technology, in the detection of defects in drainage pipelines, the image extraction method has low efficiency and poor accuracy. Especially when the texture changes little, the lighting conditions change and the image quality is poor, it is difficult to accurately extract defect information.
By collecting images of defective pipelines and normal pipelines, perform preprocessing, grayscale and image segmentation, calculate differences and deviations, adjust defect threshold intervals, and use weighted average and cluster analysis techniques to output target defect images to improve image extraction. accuracy and efficiency.
The accuracy and efficiency of defect image extraction are improved, pipeline defects can be accurately identified under different lighting conditions and image quality, and detection efficiency is improved.
Smart Images

Figure CN118505712B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a defect image extraction method, device and electronic equipment. Background Art
[0002] At present, the detection methods for the internal conditions of drainage pipes mainly include the following: 1) Pipeline periscope detection (QV detection): Use a pipeline periscope to observe the operation of the pipeline and the distribution of defects in the inspection well. It is suitable for situations where there are many debris inside the pipeline or conventional robots cannot be used; 2) Television detection (CCTV detection): A robot carrying a camera crawls along the inside of the pipeline and conducts a full-range camera inspection of the pipeline, which can find out the specific location of various defects such as water leakage, corrosion, misalignment, fracture, and foreign body penetration inside the pipeline; 3) Sonar detection: A technology that uses sound waves to detect and locate underwater objects. It is suitable for online detection of drainage pipes that are full or half full of water, and can detect underwater environmental structures; 4) Diving inspection: Divers enter the pipeline and intuitively judge the defects such as blockage and dislocation of the pipeline. For whether there are defects inside the pipeline, manual interpretation is generally used. Experienced operators read the video shot by the detection equipment and capture the defective pictures frame by frame. The captured images are generally read by manual or intelligent algorithms. The manual interpretation method is inefficient, has a huge workload, and has obvious shortcomings. At present, intelligent algorithms are generally used to extract and interpret image features.
[0003] At present, the image extraction methods mainly include the following: 1) Methods based on texture feature extraction: such as gray level co-occurrence matrix method, texture spectrum analysis and Gabor filter; 2) Methods based on color feature extraction: mainly using weighted Euclidean distance measurement (matching of color distribution), color histogram intersection method and distance comparison; 3) Methods based on shape feature extraction: using the Euclidean distance of the shape attribute set to describe the image content, the shape feature set usually includes moment, area, etc. The processor method also has some defects, such as: ① The effect of texture feature extraction depends largely on the consistency and distinguishability of the texture in the image. If the texture in the image does not change much or the texture features are not obvious, this method may be difficult to accurately extract useful information; ② The influence of lighting and shadows: Changes in lighting conditions, such as shadows and uneven lighting, may affect the extraction of texture features, resulting in feature distortion or inaccurate extraction; ③ The extraction of shape features often depends on clear image boundaries and contour information; ④ Poor image quality, such as blur, noise or occlusion, will affect the accuracy of shape features.
[0004] Therefore, it is necessary to develop a method for identifying and extracting defective boundaries of drainage pipes, which not only needs to lock the image boundaries but also has high accuracy and optimize the image with defects in order to obtain a clear image. Summary of the invention
[0005] The purpose of the present invention is to provide a defect image extraction method 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.
[0006] In a first aspect, an embodiment of the present invention provides a defect image extraction 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 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, grayscale processing and image segmentation of preset parameters on the initial defective pipe image and the initial non-defective pipe image 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 the preset first defect parameter to obtain a marked image; and comparing the marked image and the first grayscale value of the center position of the marked image and the second sub-image corresponding to the marked image. Subtract the second grayscale value of the second target image at the center of the image to obtain multiple differences; perform weighted averaging on the above multiple differences to obtain an average deviation; and calculate the deviation of each of the above-mentioned marked images; calculate the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold range; output the target defect image of the above-mentioned marked image based on the above-mentioned inclusion relationship; output the target defect-free image of the above-mentioned marked image based on the above-mentioned multiple distance degrees; determine the first accuracy of the above-mentioned target defect image and the second accuracy of the above-mentioned target defect-free image based on a preset second defect parameter; calculate the overall accuracy based on the above-mentioned first accuracy and the above-mentioned second accuracy; determine the size relationship between the above-mentioned overall accuracy and a preset accuracy threshold; adjust the above-mentioned defect threshold range based on the above-mentioned size relationship.
[0007] In a preferred implementation of the embodiment of the present invention, the step of outputting the target defect image of the above-mentioned marked image according to the above-mentioned inclusion relationship includes: when the inclusion relationship is that the above-mentioned defect threshold interval includes the above-mentioned distance degree, outputting the above-mentioned target defect image corresponding to the above-mentioned distance degree of the above-mentioned marked image.
[0008] In a preferred implementation of the embodiment of the present invention, the step of performing weighted averaging on the above-mentioned multiple differences to obtain the average deviation degree includes: calculating the above-mentioned average deviation degree by the following formula: ,in, is the above average deviation, , … It is 1 to the mth difference mentioned above.
[0009] In a preferred implementation manner of the embodiment of the present invention, the first accuracy includes determining the number of first images for determining the target defective image with defects and the number of second images for determining the target defective image without defects; the second accuracy includes determining the number of third images for determining the target non-defective image with defects and the number of fourth images for determining the target non-defective image without defects; the step of calculating the overall accuracy based on the first accuracy and the second accuracy includes: calculating the overall accuracy based on the number of first images, the number of second images, the number of third images and the number of fourth images.
[0010] In a preferred implementation of the embodiment of the present invention, the step of calculating the overall accuracy according to the first number of images, the second number of images, the third number of images and the fourth number of images includes: calculating the overall accuracy by the following formula: , where F is the overall accuracy, F1 is the number of the first images, F3 is the number of the fourth images, F2 is the number of the second images, and F4 is the number of the third images.
[0011] In a preferred implementation of the embodiment of the present invention, the step of adjusting the above-mentioned defect threshold interval according to the above-mentioned size relationship includes: when the above-mentioned size relationship is that the above-mentioned overall accuracy is less than or equal to the above-mentioned preset accuracy threshold, clustering analysis is performed on the first distance degree of the above-mentioned first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images to obtain analysis results; and adjusting the above-mentioned defect threshold interval according to the above-mentioned analysis results.
[0012] In a preferred implementation of the embodiment of the present invention, when the size relationship is that the overall accuracy is less than or equal to the preset accuracy threshold, cluster analysis is performed on the first distance degree of the first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images, and before the step of obtaining the analysis result, the method includes: obtaining a preset clustering category, a distance threshold between the clustering categories, a fuzzy index, and a stop iteration threshold; when the size relationship is that the overall accuracy is less than or equal to the preset accuracy threshold, the first distance degree of the first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images are clustered and analyzed. The steps of performing cluster analysis on the third distance degree of the number of images and the fourth distance degree of the fourth number of images respectively to obtain the analysis results include: step A1: taking the first distance degree, the second distance degree, the third distance degree and the fourth distance degree as initial samples respectively; step A2: calculating the distance between each of the initial samples respectively to obtain a plurality of first distance values; step A3: constructing a first matrix based on the plurality of first distance values; and selecting a first minimum value from the plurality of first distance values, and setting the first target sample corresponding to the first minimum value as the first initial cluster center; step A4: calculating the number of the initial samples except the first initial cluster center based on the first matrix. The method further comprises the following steps: selecting a second distance value between other samples of the initial cluster center and the first initial cluster center; step A5: selecting other target samples greater than the distance threshold from the second distance values; selecting a second minimum value from the multiple second distance values, and setting the second target sample corresponding to the second minimum value as the second initial cluster center; step A6: repeating the above steps A2 to A5 until the number of selections reaches the above cluster category, obtaining multiple cluster centers, and constructing the above multiple cluster centers into a cluster center matrix; step A7: calculating the Euclidean distance between the initial sample and the multiple cluster centers; step A8: calculating the membership degree of the above Euclidean distance to obtain the membership degree. degree matrix; step A9: according to the above-mentioned membership matrix, the above-mentioned cluster center matrix is updated multiple times to obtain the target updated state center matrix, until the absolute value of the difference between the above-mentioned target updated state center matrix and the previous updated state center matrix corresponding to the above-mentioned target updated state center matrix is less than the preset parameter, and the above-mentioned target updated state center matrix is output; step A10: the above-mentioned target updated state center matrix corresponding to each of the above-mentioned initial samples is determined as the above-mentioned analysis result; according to the above-mentioned analysis result, the step of adjusting the above-mentioned defect threshold interval includes: step B1: according to the above-mentioned target updated state center matrix corresponding to each of the above-mentioned initial samples, the maximum cluster community corresponding to each of the above-mentioned initial samples is determined;Step B2: Divide the maximum cluster community into a defect image distance database, a non-defect image distance database, a distance database of images determined to be defects but actually non-defects, and a distance database of images determined to be non-defects but actually defects according to the preset quadrants corresponding to the first distance, the second distance, the third distance, and the fourth distance; Step B3: Merge the defect image distance database and the distance database of images determined to be non-defects but actually defects to obtain a first database; and merge the non-defect image distance database and the distance database of images determined to be defects but actually non-defects to obtain a second database; Step B4: Map the first database to the Gaussian distribution of the defect threshold interval, and set the first overlapped part of the first database and the defect threshold interval as the first interval; and map the second database to the Gaussian distribution, and set the second overlapped part of the second database and the defect threshold interval as the second interval; Step B5: Repeat the above steps B1 to B4 until the overall accuracy is greater than the preset accuracy threshold. ;
[0013] In a preferred implementation manner of the embodiment of the present invention, the steps of preprocessing the above-mentioned initial defective pipeline image and the initial non-defective pipeline image to obtain the defective pipeline image and the non-defective pipeline image include: saving the above-mentioned original defective pipeline image and the above-mentioned original non-defective pipeline image as original images; adaptively enhancing the brightness vector, contrast vector and saturation vector of the original images to obtain enhanced images; wherein, adaptively enhancing the contrast vector of the above-mentioned original images is performed by the following formula: , where BH is the saturation of the original image, FS 1 To enhance the saturation of the image above, is the maximum value of the corresponding pixel points of the original image above, is the minimum value of the corresponding pixel points of the original image; is the average value of the corresponding pixel points of the above original image; the high-frequency component in the above brightness vector is subjected to denoising to obtain the first high-frequency component, and the low-frequency component in the above 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 first enhanced image, the HSV space of the above first enhanced image is converted into the RGB space, and finally enhanced by the unsharp masking technology to obtain the second enhanced image; wherein, the step of enhancing by the unsharp masking technology to obtain the second enhanced image includes: performing convolution calculation on the above original image Y (x, y, z) and the Gaussian function Gg (x, y, z) to obtain the blur function M (x, y, z); the expression of the above M is: By performing a difference operation between the original image and the blur function, a high-frequency image GP (x, y, z) can be obtained. The formula of the GP (x, y, z) is: GP (x, y, z) = Y (x, y, z) - M (x, y, z); the high-frequency image is enhanced to obtain the second enhanced image. The calculation formula is: ; represents the enhancement coefficient of the high-frequency image, (x, y, z) represents three pixels of the R, G, and B color channels, and the value range is [0, 255]. According to the second enhanced image, the enhanced image is determined. According to the enhanced image, the defective pipeline image and the non-defective pipeline image are determined.
[0014] In a second aspect, an embodiment of the present invention further provides a defect image extraction device, comprising: a data acquisition 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, grayscale processing and image segmentation of preset parameters are performed on the initial defective pipe image and the initial non-defective pipe image 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 the preset first defect parameter to obtain a marked image; and the first grayscale value of the marked image and the center position of the marked image and the center position of the second sub-image corresponding to the marked image are marked. subtracting the second grayscale value of the second target image from the first target image to obtain multiple differences; a target defect image output module is used to perform weighted averaging on the above multiple differences to obtain an average deviation; and calculate the deviation of each of the above-mentioned marked images; calculate the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold range; output the target defect image of the above-mentioned marked image based on the above-mentioned inclusion relationship; a parameter adjustment module is used to output the target defect-free image of the above-mentioned marked image based on the above-mentioned multiple distance degrees; determine the first accuracy of the above-mentioned target defect image and the second accuracy of the above-mentioned target defect-free image based on a preset second defect parameter; calculate the overall accuracy based on the above-mentioned first accuracy and the above-mentioned second accuracy; determine the size relationship between the above-mentioned overall accuracy and a preset accuracy threshold; adjust the above-mentioned defect threshold range based on the above-mentioned size relationship.
[0015] 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 defect image extraction method.
[0016] The embodiments of the present invention have the following beneficial technical effects:
[0017] The embodiments of the present invention provide a defect image extraction method, device and electronic device, 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 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 pipeline and the normal pipeline are the same type of pipe; preprocessing, grayscale processing and image segmentation of preset parameters on the initial defective pipeline image and the initial non-defective pipeline image 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 the preset first defect parameter to obtain a marked image; and comparing the marked image and the first grayscale value of the center position of the marked image and the first grayscale value of the marked image corresponding to the marked image. Subtract the second grayscale value of the second target image at the center of the two sub-images to obtain multiple differences; perform weighted averaging on the above multiple differences to obtain an average deviation; and calculate the deviation of each of the above-mentioned marked images; calculate the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distances; determine the inclusion relationship between each distance and the preset defect threshold interval; output the target defect image of the above-mentioned marked image based on the above-mentioned inclusion relationship; output the target defect-free image of the above-mentioned marked image based on the above-mentioned multiple distances; determine the first accuracy of the above-mentioned target defect image and the second accuracy of the above-mentioned target defect-free image based on the preset second defect parameter; calculate the overall accuracy based on the above-mentioned first accuracy and the above-mentioned second accuracy; determine the size relationship between the above-mentioned overall accuracy and the preset accuracy threshold; adjust the above-mentioned defect threshold interval based on the above-mentioned size relationship. This method can extract defect images in images to improve the efficiency of defect extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] 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.
[0019] Figure 1A schematic diagram of a defect image extraction method provided by an embodiment of the present invention;
[0020] Figure 2 A structural schematic diagram of a defect image extraction device provided by an embodiment of the present invention;
[0021] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0022] Icons: 21 - data acquisition module; 22 - target defect image output module; 41 - processor; 42 - memory; 43 - bus; 44 - communication interface. DETAILED DESCRIPTION
[0023] 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.
[0024] 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.
[0025] Based on this, an embodiment of the present invention provides a defect image extraction method and device, which can extract defect images in an image to improve defect extraction efficiency. For ease of understanding, the above defect image extraction method is first introduced in detail.
[0026] Example 1
[0027] In this embodiment, Figure 1 A schematic flow chart of a defect image extraction method provided by an embodiment of the present invention.
[0028] The method includes:
[0029] 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.
[0030] Step S102: preprocessing, grayscale processing and image segmentation with preset parameters are performed on the initial defective pipe image and the initial non-defective pipe image to obtain a plurality of first sub-images and a plurality of second sub-images.
[0031] Step S103: 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.
[0032] Step S104: 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.
[0033] Step S105: 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.
[0034] Step S106: 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.
[0035] Step S107: perform weighted averaging on the above-mentioned multiple differences to obtain an average deviation; and calculate the deviation of each of the above-mentioned marked images; calculate the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold interval; based on the above-mentioned inclusion relationship, output a target defect image of the above-mentioned marked image; based on the above-mentioned multiple distance degrees, output a target defect-free image of the above-mentioned marked image; based on a preset second defect parameter, determine a first accuracy of the above-mentioned target defect image and a second accuracy of the above-mentioned target defect-free image; based on the above-mentioned first accuracy and the above-mentioned second accuracy, calculate the overall accuracy; determine the size relationship between the above-mentioned overall accuracy and a preset accuracy threshold; based on the above-mentioned size relationship, adjust the above-mentioned defect threshold interval.
[0036] In one embodiment, the step of outputting the target defect image of the marked image according to the inclusion relationship includes: when the inclusion relationship is that the defect threshold interval includes the distance degree, outputting the target defect image corresponding to the distance degree of the marked image.
[0037] Furthermore, the step of performing weighted averaging on the above-mentioned multiple differences to obtain the average deviation degree includes: calculating the above-mentioned average deviation degree by the following formula: in, is the above average deviation, , … It is 1 to the mth difference mentioned above.
[0038] Furthermore, after the step of outputting a target defect image of the marked image according to the multiple distance degrees, the method further includes: outputting a target defect-free image of the marked image according to the multiple distance degrees; determining a first accuracy of the target defect image and a second accuracy of the target defect-free image based on a preset second defect parameter; calculating an overall accuracy according to the first accuracy and the second accuracy; determining a size relationship between the overall accuracy and a preset accuracy threshold; and adjusting the defect threshold interval according to the size relationship.
[0039] Furthermore, the first accuracy includes determining the number of first images that have defects in the target defective image and determining the number of second images that do not have defects in the target defective image; the second accuracy includes determining the number of third images that have defects in the target non-defective image and determining the number of fourth images that do not have defects in the target non-defective image; and the step of calculating the overall accuracy based on the first accuracy and the second accuracy includes: calculating the overall accuracy based on the number of first images, the number of second images, the number of third images and the number of fourth images.
[0040] Further, according to the first number of images, the second number of images, the third number of images and the fourth number of images, the step of calculating the overall accuracy includes:
[0041] The overall accuracy is calculated using the following formula:
[0042]
[0043] Wherein, F is the overall accuracy, F1 is the number of the first images, F3 is the number of the fourth images, F2 is the number of the second images, and F4 is the number of the third images.
[0044] Furthermore, the step of adjusting the defect threshold interval according to the above-mentioned size relationship includes: when the above-mentioned size relationship is that the above-mentioned overall accuracy is less than or equal to the above-mentioned preset accuracy threshold, clustering analysis is performed on the first distance degree of the above-mentioned first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images to obtain analysis results; and adjusting the above-mentioned defect threshold interval according to the above-mentioned analysis results.
[0045] Further, when the size relationship is such that the overall accuracy is less than or equal to the preset accuracy threshold, cluster analysis is performed on the first distance degree of the first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images, and before the step of obtaining the analysis result, the method includes: obtaining a preset clustering category, a distance threshold between the clustering categories, a fuzzy index, and a stop iteration threshold; when the size relationship is such that the overall accuracy is less than or equal to the preset accuracy threshold, cluster analysis is performed on the first distance degree of the first number of images, the second distance degree of the second number of images, the third distance degree of the third number of images, and the fourth distance degree of the fourth number of images, and the step of obtaining the analysis result includes:
[0046] Step A1: taking the first distance metric, the second distance metric, the third distance metric and the fourth distance metric as initial samples respectively.
[0047] Step A2: Calculate the distance between each of the initial samples to obtain a plurality of first distance values.
[0048] Step A3: construct a first matrix based on the above multiple first distance values; and select a first minimum value from the above multiple first distance values, and set the first target sample corresponding to the above first minimum value as the first initial clustering center.
[0049] Step A4: Based on the first matrix, calculate the second distance between other samples in the initial samples except the first initial cluster center and the first initial cluster center.
[0050] Step A5: Filter other target samples that are greater than the distance threshold from the second distance values; filter the second minimum value from the multiple second distance values, and set the second target sample corresponding to the second minimum value as the second initial cluster center.
[0051] Step A6: Repeat the above steps A2 to A5 until the number of selections reaches the above cluster category, a plurality of cluster centers are obtained, and the above plurality of cluster centers are constructed into a cluster center matrix.
[0052] Step A7: Calculate the Euclidean distance between the initial sample and the multiple cluster centers.
[0053] Step A8: Calculate the membership of the above Euclidean distance to obtain a membership matrix.
[0054] Step A9: According to the above-mentioned membership matrix, the above-mentioned cluster center matrix is updated multiple times to obtain the target updated state center matrix, until the absolute value of the difference between the above-mentioned target updated state center matrix and the previous updated state center matrix corresponding to the above-mentioned target updated state center matrix is less than the preset parameter, and the above-mentioned target updated state center matrix is output.
[0055] Step A10: Determine the target updated state center matrix corresponding to each of the initial samples as the analysis result.
[0056] According to the above analysis results, the steps of adjusting the above defect threshold range include:
[0057] Step B1: Determine the maximum cluster community corresponding to each of the above initial samples according to the above target updated state center matrix corresponding to each of the above initial samples.
[0058] Step B2: Divide the above-mentioned maximum cluster community into a defect image distance database, a non-defect image distance database, a distance database of objects judged to be defects but actually are non-defects, and a distance database of objects judged to be non-defects but actually are defects according to the preset quadrants corresponding to the above-mentioned first distance degree, the above-mentioned second distance degree, the above-mentioned third distance degree and the above-mentioned fourth distance degree.
[0059] Step B3: Merge the defect image distance database and the distance database of the objects judged as non-defective but actually defective to obtain a first database; and merge the non-defect image distance database and the distance database of the objects judged as defective but actually non-defective to obtain a second database.
[0060] Step B4: Map the first database to the Gaussian distribution of the defect threshold interval, and set the first overlapping part of the first database and the defect threshold interval as the first interval; and map the second database to the Gaussian distribution, and set the second overlapping part of the second database and the defect threshold interval as the second interval.
[0061] Step B5: Repeat the above steps B1 to B4 until the above overall accuracy is greater than the above preset accuracy threshold.
[0062] Further, the steps of preprocessing the above-mentioned initial defective pipeline image and the initial non-defective pipeline image to obtain the defective pipeline image and the non-defective pipeline image include: saving the above-mentioned original defective pipeline image and the above-mentioned original non-defective pipeline image as original images; adaptively enhancing the brightness vector, contrast vector and saturation vector of the original images to obtain enhanced images; wherein the contrast vector of the above-mentioned original images is adaptively enhanced by the following formula:
[0063] , where BH is the saturation of the original image, FS 1 To enhance the saturation of the image above, is the maximum value of the corresponding pixel points of the original image above, is the minimum value of the corresponding pixel points of the original image; is the average value of the corresponding pixels of the original image above;
[0064] 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 first enhanced image, converting the HSV space of the first enhanced image into RGB space, and finally enhancing the image through unsharp masking technology to obtain a second enhanced image;
[0065] The step of performing enhancement by using an unsharp masking technique to obtain a second enhanced image includes:
[0066] For the above original image Y (x, y, z) and Gaussian function G g By performing convolution calculation on (x, y, z), we can get the fuzzy function M(x, y, z); the expression of M is:
[0067] By performing a difference operation between the original image and the blur function, a high-frequency image GP (x, y, z) can be obtained. The formula of the GP (x, y, z) is: GP (x, y, z) = Y (x, y, z) - M (x, y, z);
[0068] enhancing the high-frequency image to obtain the second enhanced image;
[0069] The calculation formula is: ;
[0070] 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];
[0071] Determine an enhanced image according to the second enhanced image;
[0072] According to the enhanced image, a defective pipeline image and a non-defective pipeline image are determined.
[0073] The embodiments of the present invention have the following beneficial effects:
[0074] 1) The entire image is broken down into smaller parts, and the grayscale pixel values of different blocks of the image are used for feature extraction. The defective areas in the image are extracted, and four distances are creatively introduced to adaptively adjust the four recognition and interpretation methods, optimize the Gaussian distribution interval, and effectively improve the interpretation accuracy.
[0075] 2) Currently, the commonly used image feature extraction and recognition are mainly carried out on the original image, but some original images are not clear or even fuzzy. Therefore, the present invention adopts image enhancement technology to enhance the information such as brightness vector, contrast vector and saturation vector respectively, so that the image of the defective area is further enhanced and clearer;
[0076] The embodiment of the present invention provides a defect image extraction 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 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, grayscale processing and image segmentation with preset parameters on the initial defective pipe image and the initial non-defective pipe image 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 the preset first defect parameter to obtain a marked image; and comparing the marked image, the first grayscale value of the center position of the marked image and the second sub-image corresponding to the marked image. Subtract the second grayscale value of the second target image at the center position to obtain multiple differences; perform weighted averaging on the above multiple differences to obtain an average deviation; and calculate the deviation of each of the above marked images; calculate the distance between the deviation of each of the above marked images and the above average deviation to obtain multiple distances; determine the inclusion relationship between each distance and the preset defect threshold interval; output the target defect image of the above marked image based on the above inclusion relationship; output the target defect-free image of the above marked image based on the above multiple distances; determine the first accuracy of the above target defect image and the second accuracy of the above target defect-free image based on the preset second defect parameter; calculate the overall accuracy based on the above first accuracy and the above second accuracy; determine the size relationship between the above overall accuracy and the preset accuracy threshold; adjust the above defect threshold interval based on the above size relationship. This method can extract defect images in images to improve the efficiency of defect extraction.
[0077] Example 2
[0078] Based on the above embodiment 1, Figure 2 A schematic structural diagram of a defect image extraction device provided by an embodiment of the present invention.
[0079] Depend on Figure 2 As can be seen, the device includes:
[0080] The data acquisition 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-processing, grayscale processing and image segmentation with preset parameters are performed on the initial defective pipe image and the initial non-defective pipe image 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 the preset first defect parameter to obtain a marked image; subtracting a first grayscale value of the marked image and a center position of the marked image from a second grayscale value of a second target image at the center position of the second sub-image corresponding to the marked image to obtain a plurality of difference values;
[0081] The target defect image output module 22 is used to perform weighted averaging on the above-mentioned multiple differences to obtain an average deviation; and calculate the deviation of each of the above-mentioned marked images; calculate the distance between the deviation of each of the above-mentioned marked images and the above-mentioned average deviation to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold interval; output the target defect image of the above-mentioned marked image based on the above-mentioned inclusion relationship; output the target defect-free image of the above-mentioned marked image based on the above-mentioned multiple distance degrees; determine the first accuracy of the above-mentioned target defect image and the second accuracy of the above-mentioned target defect-free image based on a preset second defect parameter; calculate the overall accuracy based on the above-mentioned first accuracy and the above-mentioned second accuracy; determine the size relationship between the above-mentioned overall accuracy and a preset accuracy threshold; and adjust the above-mentioned defect threshold interval based on the above-mentioned size relationship.
[0082] The data acquisition module 21 is connected to the target defect image output module 22 .
[0083] The defect image extraction device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned defect image extraction embodiment. For the sake of brief description, for parts not mentioned in the embodiment of the above-mentioned defect image extraction device, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0084] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the above claims.
[0085] The defect image extraction device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned defect image extraction method embodiment. For the sake of brief description, for parts not mentioned in the embodiment of the above-mentioned defect image extraction device, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0086] The embodiment of the present invention further provides an electronic device, such as Figure 3 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 extraction method.
[0087] exist Figure 3 In 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.
[0088] 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 storage. 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 3 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.
[0089] 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 can be located in a random access memory, flash memory, read-only memory, programmable read-only memory or 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 extraction method of the above embodiment in combination with its hardware.
[0090] 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 defect image extraction method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.
[0091] The computer program product of the defect image extraction method, defect image extraction device and electronic device provided in the embodiments of the present invention includes 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 extraction method in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here.
[0092] Unless otherwise specified, 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 that can be executed 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 for 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: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
Claims
1. A defect image extraction method, It is 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, graying and image segmentation with preset parameters are performed on the initial defective pipeline image and the initial non-defective pipeline image 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; and calculating the degree of deviation of each of the marked images; Calculate the distance between the deviation degree of each of the marked images and the average deviation degree to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold interval; when the inclusion relationship is that the defect threshold interval contains the distance degree, output the target defect image corresponding to the distance degree of the marked image; Outputting a target defect-free image of the marked image according to the multiple distances; determining a first accuracy of the target defect image and a second accuracy of the target defect-free image based on a preset second defect parameter; wherein the first accuracy includes the number of first images determining that the target defect image has defects and the number of second images determining that the target defect image does not have defects; the second accuracy includes the number of third images determining that the target defect-free image has defects and the number of fourth images determining that the target defect-free image does not have defects; The step of calculating the overall accuracy according to the first number of images, the second number of images, the third number of images and the fourth number of images comprises: The overall accuracy is calculated using the following formula: Wherein, F is the overall accuracy, F1 is the number of the first images, F3 is the number of the fourth images, F2 is the number of the second images, and F4 is the number of the third images; Determining the relationship between the overall accuracy and a preset accuracy threshold; Obtaining a preset clustering category, a distance threshold between the clustering categories, a fuzzy index, and a stop iteration threshold; Step A1: taking the first distance metric, the second distance metric, the third distance metric and the fourth distance metric as initial samples respectively; Step A2: respectively calculating the distance between each of the initial samples to obtain a plurality of first distance values; Step A3: constructing a first matrix based on the multiple first distance values; selecting a first minimum value from the multiple first distance values, and setting a first target sample corresponding to the first minimum value as a first initial clustering center; Step A4: based on the first matrix, calculating the second distance values between the first initial cluster center and the other samples in the initial samples except the first initial cluster center; Step A5: Filtering other target samples that are greater than the distance threshold from the second distance values; filtering a second minimum value from the plurality of second distance values, and setting the second target sample corresponding to the second minimum value as a second initial clustering center; Step A6: repeating the steps A2 to A5 until the number of selections reaches the cluster category, obtaining a plurality of cluster centers, and constructing the plurality of cluster centers into a cluster center matrix; Step A7: Calculate the Euclidean distance between the initial sample and the multiple cluster centers; Step A8: Calculate the membership of the Euclidean distance to obtain a membership matrix; Step A9: According to the membership matrix, the cluster center matrix is updated multiple times to obtain a target updated state center matrix, until the absolute value of the difference between the target updated state center matrix and the last updated state center matrix corresponding to the target updated state center matrix is less than a preset parameter, and the target updated state center matrix is output; Step A10: determining the target updated state center matrix corresponding to each of the initial samples as the analysis result; Step B1: determining the maximum cluster community corresponding to each of the initial samples according to the target updated state center matrix corresponding to each of the initial samples; Step B2: dividing the maximum cluster community into a defect image distance database, a non-defect image distance database, a distance database of images determined to be defects but actually non-defects, and a distance database of images determined to be non-defects but actually defects according to the preset quadrants corresponding to the first distance, the second distance, the third distance, and the fourth distance; Step B3: merging the defect image distance database and the distance database of the objects judged as non-defects but actually defective to obtain a first database; and merging the non-defect image distance database and the distance database of the objects judged as defects but actually non-defective to obtain a second database; Step B4: mapping the first database to the Gaussian distribution of the defect threshold interval, and setting a first overlapping portion of the first database and the defect threshold interval as a first interval; and mapping the second database to the Gaussian distribution, and setting a second overlapping portion of the second database and the defect threshold interval as a second interval; Step B5: Repeat step B1 to step B4 until the overall accuracy is greater than the preset accuracy threshold.
2. The defect image extraction method according to claim 1, It is characterized in that The step of performing weighted averaging on the multiple differences to obtain an average deviation degree comprises: The average deviation is calculated by the following formula: in, is the average deviation, , … It is 1 to the mth difference.
3. The defect image extraction method according to claim 1, It is characterized in that The step of preprocessing the initial defective pipeline image and the initial non-defective pipeline image to obtain the defective pipeline image and the non-defective pipeline image comprises: The original defective pipe image and the original non-defective pipe image are saved as original images; The original image is adaptively enhanced in terms of brightness vector, contrast vector and saturation vector respectively to obtain an enhanced image; wherein the original image is adaptively enhanced in terms of contrast vector respectively by the following formula: Wherein, BH is the saturation of the original image, FS 1 is the saturation of the enhanced image, is the maximum value of the corresponding pixel point of the original image, is the minimum value of the corresponding pixel points of the original image; is the average value of the corresponding pixels of the original 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 first enhanced image, converting the HSV space of the first enhanced image into the RGB space, and finally enhancing the image through the unsharp masking technology to obtain a second enhanced image; The step of performing enhancement by using an unsharp masking technique to obtain a second enhanced image includes: The original image Y (x, y, z) and the Gaussian function G g (x, y, z) is convolved to obtain the fuzzy function M(x, y, z); the expression of M is: ; By performing a difference operation between the original image and the blur function, a high-frequency image GP (x, y, z) can be obtained. The formula of GP (x, y, z) is: GP (x, y, z) = Y (x, y, z) - M (x, y, z); enhancing the high-frequency image to obtain the second enhanced image; The calculation formula is: ; 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]; determining the enhanced image according to the second enhanced image; According to the enhanced image, a defective pipeline image and a non-defective pipeline image are determined.
4. A defect image extraction device, It is characterized in that include: A data acquisition module, configured 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, grayed, and segmented with 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; A target defect image output module is used to perform weighted averaging on the multiple differences to obtain an average deviation degree; and calculating the degree of deviation of each of the marked images; Calculate the distance between the deviation degree of each of the marked images and the average deviation degree to obtain multiple distance degrees; determine the inclusion relationship between each distance degree and a preset defect threshold interval; when the inclusion relationship is that the defect threshold interval contains the distance degree, output the target defect image corresponding to the distance degree of the marked image; output the target defect-free image of the marked image according to the multiple distance degrees; based on a preset second defect parameter, determine the first accuracy of the target defect image and the second accuracy of the target defect-free image; wherein the first accuracy includes the number of first images that determine that the target defect image has defects and the number of second images that determine that the target defect image does not have defects; the second accuracy includes the number of third images that determine that the target defect-free image has defects and the number of fourth images that determine that the target defect-free image does not have defects; based on the first image number, the second image number, the third image number and the fourth image number, the step of calculating the overall accuracy includes: calculating the overall accuracy by the following formula: Wherein, F is the overall accuracy, F1 is the number of the first images, F3 is the number of the fourth images, F2 is the number of the second images, and F4 is the number of the third images; determine the size relationship between the overall accuracy and the preset accuracy threshold; obtain the preset clustering category, the distance threshold between the clustering categories, the fuzzy index, and the stop iteration threshold; step A1: use the first distance degree, the second distance degree, the third distance degree, and the fourth distance degree as initial samples respectively; step A2: calculate the distance between each of the initial samples respectively to obtain multiple first distance values; step A3: construct a first matrix based on the multiple first distance values; and select the first minimum value from the multiple first distance values, And set the first target sample corresponding to the first minimum value as the first initial cluster center; step A4: based on the first matrix, calculate the second distance value between the other samples in the initial sample except the first initial cluster center and the first initial cluster center; step A5: from the second distance value, select other target samples greater than the distance threshold; and select the second minimum value from the multiple second distance values, and set the second target sample corresponding to the second minimum value as the second initial cluster center; step A6: repeat the steps A2 to A5 until the number of selections reaches the cluster category, and multiple cluster centers are obtained, and the multiple cluster centers are constructed as a cluster center matrix ; Step A7: Calculate the Euclidean distance between the initial sample and the multiple cluster centers; Step A8: Calculate the membership of the Euclidean distance to obtain a membership matrix; Step A9: According to the membership matrix, update the cluster center matrix multiple times to obtain a target updated state center matrix, until the absolute value of the difference between the target updated state center matrix and the last updated state center matrix corresponding to the target updated state center matrix is less than a preset parameter, output the target updated state center matrix; Step A10: Determine the target updated state center matrix corresponding to each of the initial samples as the analysis result; Step B1: Determine each of the initial samples according to the target updated state center matrix corresponding to each of the initial samples. The maximum cluster community corresponding to the initial sample; step B2: dividing the maximum cluster community into a defect image distance database, a non-defect image distance database, a distance database of images determined to be defects but actually non-defects, and a distance database of images determined to be non-defects but actually defects according to the preset quadrants corresponding to the first distance degree, the second distance degree, the third distance degree, and the fourth distance degree; step B3: merging the defect image distance database and the distance database of images determined to be non-defects but actually defects to obtain a first database; and merging the non-defect image distance database and the distance database of images determined to be defects but actually non-defects to obtain a second database;Step B4: Mapping the first database to the Gaussian distribution of the defect threshold interval, setting the first overlapping part of the first database and the defect threshold interval as the first interval; and mapping the second database to the Gaussian distribution, setting the second overlapping part of the second database and the defect threshold interval as the second interval; Step B5: Repeating Steps B1 to B4 until the overall accuracy is greater than the preset accuracy threshold. ; 5. An electronic device, It is characterized in that The electronic device includes a processor and a memory, wherein the memory stores computer executable programs that can be executed by the processor, and the processor executes the computer executable programs to implement the defect image extraction method according to any one of claims 1 to 3.
