-
Notifications
You must be signed in to change notification settings - Fork 0
/
importC74k.m
40 lines (33 loc) · 979 Bytes
/
importC74k.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
path = fullfile(fileparts(mfilename('fullpath')), '\c74k\raw\English\fnt');
load(fullfile(path, 'lists_var_size.mat'));
p = randperm(62992);
traininds = transpose(p(1:10000));
trainlabs = list.ALLlabels(traininds);
trainnames = list.ALLnames(traininds,:);
testinds = transpose(p(10001:11000));
testlabs = list.ALLlabels(testinds);
testnames= list.ALLnames(testinds,:);
for i = 1:size(traininds,1)
A = imread(fullfile(path, [trainnames(i,:), '.png']));
A = imresize(A, [50 50]);
if size(A, 3)==3
A = rgb2gray(A);
end
A = double(A);
trainimgs(:,:,i) = A(:,:);
end
images = trainimgs/255;
labels = double(trainlabs);
for i = 1:size(testinds,1)
A = imread(fullfile(path, [testnames(i,:), '.png']));
A = imresize(A, [50 50]);
if size(A, 3)==3
A = rgb2gray(A);
end
A = double(A);
testimgs(:,:,i) = A(:,:);
end
testImages = testimgs/255;
testLabels = double(testlabs);
images = normalize_data(images, 10000, 50);
testImages = normalize_data(testImages, 1000, 50);