DeepLSD: Line Segment Detection and Refinement with Deep Image Gradients

Rémi Pautrat, Daniel Barath, Viktor Larsson, Martin R. Oswald, Marc Pollefeys · DOI

Abstract: Line segments are ubiquitous in our human-made world and are increasingly used in vision tasks. They are complementary to feature points thanks to their spatial extent and the structural information they provide. Traditional line detectors based on the image gradient are extremely fast and accurate, but lack robustness in noisy images and challenging conditions. Their learned counterparts are more repeatable and can handle challenging images, but at the cost of a lower accuracy and a bias towards wireframe lines. We propose to combine traditional and learned approaches to get the best of both worlds: an accurate and robust line detector that can be trained in the wild without ground truth lines. Our new line segment detector, DeepLSD, processes images with a deep network to generate a line attraction field, before converting it to a surrogate image gradient magnitude and angle, which is then fed to any existing handcrafted line detector. Additionally, we propose a new optimization tool to refine line segments based on the attraction field and vanishing points. This refinement improves the accuracy of current deep detectors by a large margin. We demonstrate the performance of our method on low-level line detection metrics, as well as on several downstream tasks using multiple challenging datasets.

Introduction

Line segments serve as the structural backbone of human-made environments, making them essential for high-level computer vision tasks such as 3D reconstruction, SLAM, and vanishing point estimation. Historically, researchers have faced a trade-off between two paradigms:

  1. Classical Detectors (e.g., LSD): These are highly efficient and provide sub-pixel accuracy by relying on local image gradients. However, they are "brittle," often failing in low-light, noisy, or low-contrast conditions due to a lack of global scene context.
  2. Deep Learning Detectors: These models offer high robustness, identifying lines in blurry or dark images where classical methods fail. However, they often lack precision and suffer from "wireframe bias," where they prioritize indoor structural lines (like wall corners) while ignoring generic textures.

DeepLSD bridges this gap by creating a hybrid detector that is as robust as a neural network but as precise as a handcrafted geometric algorithm.

Methodology

The core innovation of DeepLSD is its hybrid architecture. Rather than predicting line endpoints directly—a task deep networks often struggle to perform with high precision—the authors utilize a surrogate gradient approach.

Line Attraction Fields and Surrogate Gradients

The network predicts two primary maps: a Distance Field (DF), indicating the distance of every pixel to the nearest line, and an Angle Field (AF), providing the orientation of that line. These deep predictions are then converted into "surrogate" image gradients (magnitude and angle). Because classical detectors like LSD are designed to process image gradients, they can be effectively "tricked" into using the deep network's robust output as their input.

Comparison of line detection methods. DeepLSD uses a deep line distance field to generate surrogate gradients, enabling robust detection compared to classical LSD and deep HAWP.

Training and Optimization

To train the model without millions of hand-labeled lines, the authors employed a self-supervised Homography Adaptation technique. By warping unlabeled images and aggregating classical detection results across multiple views, they created high-quality "pseudo-ground truth."

Furthermore, the pipeline includes a Vanishing Point Optimization tool. This uses the geometric constraint of vanishing points (where parallel lines converge in 3D) to refine detected lines, snapping them into a more consistent and accurate structure.

Experimental Results

DeepLSD was evaluated across diverse datasets, including Wireframe (indoor), MegaDepth (outdoor), and Hypersim (synthetic). It demonstrated significant improvements over state-of-the-art methods:

  • Robustness: On the RDNIM day-night dataset, DeepLSD achieved a homography estimation score of 0.591, nearly tripling the performance of classical LSD (0.468) and far outperforming deep methods like SOLD2 (0.182).
  • 3D Reconstruction: In tests on the Hypersim dataset, DeepLSD produced cleaner and more complete models, achieving the highest recall while maintaining high precision. Unlike many deep models, it successfully distinguishes "double edges" (e.g., parallel lines on a door frame) rather than merging them.
  • Visual Localization: The method set a new record on the challenging "Stairs" scene of the 7Scenes dataset, reducing translation error to 3.1 cm.

Conclusion

DeepLSD successfully combines the pattern recognition strengths of deep learning with the geometric precision of classical algorithms. While the current pipeline faces some computational overhead—particularly in the optimization stage—and is not yet fully differentiable for end-to-end training, it represents a major step forward in robust line detection. Future work may focus on creating a differentiable version of the LSD algorithm and incorporating semantic layers to distinguish between structural edges and transient noise like shadows.

Summary updated

BibTeX
@inproceedings{pautrat2022deeplsd,
  author = {Rémi Pautrat and Daniel Barath and Viktor Larsson and Martin R. Oswald and Marc Pollefeys},
  title = {{DeepLSD: Line Segment Detection and Refinement with Deep Image Gradients}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  doi = {10.1109/cvpr52729.2023.01662},
}
Figure