image - Vectorizing distance calculation between vectors -
i have 3 x 1000 (and later 3 x 10 000) matrix cord given, contains 3 dimensional coordinates pixels.
my intention calculate distance between pixels, , loop (see below), have calculate huge matrices soon, , wondering if vectorize code making faster...?
dist = zeros(size(cord,2),size(cord,2)); = 1:size(cord,2) j = 1:size(cord,2) dist(i,j) = norm(cord(:,i)-cord(:,j)); dist(j,i) = dist(i,j); end end
pdist that. squareform needed result in form of square, symmetric matrix:
dist = squareform(pdist(cord.')); image matlab for-loop vectorization
No comments:
Post a Comment