Reputation: 2718
I'm looking for a function to display RGB pictures represented as 3-dimensional arrays to RStudio graphics device. For example, I've read a jpeg
library(jpeg)
pic <- readJPEG(example.jpg)
str(pic)
num [1:360, 1:480, 1:3] 0.106 0.106 0.106 0.106 0.106 ...
Then how to print it to RStudioGD? The thing is that I want to do some manipulations with this array, so I want to be able to look at the picture right in RStudio.
Upvotes: 1
Views: 401
Reputation: 48241
h <- dim(pic)[1]
w <- dim(pic)[2]
plot(x = c(0, h), y = c(0, w), type = "n", xlab = "", ylab = "")
rasterImage(pic, 0, 0, h, w)
Upvotes: 3