arXiv:2610.38516cs.CVOct 2026

Manuscript Offprint

arXiv:2610.38516

The Power Watershed as a Differentiable Segmentation Layer

Galia Akl, Laurent Najman, Hugues Talbot

Galia Akl¹,², Laurent Najman³,⁴, and Hugues Talbot⁵

¹ Holy Spirit University of Kaslik, Lebanon galia.r.akl@net.usek.edu.lb

² American University of Beirut, Lebanon

³ LIGM, Univ. Gustave Eiffel, CNRS, F-77454 Marne-la-Vallée, France laurent.najman@esiee.fr

⁴ Math. Department, Khalifa University, Abu Dhabi, UAE

⁵ CentraleSupélec, Inria, Université Paris-Saclay, France hugues.talbot@centralesupelec.fr

Abstract. Can a Watershed transform, the classical tool of morphological segmentation, be placed at the end of a deep network and trained through? The Power Watershed (PW) is the p→∞p \to \infty limit of the seeded Random Walker (RW) with edge weights raised to the power pp. At every finite pp the RW solves a sparse positive-definite linear system and is exactly differentiable with respect to the edge weights and the unaries through one adjoint solve; its multi-label form costs one right-hand side per label, and its limit is the PW. We study this family as the last layer of a segmentation network, the watershed layer (WS layer). A conditioning study measures how the solve, the gradient and the distance to the limit evolve with pp, and the implicit gradient is checked against unrolling. On synthetic data with correct edge costs the WS layer transforms a soft prediction into an exact boundary. On nuclei segmentation (PanNuke), a binary WS layer is level with a thresholded U-Net. With the instances as labels, the WS layer turns the U-Net into an instance segmenter whose number of labels is set per image by the markers rather than by the output layout, and the network is trained through that partition: instance F1F_1 rises from 0.656 to 0.795 over a U-Net with connected components, level with the same network followed by a tuned marker watershed. At the training temperature the partition is a watershed of the learned costs, and the finite temperature lets the solve hedge, discounting weak markers and sharing contested pixels. The hedging puts the WS layer 0.015-0.020 F1F_1 ahead of the baseline when trained on a tenth of the data, at the price of having to deploy the finite-p solve rather than its exact limit at inference. Code and the full experimental record are released.

Keywords: Morphological segmentation · Random Walker · differentiable segmentation · instance segmentation · deep unrolling.

1 Introduction

Deep segmentation networks such as U-Nets perform well under supervision but have many parameters, which reduces explainability, and produce soft, per-pixel outputs. Boundaries come out rounded, output potentials are rarely binary, and the number of labels is fixed by a one-hot channel layout decided at design time. Watersheds have the opposite profile: results are crisp and directly explainable through labelling and the topographical nature of the input data. As a result, boundaries appear on the strongest edges of a cost map, regions are piecewise constant, and the number of regions is equal to the number of markers, not a property of the algorithm. An interesting combination is thus to add a watershed at the end of a segmenting network and train through it. The obstacle is that a watershed is a combinatorial procedure on a graph, with a gradient that is zero almost everywhere.

This article makes the case that the Power Watershed framework of Couprie et al. [13,14] can be used in this context. It provides its own relaxation, the Random Walker [21] at finite pp, and we evaluate what the resulting watershed layer (WS layer) can be used for. The framework minimises ∑ewep∣xu−xv∣q\sum_e w_e^p |x_u - x_v|^q over potentials xx fixed on seeds; q=2q=2 with finite pp is the Random Walker (RW), and p→∞p \to \infty is the Power Watershed (PW), a maximum spanning forest with a small linear solve on each plateau. Reading pp as an inverse temperature of the Gibbs distribution over spanning forests, as the probabilistic watershed of Fita Sanmartín et al. [16] suggests (the p→∞p \to \infty collapse is that of softmax→\toargmax [24]), every finite-pp member is a convex problem whose solution is exactly differentiable, and the path ends at the PW, a true watershed rather than a surrogate as in learned watersheds [32] or post-hoc watershed transforms [5,22].

Our contributions are the following. (i) A differentiable RW/PW layer with unaries, written with dense shifted-grid operators so that it is batched, running on the GPU and can be differentiated in either of two ways: by unrolling a few preconditioned conjugate-gradient steps or implicitly, by one adjoint solve (Sect. 3). Its multi-label form costs one right-hand side per label, and its limit one spanning forest whatever the number of labels, whereas graph cuts are exact only for two labels. (ii) A conditioning study of solver cost, distance to the limit and gradient support as functions of pp (Sect. 4.1). (iii) An experimental account on synthetic scenes and PanNuke nuclei [18,17] that evaluates where the WS layer helps. With correct edge costs it recovers exact boundaries; as a binary last layer on real images it is level with a thresholded U-Net; with the instances as labels it is level with a tuned marker watershed on the same network, and ahead of it when training data are scarce (Sect. 4).

References (32)