A Deep Model for Multi-Focus Image Fusion Based on Gradients and Connected Regions

Han Xu, Fan Fan, Hao Zhang, Zhuliang Le, Jun Huang

Digital imaging often suffers from a limited depth-of-field (DOF), where only objects within a specific distance range appear sharp, while others are blurred. To overcome this, multi-focus image fusion merges multiple shots of the same scene taken at different focus settings into a single "all-in-focus" image.

This paper introduces GCF, a novel unsupervised deep learning model designed to generate high-quality fused images without the need for labeled ground-truth data or hand-crafted fusion rules. By leveraging gradient information and a unique spatial constraint, the researchers developed a network that directly predicts a binary focus mask.

The Mask-Net Architecture

At the core of the GCF model is Mask-Net, an unsupervised encoder-decoder architecture. Unlike traditional supervised models that require perfectly focused reference images—which are notoriously difficult to capture in the real world—Mask-Net learns to identify focused regions by analyzing the source images themselves.

The Mask-Net architecture featuring dense connections and increasing feature map depth.

As shown in the architecture diagram, the network utilizes dense connections to improve feature propagation. It processes concatenated source images through a series of convolutional layers, batch normalization, and Leaky ReLU activations, progressively increasing the number of feature maps from 48 to 192. This structure allows the model to capture both fine-grained textures and broader spatial context necessary for accurate focus detection.

Overcoming the Vanishing Gradient Problem

A significant challenge in training networks to produce binary masks (where 0 represents blurred and 1 represents focused) is the "vanishing gradient trap." The standard Sign function used to binarize outputs has a derivative of zero almost everywhere, making standard backpropagation impossible.

Comparison between the non-differentiable Sign function (a) and the Htanh relaxation (b) used for backpropagation.

To solve this, the authors implemented the Htanh (Hard Tanh) relaxation. During the training phase, the Htanh function approximates the Sign function, providing a non-zero gradient that allows the network to learn. This mathematical bridge enables the model to converge toward binary values while maintaining the ability to update its weights through gradient descent.

Dual-Constraint Loss Function

The unsupervised nature of GCF is driven by a two-part loss function:

  1. Gradient Relation Map ($L_{gra}$): This loss is based on the physical principle that focused regions contain sharper edges and higher gradient intensities. It forces the network to align its predicted mask with the areas of highest gradient in the source images.
  2. Connected Region Loss ($L_{con\_reg}$): Recognizing that real-world objects are continuous, this constraint penalizes the network for creating fragmented or "noisy" masks. It encourages the formation of clean, contiguous focused regions, effectively acting as a spatial regularizer.

Following the network's output, a Consistency Verification post-processing step is applied to remove any remaining small, misclassified "islands" based on a size threshold, ensuring a smooth final transition between focused and defocused areas.

Performance and Key Insights

The GCF model was evaluated using the Lytro Multi-focus dataset. In comparisons against both traditional methods (like DSIFT) and other deep learning approaches (like DenseFuse), GCF demonstrated several key advantages:

  • Quantitative Excellence: The model achieved top-tier scores in metrics such as Feature Mutual Information (FMI) and Spatial Frequency (SF), indicating superior transfer of fine details and edges.
  • Visual Fidelity: Qualitative results showed that GCF avoids common artifacts like "pseudo-edges" or blurred boundaries, producing the cleanest separation between focus zones.
  • Efficiency: Despite its complexity, the model processes a full image pair in approximately 0.65 seconds on an NVIDIA Titan X, making it viable for practical applications.

Conclusion

By combining gradient-based learning with spatial logic, GCF effectively bypasses the need for ground-truth data. While future work may focus on integrating post-processing directly into the architecture and improving robustness against image misregistration, GCF represents a significant step forward in unsupervised image fusion, proving that spatial constraints can effectively guide deep models toward physically realistic solutions.

Summary updated

BibTeX
@article{xu2020deep,
  author = {Han Xu and Fan Fan and Hao Zhang and Zhuliang Le and Jun Huang},
  title = {{A Deep Model for Multi-Focus Image Fusion Based on Gradients and Connected Regions}},
  journal = {IEEE Access},
  year = {2020},
  doi = {10.1109/access.2020.2971137},
}
Figure