How to interpolate 2d->2d data

12 ビュー (過去 30 日間)
qnswi free
qnswi free 2018 年 8 月 4 日
コメント済み: Adam Danz 2018 年 8 月 5 日
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 ?

回答 (1 件)

Adam Danz
Adam Danz 2018 年 8 月 4 日
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 件のコメント
qnswi free
qnswi free 2018 年 8 月 4 日
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 2018 年 8 月 5 日
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by