PDA

查看完整版本 : 以下冒号(:)在MATLAB语法中是什么意思?


poster
2019-12-10, 20:48
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”。)



回答:

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

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)是图像的红色分量。



更多&回答... (https://stackoverflow.com/questions/3955203)