【问题标题】:R raster package plot() producing monochrome imagesR 光栅包 plot() 产生单色图像
【发布时间】:2015-03-30 15:10:49
【问题描述】:

我想使用绘图功能获得单色图像。但它继续产生彩色图像。我什至有使用绘图功能绘制的单色图像,并且我得到了一些奇怪的绿色和橙色。如何使绘图功能提供单色图像?我试图阅读有关 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)

【问题讨论】:

  • 您生成的图像是单色的,因为它只包含黄色。您可能是指灰度。
  • 您的评论很有道理。谢谢

标签: r plot raster monochrome


【解决方案1】:

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

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

【讨论】:

  • 知道如何以原始颜色(而不是绿色和黄色)绘制我的图像吗?
猜你喜欢
  • 1970-01-01
  • 2015-07-06
  • 2015-06-29
  • 2015-03-19
  • 1970-01-01
  • 2014-09-24
  • 1970-01-01
  • 2015-09-03
  • 2020-03-27
相关资源
最近更新 更多