If the shear component of the deformation isn't too strong, the matchpoints function defined below might work. It will sort the rows of B to correspond with A and also return the corresponding permutation indices. It relies on absor, mentioned by Bruno, which you will have to download
function [permIndices,Bsorted]=matchpoints(A,B)
La=landmarks(A);
Lb=landmarks(B);
B3=B.'; B3(3,:)=0;
reg=absor( Lb,La,'doScale',1);
C3=(reg.s*reg.R)*B3+reg.t;
C=C3(1:2,:).';
[~,permIndices]=pdist2(C,A,'euclidean','Smallest',1);
if nargout>1
Bsorted=B(permIndices,:);
end
function L=landmarks(P)
G=pdist2(P,P); G(~G)=nan;
[i,j]=find( G==min(G(:)) ,1);
I=P(i,:);
J=P(j,:);
K=mean(P,1);
if norm(I-K)<norm(J-K)
[I,J]=deal(J,I);
end
L=[I;J;K].';
L(3,:)=0;
end
end
Applying it to your example data, I obtain,
A = [376 455;421 489;465 537;353 512;355 535;329 571;377 593;417 598;482 575;355 634];
B = [168 88;107 138;69 194;126 229;163 232;199 267;272 239;228 210;235 155;215 68];
[permIndices,Bsorted]=matchpoints(A,B)
plot(graph(1:10,1:10),'EdgeColor','none','XData',A(:,1),'YData',A(:,2));
hold on
plot(graph(1:10,1:10),'EdgeColor','none','XData',Bsorted(:,1),'YData',Bsorted(:,2));
hold off
7 Comments
darova (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753585
Yangfan Peng (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753726
darova (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753773
Yangfan Peng (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753938
Matt J (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753950
darova (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753965
Yangfan Peng (view profile)
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/484039-find-matching-points-from-two-coordinate-systems#comment_753970
Sign in to comment.