-
Notifications
You must be signed in to change notification settings - Fork 36
/
fmd_get_database.m
39 lines (31 loc) · 1.34 KB
/
fmd_get_database.m
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
function imdb = fmd_get_database(fmdDir, varargin)
opts.seed = 0 ;
opts = vl_argparse(opts, varargin) ;
rng(opts.seed, 'twister') ;
imdb.imageDir = fullfile(fmdDir, 'image') ;
imdb.maskDir = fullfile(fmdDir, 'mask') ;
cats = dir(imdb.imageDir) ;
cats = cats([cats.isdir] & ~ismember({cats.name}, {'.','..'})) ;
imdb.classes.name = {cats.name} ;
imdb.images.id = [] ;
for c=1:numel(cats)
ims = dir(fullfile(imdb.imageDir, imdb.classes.name{c}, '*.jpg'));
%imdb.images.name{c} = fullfile(imdb.classes.name{c}, {ims.name}) ;
imdb.images.name{c} = cellfun(@(S) fullfile(imdb.classes.name{c}, S), ...
{ims.name}, 'Uniform', 0);
imdb.images.label{c} = c * ones(1,numel(ims)) ;
if numel(ims) ~= 100, error('ops') ; end
sets = [1 * ones(1,40), 2 * ones(1,10), 3 * ones(1,50)] ;
imdb.images.set{c} = sets(randperm(100)) ;
end
imdb.images.name = horzcat(imdb.images.name{:}) ;
imdb.images.label = horzcat(imdb.images.label{:}) ;
imdb.images.set = horzcat(imdb.images.set{:}) ;
imdb.images.id = 1:numel(imdb.images.name) ;
imdb.segments = imdb.images ;
imdb.segments.imageId = imdb.images.id ;
imdb.segments.mask = strrep(imdb.images.name, 'image', 'mask') ;
% make this compatible with the OS imdb
imdb.meta.classes = imdb.classes.name ;
imdb.meta.inUse = true(1,numel(imdb.meta.classes)) ;
imdb.segments.difficult = false(1, numel(imdb.segments.id)) ;