P2PFormer: A Primitive-to-polygon Method for Regular Building Contour Extraction from Remote Sensing Images

Tao Zhang, Shiqing Wei, Yikang Zhou, Muying Luo, Wenling You, Shunping Ji

Introduction

Extracting accurate building footprints from satellite and aerial imagery is a foundational task in modern cartography, urban planning, and disaster response. While deep learning has significantly advanced the field, most existing models struggle to produce "regular" polygons—clean, low-vertex shapes with sharp corners that resemble human-drawn maps. Instead, they often produce "wobbly" pixel masks or overly complex contours that require extensive, handcrafted post-processing.

P2PFormer addresses this gap by introducing a novel transformer-based framework that treats building extraction as a sequence prediction problem of geometric primitives. By moving away from pixel-level segmentation and toward a primitive-to-polygon approach, P2PFormer generates clean, regularized building contours in a single end-to-end pass.

The Challenge of Regularity

Traditional approaches to building extraction generally fall into three categories, each with distinct drawbacks:

  1. Mask-based methods: These generate pixel grids that require vectorization. This process often results in jagged edges, internal holes, and a lack of geometric precision.
  2. Contour-based methods: These attempt to predict points directly along a boundary but frequently generate hundreds of redundant points, necessitating simplification algorithms like Douglas-Peucker.
  3. Vertex-based methods: These focus on identifying corners and connecting them. However, they are highly sensitive to occlusions (e.g., shadows or trees) and often rely on complex graph-search algorithms to determine the correct connection order of the vertices.

P2PFormer bypasses these issues by representing buildings as a sequence of geometric "primitives"—specifically corners—rather than isolated pixels or vertices.

Methodology

The P2PFormer architecture utilizes a streamlined three-stage pipeline designed for efficiency and geometric accuracy.

1. Detection

The process begins with a standard detector (FCOS) to identify building bounding boxes within the remote sensing imagery. This provides the localized regions of interest for subsequent geometric analysis.

2. Primitive Segmenter

At the core of the framework is the Primitive-to-Polygon (P2P) segmenter. Unlike standard DETR-style queries that target individual points, P2PFormer introduces Group Queries. In this setup, a single geometric primitive (such as a corner) is represented by a group of queries sharing a single position embedding. This allows the transformer to capture the spatial relationship between the multiple points that define a geometric feature (e.g., the three points forming a corner angle).

To further refine accuracy, the model employs an Implicit Update Strategy. This dynamically updates the query position embeddings, sharpening the model's focus on the midpoints and endpoints of building edges during the decoding process.

3. Order Decoder

One of the most significant innovations in P2PFormer is how it handles the connection of detected primitives. Rather than using unstable connection matrices or complex graph searches, the authors treat the sequence of primitives as a classification problem. The building contour is discretized into 36 "order slots." The model is then trained to assign each detected primitive to its corresponding slot in the sequence, ensuring a logical and closed polygon output.

Experimental Results

The model was rigorously evaluated on three major benchmarks, demonstrating superior performance and robustness.

  • CrowdAI: On this massive satellite dataset, P2PFormer surpassed the previous state-of-the-art (SOTA) model, PolyWorld, by 2.7 AP. Notably, it achieved a 6.5 increase in $AP_{75}$, a metric that specifically highlights the precision of the final polygon shapes.
  • WHU Building Dataset: P2PFormer outperformed traditional mask-based methods by 4.8 AP, proving that a primitive-based approach is fundamentally better suited for capturing sharp, rectilinear geometric boundaries.
  • WHU-Mix (Generalization): To test the model's ability to generalize, it was evaluated on the WHU-Mix dataset, which contains imagery from over 10 different global regions. P2PFormer maintained high accuracy across unseen cities, suggesting it has learned universal geometric principles rather than just local architectural textures.

Key Insights

  • The Power of Corners: The research demonstrates that "corners" (defined by three points) are more robust primitives than single vertices. While a single vertex can be easily obscured by shadows, a corner provides more geometric context, making it easier for the model to detect and localize.
  • Simplifying Connectivity: By framing the connection of primitives as a classification task into discretized slots, P2PFormer removes the need for handcrafted geometric rules or unstable graph-based connections.
  • End-to-End Regularization: By removing the need for post-processing simplification, the model learns the inherent regularity of buildings directly from the training data, leading to more aesthetically and geometrically pleasing results.

Limitations and Future Work

Despite its success, the authors identify several areas for further development. The model can occasionally be confused by "interior primitives"—complex roof structures or internal courtyards that are not part of the primary outer contour. Additionally, because the model uses ROI-Align with a fixed grid resolution, it may lose fine-grained detail on exceptionally large or complex architectural structures. Future research will likely explore more flexible feature extraction methods and improved handling of complex interior geometries.

Summary updated

BibTeX
@article{zhang2024p,
  author = {Tao Zhang and Shiqing Wei and Yikang Zhou and Muying Luo and Wenling You and Shunping Ji},
  title = {{P2PFormer: A Primitive-to-polygon Method for Regular Building Contour Extraction from Remote Sensing Images}},
  journal = {IEEE Trans. Geosci. Remote. Sens.},
  year = {2024},
}
Figure