繁体   English   中英

使用“imager”包中的load.image()函数在R中加载多个图像

[英]Load more than one image in R with load.image() function from “imager” package

我想用“imager”包中提供的load.image()函数加载多个图像,但是我遇到了“找不到文件”消息的错误。 有人可以帮我解决这个问题吗?

我试图在列表中加载图像,并将此列表作为参数添加到load.image()函数,但它只能读取一个文件,因此列表是不可接受的。 在此之后我尝试使用for循环在列表中进行迭代,并从循环中添加索引作为参数,我遇到了这个问题:“wrap.url中的错误(文件,load.image.internal):文件未找到”

filenames <- list.files("~/Downloads/project", pattern="*.JPG")

for(idx in filenames) {
   load.image(idx)
   "I tried here with concatenate the idx with the path string, but with no success"
   load.image(paste("~/Downloads/project",idx))  
}

尝试将full.names = T选项添加到list.files 这会添加文件的完整路径,如果不存在,则仅返回文件名。

list.files("~/Downloads/project", pattern="*.JPG", full.names = T)

然后在你的循环中只load.image(idx)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM