# Multi-Focus Image Fusion Based on Decision Map and Sparse Representation
## 2 Proposed Fusion Scheme
### Clarity Score Map  
Firstly, wavelet decomposition is performed on the two multi-focus source images by a wavelet basis, and four low-frequency sub-band images of horizontal low-frequency and vertical low-frequency (LL), horizontal low-frequency and vertical high-frequency (LH), horizontal high-frequency and vertical high-frequency (HH) are obtained, respectively. Among them, the LL low-frequency sub-band images still maintain the overview and spatial characteristics of the source images and are suitable for the analysis and extraction of the subsequent source image focusing features, so they are selected as the low-scale images of the algorithm, as shown in Figure 2c,d. Next, the sparse representation of low-scale images is carried out, and the corresponding sparsity graphs are generated. Finally, two corresponding clarity score maps are obtained by the image block-based clarity measurement method. The main steps of creating clarity score maps are described as follows:  
* The low-scale versions of source images \(I_{A}^{LL}\), \(I_{B}^{LL}\in R^{H\times W}\) are divided into \(\sqrt{n}\times\sqrt{n}\) image patches using the smooth window technique from top left to bottom right, and the sliding step is one. All patches are reshaped into \(n\) dimensional column vectors \(\left\{v_{A}^{j}\right\}_{i=1}^{N}\) and \(\left\{v_{B}^{i}\right\}_{i=1}^{N}\)\(\left(v_{A}^{i},v_{B}^{i}\in R^{n},N=(H-\sqrt{n}+1)\ast(W-\sqrt{n}+1)\right)\) via lexicographic ordering.
* Given the global dictionary \(\Phi\in R^{n\times K}(n<<K)\), each column vector can be represented by the sparse coefficient vector \(\left\{x_{A}^{i}\right\}_{i=1}^{N}\) and \(\left\{x_{B}^{i}\right\}_{i=1}^{N}\)\(\left(x_{A^{\prime}}^{i},x_{B}^{i}\in R^{K}\right)\) with the orthogonal matching pursuit (OMP) sparse coding algorithm. The L1 norms of the sparse coefficient vector \(\left\{x_{A}^{i}\right\}_{i=1}^{N}\) and \(\left\{x_{B}^{i}\right\}_{i=1}^{N}\) are calculated and reshaped to obtain the sparsity graphs \(E_{A}\) and \(E_{B}\in R^{(H-\sqrt{n}+1)\times(W-\sqrt{n}+1)}\).
* Two score maps \(S_{A}\) and \(S_{B}\in R^{H\times W}\) are initialized with all zeroes. For a given pixel \((x_{i},y_{i})\) in the sparsity graph \(E\), its value measures the activity level of the pixel's down-right corner \(\sqrt{n}\times\sqrt{n}\)  
Figure 1: Framework of the proposed fusion algorithm. (**a**) The process of generating the decision map; (**b**) fusion process.  
image patch. For each corresponding pair of \(\sqrt{n}\times\sqrt{n}\) image patches, \(e_{A}^{i}\) and \(e_{B}^{i}\) in the sparsity graphs, the sum of all the clarity values is calculated as follows:  
\[M^{i}=\sum_{u=0}^{\sqrt{n}-1}\sum_{v=0}^{\sqrt{n}-1}E(x_{i}+u,y_{i}+v) \tag{1}\]  
where \(M_{A}^{i}\) and \(M_{B}^{i}\) denote the sum values, respectively. If \(M_{A}^{i}\geq M_{B}^{i}\), each score value within the \(\sqrt{n}\times\sqrt{n}\) corresponding patch is centered at \(\left(x_{i}+\sqrt{n},y_{i}+\sqrt{n}\right)\) in the clarity score map \(S_{A}\) add one, and vice versa, as shown in Figure 3. In addition, the total times of the comparison between each corresponding pair of patches are recorded in a weight map \(W\).
* Further, the clarity score maps \(S_{A}\) and \(S_{B}\) are normalized by averaging \(W\) at each pixel location. The resulting clarity score maps are shown in Figure 2e,f.  
Figure 3: The creation of clarity score maps with the smooth window technique.  
Figure 2: (**a**) Source image \(I_{A^{i}}\); (**b**) source image \(I_{B}\); (**c**) low-scale image \(I_{A}^{LL}\); (**d**) low-scale image \(I_{B}^{LL}\); (**e**) clarity score map \(S_{A^{i}}\); (**f**) clarity score map \(S_{B}\).