Image defogging method and device based on physical model and feature dense association
By adopting a method based on dense correlation between physical models and features in image defogging, we build global feature correlation and restore shallow features, which solves the problem of poor dehazing effect in complex scenes in the existing technology and achieves image texture details and color. true restoration.
Patent Information
- Application Number
- CN202210543770.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-05-19
AI Technical Summary
Existing image dehazing methods based on deep learning are difficult to effectively utilize long-distance similar features in complex scenes, resulting in poor dehazing effects. Shallow features are difficult to fully retain under the influence of fog, affecting the texture details and true colors of the image. sex.
Using a method based on dense correlation between physical models and features, the features of foggy images are extracted through the encoder and divided into shallow and deep features. Multi-head attention is used to build global feature correlations, and the shallow features are restored based on the atmospheric scattering model, and the input is input after fusion. decoder to generate clear images and optimize the network through contrastive learning and Focal Frequency Loss.
It significantly improves the dehazing effect in complex scenes, truly restores the texture details and colors of the image, and improves the authenticity and robustness of the dehazed image.
Smart Images

Figure CN114897732B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision, and in particular relates to an image defogging method and device based on a physical model and dense feature association. Background Art
[0002] Fog is a typical atmospheric phenomenon. Affected by suspended particles in the air, fog can cause color distortion, blur and low contrast in captured images, which has an adverse effect on subsequent visual tasks such as object recognition and semantic segmentation. Therefore, image defogging is of great significance. The purpose of image defogging is to restore degraded images affected by fog to clear images. Early defogging methods relied on artificial assumptions and used mathematical statistics and other methods to find the laws of transmission maps, atmospheric light and image degradation. However, artificial assumptions do not always hold true in real foggy scenes, which makes such methods prone to image distortion. With the development of deep learning, many methods have begun to use convolutional neural networks to predict transmission maps, atmospheric light or clear images. Such methods can break the limitations of assumptions and achieve better defogging effects. However, existing learning-based methods still have shortcomings: (1) For low-level visual tasks, similar features are important. Although there is high-value long-distance similar feature information, convolution operations with fixed receptive fields cannot capture this information, making it difficult for the network to fully utilize this information to process severely degraded areas, thereby limiting the defogging performance in complex scenes. (2) Shallow features can preserve the texture details of the image. Currently, many methods use long-distance skip connections to preserve texture details, but due to the influence of fog, this information is degraded and difficult to preserve completely. In response to the above problems, the present invention focuses on constructing a dense correlation between different local features in the feature space, so that similar features over long distances can fully learn from each other. At the same time, the present invention proposes a shallow feature mapping module to restore the shallow feature information that has been degraded due to the influence of fog, thereby constructing a real and clear fog-free image. In addition, the present invention uses contrastive learning to optimize the proposed network, so that the network can fully learn the difference between foggy images and fog-free images. At the same time, Focal Frequency Loss is introduced to constrain the network, so that the network can have a more accurate expression in color. Summary of the invention
[0003] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art and to provide a single image defogging method and device based on a physical model and dense feature association, thereby improving the defogging performance in complex scenes, especially in non-uniform fog scenes, while being able to truly restore the color and texture details of the image and improve the authenticity of the defogged image.
[0004] In order to achieve the above object, the present invention adopts the following technical solutions:
[0005] On one hand, the present invention provides a single image defogging method based on a physical model and dense association of features, comprising the following steps:
[0006] A pre-established encoder is used to extract the features of the foggy image, and the encoder output features are divided into shallow features and deep features according to the number of network layers in the encoder;
[0007] Process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the extracted feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, and use the feedforward network to process the output sequence of multi-head attention to strengthen the information exchange within the elements themselves, and obtain enhanced deep features;
[0008] The joint parameters of the shallow features output by the encoder are calculated through the adjacent small-scale feature maps. The shallow feature mapping is realized based on the joint parameters and the pre-established atmospheric scattering model to obtain clear shallow texture features.
[0009] The enhanced deep features are fused with the shallow texture features, and the fused features are input into a pre-established decoder to obtain a clear image after dehazing.
[0010] As a preferred technical solution, the encoder is designed based on ResBlock and downsampling; the decoder is designed based on ResBlock and upsampling.
[0011] As a preferred technical solution, the feature map extracted by convolution is processed into a feature sequence, specifically:
[0012] A 3×3 sliding window is used to capture local features in the global range of the feature map obtained by convolution, and the features in the sliding window are expanded into a 1×9 scalar as the elements of the sequence, so that different elements of the sequence represent different local features.
[0013] As a preferred technical solution, the multi-head attention is composed of self-attention with a global receptive field, which is used to establish a dense relationship between global feature information, thereby making up for the limitations of the fixed receptive field of convolution. In the multi-head attention, one self-attention constitutes the calculation of one head, which is the key operator for multi-head attention to construct global feature associations. At the same time, different heads learn support between different local features in different global ranges, making the network more expressive. The self-attention mechanism is defined as follows:
[0014]
[0015] Among them, E represents the input vector of self-attention, Qu, Ke, and Va represent the linear operations for generating query value Query, key value Key, and value Value respectively, and d k Represents the dimension of the key value, and self-attention is passed through Qu(E)Ke(E) T The query value and the key value are matrix multiplied to build a dense association relationship between each element in the sequence E, so that the elements can influence each other. Va(E) represents the mapping of each element itself, so that it can be enhanced even when it cannot be associated with other elements.
[0016] As a preferred technical solution, the joint parameter is calculated in the following way:
[0017]
[0018] in, d It represents the feature map output by the encoder, f e It represents the decoder output and f d For feature maps of the same scale, convolution and Sigmoid are used to approximate the joint parameter K. The result is to prevent gradient explosion.
[0019] As a preferred technical solution, the atmospheric scattering model is defined as follows:
[0020] I(x)=J(x)T(x)+A(1-T(x))
[0021] Among them, I and J represent foggy images and fog-free images, T and A represent transmission maps and global atmospheric light respectively, and x represents pixels. The constructed physical model uses the joint parameters of atmospheric light and transmission maps. The model based on the joint parameters of atmospheric light and transmission maps is expressed as:
[0022] J(x)=J(x)K(x)-K(x)+b
[0023] Where K represents the joint parameter of atmospheric light and transmission diagram, and b is the constant deviation which can be set as a constant.
[0024] As a preferred technical solution, the following steps are also included: using contrastive learning method to optimize the network, and introducing Focal Frequency Loss to optimize and improve the defogging performance, specifically:
[0025] Use pre-trained VGG to construct the contrast loss function, which is:
[0026]
[0027] Among them, V represents the VGG feature extractor, i represents the number of network layers used for feature extraction, and I haze It represents the foggy image, I gt represents a clear image, F represents the dehazing network, and the contrast loss function measures the distance between the output image and the positive sample and the negative sample. The standard clear image is set as the positive sample and the input foggy image is set as the negative sample. The contrast loss can make the output image close to the positive sample and away from the negative sample. The addition of negative samples provides a new reference for the network and improves the model performance.
[0028] Focal Frequency Loss constrains the network from the perspective of the frequency domain of the image, so that the generated image is fidelity in frequency, and at the same time enables the network to pay more attention to the severely degraded areas, so as to accurately restore the texture and color of the degraded areas. Discrete Fourier transform is used to transform the image from the spatial domain to the frequency domain, and then the real part and the imaginary part are separated using the Euler formula, and then the loss is calculated. Focal Frequency Loss is:
[0029]
[0030] Among them, Cat represents the connection between the real and imaginary parts of the image, and ρ represents the dynamic weight:
[0031]
[0032] c and d represent the length and width of the image, respectively. ρ enables the network to dynamically adjust weights according to different degrees of degradation, thereby improving the performance of the network in severely degraded areas.
[0033] On the other hand, the present invention provides a single image defogging system based on physical model and feature dense association, which is applied to the single image defogging method based on physical model and feature dense association, and includes an encoding module, a feature dense association module, a shallow feature mapping module and a decoding module;
[0034] The encoding module is used to extract features of the foggy image using a pre-established encoder, and divide the encoder output features into shallow features and deep features according to the number of network layers in the encoder;
[0035] The feature dense association module is used to process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the extracted feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, use a feedforward network to process the output sequence of the multi-head attention, strengthen the information exchange within the elements themselves, and obtain enhanced deep features;
[0036] The shallow feature mapping module is used to calculate joint parameters of the shallow features output by the encoder through adjacent small-scale feature maps, and implement shallow feature mapping based on the joint parameters and a pre-established atmospheric scattering model to obtain clear shallow texture features;
[0037] The decoding module is used to fuse the enhanced deep features with the shallow texture features, and input the fused features into a pre-established decoder to obtain a clear image after defogging.
[0038] Another aspect of the present invention provides an electronic device, the electronic device comprising:
[0039] at least one processor; and,
[0040] a memory communicatively connected to the at least one processor; wherein,
[0041] The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to perform the single image dehazing method based on dense association of physical model and features.
[0042] On the other hand, the present invention provides a computer-readable storage medium storing a program, which, when executed by a processor, implements the single image defogging method based on the physical model and dense association of features.
[0043] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0044] 1. The present invention proposes an end-to-end defogging network based on physical model and dense feature association. The network is based on the proposed feature dense association module, which enables the proposed network to have a global receptive field, establish a dense association relationship between different local features, and enable local features to learn from each other. Compared with the current single image defogging method, it can better cope with the situation of uneven fog.
[0045] 2. The network proposed in the present invention is based on the proposed shallow feature mapping module. This module can obtain the parameters of the atmospheric scattering model and apply it to the mapping of shallow features, thereby restoring the information in the shallow features that is degraded by fog, so that the generated clear image has better performance in texture details.
[0046] 3. The present invention uses contrastive learning optimization to optimize the proposed defogging network, so that the network can learn the difference between foggy images and non-fog images, thereby making the model more robust. The present invention also uses the FocalFrequency Loss function to constrain the network, so that the network can maintain accuracy in color, thereby improving the authenticity of the generated image. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0048] Figure 1 is a flow chart of an image defogging method based on a physical model and dense feature association according to an embodiment of the present invention;
[0049] Figure 2 is a network diagram based on a physical model and densely associated features according to an embodiment of the present invention;
[0050] Figure 3 Schematic diagram of contrastive learning and Focal Frequency Loss in an embodiment of the present invention;
[0051] Figure 4 is a schematic diagram of a feature dense association module in an embodiment of the present invention;
[0052] Figure 5 This is a comparison chart of the defogging effects of the present invention and several advanced defogging algorithms;
[0053] Figure 6 4 is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0055] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0056] See also Figure 1 The single image defogging method based on the physical model and dense feature association in this embodiment includes the following steps:
[0057] S1. Design an encoder based on ResBlock and downsampling to extract the features of foggy images, and divide the encoder output features into shallow features and deep features according to the number of network layers in the encoder;
[0058] S2. Process the deep features output by the encoder and construct dense correlation relationships in the global scope in the deep features so that different local information can support each other, thereby enhancing local features using global information.
[0059] Furthermore, step S2 is specifically as follows:
[0060] S21, use convolution to enhance local features and extract feature maps;
[0061] S22. Subsequently, the feature map is processed into a feature sequence: a 3×3 sliding window is used to capture local features in the global range of the feature map, and the features in the window are expanded into a 1×9 scalar as an element of the sequence, so that different elements of the sequence represent different local features.
[0062] S23. Use multi-head attention to build the connection between each element and all elements in the sequence, so as to achieve the construction of dense relationship between local features in the global scope.
[0063] Furthermore, in this embodiment, the multi-head attention is composed of self-attention with a global receptive field, which can establish a dense relationship between global feature information, thereby making up for the limitations of the fixed receptive field of convolution. In the multi-head attention, one self-attention constitutes the calculation of one head, which is the key operator for multi-head attention to build global feature associations. At the same time, different heads can learn the support between different local features in different global ranges, making the network more expressive.
[0064] The self-attention mechanism is defined as follows:
[0065]
[0066] Among them, E represents the input vector of self-attention, Qu, Ke, and Va represent the linear operations for generating query value Query, key value Key, and value Value respectively, and d k Represents the dimension of the key value, and self-attention is passed through Qu(E)Ke(E) T The query value and the key value are matrix multiplied to build a dense association relationship between each element in the sequence E, so that the elements can influence each other. Va(E) represents the mapping of each element itself, so that it can be enhanced even when it cannot be associated with other elements.
[0067] In one embodiment of the present application, 8 feature dense association modules are used in the proposed dehazing network. According to the feature pyramid principle, the number of multi-head attention heads of each module is set to: [1, 2, 8, 16, 16, 8, 2, 1].
[0068] S24. Use a feedforward network to process the output sequence of multi-head attention to strengthen the information exchange within the elements themselves and restore them to feature maps.
[0069] S3. The joint parameters of the shallow features output by the encoder are calculated through the adjacent small-scale feature maps, and the shallow feature mapping is realized based on the joint parameters and the pre-established atmospheric scattering model to obtain clear shallow texture features.
[0070] Furthermore, the shallow feature mapping uses a physical model for feature mapping; the atmospheric scattering model is defined as follows:
[0071] I(x)=J(x)T(x)+A(1-T(x)) (2)
[0072] Among them, I and J represent foggy images and fog-free images, T and A represent transmission maps and global atmospheric light respectively, and x represents pixels. The constructed physical model uses the joint parameters of atmospheric light and transmission maps. Formula (2) can be expressed as:
[0073] J(x)=J(x)K(x)-K(x)+b (3)
[0074] Where K represents the joint parameter of atmospheric light and transmission map. b is a constant deviation that can be set to a constant. The shallow feature mapping module first learns the joint parameter k in the feature space, and then obtains the output containing shallow features based on the parameter and formula (3), and uses it in the decoding part of the dehazing model to restore the image texture details. First, the value of the joint parameter K is obtained on the smaller scale feature, and then it is applied to the mapping of the larger scale feature. According to formula (3), it is obtained:
[0075]
[0076] Among them, for each shallow feature association module, f d It represents the feature map of the next scale adjacent to the module output by the encoding module, f e It represents the decoder output and f d Feature maps of the same scale. In the process of obtaining the joint parameter K, convolution and Sigmoid are used to approximate The result is to prevent gradient explosion. After obtaining K, K is upsampled, and then, according to formula (2), K is applied to the mapping of shallow features of the same scale features of the module.
[0077] S4. Fuse the enhanced deep features with the mapped shallow features, and input the fused features into a decoder module based on ResBlock and upsampling to obtain a clear image after defogging; it can be understood that the feature fusion of this application adopts a conventional fusion method.
[0078] S5. Use contrastive learning and Focal Frequency Loss loss function to optimize the defogging network proposed in step S1 to step S4. The contrastive learning method uses foggy images as negative samples for training and clear images as positive samples for training, so that the network can learn the difference between foggy images and non-fog images; at the same time, Focal Frequency Loss enables the network to have accurate color representation, thereby obtaining the optimal network parameters and achieving a robust defogging effect.
[0079] This embodiment uses pre-trained VGG to construct a contrast loss function, which is:
[0080]
[0081] Among them, V represents the VGG feature extractor, i represents the number of network layers used for feature extraction, and I haze It represents the foggy image, I gt represents a clear image. F represents the dehazing network. The contrast loss function measures the distance between the output image and the positive and negative samples; the standard clear image is set as the positive sample and the input foggy image is set as the negative sample. The contrast loss can make the output image close to the positive sample and away from the negative sample. The addition of negative samples provides a new reference for the network and improves the model performance.
[0082] Focal Frequency Loss constrains the network from the perspective of the frequency domain of the image, so that the generated image is fidelity in frequency, and at the same time enables the network to pay more attention to the severely degraded areas, so that the texture and color of the degraded areas can be accurately restored. Discrete Fourier transform is used to transform the image from the spatial domain to the frequency domain, and then the real part and the imaginary part are separated using the Euler formula, and then the loss is calculated. Focal Frequency Loss is:
[0083]
[0084] Among them, Cat represents the connection between the real part and the imaginary part of the image. ρ represents the dynamic weight:
[0085]
[0086] c and d represent the length and width of the image, respectively. ρ enables the network to dynamically adjust weights according to different degrees of degradation, thereby improving the performance of the network in severely degraded areas.
[0087] It should be noted that, for the sake of convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.
[0088] Based on the same idea as the single image defogging method based on the physical model and dense association of features in the above-mentioned embodiment, the present invention also provides a single image defogging system based on the physical model and dense association of features, which can be used to execute the above-mentioned single image defogging method based on the physical model and dense association of features. For ease of explanation, the structural schematic diagram of the embodiment of the single image defogging system based on the physical model and dense association of features only shows the parts related to the embodiment of the present invention. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.
[0089] See also Figure 2 In another embodiment of the present application, a single image defogging system based on a physical model and dense feature association is provided, the system includes an encoding module, a dense feature association module, a shallow feature mapping module and a decoding module; the deep features of the foggy image obtained by the encoder are used to construct dense connections within the feature space through the dense feature association module, so that it can be locally enhanced according to global information; at the same time, the shallow features output by the encoder are passed through the shallow feature mapping module to obtain clear texture features. Finally, the decoder fuses the enhanced deep features and the mapped shallow features, and then constructs a clear image.
[0090] The encoding module is used to extract features of the foggy image using a pre-established encoder, and divide the encoder output features into shallow features and deep features according to the number of network layers in the encoder;
[0091] The feature dense association module is used to process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the extracted feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, use a feedforward network to process the output sequence of the multi-head attention, strengthen the information exchange within the elements themselves, and obtain enhanced deep features;
[0092] The shallow feature mapping module is used to calculate joint parameters of the shallow features output by the encoder through adjacent small-scale feature maps, and implement shallow feature mapping based on the joint parameters and a pre-established atmospheric scattering model to obtain clear shallow texture features;
[0093] The decoding module is used to fuse the enhanced deep features with the shallow texture features, and input the fused features into a pre-established decoder to obtain a clear image after defogging.
[0094] It should be noted that the single image defogging system based on physical model and dense association of features of the present invention corresponds one to one with the single image defogging method based on physical model and dense association of features of the present invention. The technical features and beneficial effects described in the above-mentioned embodiment of the single image defogging method based on physical model and dense association of features are applicable to the embodiment of the single image defogging based on physical model and dense association of features. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here. This is hereby declared.
[0095] In addition, in the implementation of the single image dehazing system based on the physical model and densely associated features in the above-mentioned embodiment, the logical division of each program module is only an example. In actual applications, the above functions can be assigned to different program modules as needed, for example, for the convenience of corresponding hardware configuration requirements or software implementation. That is, the internal structure of the single image dehazing system based on the physical model and densely associated features is divided into different program modules to complete all or part of the functions described above.
[0096] Please refer again Figure 2 The single image defogging system based on the physical model and dense feature association in this application is specifically:
[0097] Figure 2In the encoding module, the leftmost block represents a convolution with a kernel of 7 and a stride of 1; in the other two groups of blocks of the same size, the left block represents ResBlock and the right block represents downsampling;
[0098] Figure 2 In the decoding module, in the two rightmost blocks of the same size, the first block represents deconvolution, and the last block represents convolution with a kernel of 7 and a stride of 1; in the remaining two groups of blocks of the same size, the left block represents deconvolution, and the right block represents ResBlock;
[0099] Figure 2 In , each shallow feature mapping module includes all the solid and dotted parts connected to the “shallow feature mapping module”;
[0100] Figure 3 It shows the principle of Focal Frequency Loss and contrastive learning in the present invention.
[0101] Figure 3 The dotted box in the lower left corner represents contrastive learning, and the dotted box in the lower right corner represents the principle of FocalFrequency Loss;
[0102] In addition to Focal Frequency Loss and Contrast Loss, the present invention also uses L1 loss and perceptual loss as basic loss functions;
[0103] Figure 3 The “defogging network” in Figure 2 Network in
[0104] The present invention uses the following weights for training: L1 loss weight is 1, perceptual loss weight is 0.03, contrast loss weight is 0.03, and Focal Frequency Loss weight is 0.01;
[0105] The present invention trains 200 epochs on RTX3090, and sets the initial step size to 0.0001. The present invention uses a 240×240 window to randomly cut the image, and randomly rotates the cut image, and uses the obtained image as the input for training.
[0106] Figure 4 It is a schematic diagram of the structure of the feature dense association module in the present invention.
[0107] Figure 4 The “□” in the figure indicates that the elements are accumulated pixel by pixel;
[0108] Figure 4 The squares in the figure represent convolutions;
[0109] Figure 4 The h in it represents the number of heads of multi-head attention;
[0110] Figure 4 The self-attention in is defined as follows:
[0111]
[0112] Where E represents the input vector of self-attention. Qu, Ke, and Va represent the linear operations for generating query value Query, key value Key, and value Value respectively. k Represents the dimension of the key value.
[0113] Figure 5 The results of subjective analysis of the method of the present invention are shown.
[0114] Figure 5 As shown, the method of the invention can better cope with foggy scenes under complex conditions, fully remove fog while avoiding the generation of artifacts, and better restore the texture details of the image.
[0115] The objective evaluation results of the method are shown in Table 1. The present invention uses peak signal-to-noise ratio (PSNR) and structural similarity (SSIM) as evaluation indicators. The higher the value, the closer the generated image is to the standard clear image.
[0116] Table 1
[0117]
[0118] See also Figure 6 In one embodiment, an electronic device for implementing a single image defogging method based on a physical model and dense association of features is provided. The electronic device 100 may include a first processor 101, a first memory 102 and a bus, and may also include a computer program stored in the first memory 102 and executable on the first processor 101, such as a single image defogging program 103 based on a physical model and dense association of features.
[0119] Among them, the first memory 102 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the first memory 102 can be an internal storage unit of the electronic device 100, such as a mobile hard disk of the electronic device 100. In other embodiments, the first memory 102 can also be an external storage device of the electronic device 100, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 100. Further, the first memory 102 can also include both an internal storage unit of the electronic device 100 and an external storage device. The first memory 102 can not only be used to store application software and various types of data installed in the electronic device 100, such as the code of the single image defogging program 103 based on the physical model and the dense association of features, but also can be used to temporarily store data that has been output or is to be output.
[0120] In some embodiments, the first processor 101 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips, etc. The first processor 101 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes various functions and processes data of the electronic device 100 by running or executing programs or modules stored in the first memory 102, and calling data stored in the first memory 102.
[0121] Figure 6 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 6 The structure shown does not constitute a limitation on the electronic device 100 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0122] The single image defogging program 103 based on the physical model and dense feature association stored in the first memory 102 of the electronic device 100 is a combination of multiple instructions. When running in the first processor 101, it can achieve:
[0123] A pre-established encoder is used to extract the features of the foggy image, and the encoder output features are divided into shallow features and deep features according to the number of network layers in the encoder;
[0124] Process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the extracted feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, and use the feedforward network to process the output sequence of multi-head attention to strengthen the information exchange within the elements themselves, and obtain enhanced deep features;
[0125] The joint parameters of the shallow features output by the encoder are calculated through the adjacent small-scale feature maps. The shallow feature mapping is realized based on the joint parameters and the pre-established atmospheric scattering model to obtain clear shallow texture features.
[0126] The enhanced deep features are fused with the shallow texture features, and the fused features are input into a pre-established decoder to obtain a clear image after dehazing.
[0127] Furthermore, if the module / unit integrated in the electronic device 100 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0129] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0130] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. Single image dehazing method based on physical model and dense feature association, It is characterized in that The steps include: A pre-established encoder is used to extract the features of the foggy image, and the encoder output features are divided into shallow features and deep features according to the number of network layers in the encoder; Process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, and use the feedforward network to process the output sequence of multi-head attention to strengthen the information exchange within the elements themselves, and obtain enhanced deep features; The joint parameters of the shallow features output by the encoder are calculated through the adjacent small-scale feature maps. The shallow feature mapping is realized based on the joint parameters and the pre-established atmospheric scattering model to obtain clear shallow texture features. The enhanced deep features are fused with the shallow texture features, and the fused features are input into a pre-established decoder to obtain a clear image after dehazing.
2. According to the single image defogging method based on physical model and dense feature association according to claim 1, It is characterized in that The encoder is designed based on ResBlock and downsampling; the decoder is designed based on ResBlock and upsampling.
3. According to the single image defogging method based on physical model and dense feature association as claimed in claim 1, It is characterized in that The feature map obtained by the convolution is processed into a feature sequence, specifically: A 3×3 sliding window is used to capture local features in the global range of the feature map obtained by convolution, and the features in the sliding window are expanded into a 1×9 scalar as the elements of the sequence, so that different elements of the sequence represent different local features.
4. According to the single image defogging method based on physical model and dense feature association as claimed in claim 1, It is characterized in that The multi-head attention is composed of self-attention with a global receptive field, which is used to establish a dense relationship between global feature information, thereby making up for the limitations of the fixed receptive field of convolution. In the multi-head attention, one self-attention constitutes the calculation of one head, which is the key operator for multi-head attention to construct global feature associations. At the same time, different heads learn support between different local features in different global ranges, making the network more expressive. The self-attention mechanism is defined as follows: ; in, E represents the input vector of self-attention, They represent the linear operations for generating query value Query, key value Key, and value Value respectively. d k Represents the dimension of the key value, and self-attention is passed Perform matrix multiplication on the query value and the key value to construct a sequence E The dense associations between each element in the , make the elements affect each other, V ( E ) represents the mapping of each element itself, so that it can be enhanced even when it cannot be associated with other elements.
5. According to the single image defogging method based on physical model and dense feature association as claimed in claim 1, It is characterized in that The joint parameters are calculated as follows: ; in, f d It represents the feature map output by the encoder. f e It represents the decoder output and f d Feature maps of the same scale, when obtaining joint parameters K In the process, convolution and Sigmoid are used to approximate The result is to prevent gradient explosion.
6. Single image dehazing system based on physical model and dense feature association, It is characterized in that A single image dehazing method based on a physical model and dense feature association as described in any one of claims 1 to 5, comprising an encoding module, a dense feature association module, a shallow feature mapping module, and a decoding module; The encoding module is used to extract features of the foggy image using a pre-established encoder, and divide the encoder output features into shallow features and deep features according to the number of network layers in the encoder; The feature dense association module is used to process the deep features output by the encoder, use convolution to strengthen local features and extract feature maps, process the feature maps into feature sequences, use multi-head attention to build the connection between each element and all elements in the feature sequence, so as to achieve the construction of dense relations between local features in the global scope, use a feedforward network to process the output sequence of multi-head attention, strengthen the information exchange within the elements themselves, and obtain enhanced deep features; The shallow feature mapping module is used to calculate joint parameters of the shallow features output by the encoder through adjacent small-scale feature maps, and implement shallow feature mapping based on the joint parameters and a pre-established atmospheric scattering model to obtain clear shallow texture features; The decoding module is used to fuse the enhanced deep features with the shallow texture features, and input the fused features into a pre-established decoder to obtain a clear image after defogging.
7. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the single image dehazing method based on dense association of physical model and features as described in any one of claims 1-5.
8. A computer-readable storage medium storing a program, It is characterized in that When the program is executed by a processor, the single image defogging method based on the physical model and dense association of features as described in any one of claims 1 to 5 is implemented.
