-
Notifications
You must be signed in to change notification settings - Fork 7
/
demoSoRelease.m
91 lines (67 loc) · 2.74 KB
/
demoSoRelease.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
84
85
86
87
88
89
90
91
function C2res = demoSoRelease(cI)
%
% demonstrates how to use C2 Single-Opponent model features in a pattern classification framework
% on soccer team dataset (color predominant)
% cI is a cell of length 2: training and testing set
% See details to compute SO descriptors in SODescriptor.m
% You could mofify your spatial info., such as number of phases,
% orientations to adapt to your task
% If you find any bugs, please contact Jun Zhang([email protected])
outDir = sprintf('../results');
if ~exist(outDir,'dir')
mkdir(outDir);
end
%% ---------------------------------------------------------------
% load C1SO prototypes if exsits or extract your own prototypes
% -------------------------------------------------------------------------
READPATCHESFROMFILE = 0;
patchSizes = [4 8 12 16];
numPatchSizes = length(patchSizes);
numPatchesPerSize = 250;
numPhases = 1;
numChannel = 8; %numbers of opponent color channels
% C(cyan) = G+B, Y(yellow) = R+G
% numChannel=8, R+/G-,G+/R-,R+/C-,C+/R-,Y+/B-/B+/Y-,Wh,Bl;
% numChannel=6, then close the Wh-Bl channel.
if ~READPATCHESFROMFILE
%take more time to compute
fprintf('extracting randome SO patches');
cPatches = extractRandC1SoPatches(cI{1}, numPatchSizes, ...
numPatchesPerSize, patchSizes,numChannel,numPhases);
save(fullfile(outDir,sprintf('dictSo_%i_patches_%i_sizes.mat', ...
numPatchesPerSize, length(patchSizes))) ,'cPatches','-v7.3');
else
fprintf('reading patches');
cPatches = load(sprintf('dictSo_%i_patches_%i_sizes.mat', ...
numPatchesPerSize, length(patchSizes)) ,'cPatches');
cPatches = cPatches.cPatches;
end
%% ------------------------------------------------------------------------
% compute C2SO features
% -------------------------------------------------------------------------
%----Settings for Testing --------%
rot = [0 90];
c1ScaleSS = 1:2:18;
RF_siz = 7:2:39;
c1SpaceSS = 8:2:22;
div = 4:-.05:3.2;
Div = div;
% %--- END Settings for Testing --------%
fprintf(1,'Initializing color gabor filters -- full set...');
%creates the gabor filters use to extract the S1 layer
[fSiz,~,cfilters,c1OL,numOrients] = init_color_gabor(rot, RF_siz, Div,numChannel,numPhases);
fprintf(1,'done\n');
% % The actual C2 features are computed below for each one of the training/testing directories
C2res = cell(1,2);
tic
for i = 1:2,
C2res{i} = extractC2Soforcell(cfilters,fSiz,c1SpaceSS,c1ScaleSS,...
c1OL,cPatches,cI{i},numPatchSizes,numChannel,numPhases,numOrients);
toc
end
totaltimespectextractingC2 = toc;
% save C2SO features
save(fullfile(outDir,sprintf('c2so_%i_patches_%i_sizes.mat', ...
numPatchesPerSize, length(patchSizes))), 'C2res','-v7.3');
return
%