Detects line segments in a digital image using the Line Segment Detector (LSD), a linear-time method that controls false detections and requires no parameter tuning. Based on Burns, Hanson, and Riseman's method with an a-contrario validation approach.
image_line_segment(
img,
index = "GRAY",
scale = 0.8,
sigma_scale = 0.6,
quant = 2,
ang_th = 22.5,
log_eps = 0,
density_th = 0.7,
n_bins = 1024,
union = FALSE,
union_min_length = 5,
union_max_distance = 5,
union_ang_th = 7,
union_use_NFA = FALSE,
union_log_eps = 0
)
A list of class lsd
containing:
n
- Number of detected line segments.
lines
- A matrix with detected segments (columns: x1, y1, x2, y2, width, p, -log_nfa).
pixels
- A matrix assigning each pixel to a detected segment (0 = unused pixels).
An Image
object.
A character string with the index to be used. Defaults to "GRAY"
.
A positive numeric value. Scales the input image before detection using Gaussian filtering. A value <1 downscales, >1 upscales. Default is 0.8.
A positive numeric value determining the Gaussian filter sigma. If scale <1, sigma = sigma_scale / scale; otherwise, sigma = sigma_scale. Default is 0.6.
A positive numeric value controlling gradient quantization error. Default is 2.0.
A numeric value (0-180) defining the gradient angle tolerance in degrees. Default is 22.5.
A numeric detection threshold. Larger values make detection stricter. Default is 0.0.
A numeric value (0-1) defining the minimum proportion of supporting points in a rectangle. Default is 0.7.
A positive integer specifying the number of bins for pseudo-ordering gradient modulus. Default is 1024.
Logical. If TRUE, merges close line segments. Default is FALSE.
Numeric. Minimum segment length to merge. Default is 5.
Numeric. Maximum distance between segments to merge. Default is 5.
Numeric. Angle threshold for merging segments. Default is 7.
Logical. If TRUE, uses NFA in merging. Default is FALSE.
Numeric. Detection threshold for merging. Default is 0.0.
Grompone von Gioi, R., Jakubowicz, J., Morel, J.-M., & Randall, G. (2010). LSD: A Fast Line Segment Detector with a False Detection Control. IEEE Transactions on Pattern Analysis and Machine Intelligence, 32(4), 722-732.tools:::Rd_expr_doi("10.5201/ipol.2012.gjmr-lsd")