bnosac / image

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

added RasterLayer method #24

Closed spono closed 3 years ago

spono commented 3 years ago

I added the RasterLayer method plus some warnings...HTH! tested and it works

jwijffels commented 3 years ago

Thanks, can you add a minimal example in the documentation and add the raster package to Suggests in the DESCRIPTION file

jwijffels commented 3 years ago

Thanks for the example. Only one thing:

if( min(x, na.rm = TRUE)>=0 & max(x, na.rm = TRUE) <=255 ){ warning("Values range between 0 and 255: Q might be set to 0")}

can we put this in image_contour_detector.RasterLayer?

What does the image represent?

spono commented 3 years ago

it's a a Canopy Height Model of a cultivated area in the lowland in the north of Italy.

BTW yes, we can move that part within the raster method, if you prefer. Reading the article on which the algo is based, it seemed good to specify that: leaving Q=2 lead me always to error, while 0solved the issue.

jwijffels commented 3 years ago

Interesting image. Just wondering do you know of any tools which can make such at canopy height model or extract lidar images from a drone with a simple camera on it?

Regarding the if( min(x, na.rm = TRUE)>=0 & max(x, na.rm = TRUE) <=255 ){ warning("Values range between 0 and 255: Q might be set to 0")} It's a bit strange to request in the documentation (https://github.com/bnosac/image/blob/master/image.ContourDetector/R/contour_detector.R#L12) to pass on a matrix with values in the 0-255 range and if you pass on such a matrix, immediately get a warning.

spono commented 3 years ago

no, not in R. But you can check Open Drone Map.

you're right about the warning...I didn't notice the specification in the help page. BTW, It can be added to warn if the values exceed that range, in case. And remove on the other side the suggestion to use Q=0

jwijffels commented 3 years ago

Feel free to add your name in the description file, I'll merge these changes after that.

spono commented 3 years ago

done. many thanks!

a curiosity: both the contour and line segment detectors identify where there is a passage between two homogeneous areas. Do you know instead a tool/approach to delineate the centre line of a -homogeneous- strip object (e.g. a road centreline)?

jwijffels commented 3 years ago

maybe look at the sf/sp/rgeos R packages?

jwijffels commented 3 years ago

I've updated the package on CRAN. https://cran.r-project.org/web/packages/image.ContourDetector Thanks again for your contribution.

spono commented 3 years ago

maybe look at the sf/sp/rgeos R packages?

Found nothing. I come from those packages and that's how I arrived here :)

Ah, just a note: (I know it's not tomorrow but) in 2024 sp/raster/rgdal/rgeos will be stopped to concentrate on sf/terra/stars. cheers!

jwijffels commented 3 years ago

Good to know, I'm getting old. sp has been around always. Where did you see that announcement?

spono commented 3 years ago

here and then it rebounced in other news

jwijffels commented 3 years ago

Right. That will impact some production systems. Thanks for the link.

jwijffels commented 3 years ago

Found nothing. I come from those packages and that's how I arrived here :)

Maybe use the magick package to do all kind of morphology operations on the road to reduce it to one line.