-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTraining_Data_Generator.m
112 lines (95 loc) · 3.13 KB
/
Training_Data_Generator.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
clc;
close all;
clear all;
training_examples = [];
training_labels = [];
angle = ['0','0','0';'0','3','0';'0','6','0';'0','9','0';'1','2','0';...
'1','5','0';'1','8','0';'2','1','0';'2','4','0';'2','7','0';...
'3','0','0';'3','3','0'];
%%%% cushion , label = 0 %%%%
for i=10:40
for j=1:12
image = imread(['TrainingData\cushion\cushion1-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 0;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
%%%% grass , label = 1;
for i=10:40
for j=1:12
image = imread(['TrainingData\grass\grass1-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 1;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
%%%% linseeds , label = 2 %%%%
for i=10:40
for j=1:12
image = imread(['TrainingData\linseeds\linseeds1-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 2;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
%%%% rice , label = 3 %%%%
for i=10:40
for j=1:12
image = imread(['TrainingData\rice\rice1-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 3;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
%%%% seat , label = 4 %%%%
for i=10:40
for j=1:12
image = imread(['TrainingData\seat\seat2-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 4;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
%%%% stone , label = 5 %%%%
for i=10:40
for j=1:12
image = imread(['TrainingData\stone\stone1-a-p0',num2str(i),'-r',angle(j,:),'.png']);
image = double(image);
quantized_image = Quantizer(image,16);
L=16;
label = 5;
[PH,PV,PLD,PRD] = gray_tone(quantized_image,L);
feature_vector = [Extract_features(PH,PV,PLD,PRD) label];
training_examples = [training_examples;feature_vector];
% training_labels = [training_labels;label];
end
end
training_examples = training_examples(randperm(size(training_examples, 1)), :);
save training_examples.txt -ascii training_examples;
%save training_labels.txt -ascii training_labels;