Differentiable Mathematical Morphology for Shape and Topology Learning

This direction is split into other directions: differentiable morphological operators. Its last version stays readable and citable here.

Version 1 of 136 papers56 conceptsfrozen 2026-10-04

Mathematical Morphology (MM) is a theory of image processing based on shape and geometry. Unlike linear filters, morphological operators like dilation and erosion use non-linear logic to expand or shrink structures based on a "structuring element" (a kernel defining the shape of interest). While these tools are exceptionally robust for tasks like skeletonization or noise removal, they have historically been incompatible with deep learning because their core operations—the maximum and minimum functions—are non-differentiable.

Recent research has bridged this gap by developing differentiable proxies for morphological operations. This allows neural networks to learn geometric priors, optimize the shapes of spatial filters, and preserve complex topological structures like blood vessels or road networks through end-to-end gradient descent.

Smoothing the Max and Min

The fundamental hurdle in integrating MM into neural networks is the "hard" nature of the max and min operators. In a standard dilation, the output pixel is simply the maximum value in a neighborhood. This function has a gradient of zero almost everywhere, except at the single point of the maximum, making it difficult for backpropagation to "nudge" the weights of a kernel.

To solve this, Jesús Angulo, Jürgen Schmidhuber, and Jonathan Masci proposed using the Counter-Harmonic Mean (CHM) as a differentiable approximation of morphological operators in A Learning Framework for Morphological Operators Using Counter-Harmonic Mean. By adjusting an exponent parameter, the CHM can smoothly transition between a minimum (erosion), an arithmetic mean, and a maximum (dilation). This formulation allows the network to simultaneously optimize the shape of the structuring element and the nature of the operation itself.

Morphological Layers as Neural Modules

Beyond theoretical approximations, researchers have found ways to implement morphological logic using standard deep learning building blocks.

  1. Pooling as Morphology: Suprosanna Shit and colleagues demonstrated in clDice that iterative min-pooling and max-pooling can serve as differentiable proxies for erosion and dilation. This "soft-skeletonization" allows a network to extract the centerline of a structure while maintaining a gradient path.
  2. Convolutional Proxies: Mateus Riva and Isabelle Bloch argued in Approximation of dilation-based spatial relations that standard linear convolutions can approximate dilation if the structuring element is used as the kernel. This approach avoids the numerical instability of high-power means while providing the spatial logic needed for structural constraints.
  3. Pseudo-Morphological Layers: In Learning deep morphological networks with neural architecture search, Yufei Hu and Angela Yao used 1x1 convolutions and pixel shuffling to simulate spatial expansion and contraction. They showed that Neural Architecture Search (NAS) often prefers these morphological layers over standard convolutions for tasks requiring precise edge and shape detection.

Preserving Topology through Differentiable Skeletons

One of the most impactful applications of this research is in the segmentation of thin, tubular structures like neurons or roads. Standard loss functions like Binary Cross-Entropy or Dice loss often fail here; they might achieve 99% accuracy while still leaving a critical "break" in a one-pixel-wide vessel, which destroys the topology of the network.

To fix this, Suprosanna Shit, Johannes C. Paetzold, and others introduced clDice (centerline Dice). This loss function calculates the overlap between the skeletons of the prediction and the ground truth. Because the skeletonization process is made differentiable through iterative pooling, the network receives a direct gradient signal if it breaks a connection.

Further advancing this, Johannes C. Paetzold and Martin J. Menten developed a 3D skeletonization algorithm in A skeletonization algorithm for gradient-based optimization that is mathematically guaranteed to preserve topology while remaining fully differentiable. This allows models to "see" the underlying medial axis of complex 3D volumes.

Why It Works: The Intuition of Reachability

The success of differentiable morphology stems from the concept of reachability. In a standard segmentation task, a thin skeleton is a difficult target because a small shift in the prediction results in zero overlap with the ground truth, providing no useful gradient.

By using differentiable dilation, researchers like Yannick Kirchhoff in Skeleton Recall Loss transform a thin skeleton into a "tube." This tube creates a wider basin of attraction for the gradient. The network is no longer penalized just for missing a specific pixel; it is guided toward the general geometric structure of the target.

This shift from pixel-wise matching to shape-wise alignment—enabled by libraries like Kornia which implement these routines as PyTorch layers—allows deep learning to move beyond "black box" textures and toward a rigorous understanding of object geometry.

Papers in this version

History & citationVersion 1 · 2026-10-04

Split into other directions · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_differentiable_mathematical_morphology_f_51858b83,
  title = {Differentiable Mathematical Morphology for Shape and Topology Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/differentiable-mathematical-morphology-for-shape-and-topology-learning/rdr_51858b8311174f3b8dda96c042a97b62},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-20},
}

This exact version (version 1, frozen text):

@misc{lacuna_differentiable_mathematical_morphology_f_51858b83_v1,
  title = {Differentiable Mathematical Morphology for Shape and Topology Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/differentiable-mathematical-morphology-for-shape-and-topology-learning/rdr_51858b8311174f3b8dda96c042a97b62/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-20},
}