MFIF-GAN: A new generative adversarial network for multi-focus image fusion

Yicheng Wang, Shuang Xu, Junmin Liu, Zixiang Zhao, Chunxia Zhang, Jiangshe Zhang

TL;DR

MFIF-GAN is a new deep learning framework that produces high-quality "all-in-focus" images by merging multiple photos taken at different focus settings. By utilizing a Generative Adversarial Network (GAN) trained on a realistic synthetic dataset, it specifically solves the "defocus spread effect"—the annoying blur that typically bleeds across object boundaries in fused images—while achieving state-of-the-art processing speeds.

What Problem Does This Paper Address?

Most digital cameras suffer from a limited depth-of-field, meaning they can only focus on one plane at a time. Multi-Focus Image Fusion (MFIF) is the process of combining these partially focused images into a single, crystal-clear result.

The primary hurdle in MFIF is the Defocus Spread Effect (DSE). When an object is out of focus, its blurred edges "permeate" or bleed into the focused background. As shown in Figure 2, the boundary between focus and defocus (FDB) isn't a sharp line but a "ribbon" of uncertainty.

Comparison of an image without DSE (a) and one suffering from DSE (b)

Existing algorithms often produce unrealistic artifacts or "halos" around these boundaries because they fail to account for how light actually spreads when defocused.

Methods

The authors propose MFIF-GAN, a supervised GAN-based architecture designed to generate precise "focus maps"—binary masks that tell the system which pixels to take from which source image.

The Architecture

The network consists of two main parts:

  • Generator (G): An encoder-decoder structure. The encoder uses six parallel branches to process color channels independently, employing Squeeze-and-Excitation (SE) Residual modules. These modules act as an attention mechanism, helping the network prioritize the most informative features for detecting focus.
  • Discriminator (D): A standard CNN that tries to distinguish between "real" focus maps and those generated by the network, pushing the generator toward higher accuracy.
The detailed architecture of MFIF-GAN

The Loss Function

To stabilize training, the authors adopted the WGAN-GP (Wasserstein GAN with Gradient Penalty) framework. They combined this with an $L_1$-norm reconstruction loss to ensure pixel-level accuracy and a gradient regularization term to sharpen boundary details.

Datasets

A major contribution of this paper is the training data itself. Because real-world "ground truth" all-in-focus images are hard to obtain, the authors created a synthetic $\alpha$-matte dataset.

  • Training: They applied a sophisticated $\alpha$-matte boundary defocus model to the PASCAL VOC 2012 dataset to simulate realistic DSE.
  • Testing: The model was evaluated on three public benchmarks: Lytro (color), MFFW (specifically designed for DSE challenges), and a grayscale dataset.

Key Insights and Ideas

  • The "Larger Foreground" Strategy: The authors discovered that the best way to mitigate DSE is to generate focus maps where the foreground regions are slightly larger than the actual objects. This ensures that the blurred "bleed" from the foreground doesn't overwrite clear background pixels.
  • Realistic Simulation Matters: By training on a dataset that explicitly models DSE (via the $\alpha$-matte model) rather than simple Gaussian blur, the network learns to handle complex edge cases that trip up other deep learning models.
  • Attention is Key: The SE-ResNet blocks allow the network to model interdependencies between feature channels, which is crucial for distinguishing subtle focus differences in textured regions.

Key Results

MFIF-GAN was compared against eight state-of-the-art (SOTA) methods, including Quadtree, DSIFT, and FuseGAN.

  • Quantitative Performance: MFIF-GAN took the lead across 12 different metrics (such as Mutual Information and SSIM) on the Lytro and MFFW datasets.
  • Visual Quality: As seen in Figure 5, MFIF-GAN produces focus maps (a) that are more robust than baseline methods like FuseGAN (b). The resulting fused images (h) show significantly cleaner edges around complex foreground objects like fences.
  • Efficiency: The model is highly efficient. On an RTX 2080ti GPU, it fused Lytro images in approximately 0.22 seconds, making it the fastest among the compared methods.
Focus map and fusion results comparison

Limitations and Future Work

While MFIF-GAN performs exceptionally well, the authors note a few areas for growth:

  • Post-processing: The current method uses a simple "Small Region Removal" (SRR) strategy. While effective and fast, more sophisticated refinement techniques could potentially improve results in extremely noisy environments.
  • Generalization: The model is currently optimized for pairs of images. Extending this to multi-image sequences (more than two) would be a valuable next step for professional photography applications.

Overall, MFIF-GAN represents a significant step forward in making multi-focus fusion practical and artifact-free for real-world computer vision tasks.

Summary updated

BibTeX
@article{wang2021mfif,
  author = {Yicheng Wang and Shuang Xu and Junmin Liu and Zixiang Zhao and Chunxia Zhang and Jiangshe Zhang},
  title = {{MFIF-GAN: A new generative adversarial network for multi-focus image fusion}},
  journal = {Signal Process. Image Commun.},
  year = {2021},
  doi = {10.1016/j.image.2021.116295},
}
Figure