-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuntitled.m
More file actions
82 lines (72 loc) · 2.57 KB
/
Copy pathuntitled.m
File metadata and controls
82 lines (72 loc) · 2.57 KB
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
%for t=1:length(res_names)
save_img=true
for t = 1:50:length(all_files)
[pathstr,name,ext] = fileparts(all_files{t});
if showResOnOrig
img_name = [imgOrigDir, name, '.jpg'];
else
img_name = [img_dir, name, '.ppm'];
end
crfBinFile = fullfile(binDir,[name '.bin']);
img = imread(img_name);
map = LoadBinFile(crfBinFile, 'int16');
map(map~=15) = 0;
% map(1:21,1:10) = repmat((1:21)',1,10);
if showResOnOrig
mapRes = map;
map = zeros(size(img, 1), size(img, 2));
for cl = unique(mapRes)'
mapCl = mapRes==cl;
mapClos = round(double(imresize(mapCl, [size(img, 1) size(img, 2)], 'bilinear')));
%mapClos = bwperim(mapClos);
map = map + mapClos.*cl;
end
end
imgWithMap = img;
mapRGB = zeros(size(img));
cl_txt = {'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', ...
'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', ...
'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', ...
'train', 'tvmonitor'};
fprintf('(%d) classes for %s:', t, name)
clrNum = 0;
val = 255;
for cl = unique(map)'
if cl~=0
fprintf(' %s;', cl_txt{cl});
mapCl = map==cl;
clr = mod(clrNum, 3) + 1;
if clrNum<=2
imClMap = img(:, :, clr);
imClMap(mapCl) = val;
imgWithMap(:, :, clr) = imClMap;
mapRGB(:, :, clr) = val*mapCl;
else
imClMap = imgWithMap(:, :, clr);
imClMap(mapCl) = val;
imgWithMap(:, :, clr) = imClMap;%(imClMap+imgWithMap(:, :, clr))/2;
mapRGB(:, :, clr) = (val*mapCl + mapRGB(:, :, clr))/2;
clr2 = mod(clr,3)+1;
imClMap = imgWithMap(:, :, clr2);
imClMap(mapCl) = val;
imgWithMap(:, :, clr2) = imClMap;%(imClMap+imgWithMap(:, :, clr2))/2;
mapRGB(:, :, clr2) = (val*mapCl+mapRGB(:, :, clr2))/2;
val = (val-1)/2;
end
clrNum = clrNum+1;
end
end
fprintf('\n')
% figure(1);
h = clf;
mm = 1;
nn = 3;
vl_tightsubplot(mm,nn,1); imshow(img);
vl_tightsubplot(mm,nn,2); imshow(imgWithMap)
vl_tightsubplot(mm,nn,3); imshow(mapRGB);
% subplot(mm,nn,3); imagesc2(map == 15);
if save_img
saveas(h, ['deepLabRes/deepLabRes_', name], 'jpg');
end
% dpc
end