Description Usage Arguments Value Examples
View source: R/image_detect_corners.R
An implementation of the "FAST-9" corner detection algorithm explained at <http://www.edwardrosten.com/work/fast.html>.
1 | image_detect_corners(x, threshold = 50L, suppress_non_max = FALSE)
|
x |
a matrix of image pixel values in the 0-255 range. |
threshold |
positive integer where threshold is the threshold below which differences in luminosity between adjacent pixels are ignored. Think of it as a smoothing parameter. |
suppress_non_max |
logical |
as list of the found corners with the x/y locations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | library(pixmap)
imagelocation <- system.file("extdata", "chairs.pgm", package="image.CornerDetectionF9")
image <- read.pnm(file = imagelocation, cellres = 1)
x <- image@grey * 255
corners <- image_detect_corners(x, 80)
plot(image)
points(corners$x, corners$y, col = "red", pch = 20, lwd = 0.5)
##
## image_detect_corners expects a matrix as input
## if you have a jpg/png/... convert it to pgm first or take the r/g/b channel
library(magick)
x <- image_read(system.file("extdata", "hall.jpg", package="image.CornerDetectionF9"))
x
image <- image_data(x, channels = "Gray")
image <- as.integer(image, transpose = TRUE)
image <- drop(image)
corners <- image_detect_corners(image, threshold = 80)
plt <- image_draw(x)
points(corners$x, image_info(x)$height - corners$y, col = "red", pch = 20, lwd = 0.5)
dev.off()
plt
## same but now converting to portable grey mab
f <- tempfile(fileext = ".pgm")
library(magick)
x <- image_read(system.file("extdata", "hall.jpg", package="image.CornerDetectionF9"))
x <- image_convert(x, format = "pgm", depth = 8)
image_write(x, path = f, format = "pgm")
image <- read.pnm(f, cellres = 1)
corners <- image_detect_corners(image@grey * 255, 80)
plot(image)
points(corners$x, corners$y, col = "red", pch = 20, lwd = 0.5)
file.remove(f)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.