Debian Codegraph @

examples/depth2rgb.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 import matplotlib.colors
4 import matplotlib.pyplot as plt
5
6 import imgviz
7
8
9 def depth2rgb():
10 data = imgviz.data.arc2017()
11
12 depthviz_jet = imgviz.depth2rgb(
13 data["depth"], min_value=0.3, max_value=1, colormap="jet"
14 )
15
16 colormap = matplotlib.colors.LinearSegmentedColormap.from_list(
17 "Custom", [(0, 0, 0), (0, 1, 0)]
18 )
19 depthviz_custom = imgviz.depth2rgb(
20 data["depth"], min_value=0.3, max_value=1, colormap=colormap
21 )
22
23 # -------------------------------------------------------------------------
24
25 plt.figure(dpi=200)
26
27 plt.subplot(131)
28 plt.title("rgb")
29 plt.imshow(data["rgb"])
30 plt.axis("off")
31
32 plt.subplot(132)
33 plt.title("depth (jet color)")
34 plt.imshow(depthviz_jet)
35 plt.axis("off")
36
37 plt.subplot(133)
38 plt.title("depth (custom color)")
39 plt.imshow(depthviz_custom)
40 plt.axis("off")
41
42 img = imgviz.io.pyplot_to_numpy()
43 plt.close()
44
45 return img
46
47
48 if __name__ == "__main__":
49 from base import run_example
50
51 run_example(depth2rgb)