此MATLAB语句的作用是:[M N〜] = size(imge);? [英] What is this MATLAB statement for: [M N ~] = size(imge);?

查看:56
本文介绍了此MATLAB语句的作用是:[M N〜] = size(imge);?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这句话是什么意思?

[M N ~] = size(imge);

我不明白使用此〜"的原因,并且该语句还给出了错误消息.

I don't understand the reason to use this "~", and this statement also gives an error message.

推荐答案

在2009b以后的MATLAB版本中,您可以使用波浪号(~)

In MATLAB versions since 2009b, you can use the tilde (~) to ignore outputs which you don't need. If it gives you an error, that means your version doesn't support this use of the tilde and you have to replace it with a dummy variable name as so:

[M N dummy] = size(imge);

正如Sumona解释的那样,M将包含图像中的一个或多个行,而N将包含列的数量;虚拟对象将为1(对于一张黑白图像),3(对于一张彩色图像)或任意整数(对于图像堆栈).

As Sumona explains, M will contain the number or rows in the image and N the number of columns; dummy will be 1 (for one black-and-white image), 3 (for one colour image) or an arbitrary integer (for an image stack).

通常,只有在您随后感兴趣的其他参数时才使用波浪号. size是此处的例外,因为它检查(使用nargout)应产生多少输出并相应地更改其行为,

Usually it only makes sense to use the tilde if there are other parameters you are interested afterwards. size is an exception here in that it checks (using nargout) how many outputs it should produce and changes its behavior accordingly, as documented here..

test = zeros(3,4,5);
[M N dummy] = size(test);

产生M = 3,N = 4,正如人们所期望的那样,但是

produces M=3,N=4 as one would expect, but

test = zeros(3,4,5);
[M N] = size(test);

产生M = 3,N = 20.

produces M=3,N=20.

在您的特定情况下,我假设imge是图像堆栈,并且程序员希望找出单个图像的大小,而不是找到多少.

In your particular case, I assume imge is an image stack and the programmer wanted to find out the size of the individual images, but not how many there are.

这篇关于此MATLAB语句的作用是:[M N〜] = size(imge);?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆