## 2 Methods
### Decision Map  
The key step in high-quality image fusion is obtaining an accurate decision map for the segmentation of clear and blurred regions. By comparing the corresponding pixels of the focus information maps \(\mathrm{I_{\mathrm{\mathrm{Ipr1}}}}\) and \(\mathrm{I_{\mathrm{\mathrm{Ipr2}}}}\) based on the maximum value principle, the initial decision map \(\mathrm{I_{\mathrm{\mathrm{max}}}}\) is generated. It is expressed as the following Equation (8).  
\[\mathrm{I_{\mathrm{\mathrm{max}}}(x,y)}=\begin{cases}1,&\mathrm{I_{\mathrm{ \mathrm{Ipr1}}}(x,y)}>\mathrm{I_{\mathrm{\mathrm{Ipr2}}}(x,y)}\\ 0,&\mathrm{I_{\mathrm{\mathrm{Ipr1}}}(x,y)}\leq\mathrm{I_{\mathrm{\mathrm{Ipr2} }}(x,y)}\end{cases} \tag{8}\]  
The plane of microscopic images is irregular, with discontinuous focus areas, and is also influenced by noise and other factors. As shown in Figure 4, the initial decision map \(\mathrm{I_{\mathrm{\mathrm{max}}}}\) contains misjudged focus and defocus areas during detection. This is manifested in the image by tiny black holes in the white pixel regions and tiny white holes in the black pixel regions. To improve the image fusion quality, these small holes in the decision map need to be removed. This can be achieved by applying contour area filtering and morphological methods to eliminate the holes.  
Morphological operations, such as erosion and dilation, are used to remove small target areas and fill holes. The dilation operation works by convolving the image with a structural element, replacing the center pixel with the maximum value of the area covered by the kernel. This helps to bridge narrow gaps and thin trenches. Erosion, the reverse operation of dilation, is used to eliminate isolated pixel regions or objects.  
To effectively eliminate the hole structures in the decision map, morphological closing operations can be employed. The specific procedure involves first performing a dilation operation using a square structuring element to merge the hole regions with the foreground, followed by an erosion operation of the same scale to restore the original contours of the target. The size of the structuring element also influences the image processing results. Experimental results show that, at the current resolution, a structuring element size of 5 \(\times\) 5 can effectively fill most small holes while preserving image details.  
Figure 4: The initial decision map (1920 \(\times\) 1080 pixels @ 10\(\times\) magnification).  
Figure 3: The focus information maps derived from the adjacent frames with different focal regions of (**a**) lower-left part (\(\mathrm{I_{\mathrm{\mathrm{Ip1}}}}\)), (**b**) upper-right part (\(\mathrm{I_{\mathrm{\mathrm{Ip2}}}}\)) (for better visualization, histogram equalization was performed on the images).  
Morphological operations can filter out the majority of hole regions, and the remaining small holes are filtered through area calculations. The area of the hole is approximated as the area of a closed polygon, which is calculated using the shoelace equation [20].  
\[\text{A}=\frac{1}{2}\left|\sum_{i=1}^{n}\left(x_{i}y_{i+1}-x_{i+1}y_{i}\right) \right|, \tag{9}\]  
where \((x_{i},y_{i})\) is the vertex coordinates of the closed polygon, and \(x_{n+1}=x_{1},y_{n+1}=y_{1}\). The area A is computed by iterating over all the vertices. For example, the area threshold T is set as one sixty-fourth of the image area. If the area A of the hole is smaller than the threshold T, it is considered a small hole and removed from the contour sets. Apply morphological operations and filter out small area contours from \(I_{\text{max}}\) to obtain the final decision map \(I_{\text{fitted}}\). As shown in Figure 5, the final decision map accurately divides the clear and blurred regions while eliminating the interference of misjudged focused and defocused areas.