The image.ContourDetector R package implements Unsupervised Smooth Contour Line Detection for images.
Read in an image with values in the 0-255 range (pgm image: http://netpbm.sourceforge.net/doc/pgm.html)
library(image.ContourDetector)
library(pixmap)
<- system.file("extdata", "image.pgm", package="image.ContourDetector")
imagelocation <- read.pnm(file = imagelocation, cellres = 1)
image <- image@grey * 255
x <- image_contour_detector(x)
contourlines
contourlinesplot(image)
plot(contourlines)
If you have another type of image (jpg, png, …). Convert the image to portable grey format before applying the function
library(magick)
<- image_read(system.file("extdata", "atomium.jpg", package="image.ContourDetector"))
x <- image_data(x, channels = "gray")
mat <- as.integer(mat, transpose = TRUE)
mat <- drop(mat)
mat <- image_contour_detector(mat)
contourlines plot(contourlines)
<- image_draw(x)
plt $data$y <- image_info(x)$height - contourlines$data$y
contourlinesplot(contourlines, add = TRUE, col = "red", lwd = 3)
dev.off()
Need support in image recognition? Contact BNOSAC: http://www.bnosac.be