Interpolate arbitrary curve to regular (x,y) grid

8 次查看(过去 30 天)
Hello,
I ran into a problem that I cannot seem to solve in an elegant way.
Say, I have a spiral-like curve which I want to map onto a regular grid (constant dx and dy values). The curve is described by a large amount of points which I want to reduce to a much smaller amount of (roughly equidistant) points.
Since many points share the same x- or y-values, however, I cannot use e.g. John D'Errico's interparc tool.
Currently, my approach is as follows:
  • Calculate the length of each line segment
  • Generate an equidistant line with the desired number of points and a total length equal to my spiral-like curve
  • Use dsearchn with my original curve and the equidistant line as inputs to determine which indices of the original curve to keep
  • Use dsearchn again with my (x,y) grid and the remaining curve from the previous step as inputs to find the grid points that are closest to the remaining curve
However, this approach has 2 problems:
  • dsearchn does not take into account uniqueness of points: some of curve points map onto the same grid point. This is something I want to avoid.
  • The shape of the original curve is only roughly preserved (fair enough), but some points are pretty much inbetween 2 grid points (nearly the same distance) and the other point would preserve the original shape much better.
I am aware that mapping a pretty smooth curve to a relatively coarse Cartesian grid may give problems, but especially the first problem is one I really want to solve and I'm pretty sure there must be a way.
Does anyone have an idea?
Thanks!
  3 个评论
Niels
Niels 2015-1-15
编辑:Niels 2015-1-15
Hi John,
Using interparc I get the following error:
Error using chckxy (line 51)
The data sites should be distinct.
Error in spline (line 54)
[x,y,sizey,endslopes] = chckxy(x,y);
Error in interparc (line 316)
spl{i} = spline(cumarc,pxy(:,i));
A quick google search tells me that this error is caused due to non-distinct x or y values (unless I misunderstood). The curve segments itself are not particularly equidistant (the closer towards the center, the denser the points get in order to preserve the shape well - see the attached picture) and my goal is to maybe avoid my main problem by obtaining coordinates for points that were not in my original curve.
The real problem still is, however, the fact that dsearchn interpolates different points from my curve to the same grid coordinates.
Niels
Niels 2015-1-19
Up to now I have not been able to find a good solution for my problem.
To sum up all the above; is there a way to extract a (small) number of equidistant points from a spiral-like curve (with varying line segment sizes) and subsequently distribute these points over a regular 2D grid where each of the points is assigned to a unique grid point?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geoscience 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by