-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathupdateDatabase.m
26 lines (26 loc) · 962 Bytes
/
updateDatabase.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
function [spactDatabase, pcaLoadings, columnMeans] = updateDatabase(directory)
function absoluteFilenames = imageList(directory)
images = dir(fullfile(directory, '*.jpg'));
absoluteFilenames = arrayfun(@(x) fullfile(directory, x.name), ...
images, ...
'UniformOutput', false);
end
filenames = imageList(directory);
centristDatabase = centristFiles(filenames);
columnMeans = mean(centristDatabase);
pcaLoadings = princomp(centristDatabase);
spactDatabase = spactFiles(filenames, pcaLoadings, columnMeans);
cacheDir = fullfile(directory, 'cache');
if ~exist(cacheDir, 'dir')
% make sure there is a cache directory
mkdir(cacheDir)
end
save(fullfile(cacheDir, 'centristDatabase.mat'), ...
'centristDatabase', ...
'filenames');
save(fullfile(cacheDir, 'spactDatabase.mat'), ...
'spactDatabase', ...
'pcaLoadings', ...
'columnMeans', ...
'filenames');
end