get_coord: Get coordinates from image of points

Description Usage Arguments Value Examples

Description

Get coordinates from image of points

Usage

1
2
get_coord(input, x_ticks, y_ticks, K, K_min = K, K_max = K,
  max_pixels = 10000, plot = TRUE)

Arguments

input

Path to image or directly a Magick image.

x_ticks

Values of all ticks of the x axis.

y_ticks

Values of all ticks of the y axis.

K

Number of points in the image. Use K_min and K_max if you only know an interval.

K_min

Minimum number of points in the image.

K_max

Maximum number of points in the image.

max_pixels

Maximum number of pixels representing points.

plot

Whether to plot centers on the image? Default is TRUE.

Value

A list of coordinates. There is also an attribute "stat" which was used to guess the number of points in the image.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Create some image
file <- tempfile(fileext = ".png")
png(file, width = 600, height = 400)
plot(y <- c(0, runif(20), 1))
dev.off()

# Get coordinates
(coord <- get_coord(file, seq(5, 20, 5), seq(0, 1, 0.2),
                    K_min = 10, K_max = 30))
round(coord$x, 2)
plot(coord$y, y, pch = 20, cex = 1.5); abline(0, 1, col = "red")

# When the image is too large, you can downsize it
(coord2 <- file %>% img_read() %>% img_scale(0.7) %>%
    get_coord(seq(5, 20, 5), seq(0, 1, 0.2), K_min = 10, K_max = 30))
round(coord2$x, 2)
plot(coord2$y, y, pch = 20, cex = 1.5); abline(0, 1, col = "red")

privefl/img2coord documentation built on May 17, 2019, 10:39 a.m.