如何R中2.15 read.jpeg(how to read.jpeg in R 2.15)

2019-07-21 04:05发布

这似乎很琐碎,但我不能在JPEG或成R 2.15任何类型的图像读取。 在该R 2.10我可以用做rimage库或ReadImage库-与read.jpeg例如-但似乎没有办法做到这一点R中2.15及更高版本。 在这个有什么想法?

library('ReadImages') 
Error in library("ReadImages") : there is no package called ‘ReadImages’ > 
install.packages('ReadImages') Installing package(s) into ‘C:/Program Files/R/R-2.15.1/library’ (as ‘lib’ is unspecified) 

Warning in install.packages : package ‘ReadImages’ is not available (for R version 2.15.1) 

Answer 1:

正如在评论中指出,试试JPEG包。

install.packages("jpeg")  ## if necessary

library(jpeg)
## get help
library(help = jpeg)
## get more help
?readJPEG

例如,从帮助:

# read a sample file (R logo)
img <- readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))

另一种选择是rgdal,这可以从格式大规模的动物寓言阅读。 绘制和操作的处理方式不同。

install.packages("rgdal") ## if necessary
library(rgdal)
img <- readGDAL(file.path(R.home(), "doc", "html", "logo.jpg"))

还有在CRAN的readbitmap包,它总是值得你正在寻找一个基本的搜索软件包列表。



Answer 2:

也:

## if not already installed
install.packages("jpeg")  

library(jpeg)

?readJPEG()

img <- readJPEG("/Users/name/locationInFileDirectory/image.jpg", native = TRUE)

#this will display your image to test you read it correctly
if(exists("rasterImage")){
      plot(1:2, type='n')
      rasterImage(img,1,1,2,2)
}


文章来源: how to read.jpeg in R 2.15
标签: r import png jpeg