-
Notifications
You must be signed in to change notification settings - Fork 2
/
calculate_train_pcs.m
83 lines (58 loc) · 1.58 KB
/
calculate_train_pcs.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Loads data, calculates PCAs and stores them on files.
load_paths;
%%
numpcs = 1000;
%%
load_train_pedestrians;
disp 'Computing pedestrians grayscale mean...'
mngp = mean(pedgray,2);
disp 'Computing pedestrians grayscale PCA...'
[Pgp,Vgp] = pca(pedgray);
disp 'Saving pedestrians grayscale PCAs...'
Pgp = Pgp(:,1:numpcs);
Vgp = Vgp(1:numpcs);
save(sprintf('data/%s/pgp.mat', edge_method), 'Pgp', 'Vgp', 'mngp');
disp 'Clearing workspace...'
clear Pgp;
clear Vgp;
clear mngp;
%
disp 'Computing pedestrians edge mean...'
mnep = mean(pededge,2);
disp 'Computing pedestrians edge PCA...'
[Pep,Vep] = pca(pededge);
disp 'Saving pedestrians edge PCAs...'
Pep = Pep(:,1:numpcs);
Vep = Vep(1:numpcs);
save(sprintf('data/%s/pep.mat', edge_method), 'Pep', 'Vep', 'mnep');
disp 'Clearing workspace...'
clear Pep;
clear Vep;
clear mnep;
%%
load_train_nonpedestrians;
disp 'Computing non-pedestrians grayscale mean...'
mngn = mean(nongray,2);
disp 'Computing non-pedestrians grayscale PCA...'
[Pgn,Vgn] = pca(nongray);
disp 'Saving non-pedestrians grayscale PCAs...'
Pgn = Pgn(:,1:numpcs);
Vgn = Vgn(1:numpcs);
save(sprintf('data/%s/pgn.mat', edge_method), 'Pgn', 'Vgn', 'mngn');
disp 'Clearing workspace...'
clear Pgn;
clear Vgn;
clear mngn;
%
disp 'Computing non-pedestrians edge mean...'
mnen = mean(nonedge,2);
disp 'Computing non-pedestrians edge PCA...'
[Pen,Ven] = pca(nonedge);
disp 'Saving non-pedestrians edge PCAs...'
Pen = Pen(:,1:numpcs);
Ven = Ven(1:numpcs);
save(sprintf('data/%s/pen.mat', edge_method), 'Pen', 'Ven', 'mnen');
disp 'Clearing workspace...'
clear Pen;
clear Ven;
clear mnen;