如何解释R中的RGB数组 [英] How to interpret a RGB array in R
问题描述
我在解释从R中读取的图像中得到的RGB值时遇到了麻烦。
I'm having troubles with interpreting the RGB values I get from an image read in R.
我得到的数组显示0-1的值,当时RGB颜色范围为0-255。我试图将它转换回0-255范围,调整这样的脚本,
The array I get show values from 0-1, when the RGB colour range is from 0-255. I tried to convert it back to the 0-255 range adjusting a script like this,
picturemax <- max(picture)
picturemin <- min(picture)
p.picture <- as.numeric(picture)
if (picturemax > 255 || picturemin < 0)
p.picture <- (picture - picturemin)/(picturemax - picturemin)
p.picture
从 https://stat.ethz.ch/pipermail检索/r-help/2003-January/029098.html
我只是将脚本中的值从0-1更改为0-255,但数组仍显示0-1值,只是不同的值。
retrieved from https://stat.ethz.ch/pipermail/r-help/2003-January/029098.html I just change the values in the script from 0-1 to 0-255, but the array still show 0-1 values, just different ones.
我的图片文件也非常大,并且该阵列不适合R控制台。由于我想将RGB数据输入excel表或文本文件,我不知道该怎么做或如何解决这个问题。
My picture-files are also very large, and the array does not fit in the R Console. As I would like to get the RGB data in to an excel sheet or as a text file, I don't know what to do or how to attack that problem.
如果我的问题太基本,我道歉,但我很高兴能得到所有帮助。
有什么建议吗?
I apologize if my questions are too basic, but I'm happy for all the help I can get. Any suggestions?
干杯,
Maria
Cheers, Maria
推荐答案
如果要将值从(0,1)转换为(0,255),为什么不将它们乘以255?
If you want to transform values from (0,1) to (0,255), why don't you just multiply them by 255 ?
导出你的矩阵作为文本文件由电子表格或其他应用程序读取,您应该查看 write.table
函数。但是,如果你的数据太大而无法放入控制台,我怀疑在Excel中打开它们或者等效它会非常有帮助。
To export your matrices as text files to be read by a spreadsheet or another application, you should look at the write.table
function. But if your data are too large to fit in the console, I doubt opening them in Excel or an equivalent would be very helpful.
这篇关于如何解释R中的RGB数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!