【发布时间】:2016-11-01 20:59:31
【问题描述】:
我希望将这个 for 循环向量化。这个循环是关于获取图像像素的坐标并按行顺序形成一个数组。
rows = 812; % 812x650 image
cols = 650;
n=rows*cols; % total number of pixels
index = zeros(n,2); % n coordinates of image pixels
pt_homo = zeros(3,1,n); % [x,y,1]'
k=1;
for r=1:rows
for c=1:cols
index(k,1)=c;
index(k,2)=r;
pt_homo(1,1,k) = c;
pt_homo(2,1,k) = r;
pt_homo(3,1,k) = 1;
k=k+1;
end
end
【问题讨论】:
-
什么是
n、rows、cols。 How to create a Minimal, Complete, and Verifiable example -
我的错,我编辑了问题
标签: matlab vectorization