griddata interpolation just within a certain distance

10 views (last 30 days)
hei, i have a point cloud from a laser scanner with about 6000000 points. i did an interpolation with
[xi yi]= meshgrid(sx:d:hx,sy:d:hy);
zi = griddata(x,y,z, xi,yi,'linear');
however, the points are not distributed equally and therefore i have some gaps. in addition the points are not supposed to be interpolated along large distances. is there a possibility to give a distance limit within points are allowed to be interpolated. fig 1: interpolation so far ..
fig 2: point cloud
appreciate the help.
;-) markus
  5 Comments
Till Robin Mieling
Till Robin Mieling on 14 Nov 2017
alright, thank you for your answers, didn't really expect any regarding the age of this thread :).
my problem is actually just that i want to visualize a relatively large point cloud by using a surface plot. however i came upon your question because i end up with surfaces being created between points that are really far away from one another.
I'm trying to use a delaunay triangulation to plot my self generated data for a surface of a cone. But at the sides i allways end up with these weird artifacts i can't seem to get rid off. Maybe you guys have an idea, but i've realized my question might be quite off topic in regards to your original question...
This is the cloud i'm trying to visualize:
And this is the surface i get
thanks for listening and have a great day :)
John D'Errico
John D'Errico on 14 Nov 2017
You get strange artifacts around the edges because a delaunay triangulation is created over the entire convex hull of the data.
If there are concave regions, then there will be long, thin triangles that connect one end of the concavity to the other. You have NO choice in this matter, if you use tool that uses a delaunay triangulation. That triangulation extends to the boundaries of the convex hull. In turn, those long, thin triangles are almost always useless for interpolation, because they connect parts of the object that are not really related to each other.
For example, try this example:
x = rand(1000,1);
y = rand(1000,1);
xt = (x-y).^2;
yt = sqrt(x+y);
tri = delaunay(xt,yt);
trimesh(tri,xt,yt)
hold on
plot(xt,yt,'bo')
Now, suppose you have some value z(xt,yt) at each data point? Any interpolation that is done by a tool that uses a delaunay triangulation will use those long thin triangles that span the concave edges. And almost always, the result will be useless garbage in those regions.
This is why I suggested the use of an alpha shape. For example, an alpha shape, with an alpha ball of radius 0.25 on that data produces a much better looking triangulation.
As you see, the garbage triangles are now gone.
In the case of the region that Markus had, with large concavities, broaching into the body of the data, one would need to carefully control the choice of alpha ball, depending on how large of a cavity it is deemed acceptable to span. Note that with scattered data, there are ALWAYS cavities that you will want to see an interpolation span.

Sign in to comment.

Answers (3)

John D'Errico
John D'Errico on 12 Nov 2017
You have large holes in your data. But your data is not well defined by the convex hull of your data. So you have this long concave edge that seems to roughly define one boundary of the data. There are also some moderately scattered data points, which are scattered away from the mass of the rest of your data. Are those holes ok to fill in?
So it is apparently ok to fill in some large holes, but not others. Computers are not very good at understanding subtle differences like that. How big must a concavity be to be no longer acceptable to interpolate over?
A solution is to use an alpha shape to determine an acceptable triangulation. The result will be a triangulation, but less than a complete convex hull. That Markus was unable to deal with a triangulation does not mean computations (like gradients) are impossible to build, merely that Markus did not know how that might be done.

jose pullarello
jose pullarello on 10 Apr 2018
Hi guys, i tried the idea to apply alphashape with alpha 0.25, but i can't add a "colormap" to this case. Do you have a suggestion to set a colormap to a alphashape? Thank you :)
jp

KAE
KAE on 19 Feb 2019
One option might be to use objective mapping such as Kirill Pankratov's implementation objmap (described here, code here). You would choose the x- and y-scales over which datapoints "influence" the final map, and the amount of error to allow at your measurement locations. It returns an error map, and you could choose to set the mapped values to zero where they exceed your choice of an error threshold. You would need to do some experimentation to see if this met your needs, and it can run slowly if the amount of data is large.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!