[英]Does anybody know how to plot a graph in R with RGB values of a core sediment image?
I have an image of a core sediment and what I want to do is to make a simple plot in R with the RGB values separately, but at the same graph.我有一个核心沉积物的图像,我想做的是在 R 中分别制作一个简单的 plot RGB 值,但在同一张图中。 Is there any advice about that?对此有什么建议吗? I attach th image file of the core.我附上了核心的图像文件。 core sediment核心沉积物
Here's one option using the png
package:这是使用png
package 的一个选项:
library(png)
img <- readPNG(readBin("https://i.stack.imgur.com/IvWI9.png", "raw", 1e6))
par(mfrow = c(1, 3))
lapply(1:3, function(i) {
image(t(img[,,i]), col = grey(seq(0, 1, length = 256)),
main = c("Red", "Green", "Blue")[i], axes = FALSE)
})
The benefit here is that each of the three channels is held as a matrix in the the first three layers of the img
array, so you can get the matrix of red values by doing:这里的好处是三个通道中的每一个都作为一个矩阵保存在img
数组的前三层中,因此您可以通过执行以下操作获得红色值的矩阵:
red <- img[,,1]
and doing the same for green (2) and blue (3)对绿色(2)和蓝色(3)做同样的事情
Created on 2020-11-28 by the reprex package (v0.3.0)由代表 package (v0.3.0) 于 2020 年 11 月 28 日创建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.