I want to create an RGB image from three 2D matrices in R. I know that there was a similar post for matlab, however I could not translate that problem to the R world.
I tried already different packages such as abind for creating a 3D array, tried to turn it into a JPEG with writeJPEG. but that did not work-
any help is very much appreciated!
Try with ?rgb
,
r <- matrix(runif(9, 0, 1), 3)
g <- matrix(runif(9, 0, 1), 3)
b <- matrix(runif(9, 0, 1), 3)
col <- rgb(r, g, b)
dim(col) <- dim(r)
library(grid)
grid.raster(col, interpolate=FALSE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With