# Panchromatic and Hyperspectral Image Fusion Using Ratio Residual Attention Networks
## 3 Methods
### Loss Function  
In network design, a critical step is to design an appropriate loss function. In this section, two types of loss functions are proposed: the spatial preservation loss function and the spectral preservation loss function. These loss functions aim to preserve spatial details and spectral fidelity, respectively, by minimizing the differences between the fused image and the original image in terms of spatial features and spectral information. The overall loss function is given by the following formula:  
\[L=L_{p}+\alpha L_{h}, \tag{12}\]  
where \(L_{p}\) represents the spatial preservation loss function, and \(L_{h}\) represents the spectral preservation loss function. The overall loss function is the weighted sum of the spatial preservation loss function and the spectral preservation loss function, with \(\alpha\) as a learnable parameter.  
The goal of the fusion process is to inject the spatial detail information contained in the panchromatic image into the hyperspectral image. Since high-resolution hyperspectral images are not available as labels for supervising the fusion process, we use the spatial information of the panchromatic image to guide the generation of spatial details in the fused image. The spatial preservation loss function can be computed as follows:  
\[L_{p}=\frac{1}{N}\sum_{i=1}^{N}\left\|h\left(I_{f}^{i}\right)-h\left(I_{p} \right)\right\|_{F}^{2}+\frac{1}{N}\sum_{i=1}^{N}\left\|\
abla\left(I_{f}^{i} \right)-\
abla\left(I_{p}\right)\right\|_{F}^{2}, \tag{13}\]  
where \(N\) represents the number of samples in the training set, \(I_{f}^{i}\) represents the result of the \(i\)-th band of the fused high-resolution hyperspectral image, and \(I_{p}\) represents the panchromatic image. \(\|\cdot\|_{F}\) denotes the Frobenius norm of a matrix, \(h(\cdot)\) represents the high-pass filter used to extract high-frequency information from the image, and \(\
abla(\cdot)\) represents the gradient operation used to extract gradient information from the image. The first term on the right-hand side computes the difference between the high-frequency information of the fused image and the panchromatic image and accumulates the Frobenius norm. The goal is to minimize the difference in high-frequency details between the two images. The second term on the right-hand side accumulates the norm of the gradient difference between the fused image and the panchromatic image, controlling the gradient difference so as to be as small as possible.  
The spectral information of the fused image is provided by the hyperspectral image. Therefore, the spectral preservation loss function can be calculated by the following formula:\[L_{h}=\frac{1}{N}\sum_{i=1}^{N}\left\|\downarrow g\left(I_{f}^{i}\right)-I_{h}^{i} \right\|_{F}^{2}, \tag{14}\]  
where g(\(\cdot\)) represents the Gaussian filter function used to blur the image; \(\downarrow\) denotes the downsampling operation applied to the image to match the resolution of the original hyperspectral image; \(I_{hs}^{i}\) represents the \(i\)-th band of the hyperspectral image. The purpose of blurring and downsampling the fused image is to degrade it to a low-resolution hyperspectral image, ensuring that the spectral information of the fused image aligns with that of the original hyperspectral image.