Degraded image restoration method based on pollution area mask guidance

Through the method based on mask guidance of contaminated areas, the feature information of non-polluted areas is used to help the recovery of contaminated areas, which solves the problem of insufficient interaction of regional feature information in image recovery and achieves high-quality image recovery and good generalization ability.

CN118657691AActive Publication Date: 2024-09-17UNIV OF SCI & TECH OF CHINA

Patent Information

Application Number
CN202410747060.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-17
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

Existing image restoration methods based on deep learning fail to effectively consider the feature consistency of the texture patterns of contaminated areas and non-contaminated areas in the image when processing images of partially contaminated areas, resulting in the presence of color textures between different areas in the restored image. Inconsistencies and artifacts.

Method used

A degraded image restoration method based on contaminated area mask guidance is used to build a restoration model through a soft area mask generator, encoder, multi-scale channel attention module and decoder, and use the characteristic information of non-polluted areas to help contaminated areas step by step Reconstruction and recovery, achieving regional and pixel-level feature extraction and interaction.

Benefits of technology

This method achieves high-quality image restoration in shadow removal and flare removal tasks, has good generalization and expansion capabilities, reduces the amount of parameters and calculations, and reflects strong adaptability and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657691A
    Figure CN118657691A
Patent Text Reader

Abstract

The invention relates to the technical field of computer vision image restoration, and discloses a degraded image restoration method based on pollution area mask guidance. Inputting the image containing the pollution area and the pollution area mask into the trained recovery model, and outputting a recovered image; the construction and training method of the recovery model comprises the following steps: enabling an image containing a polluted area and a corresponding polluted area mask to pass through a soft area mask generator to obtain a soft area mask; a coding stage; performing global information interaction processing on the deep features; a decoding stage; inputting the recovered feature map into an output convolutional layer, constructing residual connection with an image containing a pollution area, and outputting a final recovered image; training the recovery model based on the training sample and the overall loss function; according to the method, the strong local feature extraction capability of the convolution operation in the traditional CNN is exerted, and the feature information interaction of the Transform self-attention mechanism in the global range is also realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision image restoration, and in particular to a degraded image restoration method based on contaminated area mask guidance. Background Art

[0002] In the initial process of shooting, imaging and information dissemination, digital images are easily affected by environmental media, imaging systems, and human intervention, which can damage image pixels, significantly reduce image quality, and cause pollution phenomena such as image blur, texture loss, and color distortion, which is called image degradation. Among them, some degradation does not occur in the entire image, but presents regional location characteristics, that is, the pixels in the region are polluted and degraded to a large extent, while the pixels outside the region are generally unaffected. Common regional pollution phenomena include shadows, flares, and incompleteness. In mid- and high-level visual tasks such as image classification, image segmentation, and target detection, the quality of the input image has an important impact on the performance and efficiency of its algorithm. The polluted area may cause target deformation, blurred boundaries, loss of details, etc., which seriously interferes with the processing of subsequent downstream tasks. For example, in medical image processing, shadows can cause blurring of the lesion area, loss of image detail information, and interfere with the identification and diagnosis of the target disease; in image semantic segmentation, semantic recognition of shadow and flare areas will be misjudged, reducing the accuracy of information; in video image processing, changes in scene and lighting conditions will change the formation and expression of shadows and flares, increasing the complexity of related processing algorithms.

[0003] Image restoration is one of the most basic underlying computer vision tasks in digital image processing. It aims to use software algorithms to alleviate and eliminate the effects of the above-mentioned image degradation, improve the quality of image details, eliminate unnecessary interference for subsequent image understanding visual tasks, and provide a relatively sufficient basic condition for image information. In the current era of deep learning, existing image restoration work has been brilliant in various related visual tasks. The structural design of the model has gradually diversified and is oriented towards specific tasks, with significant improvements in restoration quality and reasoning efficiency.

[0004] However, for the image restoration task with partial pollution, the existing deep learning-based solutions, whether parameter estimation strategies or end-to-end network architectures, mainly focus on exploring the pixel-level differences between the polluted area and its restored unpolluted version, without considering the consistency and correlation of features such as texture style in the polluted and unpolluted areas of the same image itself. As a result, there is an obvious sense of incongruity in color texture between different areas of the restored image, which is specifically manifested in insufficient restoration of texture information in the polluted area, inconsistent light brightness compared to the clean area (too bright or too dark), artifacts at the edge of the area, unnatural transitions, and other regional incoordination phenomena.

[0005] Region mask is a type of binary image that can effectively represent the location of polluted and clean areas in the original image (the default polluted area value is 1, and the clean area value is 0). How to correctly and effectively extract and construct the feature relationship between the unpolluted area and the polluted area with the help of region mask, and use the features of the unpolluted area to help restore the features of the polluted area, is the key to image restoration tasks for such polluted areas.

[0006] In view of the problems and defects existing in the current related image restoration methods, the present invention designs an algorithm module based on regional mask guidance and builds a robust and accurate contaminated area image restoration method. Summary of the invention

[0007] In order to solve the above technical problems, the present invention provides a degraded image restoration method based on the guidance of the polluted area mask. The method can be adapted to the specific image restoration task containing partially polluted areas through model training. Due to the targeted and relevant feature extraction and information interaction of different areas in the image, the present invention makes full use of the feature information of the unpolluted area to help the step-by-step reconstruction and restoration of each pixel in the polluted area. Compared with the current mainstream regional degraded image restoration method, the present invention can obtain a model with stronger scalability and better generalization ability.

[0008] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0009] A degraded image restoration method based on contaminated area mask guidance, inputting an image containing a contaminated area and a contaminated area mask into a trained restoration model, and outputting a restored image; the restoration model includes a soft area mask generator, an encoder, a multi-scale channel attention module and a decoder, and the encoder and the decoder adopt a U-Net type architecture; the construction and training method of the restoration model includes the following steps:

[0010] Step 1: The image I containing the polluted area in The corresponding contaminated area mask M in After the soft region mask generator G softmask (·), and obtain the soft region mask

[0011] Step 2: Encoding stage: Contaminated image I in , the corresponding contaminated area mask M in and soft area mask The convolution operation is performed in the channel dimension to obtain an initial feature map F0; the initial feature map is sequentially passed through multiple levels of encoding blocks in the encoder, and multiple feature extractions are performed under the guidance of the contaminated area mask to obtain a shallow feature map; the encoding block is composed of a region-level guidance module and a downsampling operation; the region-level guidance module uses the feature information of the non-contaminated area as an affine transformation parameter to guide the extraction of the contaminated area features;

[0012] Step 3: Global information interaction processing of deep features; input the shallow feature map output by the encoder into multiple cascaded pixel-level guidance modules, and obtain the pixel-level restored feature map under the guidance of the soft area mask; the pixel-level guidance module is improved on the basis of the visual Transformer for the polluted area. Based on the guidance of the soft area mask, it only needs to build an attention mechanism from the relevant pixels of the unpolluted area to the polluted area, without obtaining the correlation of all pixels in the global range;

[0013] Step 4, decoding stage: the pixel-level restored feature map is passed through the reversible network modules of multiple levels in the decoder in turn, and multiple feature restorations are performed under the guidance of the contaminated area mask to obtain the restored feature map; the reversible network module is implemented based on the area-level guidance module; the encoding block is jump-connected with the reversible network module through the multi-scale channel attention module;

[0014] Step 5: Input the restored feature map into the output convolution layer and compare it with the image I containing the contaminated area. in Construct residual connection and output the final restored image

[0015] Step 6: Based on the training samples and the overall loss function, the restoration model is trained; the training samples include images with polluted areas, masks of polluted areas, and clean images without polluted areas; the overall loss function includes a pixel-level loss function Perceptual Loss Function Boundary Gradient Loss Function Frequency domain loss function and the soft region mask loss function λ pix ,λ per ,λ grad ,λ freq ,λ soft is a balance parameter.

[0016] Furthermore, the region-level guiding module uses the feature information of the non-polluted region as an affine transformation parameter to guide the extraction of features of the polluted region, specifically including:

[0017] Feature map As input, the corresponding scaled contaminated area mask As the prior region information, H, W, and C represent the height, width, and number of channels of the input feature map, respectively;

[0018] First, the region-level guidance module transforms the feature map F in Evenly split into two feature maps F in1 and F in2 ,satisfy For the feature map F in1 , according to the corresponding contaminated area mask M in Divide it into pollution area feature map in the spatial dimension and pollution-free area characteristic map Right now:

[0019]

[0020] Then, yes Standardize using the embodiment respectively: perform affine transformation on the polluted area features by using the mean and variance extracted from the non-polluted area features, that is, for each feature point p located at (h, w, ch) in the polluted area, the specific affine transformation process is as follows:

[0021]

[0022] Among them, p h,w,ch and Represents the original value of point p and the value after affine transformation, and Represents the mean and standard deviation of the contaminated area under the feature channel dimension, and is the mean and standard deviation of the unpolluted area, calculated as follows:

[0023]

[0024] |M in =0| indicates the number of pixels in the pollution area where the median value of the mask is equal to 0, that is, the number of pixels in the non-polluted area, |M in =1| indicates the number of pixels in the polluted area;

[0025] Then the two transformed regional feature maps are re-merged in the spatial dimension to obtain the feature map

[0026] Then, the feature map F in2 With feature map Reconstruct the channel dimension to get the feature map Finally, the feature map F out After convolution and activation function operation, it is directly connected to the feature map after 1×1 convolution Connected with a residual structure, the feature map of the final output of the regional level guidance module is obtained

[0027] Furthermore, the pixel-level guidance module is improved on the basis of the visual Transformer for the polluted area. Based on the guidance of the polluted area mask, it is only necessary to build an attention mechanism from the relevant pixels of the non-polluted area to the polluted area, without obtaining the correlation of all pixels in the global range. Specifically, it includes:

[0028] Feature map As the input of the pixel-level guidance module, it corresponds to the scaled soft pollution area mask As prior information, H, W, and C represent the height, width, and number of channels of the input feature map, respectively;

[0029] First, for X in Perform position encoding to obtain feature map X p , X p Each element x in p =x in +pe, where pe is obtained by encoding the image 2D position:

[0030]

[0031] Where x and y represent the horizontal and vertical positions of the pixel, and i, j∈[0, C / 4) specify the corresponding dimension. Each dimension of the position encoding is composed of a sinusoidal signal of a specific frequency and phase, with a wavelength range that grows geometrically from 2π to 10000·2π. The first half of the full dimension encodes the horizontal position x, and the second half encodes the vertical position y.

[0032] Next, the feature map X is p Perform tiling operation to obtain N is the number of pixels in the feature map;

[0033]

[0034] Afterwards, After three sets of matrix multiplications, the linear transformation obtains the query matrix Q, the key matrix K, and the value matrix V; note that the contaminated area mask is inverted here: And act on the key matrix operation:

[0035]

[0036] in is a learnable linear transformation matrix; the query matrix obtained later with the transposed key matrix Perform dot product and introduce temperature coefficient After balancing the weight values, we get the attention correlation matrix

[0037]

[0038] After normalizing the attention relationship using the softmax function, it is multiplied by the value matrix V to obtain the feature map after the updated information interaction.

[0039]

[0040] Will The linear transformation of the feedforward network FFN is used for further feature extraction and integration to obtain the feature map FFN consists of two linear fully connected layers and a ReLU activation function in the middle, namely:

[0041]

[0042] Construct the feature map X with the input in The residual connection of the pixel-level guidance module is used to obtain the feature map Y output by out :

[0043]

[0044] Furthermore, step one specifically includes:

[0045] First, calculate the image I containing the contaminated area in And the corresponding clean image I without contamination area gt Differences in RGB color channels I diff :

[0046]

[0047] Where c is each color channel of RGB; then the normalization function N(·) is used to diff Normalize each color channel of the image; finally, calculate the average value to obtain the soft area mask reference value

[0048]

[0049] M softmaxsk The element value range is [0, 1], and M softmaxsk Learning training objectives for soft region mask generators;

[0050] Soft Region Mask Generator G softmask (·) Using the U-Net structure, we can obtain the image I containing the polluted area. in The corresponding contaminated area mask Min , to learn and generate a mask close to the soft region reference value M softmask The soft area mask of

[0051] Furthermore, the encoding block is jump-connected with the reversible network module through the multi-scale channel attention module, specifically including:

[0052] The feature map input to the multi-scale channel attention module is denoted as The multi-scale channel attention module includes a global branch and a local branch; the feature map X in In the global branch, the feature map is first obtained by global average pooling. Local branches and feature graph X in Be consistent Then the global branch and the local branch are convolved point by point through the bottleneck layer, and the features are first reduced in dimension and then increased in dimension, that is:

[0053]

[0054] Among them, all convolutions are 1×1 convolution kernels. Convolution operations Conv1 and Conv3 first reduce the dimension of the feature map to C / 4 channels, and then convolution operations Conv2 and Conv4 increase the dimension to the original channel number C. The local features after the bottleneck layer Keep and feature map X in Same size; global features after passing the bottleneck layer The full image information of each feature channel is reflected by a scalar value;

[0055] Afterwards, and Perform aggregation and weight distribution to obtain the feature map after feature recalibration

[0056]

[0057] in, Represents the weights of each feature point constructed by the multi-scale channel attention module, represents a broadcast addition operation, Represents an element-wise multiplication operation.

[0058] Compared with the prior art, the beneficial technical effects of the present invention are:

[0059] Aiming at the problem of insufficient interaction of regional feature information that is common in the current regional degradation image restoration methods, the present invention designs a new degraded image restoration method based on contaminated region mask guidance. The core of the method includes two feature extraction and interaction modes, namely, adaptive guided restoration of regional level statistical information and self-attention guided restoration of remote high correlation features at the pixel level. Through these two modes, the present invention makes full use of the information of regional masks in the whole process of the algorithm, not only exerts the powerful local feature extraction ability of the convolution operation in the traditional convolutional neural network CNN, but also realizes the feature information interaction of the Transformer self-attention mechanism in the global range. Experimental results show that the method can achieve high-quality image restoration in shadow removal and flare removal tasks with a lower number of parameters and computational complexity, and shows good generalization and expansion capabilities within a reasonable range of the proportion of contaminated areas and clean areas. In addition, based on the idea of ​​regional mask guidance, the present invention has the potential to support the personalized needs of users and can be effectively embedded and expanded to other related image restoration tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 It is a schematic diagram of the overall process of the degraded image restoration method based on contaminated area mask guidance of the present invention;

[0061] Figure 2 It is a structural schematic diagram of the regional level guidance module of the present invention;

[0062] Figure 3 is a structural schematic diagram of a pixel-level guiding module of the present invention;

[0063] Figure 4 It is a structural schematic diagram of the reversible network module of the present invention;

[0064] Figure 5 Schematic diagram of the structure of the multi-scale channel attention module of the present invention. DETAILED DESCRIPTION

[0065] The present invention proposes a degraded image restoration method based on contaminated area mask guidance. The overall idea is as follows:

[0066] 1. Aiming at the problem of insufficient feature extraction and information interaction between image regions (clean regions and polluted regions), two guidance modules based on regional masks are designed to realize feature processing at the regional and pixel levels respectively. Among them, the regional guidance module adaptively applies the statistical characteristics of the clean region features to the polluted region features from the perspective of the whole region to achieve regional recovery; the pixel-level guidance module uses the self-attention mechanism to accurately match the highly correlated features from the unpolluted region for deep features of the polluted region, and performs global pixel-by-pixel recovery. The two modules make full use of the information of the regional mask to construct the relationship between the clean and unpolluted regions and the polluted regions in the image, and establish a feature information transmission path from "clean to polluted".

[0067] 2. The overall network framework adopts the classic "encoder-decoder" mode, combining the advantages of the traditional convolutional neural network CNN architecture and the Transformer architecture in local feature and global information extraction and interaction, and further designs a soft area mask generator, a reversible network module and a multi-scale channel attention module to empower the model, realizing a more complete and comprehensive deep learning image restoration algorithm based on regional mask guidance.

[0068] 3. After sufficient experiments and analysis, the effectiveness of the overall framework of the present invention and the regional mask-based guidance module are proved. It can achieve high-quality image restoration in shadow removal and flare removal tasks with lower parameter and computational complexity, and has the potential to be expanded to other related image restoration tasks with regional pollution.

[0069] The degraded image restoration method based on contaminated area mask guidance in the present invention comprises the following steps:

[0070] Step 1: Construct a guidance module based on regional masks, including image feature extraction and information interaction processes at the regional and pixel levels.

[0071] (1-1) The region-level guidance module COAN is mainly used in the encoding and decoding stages of the algorithm. Through the structure of feature segmentation and fusion of channel dimension and spatial dimension, it better retains part of the original content feature information, reduces the information loss caused by the data offset between the polluted area and the clean area before and after standardization, and based on the guidance of the regional mask, uses the feature information of the unpolluted area as the affine transformation parameter to guide the features of the polluted area, strengthens the information interaction between regions to maintain statistical consistency, and significantly improves the image restoration performance of the polluted area.

[0072] (1-2) Pixel-level guidance module CAAT is mainly used in the global information interaction processing stage of deep features. CAAT optimizes and improves the polluted area based on the basic visual Transformer. Based on the guidance of the soft area mask, it only needs to build an attention mechanism from highly correlated pixels in the unpolluted area to the polluted area, without obtaining the correlation of all pixels in the global range. It not only achieves accurate point-to-point restoration at the pixel level, but also reduces the computational cost of the model and improves computational efficiency.

[0073] Step 2: Construct auxiliary modules, including soft region mask generator, reversible network module and multi-scale channel attention module.

[0074] (2-1) Soft region mask generator, used in the global information interaction processing stage of deep features. The soft region mask generator uses the traditional small U-Net structure to learn and generate high-quality soft region masks close to the reference value by inputting the original polluted image and its corresponding polluted region hard threshold mask. The generated soft region mask can effectively measure the degree of pixel pollution and provide more valuable region representation for the pixel-level guidance module CAAT.

[0075] (2-2) Reversible network module, used in the decoding stage of the algorithm. The present invention implements the reversible network module based on the universal affine coupling layer of the reversible neural network for image processing designed by RealNVP. Among them, the regional level guidance module symmetrical with the encoding process is designed as the transformation function. Through the feature mapping of the bijective function of its forward and reverse processes, it can not only ensure that the detail information of the deep feature map is not lost in the step-by-step recovery process, but also reduce the model memory occupancy to a certain extent. At the same time, it cooperates with upsampling and cross-layer jump connection operations to gradually improve and restore the image detail features.

[0076] (2-3) Multi-scale channel attention module, used in the cross-layer skip connection of the model. By introducing a lightweight attention mechanism to the feature maps of each layer in the encoding process, the multi-scale channel attention module assigns corresponding weights to the features, selects valuable detail information, and assists the network model to better retain and fuse the feature maps with high-resolution rich spatial information and the feature maps with low-resolution high semantic information, and gradually restore the image features in the decoding stage.

[0077] Step 3: Build the overall image restoration model. The above-mentioned guidance module based on regional masks and various auxiliary modules are embedded into the U-Net-like network of the "encoder-decoder" architecture. The process mainly includes three stages: the encoding stage of shallow feature extraction, the global information interaction processing stage of deep features, and the decoding stage of image restoration step by step, as described below:

[0078] (3-1) During the encoding process, local image feature extraction is achieved based on two-dimensional convolution and maximum pooling downsampling operations, the spatial size of the feature map is gradually reduced, and a region-level guidance module COAN is introduced in the standardization operation. The statistical information of the unpolluted area is used as the affine transformation parameters of the polluted area to ensure that the feature distribution of some features in the polluted area is statistically consistent with that in the clean area.

[0079] (3-2) In deep feature processing, the soft region mask generator is first used to measure the degree of contamination in the damaged area of ​​the image, and to provide a more detailed representation of the edge of the contaminated area, while avoiding the problem of information loss in the subsequent feature transmission process caused by the "01" hard threshold mask. Furthermore, by cascading multiple pixel-level guidance modules based on regional masks for remote feature modeling, the function of selecting highly correlated pixels from the uncontaminated area to help restore the feature points in the contaminated area is realized.

[0080] (3-3) In the decoding stage, a reversible network module and upsampling operations are used to build a symmetrical structure consistent with the encoding stage. The reversible network module can retain the detailed information of the data restored layer by layer and reduce the memory usage, making the training more stable. In addition, in the cross-layer jump connection between encoding and decoding, a multi-scale channel attention module is used to better integrate shallow and deep features with different semantic information, making the image restoration result more perfect.

[0081] Step 4: Obtain paired data for model training. Since the module and the overall image restoration algorithm introduced in the present invention require the support of the contaminated area mask, all paired data contain image triplets, i.e., images with contaminated areas, clean images without contamination, and corresponding contaminated area masks. After data enhancement including random operations such as rotation, scaling, translation, shearing, and flipping, the image is cropped to a 256×256 image size and input into the image restoration model.

[0082] Step 5: Design the optimization objectives of the network model, including pixel-level loss functions Perceptual Loss Function Boundary Gradient Loss Function Frequency domain loss function and the soft region mask loss function

[0083] Among them, λ pix ,λ per ,λ grad ,λ freq ,λ soft Optimize the balance parameters in the objective for the network.

[0084] Step 6: The training process is divided into two steps. First, a periodic cosine annealing learning rate change scheme with preheating and an Adam-based sharpness-aware minimization SAM optimizer are used. The preheating operation and periodic learning rate change can help the model to be more stable during the training process, prevent the model from overfitting and falling into the local optimal solution, and thus obtain a preliminary training model. Subsequently, the preliminary model is further retrained and optimized using the Adam optimizer and a dynamic learning rate update strategy based on the stagnation period setting to obtain the final model.

[0085] Example

[0086] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is further described below in conjunction with relevant embodiments and with reference to the accompanying drawings.

[0087] Step 1: Construct a guidance module based on regional masks, including image feature extraction and information interaction processes at the regional and pixel levels.

[0088] (1-1) Construct a regional guidance module COAN, which is used in the encoding and decoding stages of the algorithm. Its structure is as follows Figure 2 As shown. As input, the corresponding scaled contaminated area mask As the prior region information (m=1 represents a polluted area, m=0 represents a non-polluted area), H, W, and C represent the height, width, and number of channels of the input feature map, respectively.

[0089] First, COAN transforms the feature F in the channel dimension in Evenly divided into two parts F in1 and F in2 ,satisfy For F in1 Features, according to the corresponding contaminated area mask M in Divide it into contaminated areas in the spatial dimension and clean pollution-free areas Right now:

[0090]

[0091] Then, the two regions are standardized by the embodiment. Compared with the regional standardization, which performs independent operation processes on different regions and ignores any details and semantic connections between regional features, the embodiment standardization used in the present invention does not introduce learnable affine parameters, and only uses the mean and variance extracted from the features of the unpolluted region to perform affine transformation on the features of the polluted region, that is, for each feature point p located at (h, w, ch) in the polluted region, the specific affine transformation process is as follows:

[0092]

[0093] Among them, p h,w,ch and Represents the original value of the point p and the value after affine transformation, and Represents the mean and standard deviation of the contaminated area under the feature channel dimension, and is the mean and standard deviation of the unpolluted area, calculated as follows:

[0094]

[0095] |M in =0| indicates the number of pixels in the contaminated area where the median value of the mask is equal to 0, that is, the number of pixels in the non-contaminated area. in =1| represents the number of pixels in the polluted area.

[0096] Then the transformed two region features are re-merged in the spatial dimension to obtain

[0097] Then, another part of F with the original characteristics in2 After normalization and affine transformation Reconstruct it in the channel dimension and get It contains both standardized features and context feature information. Finally, F out After convolution and activation function operation, the direct connection feature after 1×1 convolution Output the corresponding result Y with residual structure out :

[0098]

[0099] (1-2) Construct a pixel-level guidance module CAAT for the global information interaction processing stage of deep features. Its structure is as follows Figure 3 As shown. As input, the corresponding scaled soft pollution area mask As prior information (the soft polluted area mask comes from the soft area mask generator, the polluted area value is close to 1, and the clean area value is close to 0), H, W and C represent the height, width and number of channels of the input feature map respectively.

[0100] First, for X in Perform position encoding to obtain X p , where each element x p =x in +pe, where pe is obtained by encoding the image 2D position:

[0101]

[0102] Where x and y represent the horizontal and vertical positions of the pixel, and i, j∈[0, C / 4) specify the corresponding dimension. Each dimension of the position encoding consists of a sinusoidal signal of a specific frequency and phase. The wavelength range grows geometrically from 2π to 10000·2π. The first half of the full dimension encodes the horizontal position x, and the second half encodes the vertical position y.

[0103] Next, for X p The feature map is flattened on each channel to obtain N is the number of pixels in the feature map.

[0104]

[0105] Afterwards, After three sets of matrix multiplications, the linear transformation results in the query matrix Q, the key matrix K, and the value matrix V. Note that the contaminated area mask is inverted here. And act on the key matrix operation:

[0106]

[0107] in is a learnable linear transformation matrix. Then the query matrix with the transposed key matrix Perform dot product and introduce temperature coefficient After balancing the weight values, we get the attention correlation matrix

[0108]

[0109] Furthermore, the attention relationship is normalized using the softmax function and then multiplied by the value matrix V to obtain the output after the updated information interaction.

[0110]

[0111] In order to ensure the consistency of the number of channels before and after the module, d = C is generally set. Intuitively, the attention operation measures the similarity between the query element and each key element, outputs the sum of value elements weighted by similarity, and completes the relevant information transfer. If the similarity is high, the corresponding more critical feature information is extracted from the value vector.

[0112] Finally, the output of the attention layer The linear transformation of the feedforward network FFN is used for further feature extraction and integration. FFN consists of two layers of linear fully connected layers and the ReLU activation function in the middle, namely:

[0113]

[0114] And reconvert it into feature map form on each channel to get Construct a residual connection with the input to enable the network to better learn differential features:

[0115]

[0116] Step 2: Construct auxiliary modules, including soft region mask generator, reversible network module and multi-scale channel attention module.

[0117] (2-1) Constructing the soft region mask generator G softmaxsk (·) is used in the global information interaction processing stage of deep features to measure the degree of pixel pollution and provide more valuable regional representation for the pixel-level guidance module.

[0118] First, calculate the input contaminated image I in And the corresponding real pollution-free image I gt Differences in RGB color channels I diff :

[0119]

[0120] Where c is the RGB color channel. Then, the normalization function N(·) is used to diff Each color channel is normalized by N(I)=(II min ) / (I max -I min ), I min and I max is the minimum and maximum value of the image I in the corresponding color channel. Finally, the soft area mask reference value is obtained by calculating the average value

[0121]

[0122] M softmask The element value range of is [0,1], which is used as the learning training objective of the soft region mask generator.

[0123] Soft Region Mask Generator G softmask (·) Using the traditional small U-Net structure, by inputting the original contaminated image I in and its corresponding contaminated area hard threshold mask M in , to learn and generate a value close to the reference value M softmaask High-quality soft area masks

[0124] (2-2) Construct a reversible network module for the decoding stage of the algorithm. The present invention implements the reversible network module based on the universal affine coupling layer for image processing reversible neural network designed by RealNVP. Its architecture is shown in the figure Figure 4 As shown, the specific operations are as follows:

[0125] For the forward process, the input of the reversible network module after 1×1 convolution First, split it into two parts in the channel dimension and

[0126]

[0127] The Split(·) operation is to evenly split the channels, that is, Then Perform an additive transformation on Use the augmented affine transform:

[0128]

[0129] Among them, φ(·), ρ(·) and η(·) all use COAN modules to strengthen regional guided recovery. In addition, in order to avoid the exponential explosion caused by the exp(·) function, this chapter uses the Sigmoid(·) function in the ρ(·) function and adds a scale term a to control the exponential size. Finally, the two parts of the output are reassembled as the output X of the reversible network module out :

[0130]

[0131] Similarly, the reverse process of the reversible network module is as follows:

[0132]

[0133] (2-3) Construct a multi-scale channel attention module for use in the cross-layer skip connections of the model to better preserve and fuse feature maps with high-resolution rich spatial information and low-resolution high-semantic information feature maps.

[0134] The multi-scale channel attention module architecture is as follows Figure 5 As shown in the figure, two branches, global and local, are used to extract channel attention. The global feature processing link preferentially uses global average pooling to extract relevant attention, while the local feature processing link directly uses convolution to extract information.

[0135] enter The global branch is first obtained by global average pooling Local branches keep input consistent Then the two branches are convolved point by point through the bottleneck layer, reducing the dimension of the features first and then increasing the dimension, that is:

[0136]

[0137] Among them, each convolution is a 1×1 convolution kernel. Conv1 and Conv3 first reduce the dimension of the feature map to C / 4 channels, and then Conv2 and Conv4 increase the dimension to the original channel number C. The local features after the bottleneck layer Keeping the same size as the input can preserve and highlight subtle details in shallow features; global features The full-image information of each feature channel is reflected by a scalar value, and the correlation and importance of each feature channel are intuitively analyzed and modeled to learn the global channel attention.

[0138] Then, the module performs global channel feature information With local channel feature information Perform aggregation and weight assignment to obtain an improved feature map

[0139]

[0140] in, Represents the weights of each feature point constructed by the multi-scale channel attention module, represents a broadcast addition operation, Represents an element-wise multiplication operation.

[0141] Step 3: Build the overall image restoration model. The above-mentioned region mask-based guidance module and various auxiliary modules are embedded into the U-Net-like network of the "encoder-decoder" architecture, such as Figure 1 As shown. Among them, Figure 1 The top shows the soft region mask generation process, the middle box and the lower right box briefly describe the CAAT and COAN modules proposed in this paper, and the corresponding dotted line is the guidance process based on the region mask information. The process mainly includes three stages: the encoding stage of shallow feature extraction, the global information interaction processing stage of deep features, and the decoding stage of image restoration step by step. The specific description is as follows:

[0142] (3-1) First, input the polluted image The corresponding contaminated area mask After the soft region mask generator G softmask (·), and obtain the soft region mask

[0143] (3-2) Then, in the encoding stage of the network model, the contaminated image I in The corresponding contaminated area mask M inand soft area mask The channels are merged and input into the initial convolutional layer, and the dimensions are increased to C=64 feature channels through 3×3 convolution to obtain the initial feature map.

[0144] (3-3) Input F0 to the first COAN module and based on the contaminated area mask According to step 1-1, the first-level feature extraction guided by the region level is realized, and the Next, After maximum pooling downsampling, we get

[0145] (3-4) Similarly, F1 is input into the second COAN module and the contaminated area mask is generated based on the geometric scaling. The second-level feature extraction guided by region level is realized, and we get then, After maximum pooling downsampling, we get

[0146] (3-5) Input F2 to the third COAN module and use the scaled contaminated area mask as the basis The third-level feature extraction guided by region level is realized, and we get

[0147] (3-6) Then, in the deep feature processing stage, first Input to the first CAAT module and based on the scaled contaminated area mask According to the guidance of step 1-2, pixel-level guided feature extraction and information interaction are realized, and the

[0148] (3-7) By cascading multiple CAAT modules (4 by default), repeating steps 3-6, we can obtain the pixel-level restored feature map

[0149] (3-8) Then, in the decoding stage of the network model, Y2 is input into the first COAN-based reversible network module, which is also based on the contaminated area mask. According to step 2-2, the first-level feature recovery of regional level guidance is achieved, and

[0150] (3-9) Pass the F2 obtained in step 3-4 through the multi-scale channel attention module to obtain the feature map after feature recalibration Combine it with Merge in the channel dimension and perform upsampling after deconvolution to obtain

[0151] (3-10) Similarly, Y1 is input into the second COAN-based reversible network module and based on the contaminated area mask The second-level feature recovery guided by region level is achieved, and we get

[0152] (3-11) Pass the F1 obtained in step 3-3 through the multi-scale channel attention module to obtain the feature map after feature recalibration Combine it with Merge in the channel dimension and perform upsampling after deconvolution to obtain

[0153] (3-12) Input Y0 to the third COAN-based reversible network module and based on the contaminated area mask The third-level feature recovery guided by region level is achieved, and we get

[0154] (3-13) Finally, Input to the output convolution layer, after 3×3 convolution, the dimension is reduced to C=3 feature channels, and we get And with the input contaminated image I in Construct residual connection to get the final output restored image

[0155] The above is a simple model architecture and process of the present invention. In addition, the overall algorithm has strong scalability. According to actual needs, the feature channel dimension can be further increased, the network structure can be deepened, and the two guiding modules of COAN and CAAT can be stacked to obtain a better and more powerful image restoration effect.

[0156] Step 4: Obtain paired data for model training. Since the module and the overall image restoration algorithm introduced in the present invention require the support of the contaminated area mask, all paired data contain image triplets, i.e., images with contaminated areas, clean images without contamination, and corresponding contaminated area masks. After data enhancement including random operations such as rotation, scaling, translation, shearing, and flipping, the image is cropped to a 256×256 image size and input into the image restoration model.

[0157] Step 5: Design the optimization objectives of the network model, including pixel-level loss functions Perceptual Loss Function Boundary Gradient Loss Function Frequency domain loss function and the soft region mask loss function

[0158] Among them, λpix ,λ per ,λ grad ,λ freq ,λ soft Optimize the balance parameters in the objective for the network.

[0159] (5-1) Pixel-level loss function

[0160] Pollution removal image of network model output Compared with the real uncontaminated image I gt The pixel-level loss is calculated using L1 distance:

[0161]

[0162] (5-2) Perceptual loss function

[0163] According to the VGG19 network pre-trained on ImageNet, calculate the output image Compared with the real image I gt Differences in perceived characteristics:

[0164]

[0165] (5-3) Boundary gradient loss function

[0166] In order to improve the restoration quality of the image boundary in the polluted area, based on the idea of ​​Poisson image editing, the boundary gradient loss function is defined:

[0167]

[0168] in represents the Laplace gradient operator, MSE(·) calculates the mean square error between the predicted value and the true value in the corresponding region, The pollution mask M in Obtained by dilating 7 pixels through morphological processing. Keep output image And the input image I in The gradient domain between non-contaminated areas and minimize the output image and the target real image I gt The gradient domain difference between the contaminated areas.

[0169] (5-4) Frequency domain loss function

[0170] Pollution removal image of network model output Compared with the real uncontaminated image I gt, first perform a 2D discrete Fourier transform to convert to its frequency representation:

[0171]

[0172] And calculate the frequency domain loss function as follows:

[0173]

[0174] (5-4) Soft Region Mask Loss Function

[0175] In the auxiliary module - soft region mask generator, in order to generate high-quality soft region masks close to the reference value, a soft region mask loss based on L1 distance is introduced:

[0176]

[0177] in, is the soft region mask generator G softmask (·) The learned and generated soft region mask, M softmask The polluted image I input by the model in Compared with the real uncontaminated image L gt It is calculated by F(·) described in step 2-1.

[0178] Step 6: The experimental training process is divided into two steps. First, the periodic cosine annealing learning rate change scheme with preheating and the Adam-based sharpness-aware minimization SAM optimizer are used. The number of iterations in the preheating period is 10 times, the initial learning rate of the periodic cosine annealing base-lr=0.002, the initial period T0=50, and the period extension factor T mult =2, the specific calculation is as follows:

[0179]

[0180] in, i represents the number of cycle restarts. When the number of iterations is T cur Reach T i When , the learning rate takes the minimum value η t =η min , then the cycle resets T cur =0, the learning rate takes the maximum value η t =η max. Warm-up operation and periodic learning rate changes can help the model become more stable during training, prevent the model from overfitting and falling into the local optimal solution, and thereby obtain a preliminary training model. Subsequently, the Adam optimizer and the dynamic learning rate update strategy based on the stagnation period setting are further used to optimize and obtain the final model. The Adam optimizer has weight-decay=0.01, β1=0.9, β2=0.99, the initial learning rate base-lr=0.0005, the stagnation period is patience=25, and the learning rate gradually decreases at a factor=0.5. The number of model training iterations is set to 300 times based on experience.

[0181] Step 7, model evaluation:

[0182] In order to objectively evaluate the model performance and algorithm effectiveness of the present invention, this invention is quantitatively evaluated on shadow image datasets (ISTD, ISTD+ and SRD, etc.) and flare image datasets (Flare7K, etc.) with shadow removal task algorithms such as BMNet, AEFNet, DHAN, and general image restoration algorithms such as HINet, Uformer, and Restormer. Four performance indicators, namely Mean Absolute Error (MAE), Peak Signal-to-Noise Ratio (PSNR), Structural Similarity (SSIM) and Learned Perceptural Image Patch Similarity (LPIPS), are selected as numerical evaluations. In the quantitative analysis, the present invention has achieved the best performance in the two types of regional contaminated image restoration tasks, namely shadow removal and flare removal. The present invention not only has a guiding restoration effect on the contaminated area, but also has the ability to learn global color brightness. It can still fit the relevant mapping for the color difference of the non-contaminated area in the paired data set, has certain adaptability and robustness to complex and changeable environmental conditions, and has a stronger feature learning representation ability. In addition, the present invention effectively utilizes the information of the regional mask, uses the non-polluted area to guide the image restoration of the polluted area, and the goals of each module in the network training are clear, without the need to introduce additional network parameters and redundant information accumulation. Therefore, the overall network framework only uses about 7% of the parameters and 5% to 20% of the computational complexity of other related comparison methods, achieving the optimal performance of image restoration.

[0183] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention, and any reference numerals in the claims should not be regarded as limiting the claims involved.

[0184] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.

Claims

1. A degraded image restoration method based on contaminated area mask guidance, characterized in that: The image containing the polluted area and the polluted area mask are input into the trained restoration model, and the restored image is output; the restoration model includes a soft area mask generator, an encoder, a multi-scale channel attention module and a decoder, and the encoder and decoder adopt a U-Net type architecture; The construction and training method of the recovery model includes the following steps: Step 1: The image I containing the polluted area in The corresponding contaminated area mask M in After the soft region mask generator G softmask (·), and obtain the soft region mask Step 2: Encoding stage: Contaminated image I in , the corresponding contaminated area mask M in and soft area mask The convolution operation is performed in the channel dimension to obtain an initial feature map F0; the initial feature map is sequentially passed through multiple levels of encoding blocks in the encoder, and multiple feature extractions are performed under the guidance of the contaminated area mask to obtain a shallow feature map; the encoding block is composed of a region-level guidance module and a downsampling operation; the region-level guidance module uses the feature information of the non-contaminated area as an affine transformation parameter to guide the extraction of the contaminated area features; Step 3: Global information interaction processing of deep features; input the shallow feature map output by the encoder into multiple cascaded pixel-level guidance modules, and obtain the pixel-level restored feature map under the guidance of the soft area mask; the pixel-level guidance module is improved on the basis of the visual Transformer for the polluted area. Based on the guidance of the soft area mask, it only needs to build an attention mechanism from the relevant pixels of the unpolluted area to the polluted area, without obtaining the correlation of all pixels in the global range; Step 4, decoding stage: the pixel-level restored feature map is passed through the reversible network modules of multiple levels in the decoder in turn, and multiple feature restorations are performed under the guidance of the contaminated area mask to obtain the restored feature map; the reversible network module is implemented based on the area-level guidance module; the encoding block is jump-connected with the reversible network module through the multi-scale channel attention module; Step 5: Input the restored feature map into the output convolution layer and compare it with the image I containing the contaminated area. in Construct residual connection and output the final restored image Step 6: Based on the training samples and the overall loss function, the restoration model is trained; the training samples include images with polluted areas, masks of polluted areas, and clean images without polluted areas; the overall loss function includes a pixel-level loss function Perceptual Loss Function Boundary Gradient Loss Function Frequency domain loss function and the soft region mask loss function λ pix ,λ per ,λ grad ,λ freq ,λ soft is a balance parameter.

2. The degraded image restoration method based on contaminated area mask guidance according to claim 1, characterized in that: The region-level guidance module uses the feature information of the non-polluted region as an affine transformation parameter to guide the extraction of the features of the polluted region, specifically including: Feature map As input, the corresponding scaled contaminated area mask As the prior region information, H, W, and C represent the height, width, and number of channels of the input feature map, respectively; First, the region-level guidance module transforms the feature map F in Evenly split into two feature maps F in1 and F in2 , satisfying F in1 , For the feature map F in1 , according to the corresponding contaminated area mask M in Divide it into pollution area feature map in the spatial dimension and pollution-free area characteristic map Right now: Then, yes Standardize using the embodiment respectively: perform affine transformation on the polluted area features by using the mean and variance extracted from the non-polluted area features, that is, for each feature point p located at (h, w, ch) in the polluted area, the specific affine transformation process is as follows: Among them, p h,w,ch and Represents the original value of point p and the value after affine transformation, and Represents the mean and standard deviation of the contaminated area under the feature channel dimension, and is the mean and standard deviation of the unpolluted area, calculated as follows: |M in =0| indicates the number of pixels in the pollution area where the median value of the mask is equal to 0, that is, the number of pixels in the non-polluted area, |M in =1|indicates the number of pixels in the polluted area; Then the two transformed regional feature maps are re-merged in the spatial dimension to obtain the feature map Then, the feature map F in2 With feature map Reconstruct the channel dimension to get the feature map Finally, the feature map F out After convolution and activation function operation, it is directly connected to the feature map after 1×1 convolution Connected with the residual structure, the feature map Y of the final output of the regional level guidance module is obtained out :

3. The degraded image restoration method based on contaminated area mask guidance according to claim 1, characterized in that: The pixel-level guidance module is improved on the basis of the visual Transformer for the polluted area. Based on the guidance of the polluted area mask, it only needs to build an attention mechanism from the relevant pixels of the non-polluted area to the polluted area, without obtaining the correlation of all pixels in the global range. Specifically, it includes: Feature map As the input of the pixel-level guidance module, it corresponds to the scaled soft pollution area mask As prior information, H, W, and C represent the height, width, and number of channels of the input feature map, respectively; First, for X in Perform position encoding to obtain feature map X p , X p Each element x in p =x in +pe, where pe is obtained by encoding the image 2D position: Where x and y represent the horizontal and vertical positions of the pixel, and i, j∈[0, C / 4) specify the corresponding dimension. Each dimension of the position encoding is composed of a sinusoidal signal of a specific frequency and phase, with a wavelength range that grows geometrically from 2π to 10000·2π. The first half of the full dimension encodes the horizontal position x, and the second half encodes the vertical position t. Next, the feature map X is p Perform tiling operation to obtain N is the number of pixels in the feature map; N=H×W; Afterwards, After three sets of matrix multiplications, the linear transformation obtains the query matrix Q, the key matrix K, and the value matrix V; note that the contaminated area mask is inverted here: And act on the key matrix operation: Where W q , W k , is a learnable linear transformation matrix; the query matrix obtained later with the transposed key matrix Perform dot product and introduce temperature coefficient After balancing the weight values, we get the attention correlation matrix After normalizing the attention relationship using the softmax function, it is multiplied by the value matrix V to obtain the feature map after the updated information interaction. Will The linear transformation of the feedforward network FFN is used for further feature extraction and integration to obtain the feature map FFN consists of two linear fully connected layers and a ReLU activation function in the middle, namely: Construct the feature map X with the input in The residual connection of the pixel-level guidance module is used to obtain the feature map Y output by out :

4. The degraded image restoration method based on contaminated area mask guidance according to claim 1, characterized in that: Step 1 specifically includes: First, calculate the image I containing the contaminated area in And the corresponding clean image I without contaminated area gt Differences in RGB color channels I diff : Where c is each color channel of RGB; then the normalization function N(·) is used to diff Normalize each color channel of the image; finally, calculate the average value to obtain the soft area mask reference value M softmask The element value range is [0, 1], and M softmask Learning training objectives for soft region mask generators; Soft Region Mask Generator G softmask (·) Using the U-Net structure, we can obtain the image I containing the polluted area. in The corresponding contaminated area mask M in , to learn and generate a mask close to the soft region reference value M softmask The soft area mask of 5. The degraded image restoration method based on contaminated area mask guidance according to claim 1, characterized in that: The method of performing jump connection between the encoding block and the reversible network module through the multi-scale channel attention module specifically includes: The feature map input to the multi-scale channel attention module is denoted as The multi-scale channel attention module includes a global branch and a local branch; the feature map X in In the global branch, the feature map is first obtained by global average pooling. Local branches and feature graph X in Be consistent Then the global branch and the local branch are convolved point by point through the bottleneck layer, and the features are first reduced in dimension and then increased in dimension, that is: Among them, each convolution is a 1×1 convolution kernel. Convolution operations Conυ1 and Conυ3 first reduce the dimension of the feature map to C / 4 channels, and then convolution operations Conυ2 and Conυ4 increase the dimension to the original channel number C; the local features after the bottleneck layer Keep and feature map X in Same size; global features after passing the bottleneck layer The full image information of each feature channel is reflected by a scalar value; Afterwards, and Perform aggregation and weight distribution to obtain the feature map after feature recalibration in, Represents the weights of each feature point constructed by the multi-scale channel attention module, represents a broadcast addition operation, Represents an element-wise multiplication operation.

Citation Information

Patent Citations

  • Image restoration method based on gating and context attention mechanism

    CN113989129A

  • Robust image watermarking method adopting two-stage precoding and wavelet network

    CN114529442A

  • Image blind restoration method based on semantic inconsistency detection

    CN114897738A

  • Medical image recognition method, electronic equipment and storage medium

    CN114972751A

  • Plug-and-play image restoration model and method based on self-attention mechanism

    CN117391994A

Cited By

  • Construction method of image enhancement model, image enhancement method, device, equipment and medium

    CN119478589A

  • Depth estimation method and system based on indirect diffusion model

    CN120031936A

  • Depth estimation method and system based on indirect diffusion model

    CN120031936B

  • Robot pushing-grabbing cooperative operation method based on spatial relation function detection

    CN120901939A

  • A robot pushing-grasping collaborative operation method based on spatial relationship functionality detection

    CN120901939B