Multiple Image Matching using SURF detectors

7 vues (au cours des 30 derniers jours)
Aishwarya Iyengar
Aishwarya Iyengar le 8 Juil 2020
Commenté : Image Analyst le 9 Juil 2020
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

Réponse acceptée

Image Analyst
Image Analyst le 8 Juil 2020
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 commentaires
Aishwarya Iyengar
Aishwarya Iyengar le 9 Juil 2020
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 le 9 Juil 2020
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for USB Webcams dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by