MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   以下冒号(:)在MATLAB语法中是什么意思? (https://www.labfans.com/bbs/showthread.php?t=24011)

poster 2019-12-10 20:48

以下冒号(:)在MATLAB语法中是什么意思?
 
a = imread('autumn.tif'); a = double(a); [row col dim] = size(a); red = a(:, :, 1); green = a(:, :, 2); blue = a(:, :, 3); 什么结肠:在过去的三线是什么意思? (以上摘录来自Dhananjay Theckedath的“ Image Processing”。)



[B]回答:[/B]

: ,在此上下文中表示“全部”。

red = a(:,:,1) 相当于

red = a(1:end,1:end,1) Matlab自动将end替换为各个维度中的元素数。

因此,如果a是23 x 55 x 3的数组,

a(:,:,1) 是

a(1:23, 1:55, 1) 这意味着,这将占用a的第一个“平面”的所有行,所有列。由于RGB图像由红色,绿色和蓝色plane (按此顺序)组成,因此a(:,:,1)是图像的红色分量。



[url=https://stackoverflow.com/questions/3955203]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:33

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.