TopoRefine: Plug-and-Play Topology-Aware Contour Refinement for Building Segmentation

Buliao Huang, Yunhui zhuNeurIPS 2026

TL;DR

Foundation models like the Segment Anything Model (SAM) are fantastic at spotting buildings from satellite imagery, but they output blobby pixel masks rather than the crisp, straight-edged polygons that mapping software actually needs. Instead of cracking open and retraining these massive models to predict geometry, TopoRefine acts as a lightweight, plug-and-play post-processor that takes rough mask outlines and iteratively sculpts them—adding missing corners, deleting noisy points, and nudging coordinates—into clean, geometrically accurate building footprints.

What Problem Does This Paper Address?

If you ask a vision foundation model like SAM 3 to segment a "building" in an aerial photo, it will hand you a binary pixel mask. While impressive for zero-shot generalization, pixel-wise classification doesn't understand architectural rules—it produces wobbly boundaries, rounded corners, and fragmented edges. Downstream mapping and cadastral systems don't want blobs of pixels; they want clean, vectorized polygons (a neat list of corner vertices connected by straight lines).

Previously, researchers tackled this in two ways, neither ideal:

  1. Modifying SAM: Bolting extra polygon-prediction branches onto SAM's decoder and retraining it. This is computationally expensive, ruins plug-and-play portability, and risks degrading the very generalization that makes SAM special.
  2. Fixed-topology contour evolution: Wrapping a predefined number of points (like a digital rubber band) around the initial mask and sliding them toward the true edges. If your initial rubber band has the wrong number of corners, sliding points around won't fix the structural mismatch.
Figure 1: Comparison of visual results and paradigms for building polygonization.

The authors ask a pragmatic question: Can we leave the segmentation model completely frozen and convert its rough contours into clean, topology-accurate polygons on the fly?

Methods

TopoRefine treats contour cleanup as an iterative, topology-adaptive evolution process. Starting from a rough polygon extracted from a frozen model's mask, it refines the shape over several steps. What makes it novel is that it doesn't just shift vertices—it jointly models vertex insertion, vertex deletion, and coordinate refinement in every single iteration.

Figure 2: Overview of the proposed TopoRefine framework. At each iteration, red points indicate newly added vertices, while green crosses indicate removed vertices.

Here is how it works under the hood:

  • Dense Boundary Sampling: Neural networks dislike inputs that change size at every step. Because adding and deleting corners changes the vertex count, TopoRefine resamples the polygon edges into a fixed-length sequence of $K=128$ points per iteration, explicitly preserving existing vertices while spacing intermediate points along long edges.
  • Hybrid Local-Global Network: Each sampled point is embedded with its 2D coordinates, interpolated visual features from the upstream model, and a flag indicating whether it's currently a corner or just an edge sample. A Circular Convolution layer (standard in contour methods) scans locally for sharp turns, while a Transformer looks globally across the whole building to reason about overall structure.
  • Dynamic Supervision: Because the polygon's shape and vertex count change at each step, static ground-truth labels won't work. During training, TopoRefine dynamically matches current vertices to ground-truth corners on the fly—flagging unmatched true corners for insertion, extra clustered points for deletion, and computing coordinate offsets. Crucially, the deletion loss includes a "corner-protection" penalty so the network doesn't accidentally snip off real building corners.

Datasets

No new datasets were introduced; the authors evaluate on three standard aerial/satellite building benchmarks:

  • WHU: High-resolution aerial imagery (~450 $\text{km}^2$, >187,000 buildings), downsampled to 0.2 m/pixel.
  • SpaceNet: Satellite imagery of over 302,000 buildings across diverse urban styles in Las Vegas, Paris, Shanghai, and Khartoum.
  • Inria: Aerial images evaluated on a within-city split of the Tyrol subset (0.3 m/pixel) to test local boundary refinement rather than cross-city generalization.

Key Insights and Ideas

  • Fixed-topology deformation can actually make shapes worse: In ablations, deforming a fixed set of contour points slightly improved pixel overlap (AP) over the baseline, but decreased geometric polygon similarity (PolySim from 79.94% to 77.69%). Sliding dozens of redundant points toward a wall just creates a jagged, overcrowded edge rather than a clean architectural line.
  • Fixing existing polygonizers' blind spots: Even specialized polygon models fail in opposite ways—E2EC outputs dense, accurate boundaries with terrible corner precision (3.76% Corner F1), while BuildMapper aggressively prunes vertices and accidentally deletes real corners. Plugging TopoRefine onto the end of either pipeline fixes both failure modes simultaneously.
  • Negligible latency tax: Because it operates on lightweight 1D point sequences (128 points) rather than heavy 2D image grids, TopoRefine adds a predictable ~10–12 ms of latency on an RTX 4090, regardless of how heavy the upstream model is.

Key Results

  • Supercharging Frozen SAM 3: On WHU using simple text prompts ("building"), TopoRefine boosts SAM 3's Average Precision (AP) by +6.17% (61.67% $\rightarrow$ 67.84%), Polygon Similarity (PolySim) by +3.53%, and Corner F1 from 40.33% to 69.34%, adding just 10.38 ms of runtime.
  • Universal Plug-and-Play Gains: Adding TopoRefine consistently improves five distinct upstream pipelines—including jumping BuildMapper's AP by +21.36% (51.15% $\rightarrow$ 72.51%) and dropping SAMPolyBuild's self-intersection error rate from 11.76% down to 1.20%.
  • State-of-the-Art Performance: Paired with E2EC initial contours, TopoRefine sets top marks across all three benchmarks, hitting 74.34% AP on WHU, 50.63% AP on Inria, and 47.47% AP on SpaceNet—outperforming specialized SAM-modified decoders like SAMPolyBuild without touching upstream weights.
  • Qualitatively: Visual progressions show TopoRefine recovering narrow recessed alcoves via vertex insertion while pruning noisy roof-edge jaggedness over 3 iterations.

Limitations and Future Work

  • Garbage in, garbage out (mostly): While TopoRefine excels at fixing local structural errors and missing corners, it relies on the initial mask to find the building in the first place. If the upstream model misses most of a building, there isn't enough evidence to reconstruct it.
  • Single outer loops only: Currently, TopoRefine models each building as a single, continuous outer ring. It cannot split merged blobs into two buildings, merge fragmented pieces into one, or carve out interior courtyards (holes). Extending the topology operator to handle multi-ring and multi-component graphs is slated for future work.

Summary updated

BibTeX
@inproceedings{huang2026toporefine,
  author = {Buliao Huang and Yunhui zhu},
  title = {{TopoRefine: Plug-and-Play Topology-Aware Contour Refinement for Building Segmentation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=v8bM1HAB90},
}
Figure