0

I have a 3d matrix with scattered points (Nx4 matrix, x-y-z-data). My aim is to link the closest points together and register each chain in an Kx4 array (x, y, z, data), K being the chain length. The total number of chains depends on the points... A particularity is that these lines only go upwards (z+), I don't want to link points on same z, or go down.

I have been trying different strategies so far, one being with another array shape (Mx4xNz - basically meaning the values were stacked per z's instead of being all on a 2d matrix): [edited after some progress, using delaunay/nearestneighbor]

  1. pick a point at level Zn
  2. go to level Zn+1, look for the closest point in a range of coordinates x,y using delaunayTriangulation and nearestNeighbor
  3. register the point into a vector

(I suspect there are other possibilities using nearestNeighbor with the Nx4 matrix, but i can't think how to 'direct' the search upwards and chain the successive points... )

I find myself with the following problem : The finding of nearest point upwards seems to work well but in 1 direction only!!

Linking doesn't work:

Linking doesn't work

Linking works:

Linking works

During the loop I have the warning : Warning: Duplicate data points have been detected and removed. The Triangulation indices are defined with respect to the unique set of points in delaunayTriangulation property X.

Lign=zeros(max_iter,4,s);

for i = 1:s;

pp_id=i; 

for  n=1:max_iter-1; 

    Wn=W(:,:,n); % W is the data 3d-matrix Mx4xNz
    Wnn=W(:,:,n+1);

    Point_n = Wn(pp_id,:); 

    xn= Point_n(1);
    yn= Point_n(2);
    zn= Point_n(3);
    vn= Point_n(4);

    if xn==0|yn==0|zn==0|vn==0;
        break
    end

    % Look for nearest neighbour at next level
    DT=delaunayTriangulation(Wnn(:,[1:2]));
    [pp_id, d]=nearestNeighbor(DT,[Point_n(1),Point_n(2)]); 

    % limit range
    if d>10 
        break
    end

    % extraction of values at new pp_id 
    Point_n=Wnn(pp_id,:);

    % register point in line
    Lign(n,:,i)=Point_n;

end

end

Anyone has an idea as to why this is happens?

mkierc
  • 1,193
  • 2
  • 15
  • 28
pcpc
  • 3
  • 2
  • Have you tried doing any clustering techniques? http://www.mathworks.com/discovery/cluster-analysis.html – rayryeng Nov 07 '14 at 16:54
  • I'm unfortunately not familiar with these. kmeans looks interesting but i'm not sure how to define the clustering rule (in my case, closest neighbour upwards, within a certain range)? – pcpc Nov 07 '14 at 17:55
  • How many points are talking about here? Dozens, hundreds, thousands? If it's small enough, a simple distance matrix would do, no? – AnonSubmitter85 Nov 07 '14 at 20:05

0 Answers0