Topograph: An Efficient Graph-Based Framework for Strictly Topology Preserving Image Segmentation

## Abstract

Abstract Topological correctness plays a critical role in many image segmentation tasks, yet most networks are trained using pixel-wise loss functions, such as Dice, neglecting topological accuracy. Existing topology-aware methods often lack robust topological guarantees, are limited to specific use cases, or impose high computational costs.
In this work, we propose a novel, graph-based framework for topologically accurate image segmentation that is both computationally efficient and generally applicable. Our method constructs a component graph that fully encodes the topological information of both the prediction and ground truth, allowing us to efficiently identify topologically critical regions and aggregate a loss based on local neighborhood information. Furthermore, we introduce a strict topological metric capturing the homotopy equivalence between the union and intersection of prediction-label pairs. We formally prove the topological guarantees of our approach and empirically validate its effectiveness on binary and multi-class datasets. Our loss demonstrates state-of-the-art performance with up to fivefold faster loss computation compared to persistent homology methods. 1 1 1 Code is available at https://anonymous.4open.science/r/Topograph

## 1 Introduction

In segmentation and structural analysis tasks, maintaining topological integrity is often more critical than simply improving pixel-wise accuracy. For example, in medical imaging, the topological integrity of segmented structures, such as blood vessels or neural pathways, can be crucial for accurate diagnosis and functional analysis (Briggman et al., ). However, topological errors, such as loss of connectivity, are common in practice, even when pixel-wise accuracy is high. Standard pixel-based loss functions, such as Dice-loss, do not adequately address these issues. While they minimize pixel-level discrepancies, they do not take into account changes in topology, which may be caused by few or even single pixels. As a result, even small pixel-wise errors can lead to significant topological failures.

Previous works have shown how different topology-aware methods can improve the integrity of target structures without sacrificing pixel-wise accuracy. Task-specific methods, such as those designed for tubular structure segmentation (Shit et al., ; Kirchhoff et al., ; Menten et al., ), are computationally efficient and perform well in their respective domains. However, they do not generalize effectively to other types of topological structures or datasets. In contrast, persistent homology (PH)-based methods can provide strong theoretical guarantees and deliver state-of-the-art performance (Hu et al., ; Stucki et al., ; Clough et al., ), but are computationally more demanding. Other topology-aware methods can be more versatile and computationally efficient, but lack theoretical guarantees for topological correctness (Mosinska et al., ; Funke et al., ; Hu et al., ).

This work proposes a loss function that generalizes to various segmentation tasks where topology is crucial. Our method is based on a component graph that combines joint topological information of ground truth and prediction (see Figure 1). A theoretically founded analysis of the nodes in the graph allows the identification of topologically critical regions, which we then use for loss computation.

Figure: Figure 1: Visualization of the proposed component graph representation. Left: Input image; Right: Overlay of the prediction ($P$) and ground truth ($G$). The bright green lines indicate the foreground structures in the ground truth, with (darker) green regions indicating correctly predicted foreground and pink regions representing incorrectly predicted foreground. A combined component graph $\mathcal{G}(P,G)$ is constructed to efficiently identify topological errors, which are used to compute a loss.
Refer to caption: x1.png

#### Our contribution.

We (1) establish a metric that captures topological correctness with strict theoretical guarantees, especially capturing the homotopy equivalence between union and intersection of a label/prediction pair, and (2) formulate a general topology-preserving loss for training arbitrary segmentation networks. Specifically, our loss formulation

- 1.
surpasses existing methods in terms of topological correctness of predictions;
- 2.
provides stricter topological guarantees than existing works, i.e., formal guarantees beyond the homotopy equivalence of ground truth and segmentation, by extending the enforced homotopy equivalence to their union and intersection through the respective inclusion maps, capturing the spatial correspondence of their topological properties;
- 3.
is time and resource-efficient because of its low asymptotic complexity ($O(n\cdot\alpha(n))$) and empirically low runtime;
- 4.
and is flexible, making it applicable to arbitrary structures and image domains.

We empirically validate the prediction performance on various public datasets for binary and multiclass segmentation tasks.

#### Related Work

Significant progress has been made in segmentation methods that aim to preserve topological accuracy.
The use of persistent homology (PH)-based loss functions for training segmentation networks (Hu et al., ; Clough et al., ; Funke et al., ) ensures global topological correctness by aligning Betti numbers when minimized to zero. However, two issues persist: 1) most methods cannot guarantee spatially related matched structures, and 2) computational cost. Stucki et al. () introduce the Betti Matching concept, which ensures spatially correct barcode matching. However, the cost of barcode computation is substantially higher compared to overlap based methods making its derived methods applicable only to relatively small patch sizes. PH-based methods typically use patch sizes of $48\times 48$, $65\times 65$, and $80\times 80$ respectively. These limit the applicability to medical and natural images, where whole images are commonly an order of magnitude larger. Another limitation is the gradient’s dependence on just two simplex values, which Nigmetov & Morozov () recently showed to hinder optimization speed. While other methods are computationally more efficient (Hu et al., ; Mosinska et al., ), they offer limited guarantees of topological correctness. Task-specific, overlap-based approaches have been proposed for tubular structures where connectivity is the key topological feature. ClDice (Shit et al., ) calculates a loss term based on the union of ground truth skeletons and predicted volumes, a method extended in recent studies (Kirchhoff et al., ; Menten et al., ). Other approaches refine tubular-structure features through iterative feedback learning strategies (Cheng et al., ) or rely on post-processing networks (Li et al., ; Wu et al., ). However, none of these approaches generalize effectively to arbitrary structures.

## 2 Method

We propose a topology-preserving loss function based on the *combined component graph* $\mathcal{G}(P,G)$, which encodes topological information from both the label and prediction. Using this graph, we implement an algorithm for identifying regions in the prediction that must be corrected to adhere to the ground truth topology. Thereby, we aim to optimize the network such that topologically critical regions are correctly predicted while less significant regions are ignored. To construct the component graph, we pair the prediction $P$ and ground truth $G$ into a 4-class image $C$ that is then partitioned into superpixels via connected component labeling. Each superpixel, composed only of pixels with the same class in $C$, corresponds to exactly one node in the resulting component graph $\mathcal{G}(P,G)$. This planar and bipartite graph, with edges connecting adjacent superpixels, captures the topology of both $P$ and $G$. Analyzing the local neighborhood of each node in $\mathcal{G}(P,G)$, we can identify critical nodes that represent incorrectly predicted regions causing topological errors. Formally, the set of critical nodes is defined by all incorrectly predicted nodes that do not have exactly one correctly predicted foreground and one correctly predicted background neighbor. The final loss function is obtained by pixel-wise aggregation for each critical region. A schematic overview of the method from graph generation to loss calculation is provided in Figure 2. In the following sections, we provide a detailed description of our method, its theoretical guarantees, its asymptotic complexity, and some interesting adaptations to the method.

Figure: Figure 2: Overview of our proposed method. (1) We use the prediction in each iteration of the training phase to build a combined image with the labels. (2) Based on the combined image, we construct a superpixel graph $\mathcal{G}(P,G)$ that encodes the full topological information of both segmentations. (3) We can identify topologically relevant errors using each node’s local neighborhood. (4) Finally, we can backtrack the critical errors to image regions and calculate a topological loss function. This allows an efficient formulation of a topological loss with strict theoretical guarantees.
Refer to caption: x2.png

### 2.1 Component Graphs Encoding Digital Image Topology

Our method relies on the fact that a *component graph* $\mathcal{G}(I)$ of a binarized segmentation encodes the relevant topological information of an underlying 2D segmentation. The vertices $\mathcal{V}(\mathcal{G}(I))$ resemble the connected components of foreground and background, whereas the edges $\mathcal{E}(\mathcal{G}(I))$ encode the neighborhood information of these components.

We model the topology of a binarized digital image $I\in\{0,1\}^{h\times w}$ by a two-dimensional cubical grid complex $C=[0,h]\times[0,w]\subset\mathbb{R}^{2}$ using the T-construction, i.e., a voxel $(i,j)\in\{1,\ldots,h\}\times\{1,\ldots,w\}$ corresponds to a top-dimensional cell $[i-1,i]\times[j-1,j]\in C$. To apply duality arguments and exclude edge cases, we add an additional background cell $c_{\star}$ that is attached to the boundary $[0,m]\times\{0,n\}\cup\{0,m\}\times[0,n]$ of $C$. This turns the cubical grid complex $C$ into a CW-complex $\widetilde{C}$ that is homeomorphic to the sphere $S^{2}$.

The *foreground* $F(I)$ is given by the closure of the union of $2$-cells whose voxels take value $1$ and its *background* $B(I)$ is given by the complement $\widetilde{C}\setminus F(I)$.
Foreground and background decompose into connected components $F_{1},\ldots,F_{k}$ and $B_{1},\ldots,B_{l}$, which together form the vertices of its *component graph* $\mathcal{G}(I)$.
The component graph is a bipartite tree with edges between a foreground component $F_{i}$ and a background component $B_{j}$ if and only if $F_{i}\cap\overline{B_{j}}\neq\emptyset$.
Note that the component graph determines the homotopy type of the foreground $F(I)$, since its Betti numbers can be inferred from it.
We find $b_{0}(F(I))$ to be the number of foreground vertices of $\mathcal{G}(I)$ and

$$ $b_{1}(F(I))=\sum_{i=1,\ldots,k}\operatorname{deg}_{\mathcal{G}(I)}(F_{i})-1,$ $$

where $\operatorname{deg}_{\mathcal{G}(I)}(F_{i})$ denotes the number of edges in $\mathcal{G}(I)$ that contain vertex $F_{i}$.
Beyond that, starting from the surrounding background node along a path to a leaf of $\mathcal{G}(I)$ informs about the relationship of consecutive nodes of the path.
A background component following a foreground component is a hole within the previous foreground component.

We consider the *thickened foreground* $F_{\epsilon}(I)=D_{\epsilon}(F(I))$ and the *thinned out background* $B_{\epsilon}(I)=\widetilde{C}\setminus F_{\epsilon}(I)$ to prevent connectivity issues in the *combined component graph*.
Here, for a subset $X\subseteq\mathbb{R}^{2}$, we denote by $D_{\epsilon}(X)=\{y\in\mathbb{R}^{2}\mid\exists x\in X\colon\ \|x-y\|_{\infty}
\leq\epsilon\}$.
Note that $F_{\epsilon}(I)$ deformation retracts onto $F(I)$ and $B(I)$ deformation retracts onto $B_{\epsilon}(I)$.

#### Combined component graph

Based on an overlay of a binarized prediction $P\in\{0,1\}^{h\times w}$ and its ground truth segmentation $G\in\{0,1\}^{h\times w}$, we can cover the CW-complex $\widetilde{C}$ by four subspaces:

- 1.
$\operatorname{TP}=F_{\epsilon}(P)\cap F_{2\epsilon}(G)$ (*true positive*),
- 2.
$\operatorname{TN}=B_{\epsilon}(P)\cap B_{2\epsilon}(G)$ (*true negative*),
- 3.
$\operatorname{FN}=B_{\epsilon}(P)\cap F_{2\epsilon}(G)$ (*false negative*),
- 4.
$\operatorname{FP}=F_{\epsilon}(P)\cap B_{2\epsilon}(G)$ (*false positive*).

Each of these subspaces decomposes into connected components $\operatorname{TP}_{1},\ldots,\operatorname{TP}_{k}$, $\operatorname{TN}_{1},\ldots,\operatorname{TN}_{l}$, $\operatorname{FN}_{1},\ldots,\operatorname{FN}_{m}$, $\operatorname{FP}_{1},\ldots,\operatorname{FP}_{n}$, which form the vertices of the *combined component graph* $\mathcal{G}(P,G)$.
Furthermore, we add an edge between two vertices of $\mathcal{G}(P,G)$ if and only if their closure intersects nontrivially.

The combined component graph $\mathcal{G}(P,G)$ combines the information of ground truth and predicted segmentation.
Since we use the thickened foregrounds and thinned out backgrounds (for visualization, see Figure 7), $\mathcal{G}(P,G)$ is a bipartite graph whose edges only occur between vertices contained in $\operatorname{T}=\operatorname{TP}\cup\operatorname{TN}$ and $\operatorname{F}=\operatorname{FP}\cup\operatorname{FN}$.
Figure 2 visualizes $\mathcal{G}(P,G)$ (bottom right) for a given prediction and ground truth segmentation (top left). The component graphs $\mathcal{G}(P)$ and $\mathcal{G}(G)$ are quotients of $\mathcal{G}(P,G)$ that can be obtained by contracting all edges incident to nodes with the same label with respect to the respective image.
Within $\mathcal{G}(P,G)$, it is possible to identify critical components of the prediction that represent topological errors in the segmentation.

### 2.2 Identifying topologically critical components

Given $\mathcal{G}(P,G)$, our goal is to find a set $\mathcal{V}_{c}$ of *critical* vertices, whose pixels must be adjusted to guarantee the same homotopy type for prediction and ground truth.
Correcting the complete set of incorrectly classified vertices

$$ $\mathcal{V}_{\operatorname{F}}=\{v\in\mathcal{V}(\mathcal{G}(P,G)):v\subseteq \operatorname{F}\}$ (1) $$

forces equality of ground truth and prediction.
However, a loss that is defined based on this relabeling is similar to a pixel-wise loss and does not focus on topologically critical components over topologically irrelevant components.
Therefore, we aim to identify all vertices $\mathcal{V}_{r}\subseteq\mathcal{V}_{\operatorname{F}}$ whose labeling is irrelevant for the homotopy type of the prediction and exclude them from $\mathcal{V}_{c}$ to emphasize the importance of topological errors.
In $\mathcal{G}(P,G)$, those vertices can be characterized as vertices that have exactly one correctly classified foreground neighbor and exactly one correctly classified background neighbor.
We define the regular vertices

$$ $\mathcal{V}_{r}=\{v\in\mathcal{V}_{\operatorname{F}}\mid(\exists!\ s\in \mathcal{N}_{\mathcal{G}(P,G)}(v):\ s\subseteq\operatorname{TP})\land(\exists! \ t\in\mathcal{N}_{\mathcal{G}(P,G)}(v):\ t\subseteq\operatorname{TN})\}.$ (2) $$

Here, $\mathcal{N}_{\mathcal{G}(P,G)}(v)$ denotes the neighboring vertices of $v$ in $\mathcal{G}(P,G)$.
We provide an intuition for this definition in the Supplementary Material (see Figure 8).

### 2.3 Component graph loss

After excluding the regular vertices $\mathcal{V}_{r}$, which are incorrectly classified but irrelevant for the topology of the prediction, the set of critical vertices is given by

$$ $\mathcal{V}_{c}=\mathcal{V}_{\operatorname{F}}\setminus{\mathcal{V}_{r}}$ (3) $$

and a loss can be created from the remaining incorrectly classified vertices in this set.

We calculate the loss of a single vertex as the average score of the predicted class among all its pixels ($\bar{y}_{v}$).
The combined loss is the sum of all loss terms from the individual regions.
Notably, the loss aggregation for each vertex in $\mathcal{V}_{r}$ remains a design choice and can be adjusted to the particularities of any target task. With the design choices described above, the loss $\mathcal{L}_{CG}$ can be denoted as

$$ $\mathcal{L}_{CG}=\alpha\sum_{v\in\mathcal{V}_{c}}\bar{y}_{v}$ (4) $$

where $\alpha$ is a factor to balance $\mathcal{L}_{CG}$ with a pixel-wise loss term.
In this formulation, all pixels that constitute the component of a vertex contribute to the loss via their class score.

### 2.4 Topological Guarantees of the component graph loss

By definition, our loss formulation drops to zero if and only if the set of critical vertices is empty,
either because no misclassified vertices remain or because all misclassified vertices in $\mathcal{G}(P,T)$ are regular.
We obtain the following proposition

###### Proposition 2.1 .

If $\mathcal{L}_{CG}(P,G)=0$, then the commutative diagram

$$ ${{F_{\epsilon}(P)}}$ ${{F_{\epsilon}(P)\cap F_{2\epsilon}(G)}}$ ${{F_{\epsilon}(P)\cup F_{2\epsilon}(G)}}$ ${{F_{2\epsilon}(G)}}$ $\scriptstyle{\simeq}$ $\scriptstyle{\simeq}$ $\scriptstyle{\simeq}$ $\scriptstyle{\simeq}$ $$

consists of deformation retractions.

Figure: Figure 3: Inclusion diagrams for two exemplary prediction label pairs (a) and (b). For example in (a), all the inclusions are homotopy equivalences, which corresponds to the absence of critical nodes in $\mathcal{G}(P,G)$. In example (b), none of the inclusions are homotopy equivalences, which corresponds to the presence of critical nodes in $\mathcal{G}(P,G)$.
Refer to caption: x3.png

We sketch a proof of the fact that the inclusion $F_{\epsilon}(P)\cap F_{2\epsilon}(G)\hookrightarrow F_{\epsilon}(P)$ is a deformation retraction. The following proof by induction can be applied similarly to the other inclusions.

*Sketch of proof.* First note that $F_{\epsilon}(P)\cap F_{2\epsilon}(G)=\operatorname{TP}$ and $F_{\epsilon}(P)=\operatorname{TP}\sqcup\operatorname{FP}$.
We will prove the statement by induction on the number of regular vertices in $\mathcal{G}(P,G)$ that are contained in $\operatorname{FP}$.
For 0 0 regular vertices, $F_{\epsilon}(P)\cap F_{2\epsilon}(G)=F_{\epsilon}(P)$ holds and $F_{\epsilon}(P)\cap F_{2\epsilon}(G)\hookrightarrow F_{\epsilon}(P)$ is trivially a deformation retraction.
So assume that $\operatorname{FP}$ contains $n>0$ regular vertices, $\operatorname{FP}_{1},\ldots,\operatorname{FP}_{n}$.
By induction hypotheses, the space $X=\operatorname{TP}\sqcup\bigl{(}\bigsqcup_{i=1,\ldots,n-1}\operatorname{FP}_{
i}\bigr{)}$ deformation retracts onto $\operatorname{TP}$.
Hence, it remains to show that $\operatorname{TP}\sqcup\operatorname{FP}$ deformation retracts onto $X$.
Since we consider thickened foregrounds and thinned out backgrounds, the closure of any connected component of $\operatorname{FP}$ is homeomorphic to a closed disk $D^{2}$ with finitely many open balls $B^{2}$ cut out.
By our assumption that $\operatorname{FP}_{n}$ is regular, it has exactly one neighbor $\operatorname{TP}_{i}$ contained in $\operatorname{TP}$ and exactly one neighbor $\operatorname{TN}_{j}$ contained in $\operatorname{TN}$.
Furthermore, it cannot have any additional neighbors, since $\mathcal{G}(P,G)$ is bipartite.
Therefore, it has exactly two neighbors, which are connected subsets of $\mathbb{R}^{2}$, and we conclude that it can be at most one ball that is cut out of the disk.
We distinguish two cases:

[Uncaptioned image]: x4.png

*Case 1*:
In case the closure of $\operatorname{FP}_{n}$ is homeomorphic to $D^{2}$, its boundary is homeomorphic to $S^{1}$ and is divided into two connected parts: a shared boundary with $\operatorname{TP}_{i}$ and a shared boundary with $\operatorname{TN}_{j}$.
This follows by connectedness of $TP_{i}$ and $TN_{j}$.
Hence, without loss of generality, we can assume that the northern hemisphere of $S^{1}$ is the shared boundary with $\operatorname{TP}_{i}$ and the southern hemisphere is the shared boundary with $\operatorname{TN}_{j}$.
Then clearly $\operatorname{TP}\sqcup\operatorname{FP}$ deformation retracts onto $X$ by pushing the shared boundary of $\operatorname{FP}_{n}$ with $\operatorname{TN}_{j}$ along the disk onto the shared boundary of $\operatorname{FP}_{n}$ with $\operatorname{TP}_{i}$.

[Uncaptioned image]: x5.png

*Case 2*:
In case the closure of $\operatorname{FP}_{n}$ is homeomorphic to an annulus $D^{2}\setminus B^{2}$, its boundary is homeomorphic to two copies of $S^{1}$.
One of those is the shared boundary with $\operatorname{TP}_{i}$, and the other one is the shared boundary with $\operatorname{TN}_{j}$.
This time, we can push the shared boundary with $\operatorname{TN}_{j}$ through the annulus to the shared boundary with $TP_{i}$ to see that $\operatorname{TP}\sqcup\operatorname{FP}$ deformation retracts onto $X$.
∎

As an immediate consequence of this deformation retractions, $\mathcal{L}_{CG}=0$ implies that the *BM error* (Stucki et al. ()) is 0 0 too.
This is because homotopy equivalences induce isomorphisms in homology and, therefore, the obtained *induced matchings* will match identical intervals of the respective barcodes.
Therefore, $\mathcal{L}_{CG}$ is a more sensitive loss function than the *BM loss*.
Similar to *Betti Matching*, our approach does not only consider the topological spaces represented by images, but also takes the natural inclusions that connect them into account.
While Betti Matching uses induced matchings of persistence barcodes to compare prediction and label with respect to the inclusions into their union, $\mathcal{L}_{CG}$ also considers the inclusions of their intersection, see Figure 3.

###### Proposition 2.1 .

### 2.5 DIU Metric

We propose a new metric that describes the Discrepancy between Intersection and Union (DIU) as a strict measure for topological accuracy. The metric is based on the linear map $i_{*}:H_{*}(F_{\epsilon}(P)\cap F_{2\epsilon}(G))\to H_{*}(F_{\epsilon}(P)\cup
F
_{2\epsilon}(G))$ in homology (with coefficients in the field with two elements, $\mathbb{F}_{2}$) induced by the inclusion $i:F_{\epsilon}(P)\cap F_{2\epsilon}(G))\to F_{\epsilon}(P)\cup F_{2\epsilon}(G)$ of the intersection into the union.
Formally, $\xi^{err}$ is defined as

$$ $\displaystyle\xi^{err}=\dim(\ker i_{*})+\dim(\operatorname{coker}i_{*}).$ (5) $$

By Alexander duality, this quantity can be expressed purely in terms of connected components (homology in degree 0 0) of foreground and background.
Writing
$j:B_{\epsilon}(P)\cap B_{2\epsilon}(G)\to B_{\epsilon}(P)\cup B_{2\epsilon}(G)$ of the intersection of backgrounds into their union.
We have

$$ $\displaystyle\dim(\ker i_{1})$ $\displaystyle=\dim(\operatorname{coker}j_{0}),$ (6) $\displaystyle\dim(\operatorname{coker}i_{1})$ $\displaystyle=\dim(\ker j_{0}).$ (7) $$

Thus, we have

$$ $\displaystyle\xi^{err}$ $\displaystyle=\dim(\ker i_{0})+\dim(\operatorname{coker}i_{0}),$ (8) $\displaystyle+\dim(\ker j_{0})+\dim(\operatorname{coker}j_{0}).$ (9) $$

Figure: Figure 4: Topological metrics for the characterization of different network predictions (b-d) with a given ground truth (a). Evaluating Betti numbers does not favor Pred. X over Y. Similarly, the Betti matching metric does not favor Y over Z. Only the DIU metric (comparing intersection (e) and union (f)) prefers the semantically favorable Y over Z.
Refer to caption: x6.png

Intuitively, the DIU metric $\xi^{err}$ counts the number of components in the union that do not have a counterpart in the intersection ($\dim(\operatorname{coker})$) and the surplus of intersection components that correspond to the same component in the union ($\dim(\ker)$). Figure 4 (d) shows an example of cases where the Betti number error and the Betti matching error both fail to capture the semantic difference between ground truth and prediction. We provide more examples of DIU metric scores in the supplementary material Figures 11 and 12.

### 2.6 Computational Complexity

Compared to 2D PH approaches ($\mathcal{O}(n\log n)$ (Edelsbrunner & Harer, )), our method’s asymptotic complexity is lower. The creation of $\mathcal{G}(P,G)$ using connected component labeling (Wu et al., ) and extraction of the node labels can be done in $O(n\cdot\alpha(n))$, where $\alpha$ is the inverse Ackermann function, upper-bounded by 5 in practice. Identifying the regular nodes depends on evaluating the node’s 1-hop neighborhood. Given the graph’s planarity, the number of edges is upper bounded by $O(n)$. Therefore, evaluating the direct neighborhood of all nodes is possible in linear time. For the final aggregation of pixel scores, every pixel is evaluated at most once, which preserves the linear complexity. In summary, our loss $\mathcal{L}_{CG}$ can be computed in linear time $O(n\cdot\alpha(n))$. Empirical evaluations on the runtime are provided in the results section; see Figure 6 and Table 2.

### 2.7 Adaptability

Our method provides a foundation for an efficient identification of topologically critical regions. Within this flexible framework, many adaptations to the method are possible. In the following, we introduce two adaptations that we found beneficial for the performance in specific tasks.

#### Aggregation Mode

Our method allows for flexible adaptation of the aggregation mode to fit task-specific needs. We show ablations on this hyperparameter in Tables 5, 6, and 7. Figure 5 shows a comparison of the dense support for the gradient that is achieved with a mean aggregation compared to the support of PH-based methods. More specialized methods can be easily implemented beyond the simple aggregations we evaluate in the ablation. Aggregations, including specific quantiles of the pixels, or aggregating distinguished points such as local maxima or saddle points, are possibilities.

#### Threshold Variation Parameter

Finally, we introduce a threshold variation parameter. This parameter $\sigma$ defines the scale of a Gaussian distribution with location $\mu=0$. This distribution is used to sample a shift parameter $x_{sh}$ to randomly alter the binarization threshold $bin_{th}=0.5+x_{sh}$. Introducing this parameter strongly enhanced our method and mitigates information loss due to the binarization step. We provide an ablation on the binarization threshold in Table 3.

## 3 Experiments

Figure: Figure 5: Visualization of the pixels that support the gradient of different losses for an exemplary label-prediction pair. The support pixels are displayed as a white overlay over the prediction. The gradient of pixel-wise loss functions (e.g. CE) is supported by every incorrectly predicted pixel. The BM gradient is supported by two pixels for every topological feature. The Topograph (ours) gradient is supported by every pixel in the incorrectly predicted and topologically relevant regions.
Refer to caption: x7.png

#### Datasets

We evaluate our method on three real-world binary and two multi-class segmentation tasks using publicly available datasets (binary: Cremi (Funke et al., ), Roads (Mnih, ), Buildings (Mnih, ); multi-class: Platelet (Guay et al., ), TopCoW (Yang et al., )). We selected tasks from different modalities with different image sizes where topological correctness represents an important characteristic, particularly in the context of downstream applications. Please refer to the supplement for more details on the used datasets. To apply the topological losses in the multiclass setting, we frame the multiclass problem as multiple binary classification problems as proposed in (Berger et al., ). This approach scales the computational complexity linearly with the number of classes compared to a single binary loss calculation of the respective loss function.

#### Baselines

In all of our experiments, we compare our method to Dice loss. This is an important baseline to validate that our loss (1) does not significantly impair pixel-wise accuracy and (2) truly improves topological correctness. Moreover, we compare our method to the task-specific clDice method (Shit et al., ) that is especially well-suited for the tubular structured roads, Cremi, and circle of Willis datasets. Next, we compare to the Mosin loss function (Mosinska et al., ), which uses a VGG’s feature representation for loss calculation. Finally, we compare to PH-based approaches. First, HuTopo proposed by (Hu et al., ), which maximizes the similarity of the predictions persistence diagram to a corresponding ground truth diagram. Second, the refined Betti matching loss, which further matches the barcodes in the persistence diagrams based on spatial correspondence.

#### Evaluation metrics

We evaluate the pixel-wise accuracy using the Dice score. To evaluate topological correctness, we report the clDice metric (Shit et al., ), the Betti number error (B0, B1) in dimensions 0 and 1, and the more refined Betti matching error (BM) (Stucki et al., ), which considers the spatial alignment of topological features in both dimensions. Furthermore, we evaluate the DIU metric, which additionally measures topological similarity between union and intersection of label and prediction pairs (see Section 2.5).

#### Training and model selection

We train a U-Net architecture (Ronneberger et al., ) with residual units from scratch and use Adam (Kingma, ) for optimization. We perform 5-fold cross-validation and evaluate on an independent test set. We perform a random hyperparameter search with 25 runs on each of the splits and select the model that has the highest balanced performance in Dice and BettiMatching score on the validation set. We report the mean performance and standard deviation on the independent test sets across the five data splits. Please refer to the supplement for specifics on the hyperparameter spaces and more details on the training. We use the paired t-test between our model and each baseline to evaluate statistically significant performance ($p$-value $<0.05$) improvements.

### 3.1 Results

#### Binary results

Our method exhibits improved topological accuracy, as shown by the best values on the DIU and BM metrics, with significant improvements compared to most baselines on the Roads dataset. Compared to loss functions such as HuTopo and Dice, we achieve significant performance improvements. Interestingly, the HuTopo baseline shows a very low B0 score and a high BM and DIU error. This observation indicates that HuTopo optimizes for the correct number of topological features but disregards spatial alignment, which is in agreement with its theoretical limitation of spatial mismatches (Stucki et al., ). Furthermore, we observe that the Dice loss yields a (naturally) high Dice and clDice score. Although this difference is insignificant, it comes at the cost of reduced topological correctness across all topological metrics. On the Roads dataset, we see that Betti Matching also achieves good DIU and BM scores, almost as low as ours, but performs worse in clDice. Specifically, the effects of a homotopy equivalence between union and intersection (achieved when minimizing our loss function, as described in Section 2.3) are especially pronounced for tubular structures (such as roads) and also typically lead to a low clDice score, as a mutual inclusion of the centerlines also implies this homotopy equivalence (see Suppl. Figure 11).
For the Cremi dataset, our methods consistently exhibits strong performance across all metrics. clDice performs comparably strong, since the tubular structure of the data is beneficial for the centerline-based loss calculation. Some of the other methods have a strong performance in one metric but worse results on other metrics.

#### Multi-class results

**Table 1: Quantitative results. Best performances indicated in bold, statistical significance underlined ($p$-value $<0.05$). Our method outperforms the baselines in strict topological metrics (DIU, BM) for all but one datasets while achieving similar Dice.**
| Dataset | Loss | DIU $\downarrow$ | BM $\downarrow$ | B0 $\downarrow$ | B1 $\downarrow$ | Dice $\uparrow$ | clDice $\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Buildings | Dice | 79.798${\scriptstyle\pm 4.70}$ | 67.101${\scriptstyle\pm 2.80}$ | 25.867${\scriptstyle\pm 2.51}$ | 1.452${\scriptstyle\pm.12}$ | .777${\scriptstyle\pm\textbf{.01}}$ | .611${\scriptstyle\pm.02}$ |
| ClDice | 80.867${\scriptstyle\pm 4.48}$ | 64.771${\scriptstyle\pm 2.37}$ | 26.188${\scriptstyle\pm 1.35}$ | 1.407${\scriptstyle\pm.06}$ | .774${\scriptstyle\pm.01}$ | .623${\scriptstyle\pm\textbf{.01}}$ |  |
| HuTopo | 86.155${\scriptstyle\pm 4.52}$ | 69.662${\scriptstyle\pm 3.36}$ | 16.062${\scriptstyle\pm\textbf{5.50}}$ | 1.481${\scriptstyle\pm.07}$ | .764${\scriptstyle\pm.01}$ | .583${\scriptstyle\pm.01}$ |  |
| BettiM. | 79.271${\scriptstyle\pm 4.24}$ | 63.310${\scriptstyle\pm 2.62}$ | 17.669${\scriptstyle\pm 2.35}$ | 1.407${\scriptstyle\pm.10}$ | .774${\scriptstyle\pm.02}$ | .605${\scriptstyle\pm.03}$ |  |
| Mosin | 81.724${\scriptstyle\pm 4.90}$ | 68.875${\scriptstyle\pm 5.15}$ | 29.157${\scriptstyle\pm 4.83}$ | 1.495${\scriptstyle\pm.08}$ | .763${\scriptstyle\pm.01}$ | .581${\scriptstyle\pm.02}$ |  |
| Ours | 77.824${\scriptstyle\pm\textbf{3.48}}$ | 62.652${\scriptstyle\pm\textbf{3.01}}$ | 20.281${\scriptstyle\pm 1.27}$ | 1.443${\scriptstyle\pm.06}$ | .769${\scriptstyle\pm.01}$ | .590${\scriptstyle\pm.02}$ |  |
| Roads | Dice | 7.313${\scriptstyle\pm.61}$ | 6.615${\scriptstyle\pm.53}$ | 1.935${\scriptstyle\pm.42}$ | 2.642${\scriptstyle\pm.17}$ | .819${\scriptstyle\pm\textbf{.01}}$ | .720${\scriptstyle\pm\textbf{.01}}$ |
| ClDice | 7.127${\scriptstyle\pm.32}$ | 5.810${\scriptstyle\pm.29}$ | 1.515${\scriptstyle\pm.21}$ | 3.058${\scriptstyle\pm.14}$ | .803${\scriptstyle\pm.01}$ | .704${\scriptstyle\pm.01}$ |  |
| HuTopo | 7.498${\scriptstyle\pm.74}$ | 6.356${\scriptstyle\pm.67}$ | 1.185${\scriptstyle\pm.62}$ | 2.683${\scriptstyle\pm.38}$ | .817${\scriptstyle\pm.01}$ | .714${\scriptstyle\pm.01}$ |  |
| BettiM. | 6.733${\scriptstyle\pm.36}$ | 5.908${\scriptstyle\pm.23}$ | 0.942${\scriptstyle\pm\textbf{.10}}$ | 2.317${\scriptstyle\pm\textbf{.08}}$ | .818${\scriptstyle\pm.01}$ | .707${\scriptstyle\pm.01}$ |  |
| Mosin | 7.221${\scriptstyle\pm.71}$ | 6.352${\scriptstyle\pm.64}$ | 1.523${\scriptstyle\pm.38}$ | 2.756${\scriptstyle\pm.11}$ | .816${\scriptstyle\pm.01}$ | .710${\scriptstyle\pm.01}$ |  |
| Ours | 6.521${\scriptstyle\pm\textbf{.47}}$ | 5.635${\scriptstyle\pm\textbf{.40}}$ | 1.212${\scriptstyle\pm.25}$ | 2.619${\scriptstyle\pm.16}$ | .817${\scriptstyle\pm.01}$ | .711${\scriptstyle\pm.01}$ |  |
| Cremi | Dice | 21.840${\scriptstyle\pm.12}$ | 10.872${\scriptstyle\pm.27}$ | 1.264${\scriptstyle\pm.12}$ | 2.936${\scriptstyle\pm.09}$ | .946${\scriptstyle\pm.01}$ | .960${\scriptstyle\pm.01}$ |
| ClDice | 21.728${\scriptstyle\pm.35}$ | 10.368${\scriptstyle\pm.13}$ | 1.296${\scriptstyle\pm.06}$ | 2.848${\scriptstyle\pm.18}$ | .944${\scriptstyle\pm.01}$ | .961${\scriptstyle\pm\textbf{.01}}$ |  |
| HuTopo | 23.192${\scriptstyle\pm.72}$ | 12.232${\scriptstyle\pm.52}$ | 1.368${\scriptstyle\pm.04}$ | 2.768${\scriptstyle\pm.17}$ | .942${\scriptstyle\pm.01}$ | .956${\scriptstyle\pm.01}$ |  |
| BettiM. | 22.832${\scriptstyle\pm.56}$ | 10.880${\scriptstyle\pm.38}$ | 0.920${\scriptstyle\pm.06}$ | 3.608${\scriptstyle\pm.33}$ | .927${\scriptstyle\pm.01}$ | .950${\scriptstyle\pm.01}$ |  |
| Mosin | 21.984${\scriptstyle\pm.37}$ | 10.944${\scriptstyle\pm.20}$ | 1.312${\scriptstyle\pm.07}$ | 2.704${\scriptstyle\pm.17}$ | .946${\scriptstyle\pm.01}$ | .960${\scriptstyle\pm.01}$ |  |
| Ours | 21.272${\scriptstyle\pm\textbf{.29}}$ | 10.392${\scriptstyle\pm.22}$ | 1.224${\scriptstyle\pm.09}$ | 2.720${\scriptstyle\pm.14}$ | .947${\scriptstyle\pm\textbf{.01}}$ | .961${\scriptstyle\pm\textbf{.01}}$ |  |
| Platelet | Dice | 14.791${\scriptstyle\pm 1.41}$ | 1.610${\scriptstyle\pm 0.19}$ | 0.640${\scriptstyle\pm 0.10}$ | 0.536${\scriptstyle\pm 0.07}$ | .752${\scriptstyle\pm\textbf{ .01}}$ | .822${\scriptstyle\pm.01}$ |
| ClDice | 50.156${\scriptstyle\pm 29.09}$ | 6.407${\scriptstyle\pm 4.08}$ | 2.949${\scriptstyle\pm 2.02}$ | 3.028${\scriptstyle\pm 2.07}$ | .728${\scriptstyle\pm.01}$ | .783${\scriptstyle\pm.02}$ |  |
| HuTopo | 11.523${\scriptstyle\pm 0.36}$ | 1.119${\scriptstyle\pm 0.05}$ | 0.372${\scriptstyle\pm 0.03}$ | 0.376${\scriptstyle\pm\textbf{0.01}}$ | .746${\scriptstyle\pm.01}$ | .823${\scriptstyle\pm.00}$ |  |
| BettiM. | 13.000${\scriptstyle\pm 1.32}$ | 1.239${\scriptstyle\pm 0.09}$ | 0.400${\scriptstyle\pm 0.03}$ | 0.451${\scriptstyle\pm 0.06}$ | .747${\scriptstyle\pm.01}$ | .826${\scriptstyle\pm.01}$ |  |
| Mosin | 11.143${\scriptstyle\pm 0.52}$ | 1.130${\scriptstyle\pm 0.06}$ | 0.356${\scriptstyle\pm\textbf{0.05}}$ | 0.407${\scriptstyle\pm 0.02}$ | .747${\scriptstyle\pm.01}$ | .835${\scriptstyle\pm.00}$ |  |
| Ours | 10.906${\scriptstyle\pm\textbf{0.26}}$ | 1.110${\scriptstyle\pm\textbf{0.04}}$ | 0.406${\scriptstyle\pm 0.02}$ | 0.376${\scriptstyle\pm\textbf{0.02}}$ | .751${\scriptstyle\pm.01}$ | .843${\scriptstyle\pm\textbf{.00}}$ |  |
| TopCoW | Dice | 15.716${\scriptstyle\pm 1.61}$ | 0.977${\scriptstyle\pm 0.89}$ | 0.722${\scriptstyle\pm 0.07}$ | 0.073${\scriptstyle\pm 0.02}$ | .729${\scriptstyle\pm.01}$ | .773${\scriptstyle\pm.01}$ |
| ClDice | 10.670${\scriptstyle\pm 1.76}$ | 0.678${\scriptstyle\pm 0.13}$ | 0.483${\scriptstyle\pm 0.11}$ | 0.049${\scriptstyle\pm\textbf{0.01}}$ | .733${\scriptstyle\pm.01}$ | .804${\scriptstyle\pm\textbf{ .02}}$ |  |
| HuTopo | 16.057${\scriptstyle\pm 6.67}$ | 0.992${\scriptstyle\pm 0.43}$ | 0.717${\scriptstyle\pm 0.33}$ | 0.092${\scriptstyle\pm 0.05}$ | .711${\scriptstyle\pm.04}$ | .758${\scriptstyle\pm.04}$ |  |
| BettiM. | 12.352${\scriptstyle\pm 0.90}$ | 0.761${\scriptstyle\pm 0.06}$ | 0.556${\scriptstyle\pm 0.06}$ | 0.064${\scriptstyle\pm 0.01}$ | .740${\scriptstyle\pm\textbf{.01}}$ | .787${\scriptstyle\pm.02}$ |  |
| Mosin | 23.534${\scriptstyle\pm 16.95}$ | 1.489${\scriptstyle\pm 0.98}$ | 1.128${\scriptstyle\pm 0.83}$ | 0.154${\scriptstyle\pm 0.07}$ | .606${\scriptstyle\pm.16}$ | .659${\scriptstyle\pm.17}$ |  |
| Ours | 10.477${\scriptstyle\pm\textbf{1.35}}$ | 0.658${\scriptstyle\pm\textbf{0.09}}$ | 0.461${\scriptstyle\pm\textbf{0.06}}$ | 0.052${\scriptstyle\pm 0.02}$ | .735${\scriptstyle\pm.01}$ | .801${\scriptstyle\pm.01}$ |  |

Figure: Figure 6: Runtime for a single loss calculation over the complete training process.
Refer to caption: x8.png

In both multiclass datasets, our method consistently surpasses all baselines in the two key topological metrics, DIU and BM score, often showing a statistically significant performance improvement. For the B0 and B1 errors, our method performs comparably or slightly below the top-performing baseline (e.g., HuTopo). However, our method’s superiority in BM score indicates that this is likely caused by spatial mismatches of topological features, which is also backed by our qualitative results (see Figures 14 and 15). Additionally, we note that our loss formulation does not compromise pixel-wise accuracy, as reflected in the Dice score, where our method matches the performance of the best baseline across both datasets, even significantly outperforming clDice and HuTopo on the Platelet dataset.

In the TopCoW dataset, which is a vessel dataset, clDice emerges as the strongest baseline. However, its specialization in tubular structures and reliance on extracting accurate centerlines leads to poor performance in the Platelet dataset, where blob-like structures with inclusions dominate. We also observe that, on the TopCoW dataset, Betti Matching yields a relatively good BM score while having a significantly worse DIU score. This observation is likely caused by Betti Matching’s weaker theoretical guarantees that do not account for homotopy equivalence between intersection and union. This difference is further underlined by Betti Matching’s significantly lower clDice score, similar to our binary experiments. In the Platelet dataset, the HuTopo baseline performs strongly, a notable contrast to its low performance on the TopCoW dataset and in binary experiments, where spatial mismatches in topological structures become more frequent.

#### Ablation on runtime

**Table 2: Computational runtime.**
| Loss | Avg. loss<br>calc. | Train<br>time |
| --- | --- | --- |
| ClDice | 9.88 ms | 1h27m |
| Mosin | 233.00 ms | 2h29m |
| Hu et al. | 602.99 ms | 3h05m |
| BettiM. | 327.64 ms | 2h46m |
| Ours | 95.94 ms | 1h53m |

We empirically measure the runtime of our loss compared to other topological losses. Figure 6 shows the time demand of different loss functions across an exemplary training run on the Platelet dataset. After a short run-in phase, our method is consistently faster than PH-based approaches and the Mosin baseline. This is also reflected in the accumulated training times in Table 2, which shows that our method saves up to one hour of training time for a single run on the Platelet dataset. For the average loss calculation, we achieve a 3-6 fold improvement compared to the PH methods.

### 3.2 Ablation on the binarization threshold variation

**Table 3: Ablation on the binarization threshold variation for the buildings dataset. Best results are in bold and second best in italics.**
| Thres.<br>Var. | DIU $\downarrow$ | BM $\downarrow$ | Dice $\uparrow$ |
| --- | --- | --- | --- |
| 0. | 51.5625 | 40.6250 | 0.80886 |
| 0.01 | 47.2500 | 37.7500 | 0.81965 |
| 0.05 | 46.1250 | 36.2500 | 0.79447 |
| 0.1 | 46.7500 | 35.5625 | 0.82555 |
| 0.2 | 47.8750 | 38.2500 | 0.80861 |
| 0.5 | 49.2500 | 36.5625 | 0.82431 |

We investigate the effect of the binarization variation parameter, described in Section 2.7 in Table 3 The results indicate that a fixed binarization without variation is inferior to additional Gaussian threshold variation. A standard deviation of 0.05 - 0.1 yields the best results.

## 4 Conclusion

This work proposes a novel framework for image segmentation to identify topologically critical regions via a component graph $\mathcal{G}(P,G)$.
Our proposed loss function improves topological accuracy over pixel-wise losses, consistently delivers state-of-the-art performance compared to other topology-preserving approaches, and is low in runtime. Formally, Topograph provides stricter topological guarantees than existing methods. Our method goes beyond ensuring homotopy equivalence between ground truth and segmentation. It further enforces homotopy equivalence to both their union and intersection through the respective inclusion maps, thereby capturing the spatial correspondence of their topological properties. Additionally, we propose a sensitive segmentation metric (DIU) capturing fine topological discrepancies which cannot be univocally captured by existing metrics.

#### Limitations and future work

PH-based methods naturally define a filtration on pixel intensities, capturing topological information across all thresholds. While binarization trades off some of this information, it significantly enhances runtime efficiency. Despite this, in many scenarios, our method surpasses PH-based methods in segmentation performance. Ablation studies on the threshold variation parameter highlight the value of including topological information beyond a fixed threshold of 0.5, with features near the binarization threshold proving particularly important in our experiments (see Table 3). Future efforts should aim to explore how our method, with its strict topological guarantees, can be integrated with filtrations to capture topological information at all thresholds, further enhancing performance in every iteration. Additionally, our framework is currently designed for 2D images, and extending the method to 3D remains a promising direction for future work.

## 5 Reproducibility

We are committed to making our work entirely reproducible for the scientific community. Our source code, released under an open-source license, is available via an anonymous public GitHub repository [https://anonymous.4open.science/r/Topograph](https://anonymous.4open.science/r/Topograph). We provide all checkpoints for all the models trained with our method and all the baselines and make them available upon request. An exemplary model checkpoint is available in the repository. All datasets used in the experiments are publicly available and are described in detail in the Supplementary Material. All applied preprocessing is documented in the code on github. We provide details on our random and equal hyperparameter search on each data-split and baseline in the main manuscript and supplement (see Table 8). We provide an extensive schematic and intuitive description of our method and proofs in the Supplementary Material. Moreover, we provide numerous qualitative examples to help the understanding of our newly presented DIU metric in Figures 11 and 12. Lastly, we provide further qualitative examples of the combined graph in Figure 10.

## Appendix A Appendix

### A.1 Schematic Topograph Loss

Figure: Figure 7: Overview of the loss calculation using our method. (1.) First, the information of prediction and ground truth is combined. Pixels with a correct prediction (purple (FG, FG), white (BG, BG)) do not influence the loss calculation. (2.) To guarantee that the prediction and ground truth foreground areas only have transversal cuts, the areas are thickened with different margins. (3) Based on a region adjacency graph of the topologically critical areas can be identified and related to the relevant pixels.
Refer to caption: x9.png

### A.2 Zero Loss Proof

Figure: Figure 8: Visual proof that a zero loss guarantees topological equivalence between ground truth and prediction. First, we present our definition of regular nodes. In the following, we prove topological equivalence in three steps using contradiction.
Refer to caption: x10.png

Figure: Figure 9: Visualization of the properties of a regular node. Only a regular node results in isomorphic contracted subgraphs after intersection and union labeling.
Refer to caption: x11.png

Figure 9 describes how errors with different neighborhoods behave under labeling according to the intersection or union. Regular nodes (exactly one correct foreground and background neighbor) result in the same graph independent of intersection and union. It follows that these nodes do not affect the isomorphism of the intersection and the union graph.

### A.3 Additional Graph Examples

Fig. 10 provides additional examples of the combined graph construction and the difference between critical and regular nodes.

Figure: Figure 10: Additional examples of our combined graph representation with critical nodes marked by a red circle and regular nodes marked by a green circle. Correctly predicted nodes are not marked. The combined graph is visualized as an overlay following the notation from Fig. 8. The three rows focus on frequent topological structures in Dimension 0 and 1 as well as two examples for Union/Intersection errors.
Refer to caption: x12.png

### A.4 DIU Examples

Fig. 11 visualizes the difference between multiple topological performance metrics and the practical implication of homotopy equivalence between union and intersection in the case of a vessel example. Fig. 12 shows comparisons between different performance metrics on further examples.

Figure: Figure 11: Comparison of different topological performance metrics on the example of tubular structure segmentation. (A) results in a Betti number (+ all stricter metrics) error since the disconnected blue vessel builds two connected components. (B) results in a Betti matching error (+ all stricter metrics) because the spatial correspondence between the blue and black vessels is not provided. (C) results in and DIU error because the two vessels lose the spatial correspondence in parts and then connect again. (D) results in a clDice score $<1$ because the overlap between the vessels does not include the skeleta in all parts.
Refer to caption: x13.png

Figure: Figure 12: Examples for comparing topological performance metrics with different strictness. In the top left and bottom right examples only the DIU metric captures a topological error. The combined graph is visualized as an overlay following the notation from Fig. 8.
Refer to caption: x14.png

### A.5 Ablation on alpha parameter

We study the effect of the loss weighting via an alpha parameter in an ablation experiment. The results, see Table 4, show that there is an optimal weighting of the parameter in combination to a pixel-wise loss.

**Table 4: Ablation on the alpha parameter. The provided results are validation scores on the TopCoW dataset. Rows where the best performance was achieved before the activation of the topological loss are marked with a star *. The best results are in bold, and the second best results are in italics.**
| Alpha | DIU $\downarrow$ | BM $\downarrow$ | B0 $\downarrow$ | B1 $\downarrow$ | Dice $\uparrow$ | clDice $\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- |
| 0.0 | 10.944 | 0.7148 | 0.5259 | 0.0704 | 0.7461 | 0.7912 |
| 0.1 | 7.1667 | 0.4815 | 0.3296 | 0.0407 | 0.7540 | 0.8238 |
| 0.2 | 6.5556 | 0.4407 | 0.3037 | 0.0407 | 0.7571 | 0.8279 |
| 0.3 | 7.6111 | 0.4926 | 0.3259 | 0.0556 | 0.7601 | 0.8293 |
| 0.4 | 7.7222 | 0.4815 | 0.3370 | 0.0556 | 0.7770 | 0.8453 |
| 0.5* | 11.3889 | 0.7148 | 0.5074 | 0.0667 | 0.7478 | 0.8047 |
| 0.6 | 7.0556 | 0.4630 | 0.3074 | 0.0815 | 0.7372 | 0.8032 |
| 0.7* | 11.3889 | 0.7148 | 0.5074 | 0.0667 | 0.7478 | 0.8047 |
| 0.8* | 11.3889 | 0.7148 | 0.5074 | 0.0667 | 0.7478 | 0.8047 |
| 0.9* | 11.3889 | 0.7148 | 0.5074 | 0.0667 | 0.7478 | 0.8047 |
| 1.0* | 11.3889 | 0.7148 | 0.5074 | 0.0667 | 0.7478 | 0.8047 |

### A.6 Ablation on the aggregation

The results of the ablations on the aggregation mode are shown in Tables 6 and 5. The results show that the aggregation mode is an influential hyperparameter with varying optima depending on the dataset. For the roads dataset, dense aggregations such as mean and root mean square (rms) that include information of all pixels in the critical region perform better than the sparse max aggregation. In the buildings dataset root mean square provides a compromise of high pixel-wise accuracy combined with good topological correctness.

**Table 5: Ablation on the aggregation type for pixels within incorrect nodes. The provided results are validation scores on the roads dataset. Best results are in bold and second best results are in italics.**
| Aggregation | DIU $\downarrow$ | BM $\downarrow$ | B0 $\downarrow$ | B1 $\downarrow$ | Dice $\uparrow$ | clDice $\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- |
| Mean | 4.70 | 3.95 | 0.40 | 1.75 | 0.90264 | 0.84036 |
| Max | 4.50 | 4.05 | 0.40 | 2.05 | 0.88350 | 0.83857 |
| RMS | 4.25 | 3.90 | 0.45 | 1.65 | 0.90137 | 0.83668 |
| Sum | 5.90 | 5.76 | 1.50 | 2.05 | 0.90140 | 0.83870 |
| CE | 4.80 | 4.00 | 0.75 | 1.75 | 0.90320 | 0.83908 |

**Table 6: Ablation on the aggregation type for pixels within incorrect nodes. The provided results are validation scores on the buildings dataset. Best results are in bold and second best results are in italics.**
| Aggregation | DIU $\downarrow$ | BM $\downarrow$ | B0 $\downarrow$ | B1 $\downarrow$ | Dice $\uparrow$ | clDice $\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- |
| Mean | 47.7500 | 37.7500 | 11.0000 | 0.3750 | 0.79831 | 0.66169 |
| Max | 45.7500 | 37.3125 | 12.1250 | 0.5625 | 0.81180 | 0.69061 |
| RMS | 48.8125 | 38.1250 | 9.1875 | 0.8125 | 0.82333 | 0.70351 |
| Sum | 49.3125 | 39.4375 | 12.2500 | 0.4375 | 0.81112 | 0.68048 |
| CE | 51.6875 | 39.0625 | 9.3125 | 0.5000 | 0.81459 | 0.70370 |

**Table 7: Ablation on the aggregation type for pixels within incorrect nodes. The provided results are validation scores on the platelet dataset. Best results are in bold and second best results are in italics.**
| Aggregation | DIU $\downarrow$ | BM $\downarrow$ | B0 $\downarrow$ | B1 $\downarrow$ | Dice $\uparrow$ | clDice $\uparrow$ |
| --- | --- | --- | --- | --- | --- | --- |
| Mean | 11.25722 | 1.18968 | 0.31548 | 0.54008 | 0.78641 | 0.86118 |
| Max | 10.86111 | 1.1496 | 0.29603 | 0.52024 | 0.77875 | 0.86652 |
| RMS | 11.66111 | 1.22381 | 0.31667 | 0.53413 | 0.77651 | 0.86383 |
| Min | 12.54722 | 1.33413 | 0.38929 | 0.53373 | 0.78872 | 0.85891 |

### A.7 Detailed Dataset Description

#### Buildings

In the buildings dataset, the aim is to segment buildings based on aerial images. The topologically interesting aspect is the number of foreground components and also the correct spatial correspondence, ensuring that, e.g., buildings are correctly identified as opposed to parking areas, roads, and other landmarks. We use the buildings dataset created by Mnih (). Our training/validation set consists of 80 images with a size of 375x375 and three color channels, the test set contains 21 images of the same size. During training, we used a random crop to a size of 128x128. The validation and test set for this dataset were split into 4 patches of size 128x128 in the 4 quadrants of the image. This results in a total of 64 validation images and 84 test images for every fold.

#### Roads

The task for the roads dataset is to provide a binary segmentation of aerial images into streets and the background. In the roads dataset the correct connectivity is the most interesting aspect. We use the dataset created by Mnih (). Our training/validation set consists of 100 images with a size of 375x375 and three color channels, the test set contains 24 images of the same size. During training, we used a random crop to a size of 128x128. The validation and test set for this dataset were split into 4 patches of size 128x128 in the 4 quadrants of the image. This results in a total of 80 validation images and 96 test images for every fold.

#### Cremi

The Cremi dataset Funke et al. () contains electron microscopy images of an adult fly brain. The segmentations consist of many closed circles of which most are connected together and thus form only a few individual connected components. The images are of size 312x312 and have just one gray-scale channel. We use 100 images for training and validation and 25 images as test set. During training we randomly crop an area of 128 x 128 per image. The validation and test set for this dataset were split into 4 patches of size 128x128 in the 4 quadrants of the image. This results in a total of 80 validation images and 100 test images for every fold.

#### Platelet

In this dataset, the aim is to segment round objects where the topology is described by ”inclusion,” e.g., a mitochondrion is always inside a cell segment. The dataset Guay et al. () contains six different classes (cell, mitochondrion, canalicular channel, alpha granule, dense granule, and dense granule core). The dataset contains 50 samples for training/validation and 25 for testing each (800$\times$800 pixels) with six classes Guay et al. (). We create overlapping patches of size 200$\times$200 during our experiments.

#### TopCoW

The goal of the circle of Willis (coW) dataset is the segmentation of the coW and the correct assignment to the 15 different vascular classes. The coW has hypoplastic and absent components across different subjects, making correct segmentation challenging Yang et al. (). We project the magentic resonance angiography scans and the labels to a 2D image and segmentation mask. We use the public MICCAI 2023 TopCoW challenge data and use 110 subjects for training/validation and 22 subjects for testing. We crop each image to a size of 100$\times$80 pixels.

### A.8 Qualitative Results

Figure: Figure 13: Qualitative results for the cremi dataset.
Refer to caption: x15.png

Figure: Figure 14: Qualitative results for the platelet dataset.
Refer to caption: x16.png

Figure: Figure 15: Qualitative results for the TopCoW dataset.
Refer to caption: x17.png

### A.9 Hyperparameter search spaces

In Table 8 we show the search space of hyperparameters for each loss method for the Cremi dataset. The hyperparameters for each run are sampled randomly from the specified distributions.

**Table 8: Hyperparameter Search Space for Different Loss Methods on Cremi dataset**
| Hyperparameter | Topograph | Dice | clDice | HuTopo | BettiMatching | Mosin |
| --- | --- | --- | --- | --- | --- | --- |
| $\alpha$ | $[0.00001,0.02]^{\beta}$ | N/A | $[0.001,0.1]^{\mathrm{u}}$ | $[0.0,0.15]^{\mathrm{u}}$ | $[0.0,0.15]^{\mathrm{u}}$ | $[0.001,0.5]^{\beta}$ |
| ClDice alpha | N/A | N/A | $[0.1,0.8]^{\mathrm{u}}$ | N/A | N/A | N/A |
| $\alpha$ warmup epochs | {20, 50, 80} | N/A | N/A | {20, 50, 80} | {20, 50, 80} | N/A |
| Learning rate | $[0.0001,0.01]^{\beta}$ |  |  |  |  |  |
| Channels | {[16, 32, 64, 128], [32, 64, 128, 256], [16, 32, 64, 128, 256], [32, 64, 128, 256, 512]} |  |  |  |  |  |
| Residual units | {2, 3, 4, 5} |  |  |  |  |  |
| Batch size | {8, 16, 32} |  |  |  |  |  |
| ^β: Log-uniform distribution, ^u: Uniform distribution |  |  |  |  |  |  |

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 8
presentation: 3
questions: Although the method demonstrates superior results in 2D, I am not convinced that it will be easy to extend to 3D, and I would like to understand the authors' intuition and thoughts about a 3D extension. The authors may want to discuss some specific challenges they anticipate in extending Topograph to 3D, and to outline potential strategies they are considering to address these challenges.

Regarding the binarization, I am wondering if it is possible to quantify or estimate how much topological information is lost through
the binarization approach compared to PH methods. Is it possible to suggest some strategy that mitigate this information loss while maintaining Topograph computational efficiency advantages?
soundness: 4
strengths: 0. The paper is clearly written and easy to understand. 

1. The paper presents **theoretical guarantees** for Topograph, demonstrating that if their novel introduced loss is zero, then there is homotopy equivalence. This means that Topograph not only guarantees homotopy equivalence between the ground truth and the segmentation, but also between their union and intersection, thus capturing the spatial correspondence of their topological properties.

2. The approach has a lower complexity than persistent-homotopy (PH) based ones, and, experimentally, a faster running time.  

3. Experimental results show that Topograph improves topological accuracy compared to pixel-based loss functions and other topology-preserving approaches, as shown by the best scores on DIU and BM metrics. At the same time, it maintains pixel-level accuracy comparable to the best benchmarks, indicating that there is no trade-off between pixel-level accuracy and topological correctness.
summary: This paper proposes a new loss function, called **Topograph**, for image segmentation, which aims to preserve the topological accuracy of predictions. The authors highlight the importance of **topological correction** in many segmentation tasks, especially in the medical domain where it is crucial for accurate diagnosis and functional analysis. The approach relies on the construction of a component graph that encodes the topological information of both the ground truth and the prediction. 

The main innovations are:
* **A DIU (Discrepancy between Intersection and Union) metric:** This new metric captures topological correctness with strict theoretical guarantees, notably by capturing the homotopy equivalence between the union and the intersection of a label/prediction pair. The DIU metric is more sensitive to fine-grained topological differences than existing metrics such as the Betti number error and the Betti matching error.
* **A graph-based loss function:** This general loss function preserves topology and can be used to train various segmentation networks. It is based on a component graph that combines topological information from the ground truth image and the prediction.
* **Computational Efficiency:** Topograph outperforms existing methods in terms of topological correction of predictions while being efficient in terms of time and resources due to its low asymptotic complexity (O(n α(n))).
weaknesses: 1. The binarization used in Topograph may result in a loss of topological information compared to PH-based methods. It might be possible to extend the construction of the component graph similarly to what is done with component trees (as defined in mathematical morphology), but it is not straightforward to do so. 

2. The method is currently limited to 2D images. Its extension to 3D images is considered, but I believe it is not obvious to do. The component graph as currently defined is difficult to extend to 3D.

---

confidence: 2
contribution: 2
initial_rating: 6
presentation: 2
questions: How does the method handle edge cases with the $\alpha$ parameter? Specifically, what is the outcome if $\alpha$ is set to 0 or to a very large value?
soundness: 2
strengths: The proposed method seems to preserve the topology of segmented regions, addressing a challenge in segmentation tasks.
summary: The authors present a method to address the segmentation problem with a focus on preserving the topology of segmented regions. They also introduce a metric for evaluating the accuracy of the predicted segmentation. The proposed approach consists of several stages: (1) The input image is binarized and overlapped with ground truth segments; (2) A graph is constructed based on this overlapped image; (3) Superpixels are created, with each node in the graph representing a superpixel; (4) A set of misclassified nodes is identified, and nodes that do not impact topological structure are removed; (5) Optimization is performed only on the nodes in this remaining set. The authors evaluate their method on multiple datasets using a range of metrics.
weaknesses: The minimization problem formulation is not well-defined (objective function, parameters, and regularization).

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: See Weakness.
soundness: 4
strengths: 1. The method proposed in this paper demonstrates a better solution for tasks emphasizing topological accuracy. 
2. Besides, a new metric aims at topology consistency is also presented showing it's advantage over previous ones.
3. With a lower asymptotic complexity, the loss introduced in this paper can be computed in linear time which make the loss easy to implement.
summary: This paper presents a method that improves the topological consistency of segmentation while preserving overall performance, like IoU. Besides, a more topologically precise metric is also introduced in this paper.
weaknesses: 1. The proposed method works well with relatively small datasets and UNet with fewer parameters. My concern is that if we have a larger dataset, can we achieve similar performance with a larger model without the implementation of Topograph?
2. In terms of binarization, this paper suggests that introducing a small random value would be helpful. But could it be beneficial if applied automatic thresholding like Otsu method?
3. In terms of DICE, Topograph seems to have similar performance with other methods. Is that indicating a tradeoff between topological critical pixels and topological irrelevant pixels?

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: Re clarity:

-- "Nontrivial" intersection of closures (p. 4 l. 190) needs to be precisely defined (i.e., please provide a formal definition) -- I guess it has to mean "not finite", otherwise there could be edges between TP and TN and the component graph would not be bipartite? This confusion is furthered by Fig. 2 (see below) where such edge is actually present (so does "nontrivial" mean non-empty after all? but how is the comp. graph bipartite then?); Also, the respective edge is not present in Fig. 3. Please clarify.

-- In Fig. 2 (bottom right) the prediction foreground appears double-thickened, while later you settle for double-thickening of ground truth foreground; this causes an edge between intersection and background in Fig. 2 which should not be there and causes confusion; The same edge is also present in Fig. 7.3 -- I do not understand why; Same holds for the edge from the rightmost (thin) FN component to the spurious component in Fig. 7.3, I do not understand why this is there -- shouldn't it go from the FN component directly to the background node? 

Re rel. work:

-- E.g., how is the DIU metric related to the common practice of counting "false split" and "false merge" errors, as commonly done for segmentation problems (cf [1] for one out of many examples where these are evaluated)? Could it be that DIU is the sum of false splits and false merges (at least for dim. 0 features?)? If not, do you see any other relation?

-- A discussion of [1] as related work appears warranted

-- Funke et al. (2018) is listed in rel. work as having a PH-based loss function, but this is not correct? Please discuss in more detail the relation of your work to their loss, which also focuses on topologically critical regions that are spatially correct

[1] https://doi.org/10.1016/j.ymeth.2016.12.013

Minor: 

-- A pointer to Fig. 11 earlier in the text would be very helpful, latest on page 6 line 297 (in addition to pointing to Fig. 3)
soundness: 3
strengths: The work provides an efficient loss that is nevertheless formally grounded, with strong topological guarantees. A comprehensive evaluation shows its strengths over existing approaches. Rich figures (also in the supplement) greatly facilitate the read.
summary: The authors present a novel loss and a novel error metric for topology-aware image segmentation. The loss reflects homotopy equivalence between union and intersection of predicted and ground truth-segmentation. It is computed by establishing a component graph on (thickened/thinned) TP, FP, TN and FN components, and identifying "regular" vs non-regular nodes in the graph, where non-regular nodes point to topology-critical, spatially meaningful pixels in the prediction which are then penalised by the loss. Computation is 3-6 times faster than for related works on persistent homology-based losses.
weaknesses: -- Some definitions are not comprehensive and some Figures appear to be not in line with the text, making the work hard to grasp (see Questions)
--> fixed post-rebuttal

-- A more thorough discussion of some related work might render the work significantly more insightful (see Questions)
--> fixed post-rebuttal

-- The authors do discuss the 2d nature of the presented approach as a limitation. However, to clearly convey the significance of this limitation, it should be mentioned in this context that their evaluation features some 3d data (evaluated as 2d slices) -- here, imposing a 2d topological loss on slices appears unsuitable / overly strict.

Meta-review: This paper proposes a topology-preserving loss for binary and multi-label image segmentation. Another contribution of this paper is a new metric for topology correctness. All four reviewers gave positive ratings of acceptance for this paper. The loss is technically sound and theoretically justified with a strong guarantee for topology preserving. In practice, using this loss does not introduce much computational overhead and can be beneficial for many segmentation networks and datasets as shown in the experiments. The loss is particularly useful in low-data regimes such as for medical images.
However, qualitative results don't show a significant difference of segmentation between the proposed method and other baselines such as using Dice loss. The AC encourages the authors to identify examples with more obvious improvement in terms of topology in the final version, and also include a discussion of extension to 3D segmentation as mentioned by the reviewer.

Decision: Accept (Spotlight)