as.cimg.data.frame | R Documentation |
This function is meant to be just like as.cimg.data.frame, but in reverse. Each line in the data frame must correspond to a pixel. For example, the data fame can be of the form (x,y,value) or (x,y,z,value), or (x,y,z,cc,value). The coordinates must be valid image coordinates (i.e., positive integers).
## S3 method for class 'data.frame'
as.cimg(obj, v.name = "value", dims, ...)
obj |
a data.frame |
v.name |
name of the variable to extract pixel values from (default "value") |
dims |
a vector of length 4 corresponding to image dimensions. If missing, a guess will be made. |
... |
ignored |
an object of class cimg
Simon Barthelme
#Create a data.frame with columns x,y and value
df <- expand.grid(x=1:10,y=1:10) %>% dplyr::mutate(value=x*y)
#Convert to cimg object (2D, grayscale image of size 10*10
as.cimg(df,dims=c(10,10,1,1)) %>% plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.