MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / colorEncode

Function colorEncode

utils.py:111–125  ·  view source on GitHub ↗
(labelmap, colors, mode='RGB')

Source from the content-addressed store, hash-verified

109
110
111def colorEncode(labelmap, colors, mode='RGB'):
112 labelmap = labelmap.astype('int')
113 labelmap_rgb = np.zeros((labelmap.shape[0], labelmap.shape[1], 3),
114 dtype=np.uint8)
115 for label in unique(labelmap):
116 if label < 0:
117 continue
118 labelmap_rgb += (labelmap == label)[:, :, np.newaxis] * \
119 np.tile(colors[label],
120 (labelmap.shape[0], labelmap.shape[1], 1))
121
122 if mode == 'BGR':
123 return labelmap_rgb[:, :, ::-1]
124 else:
125 return labelmap_rgb
126
127
128def accuracy(preds, label):

Callers

nothing calls this directly

Calls 1

uniqueFunction · 0.85

Tested by

no test coverage detected