|
a |
|
b/functions/functions_DBProc/computeLabels.m |
|
|
1 |
function [problem, labels, numImagesAll] = computeLabels(dirDB, files) |
|
|
2 |
|
|
|
3 |
|
|
|
4 |
%load mat |
|
|
5 |
filesMat = dir([dirDB '*.mat']); |
|
|
6 |
mat = load([dirDB filesMat(1).name]); |
|
|
7 |
problem = mat.problem; |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
%keep only elements which are in 'files' |
|
|
12 |
indexrem = []; |
|
|
13 |
for p = 1 : numel(problem) |
|
|
14 |
|
|
|
15 |
%get filename from problem |
|
|
16 |
filenameP = problem(p).filename; |
|
|
17 |
|
|
|
18 |
%init |
|
|
19 |
findP = -1; |
|
|
20 |
|
|
|
21 |
%loop on files |
|
|
22 |
for f = 1 : numel(files) |
|
|
23 |
|
|
|
24 |
%get filename from files |
|
|
25 |
filenameF = files(f).name; |
|
|
26 |
|
|
|
27 |
%cmp |
|
|
28 |
if strcmp(filenameP, filenameF) |
|
|
29 |
findP = 1; |
|
|
30 |
end %if strcmp |
|
|
31 |
|
|
|
32 |
end %for f |
|
|
33 |
|
|
|
34 |
%if not found, remove |
|
|
35 |
if findP == -1 |
|
|
36 |
indexrem = [indexrem p]; |
|
|
37 |
end %if findP |
|
|
38 |
|
|
|
39 |
end %for p |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
%remove indexrem |
|
|
43 |
problem(indexrem) = []; |
|
|
44 |
|
|
|
45 |
%get labels |
|
|
46 |
labels = [problem.class]; |
|
|
47 |
|
|
|
48 |
%get num of images |
|
|
49 |
numImagesAll = numel(problem); |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|