-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatascript.m
More file actions
50 lines (39 loc) · 909 Bytes
/
datascript.m
File metadata and controls
50 lines (39 loc) · 909 Bytes
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
clear all;
% Collect data
npath = 'focusnontext';
ndir = dir(npath);
ndir = ndir(3:length(ndir));
fl=154; % feature length
nl = length(ndir);
ndata = zeros(nl,fl);
for i=1:nl
i
p = fullfile(npath,ndir(i).name);
window = double(rgb2gray(imread(p)));
fs = fgen(window);
ndata(i,:) = fs;
end
tpath = 'focustext';
tdir = dir(tpath);
tdir = tdir(3:length(tdir));
tl = length(tdir);
tdata = zeros(tl,fl);
for i=1:tl
i
p = fullfile(tpath,tdir(i).name);
window = double(rgb2gray(imread(p)));
fs = fgen(window);
tdata(i,:) = fs;
end
data = [ndata; tdata];
labels = zeros(nl+tl,1);
labels(nl+1:length(labels)) = 1;
data = [data labels];
order = randperm(size(data,1));
data = data(order,:);
[data,maxout,minout] = normalize_feature(data,0,0);
settings.maxout = maxout;
settings.minout = minout;
save('data','data');
save('settings','settings');
beta=sgd(data,1,0.001);