-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathretrieve_database.m
More file actions
40 lines (33 loc) · 1.35 KB
/
retrieve_database.m
File metadata and controls
40 lines (33 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function [database] = retrieve_database(DataDir)
%=========================================================================
% This function retrieves locations of the SIFT database.
% Input: DataDir = Path of the database
% Output: database = Structure containing the required details
% database.path = path for each image file
% database.label = label for each image file
% database.className = Name of each class
%=========================================================================
database.nclass = 0;
database.imnum = 0;
database.path = {};
database.label = [];
database.cname = {};
fprintf('Retrieving SIFT features...');
categories = dir(DataDir); % Subfolders in the database
for iter1 = 1:length(categories)
ClassName = categories(iter1).name;
% if ~strcmp(ClassName, '.') & ~strcmp(ClassName, '..'),
database.nclass = database.nclass + 1;
database.cname{database.nclass} = ClassName;
Images = dir([DataDir '\' ClassName '\' '*.mat']);
i_num = length(Images);
database.label = [database.label ones(i_num,1)*database.nclass];
database.imnum = database.imnum + i_num;
for iter2 = 1:i_num
i_path = [DataDir '\' ClassName '\' Images(iter2).name];
database.path = [database.path i_path];
end
% end
end
fprintf('Done!!\n')
end