# Dense-FG: A Fusion GAN Model by Using Densely Connected Blocks to Fuse Infrared and Visible Images
## 3 Proposed Method
### Loss Function Design  
The generator loss function comprises two components, adversarial loss and content; the expression is as follows:  
\[L_{\text{G}}=L_{\text{adv}}+\lambda L_{\text{con}}. \tag{1}\]  
The coefficient for the proportion of content loss is represented by \(\lambda\), and the expression for adversarial loss is:  
\[L_{\text{adv}}=\frac{1}{N}\sum_{n=1}^{N}\Big{(}D_{\theta_{\text{D}}}\Big{(}I_{ f}^{n}\Big{)}-c\Big{)}^{2}, \tag{2}\]  
where \(D_{\theta_{D}}\Big{(}I_{f}\Big{)}\) represents the discriminator's discrimination result on the fused image, \(N\) denotes the number of fused images, and \(c\) is a soft label. The content loss expression is as follows:  
\[L_{con}=\frac{1}{HW}(\beta_{1}\Big{\|}I_{f}-I_{p}\Big{\|}_{F}^{2}+\beta_{2} \Big{\|}\
abla I_{f}-\
abla I_{p}\Big{\|}_{F}^{2}+\beta_{3}\Big{\|}I_{f}-I_{p} \Big{\|}_{F}^{2}+\beta_{4}\Big{\|}\
abla I_{f}-\
abla I_{p}\Big{\|}_{F}^{2}). \tag{3}\]  
In the above formula, the fused image is denoted by \(I_{f}\), while \(I_{r}\) and \(I_{p}\) represent the visible and infrared images, respectively. H and W stand for the height and width of the image, and \(\beta_{1}\), \(\beta_{2}\), \(\beta_{3}\), and \(\beta_{4}\) represent the proportional coefficients of various losses. \(\
abla\) denotes the gradient operation of the image matrix. The gradient loss constrained fusion image contains rich texture details; \(\beta_{2}\) and \(\beta_{4}\) represent the weight coefficients of the visible gradient and infrared gradient loss items, respectively. The intensity loss constrained fusion image maintains an image distribution similar to the source image; \(\beta_{1}\) and \(\beta_{3}\) represent the infrared intensity and visible intensity loss items weight factor, respectively. For the fusion of infrared and visible images, it is expected that the fusion result retains the visible gradient information and infrared intensity information, while the infrared gradient information and visible intensity information are secondary, satisfying the following rules:  
\[\beta_{1}>\beta_{3},\beta_{2}>\beta_{4}. \tag{4}\]  
In the process of solving the gradient, a Laplacian filter template with diagonal terms is used, which is defined as follows:  
\[\text{filter}\;=\;\left[ \begin{array}{ccc}1&1&1\\ 1&-8&1\\ 1&1&1\end{array} \right]. \tag{5}\] \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**Name** & **Layer** & **K** & **S** & **Input** & **N1** & **Output** & **N2** & **Padding** & **Function** \\ \hline Input layer & Conv1 & 3*3 & 2 & VI/F & 1 & II & 32 & VALID & LReLU \\ \hline Conv layer & Conv2 & 3*3 & 2 & II & 32 & I2 & 64 & VALID & LReLU \\ \hline Dense layer & Dense1 & 3*3 & 2 & I3 & 64 & I4 & 128 & VALID & LReLU \\  & Dense2 & 3*3 & 1 & H4 & 128 & I5 & 128 & SAME & LReLU \\  & Dense3 & 3*3 & 1 & I4+I5 & 128 & I6 & 128 & SAME & LReLU \\  & Dense4 & 3*3 & 2 & I4+I5+I6 & 128 & I7 & 256 & VALID & LReLU \\ \hline Output layer & Line1 & / & / & I7 & 256 & Lable & 1 & / & Matmul \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Discriminator network architecture parameters. Linear spatial filtering of size \(m\times n\) (the moving step is 1, and the matrix is filled with 0 from top to bottom, left to right) is performed on the image; then:  
\[\left\{ \begin{array}{l}g(1,1)=f(1,2)+f(2,1)+f(2,2)-8f(1,1)\\ \cdots\\ g(1,n)=f(1,n-1)+f(2,n)+f(2,n-1)-8f(1,n)\\ \cdots\\ g(m,1)=f(m-1,1)+f(m,2)+f(m-1,2)-8f(m,1)\\ \cdots\\ g(m,n)=f(m-1,n)+f(m,n-1)+f(m-1,n-1)-8f(m,n)\end{array} \right.. \tag{6}\]  
The expression of the gradient matrix of the fused image is as follows:  
\[\
abla I_{f}=\left[ \begin{array}{cccc}g_{f}(1,1)&g_{f}(1,2)&\cdots&g_{f}(1,n )\\ g_{f}(2,1)&g_{f}(2,2)&\cdots&g_{f}(2,n)\\ \vdots&\vdots&&\vdots\\ g_{f}(m,1)&g_{f}(m,2)&\cdots&g_{f}(m,n)\end{array} \right].