Multiple Image Matching using SURF detectors

조회 수: 3 (최근 30일)
Aishwarya Iyengar
Aishwarya Iyengar 2020년 7월 8일
댓글: Image Analyst 2020년 7월 9일
I want to compare (features) 300 images with other 300 images using SURF detectors.
With the program below, I'm facing a problem. With the 1st folder, all images are matching with only 1 image of 2nd folder.
But I want to match all 300 images with 300 images.
Can anyone help ?
path_directory_1 = 'fall';
original_files_1 = dir([path_directory_1 '/*.png']);
path_directory_2 = 'winter';
original_files_2 = dir([path_directory_2 '/*.png']);
for i = 1:length(original_files_1)
filename = ([path_directory_1 '/' original_files_1(i).name]);
I1 = rgb2gray(imread(filename))
points1 = detectSURFFeatures(I1)
[f1,vpts1] = extractFeatures(I1, points1)
for j = 1:length(original_files_2)
filename = ([path_directory_2 '/' original_files_2(j).name]);
I2 = rgb2gray(imread(filename))
points2 = detectSURFFeatures(I2)
[f2,vpts2] = extractFeatures(I2, points2)
end
indexPairs = matchFeatures(f1,f2)
matchedPoints1 = vpts1(indexPairs(:,1))
matchedPoints2 = vpts2(indexPairs(:,2))
figure; ax = axes;
showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2,'montage','Parent',ax);
legend(ax,'matchedPoints1','matchedPoints2');
end

채택된 답변

Image Analyst
Image Analyst 2020년 7월 8일
Works for me. Try this more robust code and tell me what you see in the command window:
path_directory_1 = 'fall';
% path_directory_1 = pwd;
path_directory_2 = 'winter';
% path_directory_2 = pwd;
% Alert user if either folder does not exist, then exit.
if ~isfolder(path_directory_1)
warningMessage = sprintf('Folder %s does not exist.', path_directory_1);
uiwait(errordlg(warningMessage));
return;
end
if ~isfolder(path_directory_2)
warningMessage = sprintf('No %s files found in folder %s', path_directory_2);
uiwait(errordlg(warningMessage));
return;
end
% Get file names.
filePattern = fullfile(path_directory_1, '/*.png');
original_files_1 = dir(filePattern);
filePattern = fullfile(path_directory_2, '/*.png');
original_files_2 = dir(filePattern);
% Alert user if either folder does not have any files in it.
if isempty(original_files_1)
warningMessage = sprintf('No %s files found in folder %s', filePattern, path_directory_1);
uiwait(warndlg(warningMessage));
end
if isempty(original_files_2)
warningMessage = sprintf('No %s files found in folder %s', filePattern, path_directory_2);
uiwait(warndlg(warningMessage));
end
for i = 1:length(original_files_1)
filename = ([path_directory_1 '/' original_files_1(i).name]);
fprintf('\nComparing folder 1 file "%s"\n', filename);
for j = 1:length(original_files_2)
filename = ([path_directory_2 '/' original_files_2(j).name]);
fprintf(' to folder 2 file "%s"\n', filename);
end
end
  댓글 수: 9
Aishwarya Iyengar
Aishwarya Iyengar 2020년 7월 9일
The similarity values in the similarity matrix are computed from the matchings: S(A,B) is the similarity of images A and B based on the matched features from both images.
The Matrix rows and columns represent the matched features of images in terms of binary
Image Analyst
Image Analyst 2020년 7월 9일
Sorry, I can't help you. S() is not a built-in function of MATLAB so presumably it's a custom function that you already have so go ahead and use it. And "the matched features of images in terms of binary" makes no sense to me so perhaps an example would help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by