-
Notifications
You must be signed in to change notification settings - Fork 2
/
depth_to_colormap.py
44 lines (40 loc) · 1.61 KB
/
depth_to_colormap.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
import glob
import os
from PIL import Image
from matplotlib import cm
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
if __name__ == '__main__':
files = list(glob.glob('evaluate-depths/predicted-*.png'))
files.extend(list(glob.glob('evaluate-depths/orig-depth-*.png')))
files.extend(list(glob.glob('evaluate-depths/gt-depth-*.png')))
for file in files:
im = np.array(Image.open(file))
colored_im = np.copy(im)
# if 'orig-' in file:
# im[im == 0] = 255
if 'gt-' in file:
colored_im[colored_im == 5] = 255
elif 'predicted-' in file:
colored_im[colored_im < 4] = 255
colored_im = Image.fromarray(np.uint8(cm.jet_r(colored_im) * 255.0))
colored_im.save('evaluate-depths/colored-'+os.path.basename(file)+'.png')
fig = plt.figure(figsize=(1, 3))
ax1 = fig.add_axes([0, 0.05, 0.2, 0.9])
cmap = mpl.cm.jet_r
norm = mpl.colors.Normalize(vmin=50, vmax=0)
cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap,
norm=norm,
orientation='vertical')
cb1.set_label('distance [m]')
plt.savefig('evaluate-depths/colorbar-cropped.png')
fig = plt.figure(figsize=(1, 3))
ax1 = fig.add_axes([0, 0.05, 0.2, 0.9])
cmap = mpl.cm.jet_r
norm = mpl.colors.Normalize(vmin=1000, vmax=0)
cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap,
norm=norm,
orientation='vertical')
cb1.set_label('distance [m]')
plt.savefig('evaluate-depths/colorbar-orig.png')