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

TL;DR

P2PFormer is a novel, end-to-end transformer architecture that extracts clean, regular building polygons from remote sensing images without any manual post-processing. By shifting the focus from pixel-level masks to geometric "primitives" (like corners and lines) and predicting their sequence directly, it achieves new state-of-the-art results on major benchmarks like CrowdAI and WHU.

What Problem Does This Paper Address?

Delineating building footprints from satellite and aerial imagery is a cornerstone of urban planning and disaster management. However, standard computer vision techniques often fall short of the "human-delineated" quality required for cartography.

Existing methods typically fall into three buckets, each with a catch:

  1. Mask-based: They produce pixel grids that require complex "vectorization" and "regularization" to look like real buildings.
  2. Contour-based: They regress a series of points, but often generate too many redundant ones, leading to jagged edges that need difficult "simplification" steps.
  3. Vertex-based: They find the corners but then require complex graph-search algorithms to figure out how to connect the dots.

The authors of P2PFormer identify a fundamental gap: the lack of a streamlined, end-to-end pipeline that directly outputs regular polygons. As shown in Figure 1, their "primitive-based" approach is the only one that completely eliminates handcrafted post-processing.

Fig. 1: Different pipelines for regular building contour extrac- tion. From top to bottom: mask-based, contour-based, vertex- based, and our proposed primitive-based pipeline. Blue trape- zoids represent networks, and green rectangles represent post- processing steps. Only the end-to-end primitive-based pipeline completely gets rid of the handcrafted post-processing.

Methods

P2PFormer follows a three-stage workflow: Detection, Primitive Segmentation, and Order Decoding.

  • Detection: A standard head (FCOS) identifies building bounding boxes.
  • Primitive Segmenter: This is the heart of the model. Instead of looking for single pixels, it looks for geometric primitives—specifically corners (defined by three points). To do this effectively, the authors introduced Group Queries. In a typical Transformer, one query might struggle to focus on multiple distant endpoints of a line or corner simultaneously. P2PFormer uses a group of queries that share a single position embedding, allowing the model to "see" the entire primitive structure at once.
  • Implicit Position Update: The model dynamically updates the query position embeddings during the decoding process, sharpening the focus on the correct geometric midpoints.
  • Order Decoder: Once the primitives are found, a simple transformer-based decoder treats the sequencing of these primitives as a classification problem. It predicts the relative order (e.g., clockwise) of each corner to assemble the final polygon.
Fig. 2: Overall pipeline of P2PFormer. Initially, P2PFormer detects each building. Subsequently, it carries out primitive segmentation and primitive order regression, utilizing the building feature.

Datasets

The model was evaluated on three major benchmarks:

  • CrowdAI: A massive satellite dataset with over 280,000 training images.
  • WHU: A high-quality aerial image dataset known for its precise annotations.
  • WHU-Mix: A challenging, large-scale dataset featuring diverse regions and image styles from across the globe, testing the model's ability to generalize.

Key Insights and Ideas

  • Corners > Vertices: One of the most interesting findings is that using "corners" (3-point primitives) as the base unit works significantly better than using single vertices. Corners are less likely to be completely occluded by trees or shadows, making the segmentation more robust.
  • The Power of Grouping: The "Group Query" strategy (illustrated in Figure 3) solves a common Transformer limitation. By grouping queries, the model can attend to multiple points of a single geometric feature (like the two ends of a wall) while maintaining a unified spatial reference.
  • Simplifying the Topology: By treating the connection of vertices as a simple ordering/classification problem rather than a complex graph-matching problem, the authors removed a major source of error and computational overhead found in previous state-of-the-art models like PolyWorld.
Fig. 3: Architecture of the primitive segmenter. Circles and hexagons represent group queries, while triangles denote query position embeddings. The same color signifies that they belong to the same primitive.

Key Results

P2PFormer sets a new bar for building extraction:

  • CrowdAI: It outperformed the previous state-of-the-art (PolyWorld) by 2.7 AP and a staggering 6.5 $AP_{75}$, indicating much higher precision in the final polygon shapes.
  • WHU: It achieved 72.7 mAP, surpassing both mask-based and contour-based competitors.
  • Qualitative Quality: Visually, P2PFormer produces sharp, right-angled corners that closely match manual human annotations, whereas other methods often produce "rounded" or irregular shapes.

Limitations and Future Work

While highly effective, the authors noted a few areas for improvement:

  • Internal Noise: The segmenter can sometimes be distracted by internal building features (like roof structures), leading to incorrect internal primitives.
  • Missing Pieces: If the model misses a single critical primitive, the entire contour can fail to close correctly.
  • Scale Issues: For very large buildings, the fixed-grid ROI-Align feature extraction can lose fine detail. The authors suggest that a more flexible feature extraction method could help correct points toward the true contours in these cases.

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