-
Notifications
You must be signed in to change notification settings - Fork 2
/
label2color.m
136 lines (129 loc) · 4.91 KB
/
label2color.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
function classif=label2color(label,data_name)
[w h]=size(label);
im=zeros(w,h,3);
switch lower(data_name)
case 'uni'
map=[192 192 192;0 255 0;0 255 255;0 128 0; 255 0 255;165 82 41;128 0 128;255 0 0;255 255 0];
for i=1:w
for j=1:h
switch(label(i,j))
case(1)
im(i,j,:)=uint8(map(1,:));
case(2)
im(i,j,:)=uint8(map(2,:));
case(3)
im(i,j,:)=uint8(map(3,:));
case(4)
im(i,j,:)=uint8(map(4,:));
case(5)
im(i,j,:)=uint8(map(5,:));
case(6)
im(i,j,:)=uint8(map(6,:));
case(7)
im(i,j,:)=uint8(map(7,:));
case(8)
im(i,j,:)=uint8(map(8,:));
case(9)
im(i,j,:)=uint8(map(9,:));
end
end
end
case 'center'
map=[0 0 255;0 128 0;0 255 0;255 0 0;142 71 2;192 192 192;0 255 255;246 110 0; 255 255 0];
for i=1:w
for j=1:h
switch(label(i,j))
case(1)
im(i,j,:)=uint8(map(1,:));
case(2)
im(i,j,:)=uint8(map(2,:));
case(3)
im(i,j,:)=uint8(map(3,:));
case(4)
im(i,j,:)=uint8(map(4,:));
case(5)
im(i,j,:)=uint8(map(5,:));
case(6)
im(i,j,:)=uint8(map(6,:));
case(7)
im(i,j,:)=uint8(map(7,:));
case(8)
im(i,j,:)=uint8(map(8,:));
case(9)
im(i,j,:)=uint8(map(9,:));
end
end
end
case 'india'
% map=[0 0 255;255 100 0;0 255 134;150 70 150; 100 150 255;60 90 114;255 255 125;255 0 255;100 0 255;1 170 255;0 255 0;175 175 82;100 190 56;140 67 46;115 255 172;255 255 0];
map=[140 67 46;0 0 255;255 100 0;0 255 123;164 75 155;101 174 255;118 254 172; 60 91 112;255,255,0;255 255 125;255 0 255;100 0 255;0 172 254;0 255 0;171 175 80;101 193 60;255 255 255];
for i=1:w
for j=1:h
switch(label(i,j))
% case(0)
% im(i,j,:)=uint8(map(17,:));
case(1)
im(i,j,:)=uint8(map(1,:));
case(2)
im(i,j,:)=uint8(map(2,:));
case(3)
im(i,j,:)=uint8(map(3,:));
case(4)
im(i,j,:)=uint8(map(4,:));
case(5)
im(i,j,:)=uint8(map(5,:));
case(6)
im(i,j,:)=uint8(map(6,:));
case(7)
im(i,j,:)=uint8(map(7,:));
case(8)
im(i,j,:)=uint8(map(8,:));
case(9)
im(i,j,:)=uint8(map(9,:));
case(10)
im(i,j,:)=uint8(map(10,:));
case(11)
im(i,j,:)=uint8(map(11,:));
case(12)
im(i,j,:)=uint8(map(12,:));
case(13)
im(i,j,:)=uint8(map(13,:));
case(14)
im(i,j,:)=uint8(map(14,:));
case(15)
im(i,j,:)=uint8(map(15,:));
case(16)
im(i,j,:)=uint8(map(16,:));
end
end
end
case 'dc'
map=[204 102 102;153 51 0;204 153 0;0 255 0; 0 102 0;0 51 255;153 153 153];
for i=1:w
for j=1:h
switch(label(i,j))
case(1)
im(i,j,:)=uint8(map(1,:));
case(2)
im(i,j,:)=uint8(map(2,:));
case(3)
im(i,j,:)=uint8(map(3,:));
case(4)
im(i,j,:)=uint8(map(4,:));
case(5)
im(i,j,:)=uint8(map(5,:));
case(6)
im(i,j,:)=uint8(map(6,:));
case(7)
im(i,j,:)=uint8(map(7,:));
end
end
end
end
name=sprintf('classif_%s.tif',data_name);
im=uint8(im);
classif=uint8(zeros(w,h,3));
classif(:,:,1)=im(:,:,1);
classif(:,:,2)=im(:,:,2);
classif(:,:,3)=im(:,:,3);
%imwrite(classif,name);