How to create an RGB image from three matrices in R?

I want to create an RGB image from three 2D matrices in R. I know there was a similar record for matlab , however I could not translate this problem for world R.

I tried different packages already, such as abind to create a 3D array, tried to turn it into JPEG using writeJPEG. but it didn’t work -

any help is much appreciated!

+4
source share
1 answer

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) 
+11
source

All Articles