matlab load绝对路径,如果不包含在工作目录中,也可以在Matlab中从其绝对路径加载图像(Load an image from its absolute path in Matlab als...

在Matlab中,即使图像不在工作目录下,也可以通过其绝对路径加载。问题源于`imread`和`load`函数的使用。当提供的路径不是常规字符串时,会出现错误。解决方案是确保路径是一个字符串,然后使用`imread`直接读取绝对路径的图像。
摘要由CSDN通过智能技术生成

如果不包含在工作目录中,也可以在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 ,则不需要任何转换,只需使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值