我希望使用plot函数获得单色图像。但它一直生成彩色图像。我甚至使用plot函数绘制了单色图像,但它们变成了一些奇怪的绿色和橙色。如何使plot函数提供单色图像?我尝试阅读getValues函数的相关内容,但由于我不是图像分析背景,发现它很难理解。似乎getBlocks()函数返回单色图像。但是否有办法只使用plot函数获取单色图像?
library(raster)
r <- raster(matrix(runif(100), 10))
plot(r)
#even below lines produce a yellow color image. i thought that they will produce a black or white square
r <- raster(matrix(rep(0,100), 10))
plot(r)