Image shadow removing method and device based on diffusion model, equipment and medium

Through the image de-shadowing method based on the diffusion model, shadow detection and intrinsic image decomposition are used to extract physical prior information, and the design constraints guide the diffusion model for denoising, which solves the problem of removing shadows in low-quality images and improves image quality and computer vision. task performance.

CN118691497AInactive Publication Date: 2024-09-24NAT UNIV OF DEFENSE TECH

Patent Information

Application Number
CN202411172068.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively remove shadows in low-quality images, resulting in reduced image quality and affecting the performance of computer vision tasks.

Method used

The image de-shadowing method based on the diffusion model is used to extract the physical prior information of the shadow image through the shadow detection model and the intrinsic image decomposition model, and the shadow area condition generation constraints and iterative structure texture consistency constraints are designed to guide the diffusion model in the reverse diffusion process. Denoise in the middle to obtain an enhanced image after shadow removal.

Benefits of technology

Improved de-shading performance of low-quality images, especially in artifact removal in shadow edge areas, enables more harmonious shadow-free image generation and enhances data quality for computer vision tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118691497A
    Figure CN118691497A
Patent Text Reader

Abstract

The invention relates to an image shadow removing method and device based on a diffusion model, equipment and a medium, a shadow detection model is utilized to detect a shadow area in an optical image to be subjected to shadow removal to obtain a shadow mask image, and meanwhile, an intrinsic image decomposition model is utilized to decompose the optical image to obtain an illumination image and a reflectivity image; taking the shadow mask image and the reflectivity image as physical prior information of the optical image, designing a shadow area condition generation constraint and an iterative structure texture consistency constraint based on the physical prior information, and guiding a diffusion model by utilizing the shadow area condition generation constraint and the iterative structure texture consistency constraint; and denoising the Gaussian noise image in the back diffusion process to obtain a shadow-removed enhanced image. By adopting the method, the shadow removing performance of the low-quality image can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of optical image enhancement, and in particular to an image de-shadowing method, device, equipment and medium based on a diffusion model. Background Art

[0002] In recent years, with the rapid development of artificial intelligence, all walks of life have set off a new generation of technological revolution based on intelligent technology, and many basic frameworks such as Variational Autoencoder (VAE), Generative Adversarial Network (GAN), Transformer, Diffusion model have emerged. Based on these frameworks, models such as ChatGPT and Sora were born, and many impressive results have been achieved. In addition to relying on a well-designed network framework, these achievements are also closely related to the image quality in the training data set.

[0003] However, since factors such as target position, shooting angle, and environmental weather are difficult to control, the imaging system will inevitably introduce distortion during the image capture process, thereby reducing the image quality. How to enhance low-quality images so that they can meet the data quality requirements of some image processing tasks is a very hot research direction in the current computer vision field. Shadow images are a large category of low-quality images, and the reason for their degradation is that the light in the shooting scene is partially or completely blocked. Although shadows provide important visual clues for object shape perception, lighting position, object occlusion relationships, etc., shadow-free images help improve the performance of tasks such as target detection, recognition, and tracking. In addition, since shadows can cause the loss of semantic information such as chromaticity, brightness, and texture of images, images with shadows are not conducive to being used as data sets for certain computer vision tasks. Summary of the invention

[0004] Based on this, it is necessary to provide an image shadow removal method, device, equipment and medium based on a diffusion model that can effectively remove shadows in order to solve the above technical problems.

[0005] An image shadow removal method based on a diffusion model, the method comprising: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

[0006] In one embodiment, the shadow detection model is based on a bidirectional feature pyramid architecture and is constructed using a convolutional neural network; The cyclic attention residual block is used to iteratively integrate the deep features and shallow features extracted by the convolutional layer.

[0007] In one embodiment, the intrinsic image decomposition model includes an encoder and two decoders; The encoder extracts image features of the optical image, and the two decoders respectively generate an illumination image and a reflectance image corresponding to the optical image according to the image features; The encoder and decoder are constructed using a multi-stage Transformer framework consisting of Transformer blocks based on local enhancement windows.

[0008] In one embodiment, when training the intrinsic image decomposition model: Constructing a training data set according to a plurality of sets of training samples, wherein the training samples include shadow images and corresponding de-shadowed images; Input a set of training samples into the intrinsic image decomposition model, obtain a corresponding first illumination image and a first reflectance image according to the shadow image, and obtain a corresponding second illumination image and a second reflectance image according to the de-shadowed image; Calculate an image reconstruction loss function according to the shadow image, the first illumination image, and the first reflectivity image, calculate a reflection consistency loss function according to the first reflectivity image and the second reflectivity image, and calculate an illumination smoothness loss function according to the first illumination image; The parameters in the intrinsic image decomposition model are adjusted according to the image reconstruction loss function, the reflection consistency loss function and the illumination smoothness loss function until the intrinsic image decomposition model converges, thereby obtaining a trained intrinsic image decomposition model.

[0009] In one embodiment, the image reconstruction loss function is expressed as: ; In the above formula, represent the first illumination image, the first reflectance image, and the shadow image, respectively; The reflection consistent loss function is expressed as: ; In the above formula, denote a first reflectivity image and a second reflectivity image, respectively; The illumination smoothing loss function is expressed as: ; In the above formula, represents the first illumination image, represents the gradient operator, represents the shadow mask operator, Represents a shadow edge extractor.

[0010] In one embodiment, when the diffusion model is used to denoise a Gaussian noise image, the Gaussian noise image is denoised in a multi-iteration manner. In each denoising process of the iteration: According to the result of the last iterative denoising, under the constraint of the shadow area condition generation, it is ensured that only the shadow area of ​​the image is estimated, and an intermediate variable is generated; Under the iterative structure-texture consistency constraint, the reflectivity map of the intermediate variable is ensured to be consistent with the reflectivity map of the optical image, and a result of current iterative denoising is generated.

[0011] In one embodiment, in the shadow region condition generation constraint, the shadow-free image estimated by the result of the previous iterative denoising is corrected using zero-value domain decomposition, and then back-diffusion is performed to obtain the intermediate variable; In the iterative structure-texture consistency constraint, the intrinsic image decomposition model is used to correct the shadow-free image estimated based on the intermediate variables to obtain a shadow-free estimated image with consistent reflectivity with the shadow image, and then back diffusion is performed to obtain the result of the current iterative denoising.

[0012] The present application also provides an image shadow removal device based on a diffusion model, the device comprising: A shadow image acquisition module, used to acquire an optical image to be deshadowed; A shadow mask image obtaining module, used for detecting the shadow area in the optical image using a shadow detection model to obtain a shadow mask image; An intrinsic image decomposition module, used to decompose the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; A constraint generation module, used to use the shadow mask image and the reflectivity image as physical prior information of the optical image, and to design a shadow area condition generation constraint and an iterative structure texture consistency constraint based on the physical prior information; The shadow-removed image generation module is used to use the shadow area condition generation constraints and iterative structure texture consistency constraints to guide the dynamic shadow perception diffusion model, denoise the Gaussian noise image in the reverse diffusion process, and obtain an enhanced image after the shadow is removed.

[0013] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

[0014] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

[0015] The above-mentioned image shadow removal method, device, equipment and medium based on the diffusion model use the shadow detection model to detect the shadow area in the optical image to be shadowed to obtain a shadow mask image, and at the same time, use the intrinsic image decomposition model to decompose the optical image to obtain an illumination image and a reflectance image, use the shadow mask image and the reflectance image as physical prior information of the optical image, design the shadow area condition generation constraint and iterative structure texture consistency constraint based on the physical prior information, use the shadow area condition generation constraint and iterative structure texture consistency constraint to guide the dynamic shadow perception diffusion model, denoise the Gaussian noise image in the reverse diffusion process, and obtain the enhanced image after shadow removal. The method can effectively improve the shadow removal performance of low-quality images. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A schematic diagram of a flow chart of an image shadow removal method based on a diffusion model in one embodiment; Figure 2 is a schematic diagram of the structure of a shadow detection model in one embodiment; Figure 3 is a schematic diagram of the structure of an intrinsic image decomposition model in one embodiment; Figure 4 A schematic diagram of the overall framework of an image shadow removal method based on a diffusion model in one embodiment; Figure 5 For an experiment Figure 5 (a) shows the visualization results of various methods for the shadow removal dataset, where: Figure 5 (a) is the shadow image to be deshadowed in the experiment. Figure 5 (b) is a schematic diagram of the result after image shadow removal using ShadowRemover algorithm. Figure 5 (c) is a schematic diagram of the result after image shadow removal using the DC-ShadowNet algorithm. Figure 5 (d) is a schematic diagram of the result after image shadow removal using the SG-ShadowNet algorithm. Figure 5 (e) is a schematic diagram of the result after image shadow removal using the BMNet algorithm. Figure 5 (f) is a schematic diagram of the result after image shadow removal using the ShadowFormer algorithm. Figure 5 (g) is a schematic diagram of the result after image shadow removal using this method. Figure 5 (h) is Figure 5 (a) Shadow-free ground truth map of the shadow image shown; Figure 6 For an experiment Figure 6 (a) shows the visualization results of various methods for the shadow removal dataset, where: Figure 6 (a) is the shadow image to be deshadowed in the experiment. Figure 6 (b) is a schematic diagram of the result after image shadow removal using ShadowRemover algorithm. Figure 6 (c) is a schematic diagram of the result after image shadow removal using the DC-ShadowNet algorithm. Figure 6 (d) is a schematic diagram of the result after image shadow removal using the SG-ShadowNet algorithm. Figure 6 (e) is a schematic diagram of the result after image shadow removal using the BMNet algorithm. Figure 6 (f) is a schematic diagram of the result after image shadow removal using the ShadowFormer algorithm. Figure 6 (g) is a schematic diagram of the result after image shadow removal using this method. Figure 6 (h) is Figure 6 (a) Shadow-free ground truth map of the shadow image shown; Figure 7 A schematic diagram showing the visualization results of the performance evaluation of each module in this method in an experiment; Figure 8 is a structural block diagram of an image shadow removal device based on a diffusion model in one embodiment; Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0018] In the existing technology, the problem of optical image de-shadowing currently faces two major pain points. First, it is difficult to obtain the shadow degradation function through explicit modeling. Second, there is a lack of a large amount of shadow and no-shadow pairing data. This makes the current traditional de-shadowing methods and deep learning-based de-shadowing methods have certain limitations.

[0019] In response to the above problems, Figure 1 As shown, the present application provides an image shadow removal method based on a diffusion model, which specifically includes the following steps: Step S100, obtaining an optical image to be de-shadowed.

[0020] Step S110: Detect the shadow area in the optical image using a shadow detection model to obtain a shadow mask image.

[0021] Step S120, decomposing the optical image using the intrinsic image decomposition model to obtain an illumination image and a reflectance image.

[0022] Step S130 , using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information.

[0023] Step S140 , using the shadow area condition to generate constraints and iterative structure-texture consistency constraints to guide the diffusion model, denoising the Gaussian noise image in the reverse diffusion process to obtain an enhanced image after removing the shadows.

[0024] In this embodiment, a model-driven shadow removal method based on Diffusion (diffusion model) is proposed to combine the advantages of physical models and generative networks in shadow removal. This method first extracts the physical prior information of the shadow image through shadow detection and intrinsic image decomposition, and then introduces two constraints designed based on the physical prior information of the shadow image in the Diffusion reverse diffusion sampling process: (1) Shadow area condition generation constraint. The sampled shadow-free image is corrected through the zero-value domain decomposition operation to ensure that Diffusion only estimates the shadow area of ​​the image. (2) Iterative structure and texture consistency constraint. The intrinsic image decomposition operation is used to ensure the reflectivity of all intermediate results in the sampling process. Figure 1 This guides Diffusion to produce a shadow-free result that is harmonious with the content in the shadow area.

[0025] In step S100 , the optical image to be de-shadowed is a shadow image, which is a low-quality image.

[0026] In step S110, a shadow detection model is used to detect the shadow area of ​​the optical image. The shadow detection model is constructed based on a convolutional neural network according to a bidirectional feature pyramid architecture, wherein a cyclic attention residual block is used to iteratively integrate deep features and shallow features extracted by the convolutional layer.

[0027] In this embodiment, a bidirectional feature pyramid network (BFPN) is used as the backbone framework of the shadow detection model. The network extends the general feature pyramid network architecture and designs a recurrent attention residual (RAR) module to iteratively integrate the deep and shallow features extracted by the network to maximize the shadow detection performance.

[0028] like Figure 2As shown in Figure 1, the shadow detection model is based on a pyramid architecture and uses two sets of RAR modules to fuse the feature maps of two adjacent layers of the convolutional neural network, making full use of their global and local contexts. Specifically, the shadow detection model uses an end-to-end approach, taking a single image as input and outputting the shadow detection result of the image.

[0029] Specifically, the shadow detection model is based on a bidirectional feature pyramid architecture and is constructed using a convolutional neural network to extract feature maps of different resolutions. The bottom layer of the pyramid is the original shadow image, and upwards are feature maps of different resolutions extracted by the convolutional neural network. The higher the level, the smaller the feature map and the lower the resolution. Low-level feature maps can often capture fine shadow detail information in local areas (such as information on shadow edges and penumbra areas), while high-level feature maps mainly capture the coarser shadow semantic information of the entire image. The network then uses multiple RAR modules to take feature maps of adjacent levels as input to learn feature attention maps, and then uses the residual mechanism and the learned feature attention maps to fuse feature maps of adjacent levels to obtain a more refined context feature map, thereby achieving information sharing between different feature layers.

[0030] In order to ensure that the fine shadow detail information of the local area can be integrated with the coarse shadow semantic information of the entire image, the shadow detection model embeds two sets of RAR modules into a bidirectional feature pyramid architecture, using two directional paths to obtain contextual information of different feature layers: one path from the bottom to the top, and the other path in the opposite direction. Finally, the network uses the attention fusion module to fuse the last layer of context feature maps of the two directional paths to obtain the final shadow detection result.

[0031] In this embodiment, when the shadow detection model is used, the shadow mask corresponding to the paired shadow image is used as training data, and the network parameters are updated using Binary Cross Entropy Loss (BCE Loss). The definition of Binary Cross Entropy Loss is: ; In the above formula, is a binary label, is the number of samples to be classified. During the training process, binary cross entropy loss is used for each layer output of the shadow detection model, and the total loss is the sum of the losses calculated from the feature maps of all outputs.

[0032] In this embodiment, the intrinsic image decomposition technology is used to decouple the lighting features and texture features of the shadow image, and the texture features that are not affected by the lighting conditions, namely the reflectivity image, are extracted and used as physical prior information to guide the pre-trained Diffusion model to remove shadows.

[0033] Based on the Retinex theory, an image is decomposed into the product of an illumination map and a reflectance map. The former represents the information of incident light, and the latter represents the information of scene reflection. It can be expressed by the following mathematical formula: ; In the above formula, is the optical image to be decomposed, and They are the illumination map and reflectance map, represents element-wise multiplication operation, Furthermore, if the intrinsic image decomposition model is not constrained, the decomposition problem will be a highly ill-conditioned problem. Therefore, in this embodiment, three constraints are designed for the model.

[0034] First, we need to consider the fidelity of the image, that is, whether the decomposed incident map and reflectivity map can be used to restore the input image without distortion. This is the first constraint.

[0035] Next, according to the physical formation process of the image, the illumination map reflects the lighting characteristics of the light in the shooting scene. When the light is unobstructed, the illumination intensity is continuous in the spatial dimension and will not change suddenly. When the light is obstructed, the illumination intensity will change suddenly at the obstruction boundary and remain continuous in the rest of the area. Therefore, the second constraint is that the illumination map is piecewise smooth.

[0036] The reflectivity map mainly reflects the texture structure characteristics of the shooting scene. These texture structures are determined only by the scene itself and will not change with the change of the light intensity in the shooting scene. Since shadows are caused by light being blocked, the reflectivity maps decomposed from the shadow and shadow-free images of the same scene should be consistent. This is the third constraint.

[0037] According to the above description, the optimization function proposed in this application can be expressed as follows: ; In the above formula, Ensure that the original image can be restored from the decomposed illumination map and reflectance map. Make sure the illumination map is piecewise smooth, Ensure the consistency of reflectance maps of shadowed and unshadowed images in the same scene, and are two hyperparameters.

[0038] In this embodiment, a method based on deep learning is adopted to obtain a general intrinsic image decomposer, namely, an intrinsic image decomposition model, by learning the mapping relationship between the input image and its paired reflectance map and illumination map in the training data set. The structure of the intrinsic image decomposition model is as follows: Figure 3 In step S120, the optical image is decomposed using an intrinsic image decomposition model.

[0039] In this embodiment, the intrinsic image decomposition model includes an encoder and two decoders, the encoder extracts the image features of the optical image, and the two decoders generate the illumination image and reflectance image of the corresponding optical image according to the image features. The encoder and the decoder are constructed by a multi-level Transformer framework composed of Transformer blocks based on local enhancement windows.

[0040] Specifically, the intrinsic image decomposition model By an encoder With two decoders and Composition, where the encoder Used to extract shadow image features, two decoders and They are used to obtain the illumination map and reflectance map respectively. Specifically, the network adopts an end-to-end approach, taking the shadow image as input and passing through and The two paths obtain their corresponding illumination maps and reflectance maps. In order to exploit the multi-scale non-local similarity, the encoder and decoder are composed of a multi-level Transformer framework.

[0041] However, there are two main problems with using Transformer for image decomposition. First, the standard Transformer architecture performs self-attention between all word vectors. The computational complexity of a pixel image is ,This makes it impossible to use the global self-attention mechanism on high-resolution feature maps.,Secondly, local context information is crucial for image decomposition tasks,,because neighboring pixels can be used to assist feature extraction.

[0042] To solve the above two problems, in this embodiment, a Transformer module (LeWin Block) based on a locally enhanced window (Locally-enhanced Window, LeWin) is used to form a multi-level Transformer framework.

[0043] Furthermore, this module makes two small changes compared to the standard Transformer architecture: (1) Instead of using a global self-attention mechanism, the image is divided into non-overlapping local small windows, and the self-attention mechanism is performed in each small window, which greatly reduces the computational cost while ensuring that the performance is basically unaffected. (2) The feedforward neural network (FFN) in the standard Transformer architecture is replaced with a locally enhanced feedforward neural network (LeFF) to make up for its shortcomings in extracting local context information. Compared with FFN, LeFF adds a linear projection layer to expand the feature dimension of each word vector and extract more local context information. In addition, in order to maximize the retention of multi-scale feature information extracted by the convolutional layer, the encoder and decoder use jump connections.

[0044] In this embodiment, in order to enable the intrinsic image decomposition model to better decouple the texture structure information and lighting information of the scene, in this embodiment, three loss functions, namely image reconstruction loss, reflection consistency loss, and illumination smoothness loss, are designed to jointly optimize the proposed intrinsic image decomposition model.

[0045] Specifically, when training the intrinsic image decomposition model: construct a training data set based on multiple groups of training samples, the training samples include a shadow image and a corresponding de-shadowed image, input a group of training samples into the intrinsic image decomposition model, obtain the corresponding first illumination image and first reflectance image based on the shadow image, and obtain the corresponding second illumination image and second reflectance image based on the de-shadowed image. Calculate the image reconstruction loss function based on the shadow image, the first illumination image, and the first reflectance image. Calculate the reflection consistency loss function based on the first reflectance image and the second reflectance image, and calculate the illumination smoothness loss function based on the first illumination image. Adjust the parameters in the intrinsic image decomposition model based on the image reconstruction loss function, the reflection consistency loss function, and the illumination smoothness loss function until the intrinsic image decomposition model converges, thereby obtaining a trained intrinsic image decomposition model.

[0046] Specifically, suppose a set of training samples, shadow and shadow-free images are and , the illumination map and reflectivity map obtained by decomposing the shadow image are and , the illumination map and reflectance map obtained by decomposing the shadow-free image are and .

[0047] Specifically, for the image reconstruction loss function, according to the Retinex theory, the decomposed illumination map and reflectance map can completely reconstruct the shadow image. Therefore, a norm to ensure the fidelity of the reconstructed image: ; In the above formula, Represent the first illumination image, the first reflectance image and the shadow image respectively.

[0048] Specifically, for the reflection consistency loss function, according to the analysis of the properties of the reflectance map in the previous article, the reflectance map under different lighting conditions is consistent. Therefore, for paired shadow and shadow-free images, the reflectance maps decomposed from the two should be the same. Based on this, the expression of the reflection consistency loss function is as follows: ; In the above formula, denote a first reflectivity image and a second reflectivity image, respectively; Specifically, for the illumination smoothness loss function, except for the sudden change in illumination intensity in the shadow edge area, the illumination intensity in other areas meets the spatial continuity. Therefore, the illumination map obtained by decomposing the shadow image should have the characteristics of local smoothness. The smoothness of the illumination map is ensured by minimizing the local area gradient, which is expressed as: ; In the above formula, represents the first illumination image, represents the gradient operator, represents the shadow mask operator, represents a shadow edge extractor. The shadow mask operator can be obtained from the shadow detection model. The shadow edge extractor can be implemented by morphological dilation.

[0049] By weighted summing the above three loss functions, the expression of the total loss function can be obtained as follows: ; In the above formula, , and is the hyperparameter of the weighted sum.

[0050] For the image shadow removal task, there are currently two urgent problems to be solved in order to utilize Diffusion's powerful generation capabilities: First, the existing dataset is small in scale and single in scene, and cannot accurately simulate the data distribution of the shadow removal task. If the existing dataset is directly used to train Diffusion to learn the mapping relationship between shadows and shadow-free images, it is difficult to obtain a model with generalization capabilities. Second, shadows are a natural phenomenon that occurs when light in a scene is partially or completely blocked. Although the formation mechanism is simple, its intensity distribution is uneven, and it is difficult to obtain a degradation function through explicit modeling, which makes it impossible to use DDNM's optimization strategy to directly solve the shadow removal problem.

[0051] In this embodiment, a dynamic shadow-aware extended model (DSDM) is proposed, which uses the powerful generation capability of Diffusion to solve the shadow removal problem in a model-driven manner. Specifically, DSDM does not directly perform display modeling on the shadow degradation process, but extracts the regional position prior and texture structure prior of the shadow image through the above-mentioned lightweight shadow detection model and lightweight intrinsic image decomposition model, and then uses these two prior information to guide a Diffusion model pre-trained on other data sets (such as face data sets, scene data sets, etc.) to perform image shadow removal, which effectively avoids the problem of small shadow data sets and difficulty in display modeling of shadow degradation processes.

[0052] The diffusion model defines a step forward diffusion process and a The forward diffusion process slowly adds Gaussian noise to the training data. After 10 steps, the training data will tend to Gaussian distribution; the reverse diffusion process needs to iterate the training data samples from Gaussian noise step by step in the opposite direction to the forward diffusion process, which is equivalent to a denoising process.

[0053] The forward diffusion process can be described by mathematical formula: ; In the above formula, is the training data, is a hyperparameter.

[0054] The reverse diffusion process requires Gaussian noise Start with step-by-step iteration to solve According to the Bayesian formula, if we want to Set out to find a solution , you can first use Estimate the original image at this time , and then according to and Sampling The specific mathematical formula is as follows: ; In the above formula, is the denoising network, is standard Gaussian noise.

[0055] This method uses the diffusion model to iteratively denoise the Gaussian noise image during the back diffusion process. Under the guidance of the shadow area condition generation constraint and the iterative structure texture consistency constraint, the denoised image is an optical image after shadow removal.

[0056] Specifically, when the dynamic shadow perception diffusion model denoises the Gaussian noise image, the Gaussian noise image is denoised in multiple iterations. In each denoising process, according to the result of the previous denoising, under the constraint of the shadow area condition generation, it is ensured that only the shadow area of ​​the image is estimated and an intermediate variable is generated. Under the constraint of iterative structural texture consistency, it is ensured that the reflectance map of the intermediate variable is consistent with the reflectance map of the optical image, and the result of the current denoising is generated.

[0057] In this embodiment, constraints are generated for the shadow area conditions. The image deshading problem focuses on restoring the lost lighting information in the shadow area and pursuing a consistent illumination distribution between the shadow and non-shadow areas. Therefore, in the deshading process, the Diffusion model should only focus on the reconstruction of the shadow area without estimating the non-shadow area. This will bring three advantages: (1) The non-shadow area provides partial image priors for the Diffusion model, which can assist the Diffusion model in generating more harmonious content; (2) It avoids distortion caused by estimating the non-shadow area; and (3) Compared with estimating the entire image, reconstructing only the shadow area can effectively reduce the amount of calculation of the algorithm without causing a decrease in performance.

[0058] Specifically, in the conditional generation constraint of the shadow area, the shadow-free image estimated by the result of the previous iterative denoising is corrected using zero-value domain decomposition, and then back-diffusion is performed to obtain the intermediate variable. Specifically, the mathematical formula is expressed as: ; In the above formula, is the shadow mask operator The pseudo-inverse.

[0059] In this embodiment, the above-mentioned shadow region conditional generation constraint (SCG) only ensures that the Diffusion model only estimates the shadow region of the image, and does not constrain the texture structure information of the reconstructed shadow region. The lack of conditional control will make the content generated by the Diffusion model in the shadow region tend to the distribution of the training data set (such as faces, scenes, etc.). This incorrect distribution mapping relationship will cause the result of the Diffusion estimation to be extremely inconsistent with the semantic information of the entire image. In order to solve this problem, in this embodiment, the texture structure information hidden in the shadow region of the shadow image is also used as an auxiliary to constrain the pre-trained unconditional diffusion model.

[0060] According to the physical formation law of shadows, shadows are natural phenomena that occur when light in a scene is partially or completely blocked, which means that shadows only affect the lighting information of the scene, but not the texture structure information of the scene itself. Therefore, the reflectance maps decomposed from paired shadow and shadow-free images in the same scene should be consistent. Based on the above ideas, an iterative structure-texture consistency constraint (IRC) is proposed to constrain the intermediate variables obtained by sampling the SCG constraint. Make corrections.

[0061] In this embodiment, in the iterative structure-texture consistency constraint, the intrinsic image decomposition model is used to correct the shadow-free image estimated based on the intermediate variables, and after obtaining the shadow-free estimated image consistent with the reflectivity of the shadow image, back diffusion is performed to obtain the result of the current iterative denoising.

[0062] Specifically, in the iterative structure-texture consistency constraint, the above-mentioned intrinsic image decomposition model is first used For shadow images and the estimated shadow-free image Perform the intrinsic image decomposition operation and get and Illuminance diagram And reflectivity map , then and reflectivity map Replace with Reflectivity map , and finally perform element-by-element multiplication to obtain the estimated shadow-free image after IRC constraint .

[0063] Furthermore, the specific mathematical expression of the iterative structure-texture consistency constraint can be expressed as: ; Repeat the above shadow area condition generation constraints and iterative structure texture consistency constraints until , we can sample the final estimated shadow-free image , realize low-quality optical image deshading based on Diffusion.

[0064] like Figure 4 As shown in the figure, it is a schematic diagram of the overall framework of the image de-shadowing method based on the diffusion model. It is based on the dynamic shadow-aware diffusion model, and adds shadow area conditional generation constraints (SCG) and iterative structure-texture consistency constraints (IRC) in each step of the reverse diffusion process. The regional position information and texture structure information of the shadow image are introduced to guide a Diffusion model pre-trained on other datasets (such as face datasets, scene datasets, etc.) to perform image de-shadowing, making full use of the model prior of shadow degradation and the data prior of Diffusion.

[0065] Specifically, this method defines a The backward diffusion process of the step, from the standard Gaussian noise Start by conducting a The final shadow-free image is obtained by denoising .exist Spread to In the process, it passes through (SCG) and (IRC) constraints in turn.

[0066] In SCG constraints, use zero-valued domain decomposition to Estimated shadow-free image Make corrections to obtain data consistency , and then perform reverse diffusion to obtain the intermediate variable .

[0067] In the IRC constraint, we first use the intrinsic image decomposition to The shadow-free image for conditional estimation After correction, a shadow-free estimated image with the same reflectivity as the shadow image is obtained. , and then reverse diffusion is performed to obtain Step status .

[0068] In this paper, the effectiveness of this method is also demonstrated through experimental results.

[0069] like Figure 5 and Figure 6As shown in the figure, taking two images with shadows as examples, a schematic diagram of the results after removing shadows using different methods and this method. Compared with other shadow removal algorithms, the shadow-free image reconstructed by the shadow removal algorithm proposed in this method not only has no obvious chromaticity distortion and other phenomena in the overall shadow area, but also the generated content in the shadow boundary area is very harmonious, and no shadow artifacts can be observed at the visual level.

[0070] It can be seen from Table 1 that the shadow removal method proposed in this paper has better shadow removal performance in the shadow area, non-shadow area and the entire image than other comparison methods, which proves the effectiveness of the shadow removal method proposed in this paper at the data level.

[0071] Table 1 Visualization results of various methods on the shadow removal dataset

[0072] like Figure 7 As shown in the figure, when the complete model is used, the generated result has a reasonable texture structure in the shadow area and no obvious discontinuity in the shadow edge area. This shows that in the de-shadowing framework proposed in this paper, the IRC module focuses on guiding and supervising the overall texture structure of the shadow area, and the SCG module focuses on ensuring the harmony and continuity of the generated results in the shadow edge area.

[0073] As can be seen from Table 2, from a data perspective, the IRC constraint plays a crucial role in the algorithm's de-shadowing performance, while the SCG constraint plays more of a fine-tuning optimization role and does not significantly improve the algorithm's de-shadowing performance.

[0074] Table 2 Quantitative experimental results of performance evaluation of each module in this method

[0075] In the above-mentioned image deshadowing method based on the diffusion model, the physical prior information of the shadow image is first extracted through shadow detection and intrinsic image decomposition. Then, two shadow area condition generation constraints designed based on the physical prior information of the shadow image are introduced in the reverse diffusion sampling process of the diffusion model. The constraint modifies the sampled shadow-free image through the zero-value domain decomposition operation, thereby ensuring that Diffusion only estimates the shadow area of ​​the image. And iterative structure texture consistency constraint, which ensures the reflectivity of all intermediate results in the sampling process through the intrinsic image decomposition operation. Figure 1This method can achieve end-to-end intelligent shadow removal of low-quality images without relying on a large amount of training data while taking into account interpretability. It fully combines the advantages of physical prior models and generative networks in shadow removal, and can effectively improve the shadow removal performance of low-quality images, especially in the removal of artifacts in the shadow edge area.

[0076] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0077] In one embodiment, Figure 8 As shown, an image shadow removal device based on a diffusion model is provided, comprising: a shadow image acquisition module 200, a shadow mask image acquisition module 210, an intrinsic image decomposition module 220, a constraint generation module 230 and a shadow removal image generation module 240, wherein: The shadow image acquisition module 200 is used to acquire the optical image to be de-shadowed.

[0078] The shadow mask image obtaining module 210 is used to detect the shadow area in the optical image using a shadow detection model to obtain a shadow mask image.

[0079] The intrinsic image decomposition module 220 is used to decompose the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image.

[0080] The constraint generation module 230 is used to use the shadow mask image and the reflectivity image as physical prior information of the optical image, and to design shadow area condition generation constraints and iterative structure-texture consistency constraints based on the physical prior information.

[0081] The shadow-removed image generation module 240 is used to use the shadow area condition to generate constraints and iterative structure-texture consistency constraints to guide the diffusion model, denoise the Gaussian noise image in the reverse diffusion process, and obtain an enhanced image after the shadow is removed.

[0082] For the specific definition of the image de-shadowing device based on the diffusion model, please refer to the definition of the image de-shadowing method based on the diffusion model above, which will not be repeated here. Each module in the above-mentioned image de-shadowing device based on the diffusion model can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0083] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for image deshading based on a diffusion model is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0084] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0085] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

[0086] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

[0087] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0088] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0089] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. An image shadow removal method based on a diffusion model, characterized in that: The method comprises: Acquire an optical image to be deshadowed; Using a shadow detection model to detect the shadow area in the optical image to obtain a shadow mask image; Decomposing the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; Using the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow region condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow region condition generation constraint and the iterative structure texture consistency constraint are used to guide the diffusion model, and the Gaussian noise image is denoised in the reverse diffusion process to obtain an enhanced image after the shadow is removed.

2. The image shadow removal method according to claim 1, characterized in that: The shadow detection model is based on a bidirectional feature pyramid architecture and is constructed using a convolutional neural network; The cyclic attention residual block is used to iteratively integrate the deep features and shallow features extracted by the convolutional layer.

3. The image shadow removal method according to claim 1, characterized in that: The intrinsic image decomposition model includes an encoder and two decoders; The encoder extracts image features of the optical image, and the two decoders respectively generate an illumination image and a reflectance image corresponding to the optical image according to the image features; The encoder and decoder are constructed using a multi-stage Transformer framework consisting of Transformer blocks based on local enhancement windows.

4. The image shadow removal method according to claim 3, characterized in that: When training the intrinsic image decomposition model: Constructing a training data set according to a plurality of sets of training samples, wherein the training samples include shadow images and corresponding de-shadowed images; Input a set of training samples into the intrinsic image decomposition model, obtain a corresponding first illumination image and a first reflectance image according to the shadow image, and obtain a corresponding second illumination image and a second reflectance image according to the de-shadowed image; Calculate an image reconstruction loss function according to the shadow image, the first illumination image, and the first reflectivity image, calculate a reflection consistency loss function according to the first reflectivity image and the second reflectivity image, and calculate an illumination smoothness loss function according to the first illumination image; The parameters in the intrinsic image decomposition model are adjusted according to the image reconstruction loss function, the reflection consistency loss function and the illumination smoothness loss function until the intrinsic image decomposition model converges, thereby obtaining a trained intrinsic image decomposition model.

5. The image shadow removal method according to claim 4, characterized in that: The image reconstruction loss function is expressed as: ; In the above formula, represent the first illumination image, the first reflectance image, and the shadow image, respectively; The reflection consistent loss function is expressed as: ; In the above formula, denote a first reflectivity image and a second reflectivity image, respectively; The illumination smoothing loss function is expressed as: ; In the above formula, represents the first illumination image, represents the gradient operator, represents the shadow mask operator, Represents a shadow edge extractor.

6. The image shadow removal method according to any one of claims 1 to 5, characterized in that: When the diffusion model is used to denoise the Gaussian noise image, the Gaussian noise image is denoised in a multiple-iteration manner. In each denoising process of the iteration: According to the result of the last iterative denoising, under the constraint of the shadow area condition generation, it is ensured that only the shadow area of ​​the image is estimated, and an intermediate variable is generated; Under the iterative structure-texture consistency constraint, the reflectivity map of the intermediate variable is ensured to be consistent with the reflectivity map of the optical image, and a result of current iterative denoising is generated.

7. The image shadow removal method according to claim 6, characterized in that: In the shadow region condition generation constraint, the shadow-free image estimated by the result of the previous iterative denoising is corrected using zero-value domain decomposition, and then back-diffusion is performed to obtain the intermediate variable; In the iterative structure-texture consistency constraint, the intrinsic image decomposition model is used to correct the shadow-free image estimated based on the intermediate variables to obtain a shadow-free estimated image with consistent reflectivity with the shadow image, and then back diffusion is performed to obtain the result of the current iterative denoising.

8. An image shadow removal device based on a diffusion model, characterized in that: The device comprises: A shadow image acquisition module, used to acquire an optical image to be deshadowed; A shadow mask image obtaining module, used for detecting the shadow area in the optical image using a shadow detection model to obtain a shadow mask image; An intrinsic image decomposition module, used to decompose the optical image using an intrinsic image decomposition model to obtain an illumination image and a reflectance image; A constraint generation module, used for taking the shadow mask image and the reflectivity image as physical prior information of the optical image, and designing shadow area condition generation constraints and iterative structure texture consistency constraints based on the physical prior information; The shadow-removed image generation module is used to use the shadow area condition generation constraint and iterative structure texture consistency constraint to guide the diffusion model, denoise the Gaussian noise image in the reverse diffusion process, and obtain the enhanced image after the shadow is removed.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Complex scene video shadow detection and elimination method

    CN110349099A

  • Non-paired image shadow removal method

    CN115146763A

  • Image super-resolution method and system based on gradient optimization diffusion model, and medium

    CN117974450A

  • Image shadow removal method based on wavelet non-uniform diffusion model

    CN118134800A

  • Low-illumination image enhancement network and image enhancement method

    CN118247164A

Cited By

  • Physiological parameter decomposition-based texture map generation method and device

    CN119206020A

  • Face shadow elimination method and device based on adaptive face symmetry

    CN119515733A

  • High-efficiency and high-quality image reconstruction method and system for pulse camera

    CN119540075A

  • Image shadow removal method and device based on diffusion model

    CN119762376A

  • Shielding object moving and editing method and system based on diffusion model

    CN119810263A