All Possible combinations of rows
Show older comments
I am trying to make a vector matrix where each column represents all possible points in an image. Here is what I want to do
s1=2160;
s2=3600;
count=1;
for i=1:s1
for j=1:s2
vector(:,count)=[j;i;1];
count=count+1;
end
end
but in a much faster way using vectorization. How do I do that ? This simple code takes about 40 seconds to run on my PC.
Answers (1)
Azzi Abdelmalek
on 18 Mar 2016
Edited: Azzi Abdelmalek
on 18 Mar 2016
[ii,jj]=meshgrid((1:s1),(1:s2));
v=[ jj(:) ii(:) ones(s1*s2,1)]';
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!