Detect Line Segments in Images

An implementation of the Line Segment Detector on digital images described in the paper: "LSD: A Fast Line Segment Detector with a False Detection Control" by Rafael Grompone von Gioi et al (2012). The algorithm is explained at .


image.LineSegmentDetector - Line Segment Detector for images

The image.LineSegmentDetector R package detects line segments in images.

  • It contains 1 main function image_line_segment_detector. If you give it an image matrix with grey scale values in the 0-255 range, it will find lines in the image.
  • The algorithm is defined in LSD: A Fast Line Segment Detector with a False Detection Control" by Rafael Grompone von Gioi, Jeremie Jakubowicz, Jean-Michel Morel, and Gregory Randall, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 32, no. 4, pp. 722-732, April, 2010. https://doi.org/10.5201/ipol.2012.gjmr-lsd
  • Mark that if you are looking in detecting lines, you might also be interested in https://github.com/bnosac/image/image.ContourDetector

Examples

Read in an image with values in the 0-255 range (pgm image: http://netpbm.sourceforge.net/doc/pgm.html)

library(image.LineSegmentDetector)
library(pixmap)
image <- read.pnm(file = system.file("extdata", "le-piree.pgm", package="image.LineSegmentDetector"), cellres = 1)
plot(image)
linesegments <- image_line_segment_detector(image@grey * 255)
plot(linesegments)

If you have another type of image (jpg, png, ...). Convert the image to portable grey format before applying the function

library(magick)
x   <- image_read(system.file("extdata", "atomium.jpg", package="image.LineSegmentDetector"))
mat <- image_data(x, channels = "gray")
mat <- as.integer(mat, transpose = TRUE)
mat <- drop(mat)
linesegments <- image_line_segment_detector(mat)
plot(linesegments, lwd = 2)

plt <- image_draw(x)
linesegments$lines[, "y1"] <- image_info(x)$height - linesegments$lines[, "y1"]
linesegments$lines[, "y2"] <- image_info(x)$height - linesegments$lines[, "y2"]
plot(linesegments, add = TRUE, col = "red", lwd = 2)
dev.off()

Support in image recognition

Need support in image recognition? Contact BNOSAC: http://www.bnosac.be

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("image.LineSegmentDetector")

0.1.1 by Jan Wijffels, 10 months ago


https://github.com/bnosac/image


Browse source code at https://github.com/cran/image.LineSegmentDetector


Authors: Jan Wijffels [aut, cre, cph] (R wrapper) , BNOSAC [cph] (R wrapper) , Rafael Grompone von Gioi [ctb, cph] (src/lsd)


Documentation:   PDF Manual  


AGPL-3 license


Imports Rcpp, sp

Suggests pixmap, magick

Linking to Rcpp


See at CRAN