function s=surfMatchesExample(str,name,st,en) matches_arr=[];
for num_images=st:en-1 disp(['Processing frame:',num2str(num_images),' and ',num2str(num_images+1)]); path1=[str,'\',name,'_',num2str(num_images),'.bmp']; path2=[str,'\',name,'_',num2str(num_images+1),'.bmp']; I1=imread(path1); I2=imread(path2); img_arr1=rgb2gray(I1); img_arr2=rgb2gray(I2); f1= detectSURFFeatures(img_arr1); f2= detectSURFFeatures(img_arr2); h=length(f1); g=length(f2); disp(['No. of matching features in block ',num2str(num_images),'=',num2str(h)]); disp(['No. of matching features in block ',num2str(num_images+1),'=',num2str(g)]); [features1, validf1] = extractFeatures(img_arr1, f1); [features2, validf2] = extractFeatures(img_arr2, f2); %strongestPoints = validf1.selectStrongest(1000);
%no_of_features1=length(strongestPoints);
%disp(['No. of matching features in block ',num2str(num_images),'=',num2str(no_of_features1)]);
indexPairs = matchFeatures(features1, features2); matchedIm1 = validf1(indexPairs(:,1),:); matchedIm2 = validf2(indexPairs(:,2),:); % matchedIm3 = validf2(indexPairs(:,3),:);
no_of_matchedPts=length(indexPairs); %[features3, validf3] = extractFeatures(indexPairs,1);
% m3 = matchFeatures(features3, features2);
%m4=length(m3);
disp(['No. of matching features in block ',num2str(num_images),',',num2str(num_images+1),'=',num2str(no_of_matchedPts)]); %disp(num2str(m4));
%[tform, inlierf1, inlierf2] = estimateGeometricTransform(matchedIm1, matchedIm2, 'affine');
figure; showMatchedFeatures(I1,I2, matchedIm1, matchedIm2,'montage'); %g=length(h);
%disp(['No. of matching features in block ','=',g]);
endend
Best Answer