[R] Is it possible to save raster data as a bitmap?
Vries, Pepijn de
Pepijn.deVries at wur.nl
Wed Jul 20 09:48:51 CEST 2011
I intend to use R for some image manipulations/analysis. It's relatively straightforward to read and manipulate image files in R, but I also would like to store the resulting image (after manipulation) as a bitmap image with the same resolution as the original image. Here is a simplified version of what I'm working on:
# Start example
# first open image and store as raster
logo <- system.file("images", "R.jpg", package = "RImageJ")
img <- as.raster(IJ$openImage(logo))
# do some modifications
modify <- as.raster(matrix(hsv(1, 1, 0.5 * rgb2hsv(col2rgb(img))[3,]), nrow(img), ncol(img)))
# End example
The next step in the example would be to store the raster data 'modify' as a bitmap image. I know that the 'image' function of the 'graphics' library might be usable for this purpose. However, I'm at a loss on how to maintain the exact RGB-information of each pixel using the 'image' function. Any suggestions on this issue would be most welcome. Thanks in advance!
Pepijn de Vries M.Sc.
Institute for Marine Resources and Ecosystem Studies (IMARES)
More information about the R-help