## 2 Materials and Methods
### Image Fusion Using Low-Rank and Sparse Matrix  
According to the fusion algorithm processing flow in Figure 4, the image fusion algorithm was verified. In the process, the diagram of a matrix structure of the source image for multifocus image of NVG was as shown in Figure 6. In particular, **I** is a two-dimenisonal image matrix, \(t\) is the total number of images, the image height is \(n\), and the width is \(m\).  
First, single source images were converted into one-dmetiensional vectors. Data arrangement in this step was as shown in Figure 7, where **I\({}^{\textbf{R}}\)** was a one-dimensional vector. Each one-dimensional vector \(\textbf{I}_{t}^{\textbf{R}}\) was sequenced from top to bottom according to frame sequence. After combination, it was named **D** matrix (data matrix).  
Then, the deep semi-NMF model method proposed by [PERSON], [PERSON], [PERSON], and [PERSON] [34] was used here to obtain the low-dimensional representation. The equation is as shown in Equation (1):  
\[\textbf{D}\approx\textbf{Z}\times\textbf{H}. \tag{1}\]  
In particular, **D** is data matrix, **Z** is loadings matrix, and **H** is features matrix. This study adopted the method with low-dimesional characteristics to obtain **A** and **E** matrices. **A** is low-rank matrix and **E** is sparse matrix:  
\[\textbf{A}=\textbf{Z}\times\textbf{H}, \tag{2}\]  
\[\textbf{E}=\textbf{D}-\textbf{A}. \tag{3}\]  
In **A** matrix, the relationship bewteen respective row vectors and images was as shown in Equation (4):  
\[\textbf{A}=\left[\begin{array}{c}\textbf{A}\textbf{I}_{1}^{\textbf{R}}\\ \textbf{A}\textbf{I}_{2}^{\textbf{R}}\\ \vdots\\ \textbf{A}\textbf{I}_{t}^{\textbf{R}}\end{array}\right]\textbf{A}\textbf{I}_{1 }^{\textbf{R}}\text{: the size is 1 by L} \tag{4}\]  
In particular, the length of \(L\)_isn_\(\times\)_m_. In **A** matrix, the respective row vectors are, \(\textbf{A}\textbf{I}_{1}^{\textbf{R}}\), \(\textbf{A}\textbf{I}_{2}^{\textbf{R}},\ldots,\textbf{A}\textbf{I}_{t}^{\textbf {R}}\), respectively. In this paper, **D** matrix formed by respective images was decomposed into **A** and **E** matrices. Therefore, these two characteristics were targeted for processing. In particular, **A** process involved reshaping the row vectors from \(\textbf{A}\textbf{I}_{1}^{\textbf{R}}\) through \(\textbf{A}\textbf{I}_{t}^{\textbf{R}}\) to the two-dimensional images of \(\textbf{A}\textbf{I}_{1}-\textbf{A}\textbf{I}_{t}\) and obtaining the mean value. The result was called \(\textbf{A}\textbf{I}_{\textbf{best}}\), and the process was as shown in Equation (5):  
\[\textbf{A}\textbf{I}_{\textbf{best}}=\big{(}\textbf{A}\textbf{I}_{1}+\textbf{ A}\textbf{I}_{2}+\ldots+\textbf{A}\textbf{I}_{t}\big{)}/t \tag{5}\]  
The first image corresponding to sparse matrix \(\textbf{{}^{E}\textbf{I}_{1}}\) and mask offset manipulation was as shown in Figure 8.  
Figure 6: Diagram of matrix structure of the source image.  
Figure 7: Diagram of the image matrix converted into one-dimensional vectors.  
The corresponding image in sparse matrix was as shown in Equations (6) and (7):  
\[OptInd_{z}^{x}=\begin{array}{c}\underset{x\in[1,\ t]}{\operatorname{argmax}}\\ \end{array}\left(\operatorname{Var}\!\left(\mathbf{m}_{\mathbf{r}}\mathbf{I}_{x} \right)\right),\ Z=1,\ 2,\ \ldots,len \tag{6}\]  
\[\mathbf{{}^{E}I_{best}}=\mathbf{{}^{E}I}(OptIndex_{z}^{x}) \tag{7}\]  
In particular, Var in Equation (6) is the computed variance, and \(len\) is the total number of images undergoing mask offset. The best label obtained according to Equation (6) was used to acquire the \(\mathbf{{}^{E}I_{best}}\) image in Equation (7), through which the best edge information was retained. Finally, the image obtained in Equation (5) was added to the images in \(\mathbf{{}^{A}I_{best}}\) and Equation (7) to get the best fusion image \(\mathbf{{}_{best}}\), as shown in Equation (8):  
\[\mathbf{{}_{best}}=\mathbf{{}^{A}I_{best}}+\mathbf{{}^{E}I_{best}} \tag{8}\]