%This software implements the point matching algorithm described in the paper:
%"Rotation Invariant Nonrigid Point Set Matching in Cluttered Scenes", IEEE transaction on Image Processing, 2012

%Author: Wei Lian (Changzhi University, Changzhi, 046011, Shanxi Province, P.R. China, Email: lianwei3 at gmail.com)

%If you use this software for research purposes, you should cite the aforementioned paper in any resulting publications.




X=load('fish_model_set.txt');
Y=load('fish_target_set.txt');

tic
lambda=1; %parameter lambda appeared in equation (3) of the paper
[P,enmin]=minSpanTreeTri_DP_SC_simi(X,Y,lambda);
time_DPSC_treeTri=toc

%%plot result
Xe=[X ones(size(X,1),1)];%%homogenous coordinate
Xtran=Xe*inv(Xe'*Xe)*(Xe'*P*Y);%%affine
figure;hold on;axis off;
plot(Y(:,1),Y(:,2),'b+','LineWidth',2);
plot(Xtran(:,1),Xtran(:,2),'ro','LineWidth',2); %%transformed model
plot([Xtran(:,1) P*Y(:,1)]',[Xtran(:,2),P*Y(:,2)]','k-','LineWidth',2); %%%%line segments for point correspondences
