%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.


function corr=tree_match_recover(node,edges,pointer,corr)
%recover correspondence from Ny x Ne array 'pointer', 
%a recursion due to the structure of tree
for ii=1:size(edges,1)
    if edges(ii,1)==node||edges(ii,2)==node
        if edges(ii,1)==node
            nex=edges(ii,2);
        else
            nex=edges(ii,1);
        end
        corr(nex)=pointer(corr(node),nex);
        edges2=edges;
        edges2(ii,:)=[];%eliminate edge [node,nex]
        corr=tree_match_recover(nex,edges2,pointer,corr);
    end
end
