这里有一段代码,是从一篇硕士论文上复制来的 (变量名字已经改变):
R =f (:,:,1);% take all of the first element
G =f (:,:,2);
B =f (:,:,3);
R =R(1:end);%make it into one column matrix
G =G(1:end);
B =B(1:end);
%concentrate these R,G,B into a single 3 dimensional matrix
imf =[R;G;B];
imf =imf';
其实这段代码冗长,可以简写为
imf= reshape(f, M*N, 3);
如果不使用函数 'reshape' , 代码同样可以改进:
R =R(:);%make it into one vector matrix
G =G(:);
B =B(:);
imf =[R,G,B];
英文版:
没有评论:
发表评论