Image exposure correction method based on Transform and double-branch fusion network
Through the method based on Transformer and dual-branch fusion network, the problem of simultaneous underexposure and overexposure in the image is solved, more efficient image exposure correction is achieved, image detail information is restored, and image quality is improved.
Patent Information
- Application Number
- CN202410914965.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-15
AI Technical Summary
Existing technology is difficult to effectively solve the problems of simultaneous underexposure and overexposure in images, resulting in uneven illumination, loss of details, and color deviation. The accuracy and robustness of image exposure correction methods are insufficient.
An image exposure correction method based on Transformer and dual-branch fusion network is used to generate a binary partition mask by obtaining the image illumination map and adaptive segmentation threshold, construct a gamma correction parameter estimation network, obtain double gamma correction parameters, and perform exposure adjustment. Feature fusion is performed through a dual-branch fusion network to restore image detail information.
The accuracy and robustness of the image exposure correction method are improved, and it can more naturally adapt to a variety of scenes and exposure conditions, restore rich image detail information, and improve image quality.
Smart Images

Figure CN118781027A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image enhancement in computer vision, and in particular to an image exposure correction method based on Transformer and a dual-branch fusion network. Background Art
[0002] Image enhancement is an image processing technique that aims to improve the visual effect and quality of an image. It usually involves highlighting useful information in an image, such as improving the clarity of an image or emphasizing certain feature information by enhancing brightness, color, and contrast. It is a basic but challenging task in computer vision and has been widely used in many practical fields such as video surveillance, intelligent transportation, and shooting in extreme conditions. Computer technology is developing rapidly, and many branches have been derived from the direction of computer vision. As an important research field, image processing has shown a strong development momentum in recent years. In environments with low visibility or complex lighting conditions such as low light at night, backlight, and overly bright lighting, photos taken often have various problems, such as too dark, overexposure, noise amplification, color distortion, and loss of details. Generally speaking, the lost information in an image mainly exists in the underexposed and overexposed areas of the image. Therefore, how to properly correct the exposure of the image and restore rich image information becomes a challenge. In recent years, although the performance of various image enhancement algorithms has been greatly improved, especially in the field of low-light image enhancement, there are still few methods that can solve the problem of overexposure or the problem of images with both underexposed and overexposed areas. In addition, existing methods still have problems such as uneven lighting, loss of details, and color deviation, so image exposure correction still faces huge challenges. Summary of the invention
[0003] In view of the above shortcomings of the prior art, the present invention provides an image exposure correction method based on Transformer and dual-branch fusion network. Its purpose is to solve the problem of poor exposure in images, especially the problem of overexposure and underexposure at the same time, and to restore the lost detail information in the image, thereby improving the accuracy and robustness of the exposure correction method.
[0004] In order to achieve the above object, the present invention provides an image exposure correction method based on Transformer and dual-branch fusion network, comprising the following steps:
[0005] S1, obtain the image illumination map and adaptive segmentation threshold to generate a binary partition mask;
[0006] S2. Construct a Transformer-based gamma correction parameter estimation network;
[0007] S3, obtaining dual gamma correction parameters;
[0008] S4, applying the estimated parameters to the original image for exposure adjustment;
[0009] S5, build a dual-branch fusion network;
[0010] S6. Send the original image and the exposure-corrected image into a dual-branch fusion network for feature fusion to obtain the final enhanced image.
[0011] The present invention provides an image exposure correction method based on Transformer and dual-branch fusion network. Compared with the prior art, it has the following beneficial effects:
[0012] The present invention improves the performance of the exposure correction method from two perspectives. On the one hand, the image exposure area is divided by calculating the illumination map and the adaptive threshold, and the dual gamma correction model parameters are learned through the improved Transformer parameter estimation network to correct the image exposure, which can better adapt to images of various scenes and different exposure conditions, so as to adjust the image lighting more naturally. On the other hand, the original image is fused with the image after exposure correction through the dual-branch fusion module, and through multi-scale feature extraction and fusion, the advantages of the two can be effectively combined to restore more detailed information of the image and maintain normal exposure of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0014] Figure 1 This is a flow chart of an image exposure correction method based on Transformer and dual-branch fusion network in an embodiment of the present invention.
[0015] Figure 2 This is a schematic diagram of a parameter estimation module based on Transformer in an example of the present invention.
[0016] Figure 3 This is a schematic diagram of a dual-branch fusion module in an example of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention 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 invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0018] The present invention will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0019] like Figure 1 As shown, an image exposure correction method based on Transformer and dual-branch fusion network includes steps S1 to S6:
[0020] S1, obtain the image illumination map and adaptive segmentation threshold to generate a binary partition mask;
[0021] S2. Construct a Transformer-based gamma correction parameter estimation network;
[0022] S3, obtaining dual gamma correction parameters;
[0023] S4, applying the estimated parameters to the original image for exposure adjustment;
[0024] S5, build a dual-branch fusion network;
[0025] S6. Send the original image and the exposure-corrected image into a dual-branch fusion network for feature fusion to obtain the final enhanced image.
[0026] Each step is described in detail below.
[0027] In step S1, the steps of obtaining the image illumination map and the adaptive segmentation threshold to generate a binary partition mask are specifically as follows:
[0028] S101, calculating the inverse of the image grayscale map as the illumination map, the illumination map is calculated as follows:
[0029] E(i,j)=1-(0.299·I(i,j,R)+0.587·I(i,j,G)+0.114·I(i,j,B)) (1)
[0030] Where I∈R H×W×3 is the input image, E∈R H×W is the illumination map, (i, j, k) represents the pixel value of the input image at the position (i, j) of the k channel, k∈{R,G,B}.
[0031] S102. Determine a unique threshold h for each image based on the obtained illumination map E and histogram. By calculating the image histogram, sort all pixels in the image by intensity. Divide all pixels into two sets, with the first 30% of pixels with high intensity as set A and the remaining 70% of pixels as set B. The threshold h is determined based on the intersection of the two sets.
[0032] S103, obtain a binary partition mask according to the adaptive threshold h. Set the first 30% of the pixel values with high intensity, that is, the pixel values of set A, to 0, and the pixel values of set B to 1. The binary partition mask formula obtained according to the above method is as follows:
[0033]
[0034] Among them, E∈R H×W is the illumination map, M∈R H×W is a binary partition mask, (i, j) represents the index of each pixel, and h is the adaptive threshold.
[0035] In step S2, a Transformer-based gamma correction parameter estimation network is constructed. The specific steps are:
[0036] S201, such as Figure 2 As shown in Figure 1, the Transformer-based gamma correction parameter estimation network is divided into three parts: introduction of illumination guidance, Transformer module, and parameter update.
[0037] S202: The illumination map obtained in S1 is used as a guide image and connected to the input image through a channel so as to guide the training of the network and pay different attention to different brightness areas in the image, so as to make the image exposure recovery more consistent as a whole.
[0038] S203, the design of the Transformer module consists of three parts: encoder, Transformer self-attention mechanism and feedforward neural network layer. The encoder extracts low-scale global features, and the features are generated through the fully connected layer to generate V, K; Q in the Transformer encoder is the initialized gamma correction model parameter. Q, K and V are calculated and sent to the feedforward neural network layer. The calculation formula is as follows:
[0039]
[0040] Among them, the inner product of each row vector of Q and K is calculated and then divided by d k The square root of is used to calculate the attention score of each position element of the input vector, normalize it through the softmax function, and finally multiply it with V to get the output.
[0041] In step S3, dual gamma correction parameters are obtained. The specific steps are:
[0042] S301, Q are the three parameters of the initial gamma correction model: c, γ L and γ H ,Before training the network, the parameters are initialized to 1, and the parameters are ,updated iteratively during the training process.
[0043] S302, training the gamma correction parameter estimation network of Transformer, the input of the network is the poorly exposed image, and the output is the dual gamma correction parameters. Through multiple iterative training, the network parameters and dual gamma correction model parameters are updated.
[0044] In step S4, the estimated gamma correction parameters are applied to the original image for exposure adjustment. The specific steps are:
[0045] S401. Gamma correction is a traditional nonlinear image enhancement technology, which is usually used to adjust the brightness and contrast of an image. Its formula is as follows:
[0046] H(i,j,k)=c·I(i,j,k) γ ,k∈{R,G,B} (4)
[0047] Where I represents the input image, E∈R H×W×3 represents the image after gamma correction, I(i,j,k) represents the pixel value of the input image at (i,j,k), c is the gain coefficient, and γ is the gamma correction parameter.
[0048] Two different gamma values obtained in S402 and S3: γ L and γ H , will be used to correct the exposure of different regions of the image to achieve partitioned exposure correction. Specifically, when the partition mask M(i,j) is 1, we use γ H , when M(i,j) is 0, we use γ L Finally, all pixels of the image are multiplied by the gain coefficient c to obtain the final exposure-corrected image. The formula is as follows:
[0049]
[0050] Where I represents the input image, H represents the gamma-corrected image, I(i,j,k) represents the pixel value of the image at (i,j,k), c is the gain coefficient, γ L and γ H are the gamma correction model parameters applied to different regions, and the values in M(i,j) represent underexposed and overexposed regions.
[0051] In step S5, a dual-branch fusion network is constructed to better fuse the input image and the exposure-corrected image features, thereby enhancing the image detail information. Figure 3 As shown in the figure, the dual-branch fusion network consists of three main parts: encoder, decoder and attention module. The specific steps are:
[0052] S501, two encoder structures extract features from the original image and the exposure-corrected image respectively. In the encoder design, four downsampling blocks are used to extract image features from multiple scales. The downsampling block consists of a 3×3 convolution, a LeakyReLU activation function, and a maximum pooling operation. It is used to obtain feature information of different scales of the two images.
[0053] S502, the upsampling block in the decoder consists of a channel attention layer, a 3×3 convolution, and a 2×2 deconvolution, which is used to integrate features and restore the image to its original scale.
[0054] S503. In order to better integrate the image feature information, a jump connection is added between the encoder and the decoder. An attention module is added before the jump connection. The attention module scales the illumination map through the maximum pooling operation, and then multiplies the pixels with the original image feature map passed through encoder 1 to obtain weighted features. The weighted features are channel-connected with the features in encoder 2, and then the acquired features are integrated with the same-scale features of the decoder in the form of a jump connection.
[0055] S6, sending the original image and the exposure-corrected image to a dual-branch fusion network for feature fusion to obtain the final enhanced image. The specific steps are:
[0056] S601. In order to better integrate the characteristics of the original image and the image after exposure correction, the original image and the image after exposure correction are used as inputs of a dual-branch fusion network.
[0057] S602: The two images are respectively passed through encoder 1 and encoder 2, and four downsampling operations are performed respectively to obtain feature maps of multiple scales.
[0058] S603: Connect the feature maps of each scale to the feature maps of each scale in the decoder through attention blocks and skip connections, and then restore them to the original image size through upsampling operations.
[0059] S604, calculate the loss of the entire network, the loss function consists of four parts: reconstruction loss, structural similarity loss, VGG loss, and color loss. Its expression is as follows:
[0060] L=L rec +λ 1 L SSIM +λ 2L VGG +λ 3 L col (6)
[0061] Where L rec is the reconstruction loss, L SSIM is the structural similarity loss, L VGG is the perceptual loss, L col is the color loss, λ 1 , 2 and λ 3 is the loss term coefficient. 1 , 2 and λ 3 To balance the hyperparameters of these losses, they are set to 0.2, 0.1, and 0.8 respectively in our method.
[0062] Among them, the reconstruction loss is defined as follows:
[0063]
[0064] Among them, I is the predicted image, I′ is the reference image, I(i,j) is the pixel value of the predicted image at (i,j), and N is the number of pixels.
[0065] The structural similarity loss is defined as follows:
[0066] L SSIM =1-SSIM(I′,I) (8)
[0067] The perceptual loss is defined as follows:
[0068]
[0069] Among them, W, H, C represent the three dimensions of the image: width, height and channel; F VGG Represents the feature map extracted by VGG-16. Here we use the mean square error to calculate the error between the predicted image and the reference image.
[0070] Color loss is defined as follows:
[0071]
[0072] Among them, ∠(·,·) calculates the color angle between the reference image and the predicted image as a 3D vector.
[0073] S605: According to the model weight with the minimum loss during training, the image processed by the network is used as the final enhancement result.
[0074] In view of the limitations of previous image enhancement methods in simultaneously processing underexposed and overexposed images, the present invention proposes an image exposure correction method based on Transformer and dual-branch fusion network. The image is first adaptively partitioned, and then the corresponding exposure correction and enhancement operations are completed. The invention makes good use of the global characteristics of Transformer to estimate the exposure correction parameters. The dual-branch fusion module plays an important role in solving the problem of loss of details and textures caused by uneven exposure, and greatly improves the image quality. It provides a more efficient framework for exposure correction, image enhancement and other tasks in practical applications.
[0075] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. An image exposure correction method based on Transformer and dual-branch fusion network, characterized in that: The method is executed by a computer and comprises the following steps: S1. Obtain image illumination map and adaptive segmentation threshold to generate binary partition mask. S2. Construct a Transformer-based gamma correction parameter estimation network. S3. Obtain dual gamma correction parameters. S4. Apply the estimated parameters to the original image for exposure adjustment. S5. Build a dual-branch fusion network. S6. Send the original image and the exposure-corrected image into a dual-branch fusion network for feature fusion to obtain the final enhanced image.
2. In the image exposure correction method based on Transformer and dual-branch fusion network as described in claim 1, the specific implementation process of S1 is as follows. S101, calculating the inverse of the image grayscale map as the illumination map, the illumination map is calculated as follows: E(i,j)=1-(0.299·I(i,j,R)+0.587·I(i,j,G)+0.114·I(i,j,B)) (1) in, I∈R H×W×3 is the input image, E∈R H×W is the illumination map, (i, j, k) represents the pixel value of the input image at the position (i, j) of the k channel, k∈{R,G,B}. S102. Determine a unique threshold h for each image based on the obtained illumination map E and histogram. By calculating the image histogram, sort all pixels in the image by intensity. Divide all pixels into two sets, with the first 30% of pixels with high intensity as set A and the remaining 70% of pixels as set B. The threshold h is determined based on the intersection of the two sets. S103, obtain a binary partition mask according to the adaptive threshold h. Set the first 30% of the pixel values with high intensity, that is, the pixel values of set A, to 0, and the pixel values of set B to 1. The binary partition mask formula obtained according to the above method is as follows: Among them, E∈R H×W is the illumination map, M∈R H×W is a binary partition mask, (i, j) represents the index of each pixel, and h is the adaptive threshold.
3. The image exposure correction method based on Transformer and dual-branch fusion network according to claim 1, characterized in that: In step S2, a Transformer-based gamma correction parameter estimation network is constructed. The specific steps are: S201. The Transformer-based gamma correction parameter estimation network is divided into three parts: introduction of illumination guidance, Transformer module, and parameter update. S202: The illumination map obtained in S1 is used as a guide image and connected to the input image through a channel so as to guide the training of the network and pay different attention to different brightness areas in the image, so as to make the image exposure recovery more consistent as a whole. S203, the design of the Transformer module consists of three parts: encoder, Transformer self-attention mechanism and feedforward neural network layer. The encoder extracts low-scale global features, and the features are generated through the fully connected layer to generate V, K; Q in the Transformer encoder is the initialized gamma correction model parameter. Q, K and V are calculated and sent to the feedforward neural network layer. The calculation formula is as follows: Among them, the inner product of each row vector of Q and K is calculated and then divided by d k The square root of is used to calculate the attention score of each position element of the input vector, normalize it through the softmax function, and finally multiply it with V to get the output.
4. The image exposure correction method based on Transformer and dual-branch fusion network according to claim 1, characterized in that: In step S3, dual gamma correction parameters are obtained. The specific steps are: S301, Q are the three parameters of the initial gamma correction model: c, γ L and γ H ,Before training the network, the parameters are initialized to 1, and the parameters are ,updated iteratively during the training process. S302, training the gamma correction parameter estimation network of Transformer, the input of the network is the poorly exposed image, and the output is the dual gamma correction parameters. Through multiple iterative training, the network parameters and dual gamma correction model parameters are updated.
5. The image exposure correction method based on Transformer and dual-branch fusion network according to claim 1, characterized in that: In step S4, the estimated gamma correction parameters are applied to the original image for exposure adjustment. The specific steps are: S401. Gamma correction is a traditional nonlinear image enhancement technology, which is usually used to adjust the brightness and contrast of an image. Its formula is as follows: H(i,j,k)=c·I(i,j,k) γ ,k∈{R,G,B} (4) Where I represents the input image, E∈R H×W×3 represents the image after gamma correction, I(i,j,k) represents the pixel value of the input image at (i,j,k), c is the gain coefficient, and γ is the gamma correction parameter. Two different gamma values obtained in S402 and S3: γ L and γ H , will be used to correct the exposure of different regions of the image and achieve partitioned exposure correction. Specifically, when the partition mask M(i,j) is 1, we use γ H , when M(i,j) is 0, we use γ L Finally, all pixels of the image are multiplied by the gain coefficient c to obtain the final exposure-corrected image. The formula is as follows: Where I represents the input image, H represents the gamma-corrected image, I(i,j,k) represents the pixel value of the image at (i,j,k), c is the gain coefficient, γ L and γ H are the gamma correction model parameters applied to different regions, and the values in M(i,j) represent underexposed and overexposed regions.
6. The image exposure correction method based on Transformer and dual-branch fusion network according to claim 1, characterized in that: In step S5, a dual-branch fusion network is constructed to better fuse the input image and the exposure-corrected image features, thereby enhancing the image detail information. The dual-branch fusion network consists of three main parts: encoder, decoder, and attention module. The specific steps are: S501, two encoder structures extract features from the original image and the exposure-corrected image respectively. In the encoder design, four downsampling blocks are used to extract image features from multiple scales. The downsampling block consists of a 3×3 convolution, a LeakyReLU activation function, and a maximum pooling operation to obtain feature information of different scales of the two images. S502, the upsampling block in the decoder consists of a channel attention layer, a 3×3 convolution, and a 2×2 deconvolution, which is used to integrate features and restore the original scale of the image. S503. In order to better integrate the image feature information, a jump connection is added between the encoder and the decoder. An attention module is added before the jump connection. The attention module scales the illumination map through the maximum pooling operation, and then multiplies the pixels with the original image feature map passed through encoder 1 to obtain weighted features. The weighted features are channel-connected with the features in encoder 2, and then the acquired features are integrated with the same-scale features of the decoder in the form of a jump connection.
7. The image exposure correction method based on Transformer and dual-branch fusion network according to claim 1, characterized in that: In step S6, the original image and the exposure-corrected image are sent to a dual-branch fusion network for feature fusion to obtain the final enhanced image. The specific steps are as follows: S601. In order to better integrate the characteristics of the original image and the image after exposure correction, the original image and the image after exposure correction are used as inputs of a dual-branch fusion network. S602: The two images are respectively passed through encoder 1 and encoder 2, and four downsampling operations are performed respectively to obtain feature maps of multiple scales. S603: connect the feature maps of each scale to the feature maps of each scale in the decoder through attention blocks and skip connections, and then restore to the original image size through upsampling operations. S604, calculate the loss of the entire network, the loss function consists of four parts: reconstruction loss, structural similarity loss, VGG loss, and color loss. Its expression is as follows: L=L rec +λ1L SSIM +λ2L VGG +λ3L col (6) Where L rec is the reconstruction loss, L SSIM is the structural similarity loss, L VGG is the perceptual loss, L col is the color loss, λ1, λ2, and λ3 are the loss term coefficients. λ1, λ2, and λ3 are hyperparameters used to balance these losses, which are set to 0.2, 0.1, and 0.8 respectively in our method. Among them, the reconstruction loss is defined as follows: Among them, I is the predicted image, I′ is the reference image, I(i,j) is the pixel value of the predicted image at (i,j), and N is the number of pixels. The structural similarity loss is defined as follows: L SSIM =1-SSIM(I′,I) (8) The perceptual loss is defined as follows: Among them, W, H, C represent the three dimensions of the image: width, height and channel; F VGG Represents the feature map extracted by VGG-16. Here we use the mean square error to calculate the error between the predicted image and the reference image. Color loss is defined as follows: Among them, ∠(·,·) calculates the color angle between the reference image and the predicted image as a 3D vector. S605: According to the model weight with the minimum loss during training, the image processed by the network is used as the final enhancement result.
Citation Information
Cited By
Extreme overexposure image restoration method, system, medium, program product and equipment
CN119784647A
Extreme overexposure image repair method, system, medium, program product, and device
CN119784647B
