This is how to use the Pixmap library to read in an image as a matrix.
> library(pixmap) # the next command may only work on Linux > system("convert foo.tiff foo.ppm") > img <- read.pnm("foo.ppm")
To get info on your new object:
Although included in the previous output, the size of the image can be extracted by:
Then to extract the red channel from the image for the first ten rows:
> myextract <- [email protected][1:10,]
Or to extract the entire red channel to an actual matrix:
> red.mat<-matrix(NA,[email protected],[email protected]) > red.mat<[email protected]