[英]Load more than one image in R with load.image() function from “imager” package
I want to load more than one image with load.image() function provided in "imager" package, but i have got an Error with "File not found" message. 我想用“imager”包中提供的load.image()函数加载多个图像,但是我遇到了“找不到文件”消息的错误。 Could someone please help me in this problem?
有人可以帮我解决这个问题吗?
I've tried to load the images in the list, and add this list as a parameter to the load.image() function, but it can only read one file, so the list is not acceptable. 我试图在列表中加载图像,并将此列表作为参数添加到load.image()函数,但它只能读取一个文件,因此列表是不可接受的。 After this i tried to iterate in the list with a for loop, and add the index from the loop as the parameter, and i've got this problem: "Error in wrap.url(file, load.image.internal) : File not found"
在此之后我尝试使用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))
}
Try adding full.names = T
option to the list.files
. 尝试将
full.names = T
选项添加到list.files
。 This adds the full path to the file, if not present only the file name is returned. 这会添加文件的完整路径,如果不存在,则仅返回文件名。
list.files("~/Downloads/project", pattern="*.JPG", full.names = T)
then just load.image(idx)
in your loop 然后在你的循环中只
load.image(idx)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.