Concrete dam crack matting method and system based on diffusion model

By combining diffusion models and image matting techniques, and utilizing crack boundary feature extraction and correction modules, the problem of insufficient image segmentation accuracy for water conservancy dams was solved, achieving high-precision identification and robust detection of cracks in concrete dams.

CN118781148BActive Publication Date: 2025-12-12ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410793040.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2025-12-12
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

Existing image segmentation networks cannot obtain high-precision segmentation results on water conservancy dam images. Traditional manual inspections are inefficient and easily affected by human factors. Automated algorithms have insufficient detection accuracy and generalization ability, making it difficult to comprehensively cover various types of dam image data.

Method used

By combining diffusion model and image matting technology, basic edge information is obtained through crack boundary feature extraction module. Then, diffusion restoration crack boundary feature module and correction module are used to iteratively optimize the model to improve detection accuracy and reduce missed detections. By leveraging the high accuracy of diffusion model and the sensitivity of matting technology to edge information, accurate identification of cracks in concrete dams can be achieved.

Benefits of technology

It improves the accuracy and robustness of crack detection in concrete dams, reduces missed detections, and enhances the overall performance and detection efficiency of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118781148B_ABST
    Figure CN118781148B_ABST
Patent Text Reader

Abstract

The application discloses a concrete dam crack segmentation method and system based on a diffusion model, which comprises the following steps: 1) preprocessing a water conservancy dam image; 2) encoding a concrete dam crack feature; 3) removing image noise to obtain a crack boundary feature by using a diffusion network; 4) adjusting a predicted crack boundary feature in combination with a known region; and 5) post-processing a dam image crack segmentation result. The application uses a crack boundary feature extraction module to obtain basic crack edge information, uses a Trimap form to guide the training direction of the model, makes the model faster to fit to a global optimal point, then uses a diffusion crack boundary feature restoration module to obtain a refined segmentation result from the Trimap, and finally uses a crack boundary prediction correction module to combine the labeled information, so that the model pays more attention to the foreground crack region rather than the background region, a more accurate feature representation is obtained, the detection precision is improved, the missed detection situation is reduced, and the overall performance of the model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of image matting, and particularly relates to a concrete dam crack matting method and system based on a diffusion model. BACKGROUND

[0002] As an important part of infrastructure, the safety of water conservancy dams is of great importance to the safety of people's lives and property and social stability. Once a dam has a problem, such as structural cracks, it is likely to cause serious safety accidents, even dam collapse, causing catastrophic losses to residents and towns along the line. The safety of the dam is not only related to the safety of the lives and property of the residents along the line, but also an important foundation for the economic and social development of the country. As we all know, dams play a crucial role in power generation, irrigation, flood control and other aspects. Once a dam has a safety accident, not only will it cause direct loss of life and property, but also will cause a chain reaction of power supply interruption, agricultural irrigation obstruction, loss of flood control function, etc., which will have a serious impact on local and even regional economic and social development. Therefore, ensuring the safety of the dam has become a top priority in the construction and management of national infrastructure, and crack detection of the dam, as one of the most important technical solutions to ensure the safety of the dam, has naturally become one of the main fields of current dam safety maintenance.

[0003] However, the current dam crack detection technology still has some shortcomings. Traditional manual inspection and monitoring methods are inefficient and difficult to find subtle cracks in a timely manner, and are easily affected by human factors, limiting the objectivity and accuracy of the detection results. While the automatic algorithm based on image segmentation can improve the detection efficiency, its detection accuracy and generalization ability are still weak, and it cannot fully cover various types of dam image data. These problems have greatly limited the level of dam safety management, and there is an urgent need for more advanced technology to make up for these shortcomings and provide strong support for dam safety monitoring.

[0004] Diffusion model is a new emerging generative machine learning model that can accurately extract subtle crack features from dam images by simulating the inverse process of data from noise to clarity, and has higher detection accuracy and robustness than traditional image segmentation algorithms. The present application combines diffusion model and image matting technology, uses the high-precision extraction of diffusion model to obtain high-quality Trimap, and combines the characteristics of image matting technology that is more sensitive to edge information, to realize accurate identification of concrete dam cracks. SUMMARY

[0005] The present application aims to solve the problem that the current general image segmentation network cannot obtain high-precision segmentation results on water conservancy dam images, and in view of this, provides a concrete dam crack matting method and system based on a diffusion model.

[0006] This invention utilizes a crack boundary feature extraction module to obtain basic crack edge information, which is then used as a Trimap to guide the model's training direction, enabling the model to fit the global optimum more quickly. Next, a diffusion-based crack boundary feature extraction module is used to obtain refined matting results from the coarse Trimap. Finally, a crack boundary prediction and correction module, combined with labeled information, makes the model focus more on the foreground crack region rather than the background region, obtaining a more accurate feature representation, improving detection accuracy, reducing missed detections, and thus improving the overall performance of the model.

[0007] The first aspect of this invention relates to a method for masking cracks in concrete dams based on a diffusion model, comprising the following steps:

[0008] 1. Preprocess the water conservancy dam image, remove the image shadow area and reduce noise, and enhance the image contrast through adaptive grayscale stretching;

[0009] 1) Process image shadows;

[0010] Input an image of cracks in a concrete dam to obtain its grayscale image I (grayscale values ​​range from 0 to 255). Then, process the grayscale image I in the frequency domain by using a Gaussian low-pass filter to remove the high-frequency components, resulting in the low-frequency background image I. b D(u,v) represents the frequency of the grayscale image.

[0011] The distance from the origin of the domain to the point (u,v), where D0 represents the scale of the Gaussian low-pass filter.

[0012]

[0013] Then, based on the original grayscale image I, the background image is removed using image difference, retaining the foreground image of the target crack in the image, as shown in the following formula, I r (x,y) represents the resulting image after Gaussian low-pass filtering. g (x,y) represents the original grayscale image, I b (x,y) represents the background portion of the image obtained by Gaussian low-pass filtering, and u represents the mean gray level.

[0014] I r (x,y)=I g (x,y)-I b (x,y)+u#(2)

[0015] 2) Suppress image noise;

[0016] Firstly, the sensitivity to noise is reduced by adaptive threshold method. The gray level histogram H(i) of the selected sub-region image is calculated, i = 0, 1,..., L-1, L represents the number of gray levels, the total average gray level μ of the sub-region image is calculated, the calculation method is as follows, M and N represent the number of rows and columns of the gray image respectively, f(i,j) is the gray value at coordinate (i,j):

[0017]

[0018] Then the probability P(i) and the average gray level μ(i) of each gray level i are calculated, and the inter-class variance g(i) of each gray level i is calculated, and the gray level k with the maximum inter-class variance is the best threshold value we need.

[0019]

[0020] The best threshold value is compared with the gray value of each pixel, the pixel with a gray value greater than or equal to the best threshold value is identified as a pixel point, otherwise it will be identified as a noise point and needs to be further processed using a sub-region filtering window.

[0021] Through the sliding window filter, each fixed size window is further divided into upper left, lower left, upper right and lower right four sub-regions with each pixel point in the image as the center, the gray value variance of the pixels in different sub-regions of the same window is calculated and compared, and the gray value variance of the sub-region with the smallest variance is selected as the gray value of the center pixel of the window. Taking a square window with (2n+1) (n is a natural number) pixels in row and column as an example, the four sub-regions contain (n+1) 2 pixels respectively. The average value m k and variance of the sub-region are calculated as follows, where θ k (k∈{1,2,3,4}) represents the four sub-regions divided by the window, f(i,j) is the pixel value at coordinate (i,j), M=(n+1), N=(n+1), MN is the number of pixels in the current region, and n is the size of the window filter:

[0022]

[0023] The gray image after denoising is denoted as

[0024] 3) Stretch adaptive gray

[0025] Let the gray level range in the image be [0, 255], the gray level is linearly divided into The three segments [u, 255] will... Stretching grayscale values ​​between Other grayscale values ​​will be compressed to achieve the grayscale stretching effect of the crack, g(x,y).

[0026]

[0027] The resulting image after adaptive grayscale stretching is denoted as

[0028] 2. Extract crack boundary features: The encoder extracts image features step by step to obtain high-dimensional semantic information, reduce the size of the input matrix, and encodes the crack features of the concrete dam; the decoder uses the number of feature maps to restore the image to its original size and decodes the feature image into a Trimap image.

[0029] Preprocessed image As input, let the image matrix initially input to the crack boundary feature extraction module be P0. After multiple convolution operations and nonlinear activation functions, the semantic features S0 of the initial image are obtained. Then, max pooling is performed on S0 to reduce the size of the input matrix, resulting in feature P1. P1 is then used as the input for the next layer, and the above process is repeated to obtain crack semantic information of different dimensions. Let n be the number of layers for feature extraction encoding. Then, in the decoding part, the corresponding image features P... n After the above sampling operation, connect the image features P from the previous layer. n-1 Then, deconvolution is applied to combine the semantic information from each dimension, restoring the feature matrix to obtain a feature matrix M with richer semantic information and more obvious crack boundary features. n-1 M n-1 The above decoding process is repeated as the input to the next layer, and finally the feature matrix M0 is obtained. After passing through the nonlinear activation function, the result T is obtained, which serves as the image to guide the training direction of the model, and then proceeds to step 3.

[0030]

[0031] W i It is the convolution kernel selected in the convolution operation, b i It is the bias coefficient.

[0032] Among them W i This represents the convolution kernel selected in the convolution operation, b i is the bias coefficient, and i represents the index of the hierarchy.

[0033] 3. Diffuse crack boundary features, add noise to the input Trimap image to get a noisy image T', then use the pre-trained diffusion model to denoise the noisy image, and get a high-quality alpha matte m after passing through the correction network T-1 ;

[0034] The diffusion model consists of a forward process and a reverse process. In the forward process, Gaussian noise is added to the input crack feature information image. In the reverse process, the processed image is input into the diffusion model to learn to recover a high-quality alpha matte from the noisy image. At the same time, the module uses diffusion denoising implicit model inversion technology to obtain a deterministic denoising path, which can be used to guide and correct the behavior of the model during inference. In this way, the diffusion crack boundary feature restoration module can effectively reduce the time steps required during inference while maintaining high generation quality. The role of the correction network is to receive the noise Trimap and image features at each denoising step as input and output a corrected Trimap that is closer to the true alpha matte distribution. This part can be regarded as a conditional denoising model, and its goal is to reduce errors in the denoising process, especially in uncertain areas. The obtained matte m T-1 is input into step 4.

[0035] 4. Correct crack boundary prediction, adjust and optimize the intermediate results in the denoising process by using the information of known areas, thereby improving the learning efficiency and prediction accuracy of the model in uncertain areas, and obtaining the processed alpha matte m' T-1 .

[0036] A mask is generated from the known areas, with values of 0 on known areas and values of 1 on uncertain areas. Then, the module multiplies the corrected alpha matte obtained in step 3 with this mask to ensure that only the alpha values of the uncertain areas are updated, obtaining the updated image m' T-1 . In addition, by calculating the loss function of the difference between the image m' T-1 and the true alpha image, the difference between the result and the true result is quantified, the model is updated through backpropagation, the model is focused on the crack boundary information in the uncertain area through the mask, and the model is encouraged to make more accurate boundary division, thereby obtaining a result image with higher precision.

[0037] 5. Repeat steps 3 and 4 T times for iterative denoising, and the final image generated in the last iteration is the final result crack binary image. Calculate the result image and the true alpha image to quantitatively evaluate the performance of the model.

[0038] Through multiple iterations, each time refining the alpha matte, the prediction error can be gradually reduced, making the final alpha matte closer to the true value. During the iterative denoising process, the model can learn and adapt to multiple different noise levels, which helps the model remain robust when facing different types of images and matte difficulties. In addition, information in the time dimension is used in the iteration, which is not available in a single prediction. By continuously adjusting and optimizing the alpha value over time, the model can better understand and reconstruct the image structure. Finally, the performance of the model is evaluated by comparing the pixel level of the result crack binary image and the real alpha image.

[0039] The application also relates to a concrete dam crack segmentation system based on edge information fusion, comprising an image preprocessing and boundary label generation module, a crack boundary feature extraction module, a diffusion and restoration crack boundary feature module, a crack boundary prediction correction module, and a crack matting result and post-processing module.

[0040] The application has the advantages that: considering that the existing general image segmentation method has the problems of misjudgment and low precision due to difficulty in distinguishing cracks and background, the diffusion model and the image matting technology are combined, high-quality Trimap is extracted by using the high-precision diffusion model, and the characteristics of the matting technology are combined with the characteristics of the edge information, so that the concrete dam cracks are accurately identified. BRIEF DESCRIPTION OF DRAWINGS

[0041] Figure 1 is a diffusion model schematic diagram of the application.

[0042] Figure 2 is a flowchart of the concrete dam crack matting method based on the diffusion model fusion of the application. DETAILED DESCRIPTION

[0043] The technical solutions of the application will be clearly and completely explained and described below with reference to the drawings.

[0044] Embodiment 1

[0045] Referring to Figure 1 and Figure 2 , the embodiment relates to a concrete dam crack matting method based on a diffusion model, comprising the following steps:

[0046] 1. Preprocessing the water conservancy dam image, removing the image shadow area and denoising, and enhancing the image contrast through adaptive gray scale stretching;

[0047] 1) processing the image shadow;

[0048] An image of a concrete dam crack is inputted to obtain a gray image I (the gray scale is 0-255), and then the high-frequency part in the image is removed by using a Gaussian low-pass filter to obtain a low-frequency background image I b D(u,v) represents the distance from the origin of the frequency domain of the gray image to the point (u,v), and D0 represents the scale of the Gaussian low-pass filter.

[0049]

[0050] Then, on the basis of the original gray image I, the background image is removed by using image difference to retain the target crack foreground image in the image, as shown in the following formula, I r (x,y) represents the result image after the Gaussian low-pass filter processing, I g (x,y) represents the original gray image, I b (x,y) represents the image of the background part obtained by the Gaussian low-pass filter processing, and u represents the mean value of the gray scale.

[0051] I r (x,y) = I g (x,y) - I b (x,y) + u#(2)

[0052] 2) Suppress image noise;

[0053] Firstly, the sensitivity to noise is reduced by using an adaptive threshold method. The gray scale histogram H(i) of the selected sub-region image is calculated for the entire image, i=0,1,...,L-1, L represents the number of gray scales, the total average gray scale μ of the sub-region image is calculated, and the calculation method is as follows, M and N represent the number of rows and columns of the gray image respectively, and f(i,j) is the gray scale value at the coordinate (i,j):

[0054]

[0055] Then, the probability P(i) and the average gray scale μ(i) of each gray scale i are calculated, and the between-class variance g(i) of each gray scale i is calculated, and the gray scale k with the maximum between-class variance is the best threshold value.

[0056]

[0057] The best threshold value is compared with the gray scale value of each pixel, and the pixel with a gray scale value greater than or equal to the best threshold value is identified as a pixel point, otherwise it will be identified as a noise point and needs to be further processed using a sub-region filter window.

[0058] Through the sliding window filter, each fixed size window is further divided into four sub-regions of upper left, lower left, upper right and lower right, taking each pixel point in the image as the center. The gray value of the center pixel point is selected by calculating and comparing the variance of the pixel gray value of different sub-regions of the same window. Taking a square window with (2n+1) (n is a natural number) pixels in row and column as an example, the four sub-regions contain (n+1) 2 pixels respectively. The average value m k and variance of the sub-region are calculated as follows, wherein θ k (k∈{1,2,3,4}) represents the four sub-regions divided by the window, f(i,j) is the pixel value at the coordinate (i,j), M=(n+1), N=(n+1), MN is the number of pixels in the current region, and n is the size of the window filter:

[0059]

[0060] The gray image after the denoising processing is denoted as

[0061] 3) Stretch adaptive gray scale;

[0062] Suppose the gray scale range in the image is [0, 255], the gray scale is linearly divided into and [u, 255] three sections, the gray value between is stretched to , and other gray values are compressed to realize the gray scale stretching effect g(x,y) of the crack.

[0063]

[0064] The result image after the adaptive gray scale stretching is denoted as

[0065] 2. Extracting crack boundary features, using an encoder to gradually extract image features, obtaining high-dimensional semantic information, reducing the size of the input matrix, and encoding the crack features of the concrete dam; using a decoder, restoring the image to the original size by compressing the number of feature maps, and decoding the feature image into a Trimap image;

[0066] The image after the preprocessing is denoted as As input, the image matrix input into the initial crack boundary feature extraction module is P0, after multiple convolution operations and nonlinear activation functions, the semantic features S0 of the initial image are obtained, then the maximum pooling operation is performed on S0 to reduce the size of the input matrix to obtain the feature P1, and P1 is taken as the input of the next level to repeat the above process, thereby obtaining crack semantic information of different dimensions. Denote the number of layers of feature encoding as n, then in the decoding part, the corresponding image features P n After the above operation, the image features P n-1 Then deconvolution is performed, the semantic information of different dimensions is combined, the feature matrix is restored, and a feature matrix M n-1 is obtained, which has richer semantic information and more obvious crack boundary features. n-1 The above decoding process is repeated as the input of the next layer, and finally the feature matrix M0 is obtained, which is subjected to a nonlinear activation function to obtain the result T as the image guiding the model training direction, which enters step 3.

[0067]

[0068] W i is the selected convolution kernel in the convolution operation, and b i is the bias coefficient

[0069] where W i is the selected convolution kernel in the convolution operation, and b i is the bias coefficient, and i represents the index of the level.

[0070] 3. Diffusion restores crack boundary features, adds noise to the input Trimap image to obtain a noise image T', and then uses a pre-trained diffusion model to denoise the noise image, and after the correction network, a high-quality alpha matte m T-1 is obtained.

[0071] The diffusion model consists of two parts: forward process and backward process. In the forward process, Gaussian noise is added to the input image of crack feature information. In the backward process, the processed image is input into the diffusion model to learn to recover high-quality alpha matte from the noise image. At the same time, the diffusion denoising implicit model inversion technology is used to obtain a deterministic denoising path, which can be used to guide and correct the behavior of the model during inference. In this way, the diffusion crack boundary feature restoration module can effectively reduce the time steps required during inference while maintaining high generation quality. The role of the correction network is to receive the noise trimap and image features of the current step as input at each denoising step, and output a corrected trimap that is closer to the true alpha matte distribution. This part can be regarded as a conditional denoising model, and its goal is to reduce errors in the denoising process, especially in uncertain areas. The obtained matte m T-1 is input into step 4.

[0072] 4. Correct the crack boundary prediction; by using the information of the known area to adjust and optimize the intermediate results in the denoising process, so as to improve the learning efficiency and prediction accuracy of the model in the uncertain area, and obtain the processed alpha matte m′ T-1 .

[0073] A mask is generated by the known area, and the values of the mask on the known area are 0, and the values of the mask on the uncertain area are 1. Then, the module multiplies the corrected alpha matte obtained in step 3 with the mask to ensure that only the alpha values of the uncertain area are updated, and obtains the updated image m′ T-1 . In addition, by calculating the loss function of the difference between the image m′ T-1 and the true alpha image, the difference between the result and the true result is quantified, the model is updated by back propagation, the model is focused on the crack boundary information in the uncertain area through the mask, and the model is encouraged to make more accurate boundary division, so as to obtain a result image with higher precision.

[0074] 5. Repeat steps 3, 4, T times for iterative denoising, and the final image generated in the last iteration is the final result crack binary image. Calculate the result image and the true alpha image to quantitatively evaluate the performance of the model.

[0075] Through multiple iterations, each time refining the alpha matte, the prediction error can be gradually reduced, making the final alpha matte closer to the true value. During the iterative denoising process, the model can learn and adapt to multiple different noise levels, which helps the model remain robust when facing different types of images and matte difficulties. In addition, information in the time dimension is used in the iteration, which is not available in a single prediction. By continuously adjusting and optimizing the alpha value over time, the model can better understand and reconstruct the image structure. Finally, the performance of the model is evaluated by comparing the binary image of the crack and the true alpha image at the pixel level.

[0076] The method of the present application overcomes the problem that the traditional image segmentation network cannot effectively integrate feature information on the water conservancy dam image, uses a diffusion model to extract crack boundary information, and improves the accuracy and detection rate of concrete dam crack segmentation.

[0077] Embodiment 2

[0078] This embodiment relates to a concrete dam crack matting system based on a diffusion model, which is used to implement the concrete dam crack matting method based on the diffusion model of embodiment 1, comprising:

[0079] An image preprocessing and boundary annotation generation module is used to preprocess the water conservancy dam image, remove the image shadow area and reduce noise, and enhance the image contrast through adaptive gray stretch;

[0080] A crack boundary feature extraction module uses an encoder to gradually extract image features, obtain high-dimensional semantic information, reduce the size of the input matrix, and encode the crack features of the concrete dam; a decoder is used to restore the image to its original size by compressing the number of feature maps, and decode the feature image into a Trimap image;

[0081] A diffusion restoration crack boundary feature module adds noise to the input Trimap image to obtain a noisy image T', and then uses a pre-trained diffusion model to denoise the noisy image to obtain a high-quality alpha matte m T-1 ;

[0082] A crack boundary prediction correction module uses the information of the known area to adjust and optimize the intermediate results in the denoising process, thereby improving the learning efficiency and prediction accuracy of the model in the uncertain area, and obtaining the processed alpha matte m' T-1 ;

[0083] The crack matting result and post-processing module, the crack boundary feature module of repeated diffusion reduction T times, the crack boundary prediction correction module, the iterative denoising, the final image generated in the last time is the final result crack binary image, and the result image and the real alpha image are calculated to evaluate the performance of the model.

[0084] The embodiments of the present specification only list the implementation forms of the inventive concept, and the protection scope of the present application should not be regarded as being limited to the specific forms stated in the embodiments, and the protection scope of the present application also extends to the equivalent technical means that can be thought of by those skilled in the art according to the inventive concept.

Claims

1. A concrete dam crack segmentation method based on a diffusion model, comprising the following steps: Step 1. Preprocessing the concrete dam crack image, removing the image shadow area and reducing noise, and enhancing the image contrast by adaptive gray scale stretching; Step 2. Extracting crack boundary features, using an encoder to gradually extract image features, obtaining high-dimensional semantic information, reducing the size of the input matrix, and encoding the crack feature image; using a decoder, restoring the crack feature image to its original size by compressing the number of feature maps, and decoding the restored feature image into a Trimap image; Step 3. Diffusion reduction crack boundary feature, add noise to the input Trimap image to obtain a noisy image T ' , and then use the pre-trained diffusion model to denoise the noisy image T ' After the correction network, a high-quality alpha matte m T-1 is obtained. Step 4. Optimize crack boundary prediction, by using the information of the known region to adjust and optimize the intermediate results in the denoising process, so as to improve the learning efficiency and prediction accuracy of the model in the uncertain region, and obtain the processed alpha matte m' T-1 ; Specifically comprising: Generate a mask from the known area, the value of the mask on the known area is 0, and the value on the uncertain area is 1; Then, the alpha matte m is obtained by step 3 T-1 Multiplying with this mask, it ensures that only the alpha values of uncertain regions are updated, and the updated alpha matte m' is obtained T-1 In addition, by calculating the loss function of the difference between the alpha matte m' and the real alpha image, the diffusion model is updated by back propagation T-1 and the real alpha image, the diffusion model is updated by back propagation Step 5. Repeat steps 3 and 4 T times to iteratively denoise, and generate a final crack binary image in the last iteration. Compare the final crack binary image with the real alpha image to quantitatively evaluate the model performance.

2. The diffusion model based concrete dam crack matting method of claim 1, wherein: Step 1 includes: 1) Process the image shadow; An image of a concrete dam crack is inputted to obtain a gray scale image I g , and then processed in the frequency domain of the gray scale image I g . The high frequency part of the image is removed by using a Gaussian low-pass filter to obtain a low frequency background image I b ; D(u,v) represents the distance from the origin of the frequency domain of the gray scale image to the point (u,v), and D0 represents the scale of the Gaussian low-pass filter. Then on the basis of the original gray scale image I g , the background image is removed by image difference, and the target crack foreground image in the image is reserved, as shown in the following formula, I r (x,y) represents the result image after Gaussian low-pass filtering processing, I g (x,y) represents the original gray scale image, I b (x,y) represents the image of the background part obtained by Gaussian low-pass filtering processing, and u represents the mean value of the gray scale. I r (x,y) = I g (x,y) - I b (x,y) + u (2) 2) Suppress image noise; First, reduce the sensitivity to noise by adaptive thresholding; calculate the total average gray level μ of the sub-region image by counting the gray level histogram H(i) of the selected sub-region image, i = 0, 1,..., L-1, L represents the number of gray levels, M and N represent the number of rows and columns of the gray image respectively, and f(i,j) is the gray value at coordinate (i,j): Then calculate the probability P(i) and the average gray level μ(i) of each gray level i, and then calculate the inter-class variance g(i) of each gray level i, and the gray level k with the maximum inter-class variance is the optimal threshold we need; Compare the optimal threshold with each pixel gray value, and the pixel with a gray value greater than or equal to the optimal threshold will be identified as a pixel point, otherwise it will be identified as a noise point, and further processing is performed using a sub-region filtering window; Through the sliding window filter, each fixed size window is further divided into upper left, lower left, upper right and lower right four sub-regions with each pixel point in the image as the center, the gray value variance of the same window is calculated and compared, and the gray value variance of the sub-region with the minimum variance is selected as the gray value of the window center pixel point; the window is a square window containing 2n+1 pixels in row and column, and the four sub-regions contain (n+1) 2 pixel points respectively; the average value m k and the variance of the sub-region are as follows, wherein θ k (k∈{1,2,3,4}) represents four sub-regions divided by the window, f(i,j) is the pixel value at the coordinate (i,j), M=(n+1), N=(n+1), MN is the pixel number of the current region, and n is the size of the window filter: The denoised gray scale image is denoted as 3) Stretch the adaptive gray scale; Let image The range of gray level in image is [0, 255], which is linearly divided into and [u, 255] three sections, which stretch the gray value between to Other gray values will be compressed to achieve the gray stretch effect of the crack g(x, y); The resulting image after adaptive gray stretch is denoted as 3. The diffusion model based concrete dam crack matting method of claim 1, wherein: Step 2 includes: The pre-processed image is input into an encoder The initial image semantic feature S0 is obtained after multiple convolution operations and nonlinear activation functions on the image feature P0 extracted initially, and then the maximum pooling operation is performed on S0 to obtain the feature P1, and the above process is repeated again by taking P1 as the input of the next level to obtain crack semantic information of different dimensions; the number of layers of the feature encoding is denoted as n, and then the corresponding image feature P n After the upsampling operation, the image feature P n-1 After the deconvolution, the two-dimensional semantic information is combined, the feature matrix is restored, and a feature matrix M is obtained, which has richer semantic information and more obvious crack boundary features n-1 , and M n-1 is taken as the input of the next layer to repeat the above decoding process, and finally a feature matrix M0 is obtained, and a result T is obtained after a nonlinear activation function, and the step 3 is entered.

4. The diffusion model based concrete dam crack matting method of claim 1, wherein: Step 3 includes: The diffusion model consists of two parts, the forward process and the backward process. In the forward process, Gaussian noise is added to the input trinap image. In the backward process, the processed image is input into the diffusion model to learn to recover a high-quality alpha matte from the noisy image. At the same time, the module uses a diffusion denoising implicit model inversion technique to obtain a deterministic denoising path, which can be used to guide and correct the behavior of the model during inference. In this way, the diffusion crack boundary feature restoration module can effectively reduce the time steps required during inference while maintaining high generation quality. The role of the correction network is to receive the noise trinap and image features of the current step as input at each denoising step and output a corrected trinap image closer to the true alpha map distribution. This part can be regarded as a conditional denoising model, and its goal is to reduce errors in the denoising process, especially in uncertain areas. The alpha matte m T-1 is input to step 4 as input.

5. A system for implementing the method for concrete dam crack matting based on diffusion model as claimed in claim 1, wherein, It includes: An image preprocessing and boundary annotation generation module for preprocessing the concrete dam crack image, removing the image shadow area and reducing noise, and enhancing the image contrast by adaptive gray scale stretching; A crack boundary feature extraction module that uses an encoder to gradually extract image features, obtains high-dimensional semantic information, reduces the size of the input matrix, and encodes the crack features of the concrete dam; using a decoder, restore the image to its original size by compressing the number of feature maps, and decode the feature image into a Trimap image; The diffusion reduction crack boundary feature module adds noise to the input Trimap image to obtain a noise image T ' Then, a pre-trained diffusion model is used to denoise the noise image, and a high-quality alpha matte m is obtained after passing through the correction network T-1 ; The crack boundary prediction correction module adjusts and optimizes the intermediate result in the denoising process by using the information of the known region, thereby improving the learning efficiency and prediction accuracy of the model in the uncertain region, and obtaining the processed alpha matte m ' T-1 ; A crack segmentation result and post-processing module that repeats the crack boundary feature restoration module and the crack boundary prediction correction module T times to iteratively denoise, and the final image generated in the last iteration is the final result crack binary image. Calculate the quantitative evaluation model performance of the result image and the real alpha image.

Citation Information

Patent Citations

  • Remote sensing image building extraction method and device based on diffusion model

    CN117372873A

  • Infrared small target detection method and device based on data enhancement

    CN117409192A