How to interpret a RGB array in R

2019-08-03 01:49发布

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

标签: image r rgb
1条回答
Juvenile、少年°
2楼-- · 2019-08-03 02:23

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.

查看更多
登录 后发表回答