-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualize.py
74 lines (59 loc) · 1.64 KB
/
visualize.py
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
#visualize annotations in color
import cv2
import numpy as np
import os
import matplotlib.pyplot as plt
import sys
source = '/home/shruti/camvid/tesannot/'
support = '/home/shruti/camvid/test/'
#unannotated = [0, 0, 0]
#Sky = [0, 255, 255]
#Building = [128, 0, 0]
#Shadows = [128, 128, 128]
#Grass = [0, 255, 0]
#Trees = [0, 128, 0]
#Parking_Lot = [128, 128, 0]
#Street = [192, 192, 192]
#Sidewalk = [0, 128, 128]
#Crosswalk = [0, 0, 128]
#Intersection = [255, 0, 0]
#Umbrella = [255, 255, 0]
#label_colours = np.array([unannotated,Building, Grass, Trees, Parking_Lot, Street])
Sky = [128,128,128]
Building = [128,0,0]
Pole = [192,192,128]
Road_marking = [255,69,0]
Road = [128,64,128]
Pavement = [60,40,222]
Tree = [128,128,0]
SignSymbol = [192,128,128]
Fence = [64,64,128]
Car = [64,0,128]
Pedestrian = [64,64,0]
Bicyclist = [0,128,192]
Unlabelled = [0,0,0]
label_colours = np.array([Sky, Building, Pole, Road, Pavement, Tree, SignSymbol, Fence, Car, Pedestrian, Bicyclist, Unlabelled])
for root, directories, files in os.walk(source):
for filename in files:
path = source + filename
s_path = support +filename
print s_path
org1 = cv2.imread(s_path, 1)
im = cv2.imread(path,0)
ind = im
r1 = ind.copy()
g1 = ind.copy()
b1 = ind.copy()
for l1 in range(0,11):
r1[ind==l1] = label_colours[l1,0]
g1[ind==l1] = label_colours[l1,1]
b1[ind==l1] = label_colours[l1,2]
rgb = np.zeros((ind.shape[0], ind.shape[1], 3))
rgb[:,:,0] = r1/255.0
rgb[:,:,1] = g1/255.0
rgb[:,:,2] = b1/255.0
plt.figure()
plt.imshow(org1, vmin=0, vmax=1)
plt.figure()
plt.imshow(rgb,vmin=0, vmax=1)
plt.show()