%Tae Soo Kim
%tkim60@jhu.edu
%Computer Vision, 600.361
%Assignment 3
%Question 4
function [p1, p2] = findCorrespondences(I, J)

run('C:\Users\TK\Desktop\docs\Computer_Vision\hw2\vlfeat/toolbox/vl_setup');
vl_version verbose
%%
%%SIFT matching from vlfeat.org

 I = single(rgb2gray(I)); % Conversion to single is recommended
 J = single(rgb2gray(J)); % in the documentation

 [F1 D1] = vl_sift(I);
 [F2 D2] = vl_sift(J);

 [matches score] = vl_ubcmatch(D1,D2,3); 

 p1 = zeros(length(F2(1,matches(2,:))),2);
 p2 = zeros(length(F2(1,matches(2,:))),2);
 for i=1:length(F2(1,matches(2,:)))
    p1(i,1) = F1(1,matches(1,i));
    p1(i,2) = F1(2,matches(1,i));
    p2(i,1) = F2(1,matches(2,i));
    p2(i,2) = F2(2,matches(2,i));
 end

end



