index.coord | R Documentation |
Pixels are stored linearly in (x,y,z,c) order. This function computes the vector index of a pixel given its coordinates
index.coord(im, coords, outside = "stop")
im |
an image |
coords |
a data.frame with values x,y,z (optional), c (optional) |
outside |
what to do if some coordinates are outside the image: "stop" issues error, "NA" replaces invalid coordinates with NAs. Default: "stop". |
a vector of indices (NA if the indices are invalid)
Simon Barthelme
coord.index, the reverse operation
im <- as.cimg(function(x,y) x+y,100,100)
px <- index.coord(im,data.frame(x=c(3,3),y=c(1,2)))
im[px] #Values should be 3+1=4, 3+2=5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.