def imsave(image, path):
label_colours = [
(0,0,0),
# 0=background
(128,0,0),(0,128,0),(128,128,0),(0,0,128),(128,0,128),
# 1=aeroplane, 2=bicycle, 3=bird, 4=boat, 5=bottle
(0,128,128),(128,128,128),(64,0,0),(192,0,0),(64,128,0),
# 6=bus, 7=car, 8=cat, 9=chair, 10=cow
(192,128,0),(64,0,128),(192,0,128),(64,128,128),(192,128,128),
# 11=diningtable, 12=dog, 13=horse, 14=motorbike, 15=person
(0,64,0),(128,64,0),(0,192,0),(128,192,0),(0,64,128)]
# 16=potted plant, 17=sheep, 18=sofa, 19=train, 20=tv/monitor
images = np.ones(list(image.shape)+[3])
for j_, j in enumerate(image):
for k_, k in enumerate(j):
if k < 21:
images[j_, k_] = label_colours[int(k)]
scipy.misc.imsave(path, images)
评论列表
文章目录