%This is the implementation of the method proposed in paper
%“Robust Point Matching Revisited: A Concave Optimization Approach,” 
%by Wei Lian and Lei Zhang, published in ECCV 2012

%2D affine point matching demonstration

%Average maximum allowed distance between a model point and its
%corresponding data point, which is later converted to tolerance error.
%Warning: smaller this value, significantly more time will be required.
err_dst=0.2;

%model and data point sets
X=load('fu_model_set.txt');
Y=load('fu_target_set.txt');

%rotate Y for 90 degree
ang=pi/2;
Y=Y*[cos(ang) -sin(ang);sin(ang) cos(ang)];

%size of model point set should not exceed that of data point set, or the constraint on P will be violated
assert(size(X,1)<=size(Y,1))

P=RPM_concave_point_matching(X,Y,err_dst,'simi');

plot_matching_result(X,Y,P);