How to interpret a RGB array in R

时光怂恿深爱的人放手 提交于 2019-12-11 06:32:40

问题


I'm having troubles with interpreting the RGB values I get from an image read in R.

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

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.

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?

Cheers, Maria


回答1:


If you want to transform values from (0,1) to (0,255), why don't you just multiply them by 255 ?

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.



来源:https://stackoverflow.com/questions/14773830/how-to-interpret-a-rgb-array-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!