forked from lipiji/PG_BOW_DEMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ini.m
55 lines (45 loc) · 1.61 KB
/
ini.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
53
54
55
% ========================================================================
% Image Classification using Bag of Words and Spatial Pyramid BoW
% Created by Piji Li ([email protected])
% Blog: http://www.zhizhihu.com
% Weibo: http://www.weibo.com/pagecn
% IRLab. : http://ir.sdu.edu.cn
% Shandong University,Jinan,China
% 10/24/2011
clear pg_opts
rootpath='/home/lipiji/PG_BOW_DEMO/';
%%
addpath libsvm;
addpath BOW;
%% change these paths to point to the image, data and label location
images_set=strcat(rootpath,'images');
data=strcat(rootpath,'data');
labels=strcat(rootpath,'labels');
%%
pg_opts.imgpath=images_set; % image path
pg_opts.datapath=data;
pg_opts.labelspath=labels;
%%
% local and global data paths
pg_opts.localdatapath=sprintf('%s/local',pg_opts.datapath);
pg_opts.globaldatapath=sprintf('%s/global',pg_opts.datapath);
% initialize the training set
pg_opts.trainset=sprintf('%s/trainset.mat',pg_opts.labelspath);
% initialize the test set
pg_opts.testset=sprintf('%s/testset.mat',pg_opts.labelspath);
% initialize the labels
pg_opts.labels=sprintf('%s/labels.mat',pg_opts.labelspath);
% initialize the image names
pg_opts.image_names=sprintf('%s/image_names.mat',pg_opts.labelspath);
% Classes
pg_opts.classes = load([pg_opts.labelspath,'/classes.mat']);
pg_opts.classes = pg_opts.classes.classes;
pg_opts.nclasses = length(pg_opts.classes);
load(sprintf('%s',pg_opts.labels));
pg_opts.nimages = size(labels,1);
load(pg_opts.trainset);
load(pg_opts.testset);
pg_opts.ntraning = length(find(trainset==1));
pg_opts.ntesting = length(find(testset==1));
%% creat the directory to save data
MakeDataDirectory(pg_opts);