Haze image restoration method based on deep learning and gamma correction
Through deep learning Uformer network and gamma correction technology, combined with self-attention mechanism and RGB channel processing, the problem of poor image dehazing effect in the existing technology is solved, high-quality haze image restoration is achieved, and the visual quality of the image is improved. accuracy of effects and subsequent processing.
Patent Information
- Application Number
- CN202410846037.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-06-26
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-06-27
AI Technical Summary
When the existing technology processes images in bad weather, especially in dense fog environments, the dehazing effect is poor in robustness, resulting in low image restoration quality, chromatic aberration and noise problems, and cannot effectively improve the imaging quality of the optical system.
The Uformer network structure based on deep learning is combined with the image dehazing method of gamma correction. Through the generation of adversarial network and self-attention mechanism, the dehazed image is generated, and the gamma correction function is used for image correction, combined with RGB channel weight and normalization processing, to improve Image restoration quality.
It effectively improves the quality of the image after dehazing, enhances the visual comfort and perception range of the image, ensures the information accuracy of subsequent processing, and significantly improves the detail recovery effect of the image.
Smart Images

Figure CN118840291A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer digital image processing, and in particular to a haze image restoration method based on deep learning and gamma correction. Background Art
[0002] With the development of current computer technology, the performance of hardware equipment is constantly improving, and image processing technology plays an increasingly important role in today's social development. In the fields of intelligent security, industrial automation, satellite imaging, navigation and guidance, new technologies based on computer vision are constantly being applied. In the past few decades, severe weather such as haze and dust have occurred frequently around the world. The atmospheric scattering caused by haze and other weather conditions has significantly reduced the imaging quality of optical equipment, resulting in a decrease in image contrast and chromatic aberration. This has greatly limited the application scenarios of many optical devices, and the success rate of target recognition and detection by computer vision systems has been significantly reduced.
[0003] Therefore, effective image dehazing and enhancement methods are of great value in improving the imaging quality of optical systems and improving the image perception level. They are also an important basis for subsequent image segmentation, image classification, target detection and other related work.
[0004] In previous studies, many methods are based on traditional prior information or the construction of atmospheric physics models to restore degraded images. Images are restored by analyzing information such as brightness and color distribution. Such methods often have poor robustness and limited dehazing effects on complex scenes such as dense fog environments. The restored images may have problems such as color aberration and noise, and cannot restore the input degraded images with high quality.
[0005] In view of the above problems, the present invention proposes an image dehazing method which combines a deep learning uformer network structure with gamma correction to improve the quality. Summary of the invention
[0006] The purpose of the present invention is to provide a haze image restoration method based on deep learning and gamma correction, which can effectively solve the problem.
[0007] In order to solve the above technical problems, the present invention adopts the following technical solution: a haze image restoration method based on deep learning and gamma correction, characterized in that it includes:
[0008] The transformer-based image restoration architecture Uformer is used as the generator of the generative adversarial network;
[0009] Input the foggy image into the generator of the adversarial network to generate the defogged image;
[0010] The discriminator compares the dehazed image generated by the generator with the real image without haze, and optimizes the parameters of the generative adversarial network model by minimizing the Charbonnier loss function;
[0011] Repeat the above steps for the number of iterations set for training, and
[0012] In the forward propagation inference process of the trained generator, a gamma correction function is added to correct the input dehazed image and output a preliminary restored image;
[0013] The gamma-corrected image is split into three channels of RGB, each channel is multiplied by the corresponding weight, and the final restoration result is obtained after merging the channels and standardizing them.
[0014] Preferably, the dark channel prior principle and atmospheric light estimation are used in combination with transmittance estimation to generate a foggy image. The atmospheric scattering model formula is:
[0015]
[0016] Where I represents the synthetic haze image, J represents the clear image, t is the atmospheric transmittance, A is the atmospheric light value, and E is the unit matrix.
[0017] Preferably, the generator generates the dehazed image as follows:
[0018] The input foggy image first passes through a convolution layer, extracts the underlying features through a 3×3 convolution kernel, and then is activated by LeakyReLU to output a feature map.
[0019] Use the encoder output as the decoder input;
[0020] The encoder output feature map and the decoder feature map at the corresponding resolution are spliced at the channel position through jump connections to achieve multi-scale feature information fusion.
[0021] Preferably, the encoder uses a multi-head self-attention module with multiple local enhanced windows, the multi-head self-attention module includes a non-overlapping window multi-head attention mechanism and a local enhanced feed-forward network, combined with a downsampling module to capture global dependencies; and
[0022] The decoder also contains multiple self-attention modules with local enhancement windows to upsample the input feature information and increase the resolution of the feature map.
[0023] Preferably, the encoder specifically operates as follows:
[0024] Step 1: Windowed Multi-Head Attention Mechanism (W-MSA) for a given input sequence Divide X into i windows with no overlap between them. For each window, W-MSA applies a multi-head self-attention module to calculate the attention weights between elements in the window and generate representations of the elements in the window. The self-attention of the Kth head can be expressed as:
[0025]
[0026] Among them,,,∈ represent the mapping matrices of query, key and value of the Kth head respectively.
[0027] Step 2: Calculate the attention weight based on the known Q, K, and V. The formula can be expressed as:
[0028]
[0029] Among them, is the relative position deviation, and its value is obtained through learning.
[0030] Step 3: Calculate the multi-head self-attention module of the local enhancement window. The calculation formula is expressed as:
[0031] X′ m =W-MSA(LN(X m-1 ))+X m-1 ;
[0032] X m =LeFF(LN(X′ m ))+X′ m ;
[0033] Among them, X′ m and are the outputs of W-MSA and LeFF respectively, and LN represents layer normalization.
[0034] Preferably, downsampling uses a 4×4 convolution kernel with a stride of 2 to reduce the image resolution to 1 / 4 and double the number of channels, and upsampling uses a 2×2 convolution kernel with a stride of 2 transposed convolution. After processing, the image resolution becomes 4 times and the number of channels is halved.
[0035] Preferably, a skip connection is introduced, that is, in the decoder, the output of the encoder and the residual term are added as the input of the decoder, so as to combine the low-level and high-level feature information together, capture features at different levels, and improve the performance and convergence speed of the model during training.
[0036] Preferably, the Charbonnier loss function formula is:
[0037]
[0038] Where is a clear image and is an empirical constant.
[0039] Preferably, the correction of the input defogging image is specifically performed as follows:
[0040] Step 1: Normalize the pixel values of the dehazed image and map them to between 0 and 1;
[0041] Step 2: Calculate the normalized data using 1 / gamma as the exponent.
[0042] Step 3: Inversely transform the pre-compensated real value into an integer value between 0 and 255.
[0043] Preferably, the standardization process is:
[0044]
[0045] Where X is the gamma-corrected image, μ is the mean of the image, σ is the standard deviation of the image, and Z is the standardized image.
[0046] Beneficial effects: The generator of the generative adversarial network is modified using the transformer-based image restoration architecture Uformer, which uses the self-attention mechanism to effectively capture the global and local features in the image, and can effectively achieve image dehazing and produce clear restored images;
[0047] In addition, by adding a gamma correction function, the image data is transformed into a power to adjust its nonlinear response method to achieve a more accurate light intensity representation, combined with RGB channel weight processing and data standardization operations, so that the enhanced image has a better perception range and application value. This method is crucial to maintaining the accuracy and visual comfort of the image information after dehazing, and is the prerequisite for the subsequent visual system to further process and obtain information. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0049] In the attached picture:
[0050] Figure 1 It is a flow chart of the haze image restoration method based on deep learning and gamma correction of the present invention;
[0051] Figure 2 is a degraded image with fog according to the present invention;
[0052] Figure 3 A clear image restored by the deep learning method of the present invention;
[0053] Figure 4This is a clear image restored by the deep learning method of the present invention with gamma correction. DETAILED DESCRIPTION
[0054] In order to make the purpose and advantages of the present invention more clear, the present invention is specifically described in combination with embodiments below. It should be understood that the following text is only used to describe a haze image restoration method based on deep learning and gamma correction or several specific implementation methods of the present invention, and does not strictly limit the scope of protection of the specific request of the present invention.
[0055] Example: Figure 1 A haze image restoration method based on deep learning and gamma correction is shown, comprising the following steps:
[0056] Step 1: Create a synthetic foggy dataset based on the atmospheric scattering model;
[0057] Among them, an image defogging dataset is established, and the dark channel prior principle and atmospheric light estimation are used to generate foggy images combined with transmittance estimation. The atmospheric scattering model formula is:
[0058]
[0059] Where I represents the synthetic haze image, J represents the clear image, t is the atmospheric transmittance, A is the atmospheric light value, and E is the unit matrix.
[0060] Step 2: Initialize the model parameters, the foggy image passes through the first convolutional layer for underlying feature extraction and is input into the encoder module;
[0061] Among them, the underlying features are extracted through the 3×3 convolution kernel, and the feature map is obtained after LeakyReLU activation;
[0062] Step 3: The encoder uses a self-attention module with multiple local enhanced windows, which includes a non-overlapping window multi-head attention module (W-MSA) and a local enhanced feedforward network (LeFF), combined with a downsampling module to reduce computational complexity and capture global dependencies. Downsampling uses a 4×4 convolution kernel with a stride of 2 to reduce the image resolution to 1 / 4 and double the number of channels; the main operations are:
[0063] (1) W-MSA for a given input sequence Divide X into i windows with no overlap between them. For each window, W-MSA applies a multi-head self-attention mechanism to calculate the attention weights between elements in the window and generate representations of the elements in the window. The self-attention of the k-th head can be expressed as:
[0064]
[0065] Among them, ,∈ represent the mapping matrices of query, key and value of the Kth head respectively;
[0066] (2) Calculate the attention weight based on the known Q, K, and V. The formula can be expressed as:
[0067]
[0068] Where is the relative position deviation, whose value is obtained through learning;
[0069] (3) Calculate the multi-head self-attention module of the local enhancement window. The calculation formula is expressed as:
[0070] X′ m =W-MSA(LN(X m-1 ))+X m-1 ;
[0071] X m =LeFF(LN(X′ m ))+X′ m ;
[0072] where X′ m and are the outputs of W-MSA and LeFF respectively, LN represents layer normalization;
[0073] Step 4: The output of the encoder is used as the input of the decoder. The decoder also contains a self-attention module with multiple local enhancement windows to upsample the input feature information and increase the resolution of the feature map. The upsampling uses a 2×2 convolution kernel with a step size of 2 transposed convolution. After processing, the image resolution becomes 4 times and the number of channels is halved.
[0074] Step 5: The encoder output feature map and the decoder feature map at the corresponding resolution are spliced at the channel position through jump connections to achieve multi-scale feature information fusion, thereby further improving the image dehazing effect; in the decoder, the encoder output and the residual term are added as the input of the decoder to capture feature information at different levels, thereby improving the performance and convergence speed of the model during training.
[0075] Step 6: The discriminator compares the defogging image generated by the generator with the real image without fog. That is, the discriminator extracts features through 4×4 convolution kernel and Leaky ReLU layer downsampling, judges the difference between the generated defogging image and the actual clear image, and optimizes the model parameters by minimizing the Charbonnier loss function; Charbonnier_loss is a loss function for image generation tasks similar to L1 loss, and its formula is:
[0076]
[0077] Among them, I′ is the model generated image, It is a clear image and an empirical constant;
[0078] Step 7: Repeat steps 2 to 6 until the number of iterations set for model training is reached;
[0079] Step 8: Add gamma correction to the forward propagation inference process of the trained dehazing model, edit the gamma curve of the image, and finally output the restored image; specifically:
[0080] (1) Normalize the pixel values of the dehazed image and map them to between 0 and 1;
[0081] (2) The normalized data is calculated using 1 / gamma as the exponent;
[0082] (3) transforming the pre-compensated real value back into an integer value between 0 and 255;
[0083] Step 9: Split the gamma-corrected image into three channels, RGB, and multiply each channel by the corresponding weight, that is, multiply by the corresponding weights WR, WG, and WB, to obtain a new channel value. After merging the channels and standardizing, the final restoration result is obtained; the formula for standardization is:
[0084]
[0085] Where X is the gamma-corrected image, μ is the mean of the image, σ is the standard deviation of the image, and Z is the standardized image.
[0086] Based on the above operations, the results are as follows Figure 2-Figure 4 As shown, Figure 2 and Figure 3 In comparison, the deep learning self-attention mechanism effectively captures the global and local features in the image. This method can effectively realize image defogging and produce clear restored images. It can be seen that the visibility of the image is significantly improved after defogging, and the image details are effectively restored. Figure 3 and Figure 4 In comparison, a method of adjusting the nonlinear response of image data by power transformation is used to achieve a more accurate light intensity representation, and the RGB channel weight processing is combined with data standardization operations, so that the enhanced image has a better perceptual range and application value.
[0087] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. For ordinary technicians in this technical field, after knowing the contents recorded in the present invention, they can make several equivalent changes and substitutions without departing from the principle of the present invention. These equivalent changes and substitutions should also be regarded as belonging to the protection scope of the present invention.
Claims
1. A haze image restoration method based on deep learning and gamma correction, characterized in that: include: The transformer-based image restoration architecture Uformer is used as the generator of the generative adversarial network; Input the foggy image into the generator of the adversarial network to generate the defogged image; The discriminator compares the dehazed image generated by the generator with the real image without haze, and optimizes the parameters of the generative adversarial network model by minimizing the Charbonnier loss function; Repeat the above steps for the number of iterations set for training, and In the forward propagation inference process of the trained generator, a gamma correction function is added to correct the input dehazed image and output a preliminary restored image; The gamma-corrected image is split into three channels of RGB, each channel is multiplied by the corresponding weight, and the final restoration result is obtained after merging the channels and standardizing them.
2. The haze image restoration method based on deep learning and gamma correction according to claim 1, characterized in that: Using the dark channel prior principle and atmospheric light estimation, combined with transmittance estimation, a foggy image is generated. The atmospheric scattering model formula is: Where I represents the synthetic haze image, J represents the clear image, t is the atmospheric transmittance, A is the atmospheric light value, and E is the unit matrix.
3. The haze image restoration method based on deep learning and gamma correction according to claim 1, characterized in that: The generator generates the dehazed image as follows: The input foggy image first passes through a convolution layer, extracts the underlying features through a 3×3 convolution kernel, and then is activated by LeakyReLU to output a feature map. Use the encoder output as the decoder input; The encoder output feature map and the decoder feature map at the corresponding resolution are spliced at the channel position through jump connections to achieve multi-scale feature information fusion.
4. The haze image restoration method based on deep learning and gamma correction according to claim 3, characterized in that: The encoder uses a multi-head self-attention module with multiple local enhancement windows. The multi-head self-attention module includes a non-overlapping window multi-head attention mechanism and a local enhancement feed-forward network, combined with a downsampling module to capture global dependencies; and The decoder also contains multiple self-attention modules with local enhancement windows to upsample the input feature information and increase the resolution of the feature map.
5. The haze image restoration method based on deep learning and gamma correction according to claim 4, characterized in that: The specific operations of the encoder are: Step 1: W-MSA is used to calculate the input sequence X∈R with a given length H, width W and number of channels C. C×H×W , X is divided into F P×P windows with no overlap between windows; for each window, W-MSA applies a multi-head self-attention module to calculate the attention weights between elements in the window and generate representations of the elements in the window; the self-attention of the kth head can be expressed as: Among them,,,∈ represent the mapping matrices of query, key and value of the kth head respectively. Step 2: Calculate the attention weight based on the known Q, K, and V. The formula can be expressed as: Among them, the dimension of the attention head is d k =C / k, B is the relative position deviation, and its value is obtained through learning. Step 3: Calculate the multi-head self-attention module of the local enhancement window. The calculation formula is expressed as: X′ m =W-MSA(LN(X m-1 ))+X m-1 ; X m =LeFF(LN(X′ m ))+X′ m ; Among them, X′ m and are the outputs of W-MSA and LeFF respectively, and LN represents layer normalization.
6. The haze image restoration method based on deep learning and gamma correction according to claim 4, characterized in that: Downsampling uses a 4×4 convolution kernel with a stride of 2 to reduce the image resolution to 1 / 4 and double the number of channels. Upsampling uses a 2×2 convolution kernel with a stride of 2 transposed convolution. After processing, the image resolution is quadrupled and the number of channels is halved.
7. The haze image restoration method based on deep learning and gamma correction according to claim 3, characterized in that: The skip connection is introduced, that is, in the decoder, the output of the encoder and the residual term are added as the input of the decoder, so as to combine the low-level and high-level feature information together, capture the features of different levels, and improve the performance and convergence speed of the model during training.
8. The haze image restoration method based on deep learning and gamma correction according to claim 1, characterized in that: The Charbonnier loss function formula is: Where I′ is the model generated image, is a clear image, and ε is an empirical constant.
9. The haze image restoration method based on deep learning and gamma correction according to claim 1, characterized in that: Correction of the input defogging image is as follows: Step 1: Normalize the pixel values of the dehazed image and map them to between 0 and 1; Step 2: Calculate the normalized data using 1 / gamma as the exponent. Step 3: Inversely transform the pre-compensated real value into an integer value between 0 and 255.
10. The haze image restoration method based on deep learning and gamma correction according to claim 1, characterized in that: The standardized processing is: Where X is the gamma-corrected image, μ is the mean of the image, σ is the standard deviation of the image, and Z is the standardized image.
Citation Information
Patent Citations
A Generative Adversarial Network (GAN) Method for Haze Image Restoration Based on Memory-Perception Module
CN114936976A
Image defogging method and system
CN116703759A
Image super-resolution method based on image pre-training strategy
WO2023206343A1
Cited By
Recognition and continuous casting judgment method based on high-efficiency beam blank continuous casting machine
CN120635878A
Image processing method based on curve recovery and related equipment
CN120833281A
