# Multi-Focus Image Fusion Based on Decision Map and Sparse Representation
## 2 Proposed Fusion Scheme
### Fusion  
Based on the final decision map \(D\), the fused image \(\overline{I_{F}}\) can be simply obtained by  
\[\overline{I_{F}}(x,y)=D(x,y)I_{A}(x,y)+(1-D(x,y))I_{B}(x,y). \tag{5}\]  
However, in this way, the pixels in the transitional area are actually averaged. This can cause undesirable effects such as the edge-blocking effect and artificial-edge effect. In order to suppress these effects at the same time, it is considered that the pixel classification of the transitional area has the following difficulties: the difference in the clarity of the pixels is small, the gray change is irregular, and the traditional classification methods have difficulty with accurate division. For the transitional area, we choose the fusion method based on sparse representation. The determination of the transitional area and the specific fusion algorithm are as follows:  
* The boundary line of the final decision map \(D\) is centered, the appropriate radius (3-5 pixels) is set, and the corresponding rectangular area is delineated as the transitional area \(R\).
* Via smooth window technology, each source image is divided into image blocks of size \(\sqrt{n}\times\sqrt{n}\), image blocks containing transitional area pixels are converted into column vectors, and all column vectors constitute a vector matrix \(V\in R^{n\times p}\) (\(p\) is the total number of image patches intersecting the transitional area). At the same time, the matrix \(\Lambda\) is used to record the initial spatial position of each column vector.
* For the \(j\)-th patches \(v^{j}_{A}\) and \(v^{j}_{B}\) (\(1\leq j\leq p\)), the discrete cosine (DC) components \(dc^{j}_{A}\) and \(dc^{j}_{B}\) are extracted first, and then we get \(v^{j}_{A}\) and \(v^{\prime j}_{B}\) with no DC component.
* The sparse coefficients of each vector in the vector matrix \(V^{\prime}_{A}\) and \(V^{\prime}_{B}\) are calculated by the sparse coding algorithm OMP, and the corresponding sparse coefficient matrices \(C_{A}\) and \(C_{B}\) are obtained. Then, each coefficient vector is processed according to the maximum pooling principle: \[c^{j}_{F}(\tau)=c^{j}_{\Gamma}(\tau),\,\hat{\Gamma}=\arg\max_{\Gamma=\Lambda, b}\left(\left|c^{j}_{\Gamma}(\tau)\right|\right)\] (6) where \(j\) is the column index of the sparse coefficient matrix, and \(\tau\) is the index of the atom in the dictionary \(\Phi\).
* The fused vector \(V^{\prime}_{F}\) without the DC components is obtained by \[V^{\prime}_{F}=\Phi C_{F}\] (7) The fused DC component obeys the following rule: \[dc^{j}_{F}=\left\{\begin{array}{cc}\frac{dc^{j}_{A}+dc^{j}_{B}}{2},&\text{ if }0.85\leq\left|\frac{dc^{j}_{A}}{dc^{j}_{B}}\right|\leq 1.15\\ \min(dc^{j}_{A},dc^{j}_{B}),&\text{otherwise}\end{array}\right.\] (8)* The fused vector \(v_{F}^{j}\) is determined as follows: \[v_{F}^{j}=\,{v^{\prime}}_{F}^{j}+dc_{F}^{j}\cdot 1\] (9) where each column vector \(v_{F}^{j}\) in \(V_{F}\) is reshaped into a block with size \(\sqrt{n}\times\sqrt{n}\) and then overlaid at its recorded position in \(\Lambda\).
* Finally, the transitional area fused image \(V_{F}\) based on the sparse representation and the fused image \(\overline{I_{F}}\) based on the final decision map are averaged to generate the final fused image \(I_{F}\). As shown in Figure 5, compared with the fused image \(\overline{I_{F}}\) based on the final decision map, our final fused image \(I_{F}\) is significantly clearer at the \"brim edge\" and \"sweater texture\".  
On the fifth step of the algorithm, most of the existing fusion methods calculate the fused DC components using a simple average. However, this easily produces fuzzy effects around some strong edges due to the great change in brightness. The main reason for this is that the energy of the region with high brightness diffuses into the region with low brightness when losing focus. Therefore, we modify the fusion rule for DC components. When the DC components from different source images are close to each other, we choose the average operation; otherwise, the minimal DC component is selected.