Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert a JPEG to an image matrix in R

Tags:

r

image

matrix

jpeg

I need to convert a JPEG image to a matrix. I want to run SVD on the matrix.

I had used

library(jpeg)
library(biOps)
myjpg <- readJpeg("Snapshot_1.jpg")
> dim(myjpg)
[1] 398 506   3

I want to get an image matrix of "myjpg" in grey scale preferably. Is there an R command which does that.

Thanks

like image 435
user1946217 Avatar asked Jan 11 '23 02:01

user1946217


1 Answers

You are looking for:

imagedata(myjpg, type="grey")
like image 144
Jota Avatar answered Jan 20 '23 01:01

Jota