# \dontshow{
if(require(pixmap))
{
# }
library(pixmap)
imagelocation <- system.file("extdata", "image.pgm", package="image.ContourDetector")
image <- read.pnm(file = imagelocation, cellres = 1)
# \dontshow{
image <- image[1:100, 1:100] ## speedup to have CRAN R CMD check within 5 secs
# }
x <- image@grey * 255
contourlines <- image_contour_detector(x, Q = 2)
contourlines
plot(image)
plot(contourlines, add = TRUE, col = "red")
# \dontshow{
}
# End of main if statement running only if the required packages are installed
# }
##
## line_segment_detector expects a matrix as input
## if you have a jpg/png/... convert it to pgm first or take the r/g/b channel
# \dontshow{
if(require(magick))
{
# }
library(magick)
x <- image_read(system.file("extdata", "atomium.jpg", package="image.ContourDetector"))
x
mat <- image_data(x, channels = "gray")
mat <- as.integer(mat, transpose = TRUE)
mat <- drop(mat)
contourlines <- image_contour_detector(mat)
plot(contourlines)
# \dontshow{
}
# End of main if statement running only if the required packages are installed
# }
##
## working with a RasterLayer
##
# \dontshow{
if(require(raster))
{
# }
# \donttest{
library(raster)
x <- raster(system.file("extdata", "landscape.tif", package="image.ContourDetector"))
contourlines <- image_contour_detector(x)
image(x)
plot(contourlines, add = TRUE, col = "blue", lwd = 10)
# }
# \dontshow{
}
# End of main if statement running only if the required packages are installed
# }
Run the code above in your browser using DataLab