2

I have to generate the mesh of the 3D-point cloud. So I used the delaunay function to perform the triangulation of points. The lidar data is a result of a human head scanning.

dt = delaunay(X,Y); 
trisurf(dt,X,Y,Z);

When I used delaunay with two inputs it gives me output but not perfect. So I used three inputs (X,Y,Z)

dt = delaunay(X,Y,Z); 
trisurf(dt,X,Y,Z);

But now the result comes out worse. I don't know what the problem is?


This is the full code that I have written:

load Head_cloud_point.txt; 
data = Head_cloud_point; 

for i = 1 : 3 
    X = data(:, 1); 
end 

for i = 1 : 3 
    Y = data(:, 2); 
end 

for i = 1 : 3 
    Z = data(:, 3); 
end 

[m n] = size(X); 
[o p] = size(Y); 
[r s] = size(Z); 
[XI,YI]= meshgrid(X(m,n),Y(o,p)); 
ZI = interp2(X,Y,Z,XI,YI); 
% dt = delaunay(X,Y); 
% trisurf(dt,X,Y,ZI); 

Head_cloud_point is the file with X,Y,Z coordinates. I have to generate the mesh using these coordinates.

Andre Silva
  • 4,782
  • 9
  • 52
  • 65
  • Can you provide some code? Settings that could contribute to the issue? There isn't enough detail here, generally speaking. – Matthew Bakaitis Jun 18 '14 at 03:42
  • load Head_cloud_point.txt; data = Head_cloud_point; for i = 1 : 3 X = data(:, 1); end for i = 1 : 3 Y = data(:, 2); end for i = 1 : 3 Z = data(:, 3); end [m n]= size(X); [o p]= size(Y); [r s]= size(Z); [XI,YI]= meshgrid(X(m,n),Y(o,p)); ZI = interp2(X,Y,Z,XI,YI); % dt = delaunay(X,Y); % trisurf(dt,X,Y,ZI); This is the code. Head_cloud_point is the file with X,Y,Z coordinates. I have to generate the mesh using this coordinates, so I am using delaunay triangulation method to approach their. – user3745905 Jun 18 '14 at 04:23
  • possible duplicate of [Mesh generation from points with x, y and z coordinates](http://stackoverflow.com/questions/4882993/mesh-generation-from-points-with-x-y-and-z-coordinates) – Andre Silva Apr 20 '15 at 23:39

2 Answers2

2

Well, Delaunay is not going to do the trick directly here, neither the 2D nor the 3D version. The main reason is the way Delaunay is working. You can get some of the way, but the result is in general not going to be perfect.

You have not specified whether the poing cloud is the surface of the head, or the entire inner of the head (though another answer indicates the former).

First remember that Delaunay is going to triangulate the convex hull of the data, filling out any concavities, e.g. a C-like shape will have the inner part of the C triangulated (Ending like a mirrored D triangulation).

Assuming the point cloud is the surface of the head.

When using 2D Delaunay on all (X,Y), it can not distinguish between coordinates at the top of the head and at the bottom/neck, so it will mix those when generating the triangulation. Basically you can not have two layers of skin for the same (X,Y) coordinate.

One way to circumvent this is to split the data in a top and bottom part, probably around the height of the tip of the nose, triangulate them individually and merge the result. That could give something fairly nice to look at, though there are other places where there are similar issues, for example around the lips and ears. You may also have to connect the two triangulations, which is somewhat difficult to do.

Another alternative could be to transform the (X,Y,Z) to spherical coordinates (radius, theta, gamma) with origin in the center of the head and then using 2D Delaunay on (theta,gamma). That may not work well around the ear, where there can be several layers of skin at the same (theta,gamma) direction, where again Delaunay will mix those. Also, at the back of the head (at the coordinate discontinuity) some connections will be missing. But at the rest of the head, results are probably nice. The Delaunay triangulation in (theta, gamma) is not going to be a Delaunay triangulation in (X,Y,Z) (the circumcircle associated with each triangle may contain other point in its interior), but for visualization purposes, it is fine.

When using the 3D Delaunay using (X,Y,Z), then all concavities are filled out, especially around the tip of the nose and the eyes. In this case you will need to remove all elements/rows in the triangulation matrix that represents something "outside" the head. That seems difficult to do with the data at hand.

For the perfect result, you need another tool. Try search for something like:

meshing of surface point cloud
1

Since you have a cloud of raw data representing a 3D surface, you need to do a 3D surface interpolation to remove the noise. This will determine a function z=f(x,y) that best fits your data. To do that, you can use griddata, triscatteredinterp (deprecated) or interp2. Note: From the context of your question, I assumed you use MATLAB. [EDIT] As you indicated that your data represents a head, the surface of a head which is a spheroid, it is not a function of the form z=f(x,y). See this post concerning possible solutions to visualizing spherical surfaces http://www.mathworks.com/matlabcentral/newsreader/view_thread/2287.

Tarik
  • 10,810
  • 2
  • 26
  • 40
  • load Head_cloud_point.txt; data = Head_cloud_point; for i = 1 : 3 X = data(:, 1); end for i = 1 : 3 Y = data(:, 2); end for i = 1 : 3 Z = data(:, 3); end [m n]= size(X); [o p]= size(Y); [r s]= size(Z); [XI,YI]= meshgrid(X(m,n),Y(o,p)); ZI = interp2(X,Y,Z,XI,YI); % dt = delaunay(X,Y); % trisurf(dt,X,Y,ZI); – user3745905 Jun 18 '14 at 04:20
  • @user3745905 Please, edit your question and post your code there so that we can properly visualize it. That said, I assumed that your data represents a 3D surface that you want to visualize. Since the raw data is usually noisy, plotting it as is will probably result in an extremely uneven surface. Please, carefully consider my original answer or restate and clarify your question, providing more insight into the nature of your data and what you are trying to achieve. – Tarik Jun 18 '14 at 04:30
  • I have a point cloud of lidar for the human head which contains X,Y,Z coordinates. I want to generate the mesh of that point cloud using delaunay triangulation method. but when I am using that delaunay(X – user3745905 Jun 18 '14 at 04:37
  • See updated answer. Please, concentrate on the issue you are facing from a mathematical rather than a programming point of view. Only with the right perspective, will you indeed reach a proper solution. Again, please edit your question and post your code in there for clarity. – Tarik Jun 18 '14 at 04:56
  • Please, merge your other question that you posted with this one and delete the other to avoid duplicate efforts and waste of energy. – Tarik Jun 18 '14 at 05:07
  • thanks @Tarik, but when I am using delaunay(x,y), it generate the triangle between X and Y coordinates which gives me some of output then I tried for (x,z), its also gives output except point of Y. So when I use all of the three (x,y,z). The output is worst. So my question is if we have cloud points as X,Y,Z then how can I generate mesh using that? Do I need to go for any filtering method? – user3745905 Jun 18 '14 at 05:55
  • As I already told you, you potentially have two issues: noise, which can be solved using 3D surface interpolation and the fact that a spheroid surface not being a function can not be used as an argument to delaunay and I provided a link to possible solutions. – Tarik Jun 18 '14 at 06:01
  • You may want to use scatter3(X,Y,Z) to plot your data to get an idea of what it looks like before attempting to massage it. – Tarik Jun 18 '14 at 06:09
  • I did that, Thats y I telling you when I using delaunay(X,Y), it gives some what like scatter3 output but when i use delaunay(X,Y,Z) its gives me in tetrahedran which is not like scatter3. So what can be the problem according to you ? – user3745905 Jun 18 '14 at 06:28
  • From the code you posted, I do not see the point of using delaunay after interp2. Just plot the result of interp2 directly or alternatively dt=delaunay (x,y) followed by trisurf (dt,x,y,z) – Tarik Jun 18 '14 at 07:03
  • Bottom line: use delaunay for good quality data with little or no noise. Use interp2 or the like followed by trisurf for noisy data. – Tarik Jun 18 '14 at 07:13