在R(3.2.1)

时间:2015-07-28 22:00:08

标签: r image function matrix jpeg

如何在R(版本3.2.1)中将jpeg图像转换为矩阵?(因为此版本中没有imagedata函数)

2 个答案:

答案 0 :(得分:1)

There is a jpeg package. If it's an RGB file then you get three layers (an R array); if greyscale, you get one layer (which would be a matrix).

> img <- jpeg::readJPEG("/Volumes/BOOTCAMP/Program Files/HP/Digital Imaging/bin/hpqscimg/ZeroDevice.jpg")
> str(img)
 num [1:470, 1:580, 1:3] 1 1 1 1 1 ...

答案 1 :(得分:0)

library(EBImage)
im <- readImage("imagen.jpg")

The EBImage package is available on Bioconductor.

http://bioconductor.org/packages/release/bioc/html/EBImage.html