How to interpolate 2d->2d data

12 views (last 30 days)
qnswi free
qnswi free on 4 Aug 2018
Commented: Adam Danz on 5 Aug 2018
I have two sets of data. The first set of data contains (x,y) coordinates of a certain number of points, and the second set of data corresponds to the (x',y') image coordinates of the (x,y) points. Is there a way to interpolate this transformation ?

Answers (1)

Adam Danz
Adam Danz on 4 Aug 2018
Your question isn't super clear but I think I understand what you want.
The first data set is (x,y) coordinates. I interpret this as a [n-by-2] matrix of [x,y] coordinates.
The 2nd data set is the same coordinates in (x',y') format which is a vector [1, n*2].
If that's correct, here's how to reshape each data set to the other format. No interpolation is needed.
% Fake data
x = [1:5]';
y = [11:15]';
set1 = [x,y];
set2 = [x',y'];
% set1 -> set2
set_2 = set1(:)'
% set2 -> set1
set_1 = reshape(set2', [], 2)
  2 Comments
qnswi free
qnswi free on 4 Aug 2018
Hi, thanks for your answer. The two sets of data are [2, n] matrix coordinates.
What I am originally trying to do is to flatten a closed polygon on the x-axis. To do so, I have a set of coordinates (x,y) that I know the 'flattened' coordinates (x', y'). Typically the set of (x,y) coordinates correspond to the medial axis and the contour of the object (see the image attached).
Then, I want to get the 'flattened' coordinate of any point within the original polygon. I first try to interpolate separately the x'(x,y) and y'(x,y) functions (using scatteredInterpolant function in matlab), but the result is not accurate in some cases where the curvature of the object is important.
I think a direct 2d->2d interpolation might solve this problem, but I don't see any way of doing this in Matlab.
Adam Danz
Adam Danz on 5 Aug 2018
That's much clearer (and different) from your question. But there are still some points to clarify. From your attached image, you have the (x,y) coordinates of the black line on the left and you have the (x2,y2) coordinates of the black line on the right, but you'd like to perform the transformations of the left coordinates to the right. Is that correct?
Could you share a minimal working example of your code? Could you also show us what's wrong with the scatteredInterpolant output?

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!