Line segment detection algorithm in image extraction improvement study

Yuemei Ren, Lei LiJournal of Measurements in Engineering 2024

Abstract

In recent years, image processing technology has matured, yet redundant information and interference often hinder accurate extraction. This study presents an improved Line Segment Detection (IM-LSD) algorithm designed for rectangular target extraction. By utilizing RGB three-channel grayscale maps and advanced segment merging strategies, the algorithm addresses common issues like line breakage and missing segments. Experimental results on the Tu-pxiang dataset demonstrate a peak accuracy of 94.50% and an average processing time of 0.2 seconds per image. The IM-LSD algorithm shows significant advantages in extracting rectangular targets from document, text, and book images due to its high speed, low error rate, and robust anti-interference capabilities.

Introduction: The Challenge of Line Segment Detection

Line Segment Detection (LSD) is a cornerstone of computer vision, providing the geometric foundation for scene understanding. However, real-world applications—such as mobile document scanning—face significant hurdles. Uneven lighting, complex backgrounds, and varying resolutions often lead to fragmented or missing line segments in standard LSD outputs. These "broken" lines make it difficult to accurately identify the boundaries of rectangular objects like books or ID cards. Existing solutions often struggle with a trade-off between real-time performance and accuracy across diverse environments.

Methodology: The IM-LSD Workflow

The proposed IM-LSD algorithm improves upon traditional single-channel grayscale processing through a multi-stage pipeline:

1. Multi-channel Fusion and Scaling

Unlike standard methods that convert color images to a single grayscale map, IM-LSD processes the Red, Green, and Blue channels independently. This preserves contrast information that might be lost during grayscale conversion. Furthermore, the algorithm employs optimal Gaussian scaling with $\sigma = 0.6$. This "Goldilocks" scale effectively suppresses noise without sacrificing the detail of shorter line segments.

Figure 1: Diagram of the process of obtaining the line support region, showing the transition from raw image to level-lines and finally to line support regions.

2. Smart Merging and Filtering

The core improvement lies in the segment-merging strategy. Detected segments are reordered by length, and those within specific Euclidean distance thresholds are linked. Geometric constraints, including slope and angle calculations, are applied to identify parallel and perpendicular relationships. This process "heals" broken segments, reconstructing clean rectangular boundaries from fragmented data.

3. Intersection and Vertex Calculation

Finally, the algorithm calculates the intersection points of the refined lines to define the four vertices of the target rectangle, enabling precise extraction.

Experimental Setup: The Tu-pxiang Dataset

To evaluate the algorithm, the researchers introduced the Tu-pxiang dataset, comprising 2,213 images:

  • Composition: 769 books, 684 documents, and 760 cards.
  • Diversity: Images were captured using various mobile devices (vivo, Huawei, Xiaomi, iPhone) to account for different resolutions and color gamuts.
  • Ground Truth: All images were manually labeled using Labelme to provide precise vertex coordinates.

Key Insights and Results

The move to RGB three-channel detection proved critical. By maintaining separate channels until the fusion stage, the algorithm significantly reduces "line leakage" common in grayscale-only methods.

Figure 2: Illustration of the boundary rectification process, showing how fragmented segments are merged to form a clean geometric boundary.

Performance Metrics

IM-LSD was benchmarked against established methods like Kanade optical flow, MIDV, and MCMLSD:

  • Accuracy: IM-LSD achieved 94.18% accuracy, outperforming Kanade (82.34%) and standard LSD (82.21%).
  • Speed: With an average processing time of 0.2 seconds, it is significantly faster than competitors like the Linelet algorithm (0.72s).
  • Robustness: The algorithm maintained a high F-score (approx. 0.7), indicating a superior balance between precision and recall.

Conclusion and Future Work

The IM-LSD algorithm offers a high-performance solution for rectangular target extraction in document-heavy contexts. While currently optimized for straight lines, future research will explore extending these geometric constraints to curved segments and more complex polygonal shapes. Expanding the Tu-pxiang dataset to include a wider variety of object types will further enhance the algorithm's generalizability.

Summary updated

BibTeX
@article{ren2024line,
  author = {Yuemei Ren and Lei Li},
  title = {{Line segment detection algorithm in image extraction improvement study}},
  journal = {Journal of Measurements in Engineering},
  year = {2024},
  doi = {10.21595/jme.2024.23856},
}
Figure