Multiple Image Matching using SURF detectors
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
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 件のコメント
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!