-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeSiftVisualCodebook_LD.m
52 lines (43 loc) · 1.74 KB
/
makeSiftVisualCodebook_LD.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% ======================================================================= %
% Name: makeSiftVisualCodebook_LD.m
% Author: Shubhra Aich
% Affiliation: M.Eng.(Ongoing), Chonnam National University
% E-mail: s.aich.72@gmail.com
% Description: This is the third file to extract SIFT features from
% Oxford-102 flower dataset. It calculates the visual
% codebook from the SIFT descriptor set using "vlfeat" library downloaded
% from the link http://www.vlfeat.org/. For codebook calculation in this
% large dimension, "Approximate Nearest Neighbor" (ANN) option of vlfeat
% library is used. The file hierarchy for SIFT features extraction and
% testing using multiple kernel learning (Oxford-102 dataset)
% is listed as follows: (1) extractSiftFeatures.m, (2) makeSiftDesMat.m,
% (3) makeSiftVisualCodebook_LD.m, (4) makeSiftFeaMat.m,
% (5) makeSiftSimMat.m, (6) classifyMKL_Sift.m
% N.B. If the command "resourcedefaultpath" shows error, just restart
% MATLAB.
% ======================================================================= %
clear all; close all; clc;
%%%%restoredefaultpath;
echo on;
tic;
image_version = 'Images_Min_500';
%image_version = 'Images_Min_500_Div';
%image_version = 'Images_Org_Min_500';
featName = 'sift';
radius = 5; % for internal sift
spacing = 5; % both internal and boundary sift
K = 3000;
featName = [featName,'_rad_',num2str(radius),'_spc_',num2str(spacing)];
dbPath = ['../../Databases/Oxford/Features/',image_version,'/'];
run('vlfeat-0.9.20/toolbox/vl_setup.m');
load([dbPath,'TrainDesc_',featName,'.mat']);
trainDesc = trainDesc';
tic;
[VC,~] = vl_kmeans(trainDesc,K,'verbose','distance','l2',...
'algorithm','ann');
toc;
VC = VC';
save([dbPath,'VC_',num2str(K),'_',featName,'.mat'],'VC');
toc;
clear all; close all;
echo off;