bnosac / image

Computer Vision and Image Recognition algorithms for R users
274 stars 65 forks source link

Line Segment Detector pixel matrix is 0 when union = T #8

Open srvanderplas opened 6 years ago

srvanderplas commented 6 years ago

image_line_segment_detector(img, union = T) returns a pixel matrix the size of the image with all 0 values. Ideally, this would also update when union = T so that joined lines are represented by the same number.

library(imager)
library(image.LineSegmentDetector)

im <- load.image(system.file('extdata/parrots.png', package='imager'))

im_pnm <- im %>%
  grayscale() %>%
  multiply_by(255)
im_pnm <- im_pnm[ , , 1, 1]

nounion <- image_line_segment_detector(im_pnm)
withunion <- image_line_segment_detector(im_pnm, union = T)

sum(nounion$pixels != 0) # 19414
sum(withunion$pixels != 0) # 0
jwijffels commented 6 years ago

Yes, you are right, but that is not how it is implemented by the author of LSD line segment detector (original C code is here https://github.com/theWorldCreator/LSD). If union is set to 1, pixels are untouched. I think you should post your question at that repository to get further details.