How to interpret an RGB array in R

I'm having trouble interpreting the RGB values ​​that I get from an image read in R.

In the array, I get values ​​from 0-1 when the range of RGB colors is 0-255. I tried converting it back to a range of 0-255, adjusting the script as follows:

picturemax <- max(picture)
picturemin <- min(picture)
p.picture <- as.numeric(picture)
if (picturemax > 255 || picturemin < 0) 
p.picture <- (picture - picturemin)/(picturemax - picturemin)
p.picture

extracted 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 shows the values ​​0-1. only different.

My photo files are also very large, and the array does not fit in the R console. Since I would like to get the RGB data on an excel sheet or in a text file, I do not know what to do or how to attack this problem.

I apologize if my questions are too simple, but I'm glad for all the help I can get. Any suggestions?

Cheers, Maria

+1
source share
1 answer

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

To export your matrices as text files, which will be considered a spreadsheet or other application, you should look at the function write.table. But if your data is too large to fit into the console, I doubt that it will open in Excel or the equivalent will be very useful.

+1
source

All Articles