Engine liquid leakage detection method and system based on AI image processing
Through AI image processing technology, combined with ultraviolet light and fluorescent agents, and using SAM segmentation models and morphological operations, the problem of rapid and accurate engine leakage detection is solved, and efficient leakage area identification and damage judgment are achieved.
Patent Information
- Application Number
- CN202510717059.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-05-30
AI Technical Summary
Existing engine leakage detection methods and systems cannot quickly and accurately determine whether the engine has leakage, especially when it is difficult to identify trace leaks, and traditional detection methods are prone to misjudgment or missed detection.
An AI-based image processing method is used to obtain image information under engine idling and running conditions. Combined with ultraviolet lighting and fluorescent agents, image preprocessing, feature extraction and mask generation are performed. The SAM segmentation model is used to locate the leakage area, and morphological operations and intensity judgments are used to determine whether there is damage.
It significantly improves the efficiency and accuracy of engine leakage detection, can quickly identify trace leaks, reduce misjudgments, improve the accuracy and efficiency of detection, and avoid interference with the internal engine.
Smart Images

Figure CN120707474A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and more specifically, to an engine leakage detection method and detection system based on AI image processing. Background Art
[0002] The contents of this section merely provide background information related to this application and may not constitute prior art.
[0003] After the engine is assembled, it needs to be inspected for leaks. There are generally three types of fluids in an engine: fuel, oil, and coolant. These three fluids circulate in three different systems, and each system needs to be carefully inspected for leaks.
[0004] In existing technical solutions, inspections are generally carried out through visual image analysis systems or ultrasonic flaw detectors. In practice, visual image analysis systems can only detect larger damage, which generally includes cracks and pinholes. Different parts such as pipes, welds, sealing surfaces, and fastening points are not clear in the picture, and it is impossible to accurately determine whether there is damage, whether with the naked eye or with visual processing algorithms. Ultrasonic flaw detectors need to inspect the entire surface of the engine, which is prone to omissions in practice, and the internal structure of the engine is complex. The echo signal generated by the ultrasonic flaw detector cannot determine whether the hollow area is normal damage or a normal hollow structure. Therefore, using an ultrasonic flaw detector to check whether the engine is leaking requires a lot of time to inspect the entire surface of the engine.
[0005] In summary: There is currently a lack of an inspection method and detection system that can quickly and accurately determine whether there is a fluid leak in the engine. Summary of the Invention
[0006] In view of this, the purpose of this application is to provide an engine leakage detection method based on AI image processing, which is disclosed in this application and can solve the technical problems raised by the background technology.
[0007] The purpose of this application is achieved through the following technical solutions:
[0008] An engine fluid leakage detection method based on AI image processing includes the following steps:
[0009] Step 1: Acquire surface image information of the engine under idle conditions to obtain a first comparison image; acquire surface image information of the engine under running conditions to obtain a second comparison image;
[0010] Step 2: Preprocessing and feature extraction are performed on the first comparison image and the second comparison image respectively to obtain first image data and second image data;
[0011] Step 3: Input the first image data and the second image data into the SAM model to obtain a mask image of the initial determination area on the engine surface;
[0012] Step 4: Perform morphological operations on the mask image to generate the leakage area;
[0013] Step 5: Conduct strength assessment on the leakage area and determine whether the engine is damaged based on the strength assessment results.
[0014] This technical solution uses image processing technology to determine whether the engine is damaged, which significantly improves the detection efficiency compared to traditional ultrasonic flaw detection instruments. To further enhance the detection accuracy, the solution does not directly extract damage features through image processing technology, but focuses on detecting leakage during engine operation. Practice has shown that leakage caused by damage during engine operation is more significant than minor damage, and the detection recognition is higher, thereby effectively improving the detection accuracy. In terms of locating the leakage area, this solution improves the detection accuracy by collecting two sets of image data in the engine idle mode and working mode and performing comparative analysis. This comparison solution can quickly eliminate the complex detailed features of the engine surface, accurately extract the leakage area information, and greatly improve the accuracy of leakage area identification.
[0015] To address the problem that the color features of engine oil, fuel, and coolant themselves are poorly recognizable and it is difficult to effectively extract features from images when there is a trace leak, this application proposes the following technical solutions:
[0016] When acquiring the first comparative image and the second comparative image of the engine component, ultraviolet light is used as an illumination light source;
[0017] When the engine is running, add fluorescent agent to the engine oil and coolant.
[0018] This solution adds fluorescent agents to two types of liquids without loss of quality, giving the leaking liquid fluorescent properties. Combined with ultraviolet light illumination, the fluorescent reaction in the leaking area can be clearly captured. Compared to traditional detection methods, this technology can quickly filter out irrelevant background features in the comparison image, accurately locate potential leakage areas caused by defects such as damage, and effectively improve the detection accuracy and efficiency in trace leakage scenarios. In addition, ultraviolet light is used as the lighting source, which can clearly distinguish between fuel and background information. Therefore, even without adding fluorescent agents to the fuel, it is possible to identify trace fuel stains on the engine surface, thereby increasing recognition accuracy and avoiding the problem of carbon deposits in the engine caused by adding fluorescent agents to the engine during detection.
[0019] In some possible embodiments, the preprocessing in step 2 includes the following steps:
[0020] Step 21: using the first control image or the second control image as a preprocessed image, and performing Gaussian filtering on the preprocessed image to obtain a Gaussian filtered image;
[0021] Step 22: performing adaptive histogram equalization on the Gaussian filtered image to generate an equalized image;
[0022] Step 23: Perform gamma correction on the equalized image to generate first image data or second image data.
[0023] In the technical solution provided by this application, the image preprocessing process adopts the order of "Gaussian filtering → image equalization → image correction", which can effectively improve image quality and reduce the difficulty of subsequent feature extraction. The specific principles are as follows: Gaussian filtering suppresses image noise through smoothing processing, reducing the interference of noise data on subsequent processing. Since image equalization may amplify residual noise when enhancing contrast, the Gaussian filter in the preprocessing stage has filtered out most of the noise in advance, avoiding the unreasonable amplification of noise during the equalization process. After the equalization process, the image has reduced noise interference, optimized contrast and details. At this time, when performing image correction, the algorithm does not need to additionally process the interference caused by noise, thereby significantly reducing the amount of correction calculations. This processing sequence forms a layer-by-layer optimized preprocessing system through the logical chain of noise suppression-contrast enhancement-precision correction, ultimately achieving a systematic improvement in image quality and laying a high-quality data foundation for subsequent feature extraction.
[0024] In some possible embodiments, step 21 includes the following steps:
[0025] Step 211: setting the Gaussian kernel size and calculating the Gaussian function value G(x, y) of each pre-processed image within the Gaussian kernel;
[0026]
[0027] x, y represent the coordinates of a point in the Gaussian kernel relative to the center of the Gaussian kernel, σ represents the standard deviation of the Gaussian distribution, k represents the radius of the Gaussian kernel, π represents pi, and exp represents the natural exponential function;
[0028] Step 212: Filter each pixel in the preprocessed image using the Gaussian function value G(x, y) to obtain a Gaussian filtered image;
[0029]
[0030] Where I′(i, j) represents the pixel value of the Gaussian filtered image at position (i, j), I(i+m, j+n) represents the pixel value of the preprocessed image at position (i+m, j+n), m and n represent the offset of the Gaussian kernel, m∈[-k, k], n∈[-k, k], i and j represent the horizontal and vertical coordinates of the pixel, respectively.
[0031] In some possible embodiments, step 22 includes the following steps:
[0032] Step 221: Count the number of pixels n at each gray level in the Gaussian filtered image j ;
[0033] Step 222: Calculate the CDF value of each gray level;
[0034]
[0035] r k represents the original grayscale level of the Gaussian filter image, N represents the total number of pixels of the Gaussian filter image, k represents the upper limit of the grayscale level currently calculated, and CDF(r k ) indicates that the gray value in the image is less than or equal to r k The pixel ratio is used to describe the cumulative probability distribution of gray levels;
[0036] Step 223: Linearly map the CDF to the interval, and replace the grayscale values in the Gaussian image with the mapped values to generate a balanced image:
[0037] s k =round(CDF(r k )×(L-1));
[0038] round represents the rounding function, L represents the total number of gray levels, s k Represents the grayscale value after mapping.
[0039] In some possible embodiments, step 23 includes the following steps:
[0040] Step 231: normalizing the grayscale value of the equalized image;
[0041] Step 232: Perform power transformation on the normalized grayscale value:
[0042]
[0043] Among them, I gamma (x, y) is the pixel value at the pixel point (x, y) after power transformation, I norm (x, y) is the pixel value at the equalized image pixel point (x, y);
[0044] Step 233: I gamma (x,y) is denormalized to complete the gamma correction.
[0045] This application achieves multi-dimensional image quality optimization through a cascaded pre-processing process of "Gaussian filtering → adaptive histogram equalization → gamma correction": Gaussian filtering prioritizes noise suppression to avoid amplifying noise interference in the subsequent contrast enhancement stage; adaptive histogram equalization enhances local image details and global contrast on a low-noise basis, enhancing feature differentiation; gamma correction further precisely controls the overall brightness distribution to improve the image dynamic range. The three work together to form a progressive optimization logic of "noise reduction-sharpening-dimming", which not only significantly improves the image signal-to-noise ratio and feature recognizability, but also reduces the computational redundancy of subsequent equalization and correction through noise pre-suppression, effectively reducing the complexity of subsequent algorithms and improving overall processing efficiency.
[0046] Furthermore, the training method of the SAM model in step 3 includes the following steps:
[0047] Step 31: Preparing a standard data set in advance; the standard data set includes a number of samples, each sample including first image data, second image data, and a segmentation mask;
[0048] Step 32: Train the SAM segmentation model through transfer learning;
[0049] Step 33: Iteratively train the SAM segmentation model using the standard dataset until the expected effect is achieved.
[0050] In the technical solution provided in this application, transfer learning is used to train the SAM segmentation model, so the pre-trained weights of the SAM image encoder can be directly reused without training the SAM segmentation module from scratch, thereby increasing the segmentation efficiency of the SAM segmentation model.
[0051] When segmenting image data, in order to increase the accuracy of image data segmentation, the first image data and the second image data are used as comparison information. However, when the first image data and the second image data are input into the SAM segmentation model, many redundant features are generated, and thus the image mask cannot be accurately generated. To this end, the present application provides the following technical solutions:
[0052] Furthermore, the SAM segmentation model includes:
[0053] an image encoder, configured to input first image data and second image data and generate a high-dimensional image embedding;
[0054] Hint encoder, which takes hint data collected from the segmentation mask as input and generates hint embeddings;
[0055] Convolutional network, which performs convolution operations on image embeddings to generate convolution features;
[0056] The mask encoder takes as input the convolutional features and the hint embeddings, and aligns the hint embeddings with the convolutional features to generate the image mask.
[0057] In the technical solution provided in this application, a convolutional network is added to the SAM segmentation model. The convolutional network performs convolution operations on high-dimensional image embeddings. After the convolution operation, it can capture the difference information between the first image data and the second image data. By controlling the receptive field of the convolutional network, the local feature changes between the first image data and the second image data are captured, which on the one hand reduces the information redundancy of image embedding, and on the other hand increases the accuracy of feature extraction.
[0058] Furthermore, the generation process of image embedding is as follows;
[0059] S1: Divide the first image data and the second image data into blocks respectively to obtain N feature blocks;
[0060] S2: Perform linear projection on each feature block to generate a high-dimensional vector for each feature block;
[0061] S3: Add the high-dimensional vectors of each feature block block by block and perform Transformer encoding to generate a high-dimensional image embedding.
[0062] In the technical solution provided in the present application, the first image data and the second image data are divided into blocks respectively, so that the first image data and the second image data can be mixed, and the high-dimensional vector extracted therefrom contains detailed information of both, so the high-dimensional image embedding finally generated will contain a large amount of comparative information of the first image data and the second image data.
[0063] Furthermore, the prompt data includes point prompts and box prompts; the steps for extracting point prompts and box prompts are as follows:
[0064] Z1: Overlap the first image data and the second image data, use the pixels with the same pixel values in the first image data and the second image data as the background area, and use the pixels with different pixel values as the foreground area;
[0065] Z2: Randomly select k points from the foreground area to generate a positive point sampling set M GT ; Randomly select m points from the background area to generate a negative point sampling set M HT ;Add a random offset to each positive point and each negative point;
[0066] Z3: Get the minimum and maximum coordinates of the foreground area and generate the minimum bounding box;
[0067] Z4: The punctual sampling set MGT and negative point sampling set M HT As a point hint, use the minimum bounding box as the box hint.
[0068] In the technical solution provided in the present application, by comparing the first image data with the second image data, the foreground area and the background area can be quickly generated, so the relevant features of the area to be segmented can be accurately extracted without the need for labeling.
[0069] The generated mask image will contain some noise signals. To address this, this application provides the following technical solutions:
[0070] Step 4 includes the following steps:
[0071] Step 41: performing an opening operation of first corroding and then dilating the mask image to obtain mask information;
[0072] Step 42: performing a closing operation of first dilation and then erosion on the mask information to obtain the mask feature;
[0073] Step 43: extracting connected areas from the mask features and using the connected areas as leakage areas.
[0074] In this application, the opening operation removes isolated, small noise points (such as scattered foreground points) from the mask by "eroding first, then dilating" while preserving the main structure of the target object. The closing operation fills holes within the mask (such as breaks or missing target areas) by "dilation first, then erosion" to enhance the integrity of the mask. This process significantly improves the purity and coherence of the mask.
[0075] There may be some subtle differences between the first image data and the second image data, and these subtle differences may be identified as leakage areas. To this end, this application provides the following technical solutions:
[0076] Step 5 includes the following steps:
[0077] Step 51: Determine the area of the leakage region. If the area is smaller than a preset threshold, there is no engine damage in the leakage region. Otherwise, there is engine damage.
[0078] Step 52: Perform intensity threshold determination on the leakage area. If the fluorescence intensity is less than a preset dynamic intensity threshold, there is no engine damage in the leakage area; otherwise, there is engine damage.
[0079] The technical solution provided by this application will comprehensively judge the leakage area and whether there is real damage based on the leakage area and fluorescence threshold. According to the fluorescence characteristics generated by the damage leakage, it is accurately judged whether there is a leakage area.
[0080] An engine leakage detection system based on AI image processing uses the engine leakage detection method based on AI image processing to determine whether the engine is damaged.
[0081] The technical solutions of the embodiments of the present application have at least the following advantages and beneficial effects:
[0082] This technical solution uses image processing technology to determine whether the engine is damaged, which significantly improves the detection efficiency compared to traditional ultrasonic flaw detection instruments. To further enhance the detection accuracy, the solution does not directly extract damage features through image processing technology, but focuses on detecting leakage during engine operation. Practice has shown that leakage caused by damage during engine operation is more significant than minor damage, and the detection recognition is higher, thereby effectively improving the detection accuracy. In terms of locating the leakage area, this solution collects two sets of image data in the engine idle mode and working mode and performs comparative analysis. This comparison solution can quickly eliminate the complex detailed features of the engine surface, accurately extract the leakage area information, and greatly improve the accuracy of leakage area identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 is a grayscale image of engine oil under ultraviolet irradiation;
[0084] Figure 2 is a grayscale image of the coolant under ultraviolet irradiation;
[0085] Figure 3 is a grayscale image of fuel under ultraviolet irradiation;
[0086] Figure 4 This is a flow chart of the engine leakage detection method based on AI image processing;
[0087] Figure 5 Schematic diagram of the structure of the SAM model. DETAILED DESCRIPTION
[0088] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific implementation methods. The same figure marks in the accompanying drawings represent the same components. It should be noted that the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the described embodiments of this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0089] Compared to the embodiments shown in the drawings, feasible embodiments within the scope of protection of the present application may have fewer components, other components not shown in the drawings, different components, differently arranged components, or differently connected components, etc. In addition, two or more components in the drawings may be implemented in a single component, or a single component shown in the drawings may be implemented as multiple separate components.
[0090] Unless otherwise defined, the technical or scientific terms used herein shall have the ordinary meaning understood by persons of ordinary skill in the field to which this application belongs. The words "first", "second" and similar terms used in the specification and claims of this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "a" or "an" do not necessarily indicate a quantitative limitation. "Up", "down" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0091] Example 1:
[0092] refer to Figure 4 This application needs to detect damage on the engine surface, including cracks and sand holes. The cracks and sand holes are very small and cannot be accurately found by the naked eye or image recognition. In addition, the dust on the engine surface will block these sand holes, making it impossible to accurately detect these cracks.
[0093] The first embodiment of the present application discloses an engine fluid leakage detection method based on AI image processing, comprising the following steps:
[0094] Step 1: Acquire surface image information of the engine under idle conditions to obtain a first comparison image; acquire surface image information of the engine under running conditions to obtain a second comparison image.
[0095] When obtaining the first and second comparative images of the engine component, ultraviolet light is used as the illumination light source; when the engine is running, a trace amount of fluorescent agent is added to the engine oil and coolant.
[0096] Specifically: The wavelength of ultraviolet light is 350-365nm, the concentration of fluorescent agent in engine oil and coolant is 0.01-0.1g / L, and no fluorescent agent is added to fuel.
[0097] like Figures 1 to 3 As shown in the figure, the engine oil and coolant will be more obvious after adding fluorescent agent, and the fuel can also have a better display effect under ultraviolet light with a wavelength of 350-365nm.
[0098] After adding the fluorescent agent to the engine oil and coolant, it is necessary to shake the fluorescent agent evenly, so that there will be a certain amount of fluorescent substance in the engine oil and coolant after leakage.
[0099] The first comparison image and the second comparison image are images at the same position, the same angle and the same focal length on the engine surface.
[0100] In practice, the first comparison image and the second comparison image can be obtained in the following manner:
[0101] First, fix the camera to one side of the engine surface to be tested, aim the camera lens at the engine surface, and adjust the camera focus to make the image clear; then, remove the remaining light sources and use ultraviolet light with a wavelength of 350-365nm as the light source. The camera captures a picture, which is the first comparison image.
[0102] Then, keeping the engine stationary and other parameters unchanged, start the engine until it reaches a high speed condition. After running for 10 minutes, use ultraviolet light with a wavelength of 350-365nm as the light source, and the camera obtains a second picture, which is the second comparison image.
[0103] Therefore, the first and second comparison images are compared to images of the engine running at high speed. If there is no engine leakage, the second comparison image will be essentially the same as the first. However, if there is leakage, a fluorescent area will appear in the second comparison image, which is the key to determining whether there is leakage.
[0104] Furthermore, the image may be partially offset due to engine vibration, making it easy to miss detections by manual comparison alone. Therefore, a subsequent step is required to automatically determine whether there is damage on the engine.
[0105] Step 2: Preprocess and extract features of the first comparison image and the second comparison image respectively to obtain first image data and second image data.
[0106] The first and second comparison images have the same format and are processed in the same way. Both require preprocessing, as follows:
[0107] The preprocessing in step 2 includes the following steps:
[0108] Step 21: Use the first control image or the second control image as a preprocessed image, and perform Gaussian filtering on the preprocessed image to obtain a Gaussian filtered image.
[0109] The pre-processed image needs to be Gaussian filtered, histogram equalized and gamma corrected, that is, the first control image or the second control image. The pre-processing method of the first control image and the second control image is the same, so this application only introduces the pre-processing method of the first control image.
[0110] After obtaining the first and second comparison images, they need to be grayscale processed. Grayscale processing is to convert the image from RGB format to grayscale format. The specific conversion method is not detailed here.
[0111] Specifically: Step 21 includes the following steps:
[0112] Step 211: setting the Gaussian kernel size and calculating the Gaussian function value G(x, y) of each pre-processed image within the Gaussian kernel;
[0113]
[0114] x, y represent the coordinates of a point in the Gaussian kernel relative to the center of the Gaussian kernel, σ represents the standard deviation of the Gaussian distribution, k represents the radius of the Gaussian kernel, π represents pi, and exp represents the natural exponential function.
[0115] Step 212: Filter each pixel in the preprocessed image using the Gaussian function value G(x, y) to obtain a Gaussian filtered image;
[0116]
[0117] Where I′(i, j) represents the pixel value of the Gaussian filtered image at position (i, j), I(i+m, j+n) represents the pixel value of the preprocessed image at position (i+m, j+n), m and n represent the offset of the Gaussian kernel, m∈[-k, k], n∈[-k, k], i and j represent the horizontal and vertical coordinates of the pixel, respectively.
[0118] Gaussian filtering can remove discrete noise points in the preprocessed image and reduce the impact of noise on subsequent feature extraction.
[0119] Step 22: Perform adaptive histogram equalization on the Gaussian filtered image to generate an equalized image.
[0120] Step 22 includes the following steps:
[0121] Step 221: Count the number of pixels n at each gray level in the Gaussian filtered image j .
[0122] The grayscale value range is [0, 255]. In this application, several grayscale levels are pre-set. For example, if the grayscale levels are set to 10, the value range of each grayscale level is 25.5.
[0123] After setting the grayscale level, we can determine the value range of each grayscale level, then extract the grayscale value of each pixel in the Gaussian filtered image, count the number of pixels in each grayscale level, and we can get n j , j represents the index of the grayscale level.
[0124] Step 222: Calculate the CDF value of each gray level;
[0125]
[0126] r k represents the original grayscale level of the Gaussian filter image, N represents the total number of pixels of the Gaussian filter image, k represents the upper limit of the grayscale level currently calculated, and CDF(r k ) indicates that the gray value in the image is less than or equal to r k The percentage of pixels is used to describe the cumulative probability distribution of gray levels.
[0127] Step 223: Linearly map the CDF to the interval, and replace the grayscale values in the Gaussian image with the mapped values to generate a balanced image:
[0128] s k =round(CDF(r k )×(L-1));
[0129] round represents the rounding function, L represents the total number of gray levels, s k Represents the grayscale value after mapping.
[0130] The global equalization strategy provided in this application can over-enhance the contrast of the noisy area, thereby stretching the area with uneven grayscale distribution in the image, increasing the local contrast, and making the local details clearer.
[0131] Step 23: Perform gamma correction on the equalized image to generate first image data or second image data.
[0132] Step 23 includes the following steps:
[0133] Step 231: Normalize the grayscale value of the equalized image.
[0134] The grayscale value of the balanced image is the grayscale value, S k The value range is [0, 255].
[0135] Step 232: Perform power transformation on the normalized grayscale value:
[0136]
[0137] Among them, I gamma (x, y) is the pixel value at the pixel point (x, y) after power transformation, I norm (x, y) is the pixel value at the equalized image pixel point (x, y);
[0138] Step 233: I gamma (x,y) is denormalized to complete the gamma correction.
[0139] The key to gamma correction is to normalize the pixel values, transform them with a preset gamma value, and then perform inverse normalization to restore the grayscale value. In this application, γ=0.5.
[0140] By adopting the above solution, the first comparison image and the second comparison image can be preprocessed, and the preprocessed images have higher definition, more obvious features and less noise. The preprocessed images are the first image data and the second image data.
[0141] The subsequent step is to use the first image data and the second image data as input to extract the mask information related to the leakage.
[0142] Step 3: Input the first image data and the second image data into the SAM model to obtain a mask image of the initial determination area on the engine surface.
[0143] In step 3, the key component is the SAM model, an image processing model that automatically segments images. It typically takes a single image as input and extracts the corresponding mask information based on it. This mask information is the feature information that needs to be extracted.
[0144] In this application, in order to increase the ability to extract feature regions, it is necessary to input two images, namely, the first image data and the second image data, into the SAM model at one time.
[0145] The SAM segmentation model consists of an image encoder, a hint encoder, a convolutional network, and a mask encoder. The image encoder is connected to the convolutional network signal, the convolutional network is connected to the mask encoder, and the hint encoder is connected to the mask encoder.
[0146] The image encoder is configured to input first image data and second image data and generate a high-dimensional image embedding.
[0147] The generation process of image embedding is as follows;
[0148] S1: Divide the first image data and the second image data into blocks respectively to obtain N feature blocks.
[0149] The first image data and the second image data are input into the image encoder twice and then divided into N feature blocks. The first image data is divided into N / 2 feature blocks, and the second image data is divided into N / 2 feature blocks.
[0150] The size of the feature block can be set according to requirements. In this application, the size of the feature block is 16×16 pixels.
[0151]
[0152] H and W are divisible by 16, and H and W represent the length and width of the first image data, respectively.
[0153] S2: Linearly project each feature block to generate a high-dimensional vector for each feature block.
[0154] The specific method of high-dimensional vector is as follows:
[0155] S21: Set the projection matrix W proj :
[0156] E represents the length of the feature block, and D represents the dimension of the high-dimensional vector;
[0157] S22: Each feature block is transformed into a projection matrix W proj Perform linear projection calculation to generate high-dimensional vectors;
[0158]
[0159] Among them, I patched Represents the image matrix after the feature block is expanded, X patch Represents the high-dimensional vector after the feature block is projected;
[0160] S3: Add the high-dimensional vectors of each feature block block by block and perform Transformer encoding to generate a high-dimensional image embedding.
[0161] S3 includes the following steps:
[0162] S31: The high-dimensional vector X of each feature block patch Add position code P to get embedded information X in ; P represents the position code P of the feature block, and the position code is the serial number of the feature block.
[0163] S32: X patch Input into the Transforme encoder, gradually extract the global semantic information in the input embedding matrix to generate image embedding.
[0164] The prompt encoder takes the prompt data collected from the segmentation mask as input and generates the prompt embedding.
[0165] Prompt data includes point prompts and box prompts. The steps for extracting point prompts and box prompts are as follows:
[0166] Z1: Overlap the first image data and the second image data, use the pixels with the same pixel values in the first image data and the second image data as the background area, and use the pixels with different pixel values as the foreground area;
[0167] Z2: Randomly select k points from the foreground area to generate a positive point sampling set M GT ; Randomly select m points from the background area to generate a negative point sampling set M HT ;Add a random offset to each positive point and each negative point;
[0168] Z3: Get the minimum and maximum coordinates of the foreground area and generate the minimum bounding box;
[0169] Z4: The punctual sampling set M GT and negative point sampling set M HT As a point hint, use the minimum bounding box as the box hint.
[0170] Convolutional network, performs convolution operations on image embeddings to generate convolution features.
[0171] The convolutional network includes: input layer, convolution layer, activation function layer and pooling layer.
[0172] Input layer: Receives image embeddings whose data dimensions are determined by the output of the image encoder.
[0173] The image is embedded in [B,C,H,W], where B represents the batch size, C represents the number of channels, and H and W represent the height and width respectively.
[0174] The convolution layer consists of three parts: front-end convolution, middle convolution, and back-end convolution.
[0175] Front-end convolution: Uses a smaller convolution kernel for convolution processing. This setting can preserve local image details while performing preliminary feature extraction on the image embedding, allowing the network to begin learning basic features such as edges and textures in the image.
[0176] Intermediate convolution: Use a larger convolution kernel, such as a 5×5 convolution kernel.
[0177] Back-end convolution: Use a 1×1 convolution kernel. The number of convolution kernels is determined by the input requirements of the subsequent mask encoder, such as 32.
[0178] Activation function layer: Add ReLU activation function after the front convolution, middle convolution and back end convolution.
[0179] Pooling layer: between the middle convolution and the back-end convolution, used for average pooling.
[0180] The mask encoder takes as input the convolutional features and the hint embeddings, and aligns the hint embeddings with the convolutional features to generate the image mask.
[0181] The training method of the SAM model in step 3 includes the following steps:
[0182] Step 31: Prepare a standard data set in advance; the standard data set includes a number of samples, each sample includes first image data, second image data and a segmentation mask.
[0183] Among them, the segmentation mask is the labeled data, which is a mask correctly segmented by humans.
[0184] Step 32: Train the SAM segmentation model via transfer learning.
[0185] Step 33: Iteratively train the SAM segmentation model using the standard dataset until the expected effect is achieved.
[0186] Step 4: Perform morphological operations on the mask image to generate the leakage area.
[0187] Step 4 includes the following steps:
[0188] Step 41: performing an opening operation of first corroding and then dilating the mask image to obtain mask information;
[0189]
[0190] Among them, A represents the mask image, B represents the structural element, represents the corrosion operation, and ⊕ represents the expansion operation.
[0191] The meaning of the erosion operation is: the structural element B slides on the mask image A. If B is completely contained in the foreground area of A, the center pixel is retained as 1, otherwise it is 0.
[0192] The meaning of the dilation operation is: the structural element B slides on the mask image A, and if B intersects with the foreground area of the image, the center pixel is set to 1.
[0193] Step 42: Perform a closing operation of first dilating and then corroding the mask information to obtain the mask feature.
[0194]
[0195] Among them, C represents the corrosion operation and B represents the structural element;
[0196] The structure element is a preset binary matrix, for example, a 3×3 binary matrix.
[0197] After obtaining the mask features, Gaussian filtering can be used to filter the mask features to remove possible noise signals.
[0198] Step 43: extracting connected areas from the mask features and using the connected areas as leakage areas.
[0199] Step 43 includes the following steps:
[0200] Step 431: Mark the connected components of the mask image and identify all continuous foreground areas.
[0201] Adjacent pixels with the same mask attributes are grouped as a connected region. By scanning each pixel in the mask image, if a pixel is a foreground pixel and has not been previously labeled, a four-neighborhood search algorithm is used, starting from that pixel and spreading to its surrounding adjacent pixels. All connected foreground pixels are labeled with the same region number. By traversing the entire mask image in this way, all continuous foreground regions can be identified, which may correspond to leaking areas on the engine surface.
[0202] Step 432: Calculate the area, position, and shape characteristics of each foreground area, and select candidate areas that meet preset conditions as leakage areas.
[0203] Step 5: Conduct strength assessment on the leakage area and determine whether the engine is damaged based on the strength assessment results.
[0204] Step 5 includes the following steps:
[0205] Step 51: Determine the area of the leakage region. If the area is smaller than a preset threshold, there is no engine damage in the leakage region. Otherwise, there is engine damage.
[0206] For example: If the resolution is 100 pixels / cm, then 1cm 2 Corresponding to 100×100 pixels, if the leakage area is smaller than the preset 0.5cm 2 , then there is no leakage.
[0207] Step 52: Perform intensity threshold determination on the leakage area. If the fluorescence intensity is less than a preset dynamic intensity threshold, there is no engine damage in the leakage area; otherwise, there is engine damage.
[0208] For example: the area of the leakage area is 1cm 2 , 1cm 2The fluorescence intensity corresponding to the leakage area is 10. If the fluorescence intensity is less than 10, it means that the leakage area is not a real leakage area. If it is greater than 10, it means that the leakage area is a real leakage area and there is engine damage.
[0209] In a more specific embodiment, the engine surface may be inspected for leakage areas at different angles. If leakage is detected in the same area at multiple angles, the area is marked as a leakage area, otherwise it is not.
[0210] Example 2: An engine leakage detection system based on image processing, which uses the engine leakage detection method based on AI image processing to determine whether the engine is damaged.
[0211] The above are merely preferred embodiments of the present application and are not intended to limit the present application. Those skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. An engine leakage detection method based on AI image processing, characterized in that: The steps include: Step 1: Acquire surface image information of the engine under idle conditions to obtain a first comparison image; acquire surface image information of the engine under running conditions to obtain a second comparison image; Step 2: Preprocessing and feature extraction are performed on the first comparison image and the second comparison image respectively to obtain first image data and second image data; Step 3: Input the first image data and the second image data into the SAM model to obtain a mask image of the initial determination area on the engine surface; Step 4: Perform morphological operations on the mask image to generate the leakage area; Step 5: Conduct strength assessment on the leakage area and determine whether the engine is damaged based on the strength assessment results.
2. The engine fluid leakage detection method based on AI image processing according to claim 1, characterized in that: The preprocessing in step 2 includes the following steps: Step 21: using the first control image or the second control image as a preprocessed image, and performing Gaussian filtering on the preprocessed image to obtain a Gaussian filtered image; Step 22: performing adaptive histogram equalization on the Gaussian filtered image to generate an equalized image; Step 23: Perform gamma correction on the equalized image to generate first image data or second image data.
3. The engine leakage detection method based on AI image processing according to claim 2 is characterized in that: Step 21 includes the following steps: Step 211: setting the Gaussian kernel size and calculating the Gaussian function value G(x, y) of each pre-processed image within the Gaussian kernel; x, y represent the coordinates of a point in the Gaussian kernel relative to the center of the Gaussian kernel, σ represents the standard deviation of the Gaussian distribution, k represents the radius of the Gaussian kernel, π represents pi, and exp represents the natural exponential function; Step 212: Filter each pixel in the preprocessed image using the Gaussian function value G(x, y) to obtain a Gaussian filtered image; Where I′(i, j) represents the pixel value of the Gaussian filtered image at position (i, j), I(i+m, j+n) represents the pixel value of the preprocessed image at position (i+m, j+n), m and n represent the offset of the Gaussian kernel, m∈[-k, k], n∈[-k, k], i and j represent the horizontal and vertical coordinates of the pixel, respectively.
4. The engine fluid leakage detection method based on AI image processing according to claim 2, characterized in that: Step 22 includes the following steps: Step 221: Count the number of pixels n at each gray level in the Gaussian filtered image j ; Step 222: Calculate the CDF value of each gray level; r k represents the original grayscale level of the Gaussian filter image, N represents the total number of pixels of the Gaussian filter image, k represents the upper limit of the grayscale level currently calculated, and CDF(r k ) indicates that the gray value in the image is less than or equal to r k The pixel ratio is used to describe the cumulative probability distribution of gray levels; Step 223: Linearly map the CDF to the interval, and replace the grayscale values in the Gaussian image with the mapped values to generate a balanced image: s k =round(CDF(r k )×(L-1)); round represents the rounding function, L represents the total number of gray levels, s k Represents the grayscale value after mapping.
5. The engine fluid leakage detection method based on AI image processing according to claim 2, characterized in that: Step 23 includes the following steps: Step 231: normalizing the grayscale value of the equalized image; Step 232: Perform power transformation on the normalized grayscale value: Among them, I gamma (x, y) is the pixel value at the pixel point (x, y) after power transformation, I norm (x, y) is the pixel value at the equalized image pixel point (x, y); Step 233: I gamma (x,y) is denormalized to complete the gamma correction.
6. The engine fluid leakage detection method based on AI image processing according to claim 1, characterized in that: The training method of the SAM model in step 3 includes the following steps: Step 31: Prepare a standard data set in advance; the standard data set includes a number of samples, each sample includes first image data, second image data and a segmentation mask; Step 32: Train the SAM segmentation model through transfer learning; Step 33: Iteratively train the SAM segmentation model using the standard dataset until the expected effect is achieved.
7. The engine fluid leakage detection method based on AI image processing according to claim 6, characterized in that: The SAM segmentation model includes: an image encoder, configured to input first image data and second image data and generate a high-dimensional image embedding; Hint encoder, which takes hint data collected from the segmentation mask as input and generates hint embeddings; Convolutional network, which performs convolution operations on image embeddings to generate convolution features; The mask encoder takes as input the convolutional features and the hint embeddings, and aligns the hint embeddings with the convolutional features to generate the image mask.
8. The engine fluid leakage detection method based on AI image processing according to claim 1, characterized in that: When acquiring the first comparative image and the second comparative image of the engine component, ultraviolet light is used as an illumination light source; When the engine is running, add a small amount of fluorescent agent to the engine oil and coolant.
9. The engine fluid leakage detection method based on AI image processing according to claim 1, characterized in that: Step 4 includes the following steps: Step 41: performing an opening operation of first corroding and then dilating the mask image to obtain mask information; Step 42: performing a closing operation of first dilation and then erosion on the mask information to obtain the mask feature; Step 43: extracting connected areas from the mask features and using the connected areas as leakage areas; Step 5 includes the following steps: Step 51: Determine the area of the leakage region. If the area is smaller than a preset threshold, there is no engine damage in the leakage region. Otherwise, there is engine damage. Step 52: Perform intensity threshold determination on the leakage area. If the fluorescence intensity is less than a preset dynamic intensity threshold, there is no engine damage in the leakage area; otherwise, there is engine damage.
10. An engine leakage detection system based on image processing, characterized in that: The engine fluid leakage detection method based on AI image processing according to any one of claims 1 to 9 is used to determine whether the engine is damaged.
Citation Information
Patent Citations
Diesel engine oil leakage identification method
CN115311285A
Visual detection method for oil leakage of EMS trolley
CN116228659A
Online foreign matter line detection method and system
CN116468726A
Vehicle illegal driving detection method, device and equipment and storage medium
CN119888894A
Electrostatic charge image developing toner, electrostatic charge image developer, toner cartridge, developer cartridge, process cartridge, image forming apparatus, and image forming method
US20130252159A1