如果不包含在工作目录中,也可以在Matlab中从其绝对路径加载图像(Load an image from its absolute path in Matlab also if is not included in working directory)
我有一个图像myabspath的绝对路径
D:\myimages\venus\surface\im0012.jpg
我试过了
im=imread(myabspath);
但是没有用,因为似乎imread只接受当前工作目录中的文件名。
我也试过了
f=load(myabspath);
但是得到一个错误“ Argument必须包含一个字符串 ”。
似乎是一个非常基本的操作,但遗憾的是我还没有找到解决方案。
编辑似乎问题是由myabspath不是常规字符串而不是cell ,我试图使用myabspath=cellstr(myabspath)但是我继续收到错误,告诉我myabspath不是字符串,但是如果我打电话
display(myabspath)
我看到了正确的道路。 有解决方案吗
I have the absolute path of an image myabspath
D:\myimages\venus\surface\im0012.jpg
I have tried
im=imread(myabspath);
but doesn't work because seems that imread accept only the name of a file in the current working directory.
I have also tried
f=load(myabspath);
But get an error "Argument must contain a string".
Seems a pretty basilar operation but unfortunately I haven't found the solution.
EDIT Seems that the problem is caused by the fact myabspathis not a regular String but a cell, I have tried to use myabspath=cellstr(myabspath) but I continue to receive the error that tell me that myabspath is not a string, but if I call
display(myabspath)
I see the right path. Any solution?
原文:https://stackoverflow.com/questions/30833046
2019-12-01 06:12
满意答案
如果您有一个包含String路径的cell ,则不需要任何转换,只需使用