How do I implement such an invertible mapping(one-to-one) for curves using MATLAB?
So that several curves X
,Y
can be mapped to another curve R
,which is invertible so that I can still get X
,Y
from R
.
Anyone has ideas for this or perhaps some term I can google it myself?
UPDATE
I think some c开发者_Go百科larifications are deserved here.
map(X,Y) => R;
invertible_map(R) => (X,Y)
I'll take a shot at this, despite my comment that your question is too vague.
My guess is that you have a space curve, corresponding to triads of points in three dimensions (X,Y,R). You wish to be able to interpolate the values of x and y, given a value of r.
If this curve is well defined for interpolation as a function of r, then just call interp1 twice. That is,
xhat = interp1(R,X,rhat);
yhat = interp1(R,Y,rhat);
Feel free to use any method in interp1 for that interpolation.
By well-defined for interpolation, I mean to say that R has no replicates and is monotone, so that for any value of the independent variable r, there is a single value that we can recover for each of x and y.
If your question is really something else, please be more specific so that I can correct my answer.
If I understand you correctly, you want to project a high-dimensional curve (2D from what I understand from your post) onto a low-dimensional space (1D). Then, you select a few points in the low-dimensional space, after which you'd like to be able to find the original high-dimensional coordinates again.
The way you state the problem, this is not possible. Whenever you make a projection onto a lower dimension, you lose all information that is perpendicular to that dimension. For example assume you plot a 3D point onto a 2D plane. If all you have is the location of the projected point in the plane, you have no way of knowing how far away from the plane it was before you did the projection.
However, if you do not throw away X
and Y
once you've calculated R
, and if you keep track of the individual elements (either by never changing the order of elements in R
, or by storing a vector of indices, that indicates for each element in R
which element in X
and Y
it corresponds to, you can always use the index vector to look up the X
and Y
coordinates of your selected points.
Thus, your pseudo-code would look like this
map(X,Y) => R,idx %# idx is optional here if it's just 1:length(X)
[re_ordered_R,re_ordered_idx] = re_order(R,idx); %# idx optional, re_ordered_idx is important
%# find interesting value of R. Interesting_idx shows where the interesting value is in
%# reordered R. An example for this would be [maxVal,maxIdx] = max(re_ordered_R);
[interesting_value_of_R,interesting_idx] = find_interesting_R(re_ordered_R);
%# look up the corresponding X and Y
interesting_X = X(re_ordered_idx(interesting_idx));
EDIT
You're either doing a projection or a coordinate transformation. If you're doing a coordinate transformation, it's easy to invert the mapping. If you're doing a projection, there is no un-mapping function.
In either case, as long as you are keeping track of the indices, i.e. as long as you know which entry in X
the i-th entry in R
corresponds to, your problem is solved.
Mapping onto a curve is most likely a projection. Say you want to map the curve defined by y=x.^2
onto the curve y1=x1
. In this case, you'd map every point of the first curve onto the closest point on the second curve. However, even though y1=x1
is a curve defined in 2D, the curve itself is a 1D space. Thus, both a point at [0,0]
and a point at [-1,1]
will map onto the same point on the second curve, and there's no way to tell how far away they were initially from the second curve.
EDIT 2
You are also doing a projection if you have, say, two concentric rings that you map onto a single concentric ring by, for example, projecting it onto the medial curve between the two rings. You won't be able to tell how far away the two rings were from the medial curve initially.
However, why are you using a Fourier transform to find object boundaries? Wouldn't it be possible to use either edge
(after filtering the image) or bwboundaries
(after thresholding the image)?
精彩评论