3

我想使用绘图功能获得单色图像。但它继续产生彩色图像。我什至有使用绘图功能绘制的单色图像,并且我得到了一些奇怪的绿色和橙色。如何使绘图功能提供单色图像?我试图阅读有关 getValues 函数的信息,但发现它很难理解,因为我不是来自图像分析背景。似乎 getBlocks() 函数返回单色图像。但是有没有办法只使用绘图功能来获得单色图像?

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)
4

1 回答 1

8

如果您正在寻找颜色的灰度矢量,您可以使用gray.scale()以下col参数plot()

library(raster)
r <- raster(matrix(rnorm(100), 10))
plot(r, col = gray.colors(10, start = 0.3, end = 0.9, gamma = 2.2, alpha = NULL))

你得到果岭是plot()因为默认col使用

rev(terrain.colors(255)) 
于 2015-01-31T03:40:14.313 回答