There are several formulas for how to do this on this link . The raster
package is one approach. This basically converts the RGB stripes into a single black and white strip (this makes it smaller in size, and I assume you want to.)
library(raster) color.image <- brick("yourjpg.jpg")
I think that the EBImage
package EBImage
also help in this problem (not on CRAN, install it through source
:
source("http://bioconductor.org/biocLite.R") biocLite("EBImage") library(EBImage) color.image <- readImage("yourjpg.jpg") bw.image <- channel(color.image,"gray") writeImage(bw.image,file="bw.png")
source share