-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep2_quantize.m
33 lines (27 loc) · 1.28 KB
/
step2_quantize.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
createParams;
% Load codebook
data = hdf5read(params.codebookFile, '/clusters');
% Create kdtree
kdtreeFile = fullfile(params.dataPath, 'flann_kdtree.bin');
kdsearchFile = fullfile(params.dataPath, 'flann_kdtree_search.mat');
if exist(kdtreeFile, 'file')
fprintf('Loading kdtree ...\n');
kdtree = flann_load_index(kdtreeFile, data);
load(kdsearchFile);
else
fprintf('Building kdtree ...\n');
[kdtree, searchParams] = flann_build_index(data, params.quantStruct.buildParams);
flann_save_index(kdtree, kdtreeFile);
save(kdsearchFile, 'searchParams');
end
% Quantize and build BoW data
fprintf('Quantize all data images\n');
quantizeAllImages(fullfile(params.dataPath, 'feature'), fullfile(params.dataPath, 'quantize'), searchParams, params.quantStruct.knn);
fprintf('Make BoW vectors for all data images\n');
makeAllBoW(fullfile(params.dataPath, 'quantize'), fullfile(params.dataPath, 'bow'), params.histLen);
% Quantize and build BoW queries
fprintf('Quantize all query images\n');
quantizeAllImages(fullfile(params.queryPath, 'feature'), fullfile(params.queryPath, 'quantize'), searchParams, params.quantStruct.knn);
fprintf('Make BoW vectors for all query images\n');
makeAllBoW(fullfile(params.queryPath, 'quantize'), fullfile(params.queryPath, 'bow'), params.histLen);
clear;