-
Notifications
You must be signed in to change notification settings - Fork 10
/
visualize_scenes.py
69 lines (53 loc) · 2.47 KB
/
visualize_scenes.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
#####################################################################
# This file is part of the 4D Light Field Benchmark. #
# #
# This work is licensed under the Creative Commons #
# Attribution-NonCommercial-ShareAlike 4.0 International License. #
# To view a copy of this license, #
# visit http://creativecommons.org/licenses/by-nc-sa/4.0/. #
#####################################################################
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import util
import file_io
def visualize_scene(data_folder):
params = file_io.read_parameters(data_folder)
if params["category"] == "test":
print "Test scenes with hidden ground truth are not visualized."
return
light_field = file_io.read_lightfield(data_folder)
disp_map_highres = file_io.read_disparity(data_folder, highres=True)
disp_map_lowres = file_io.read_disparity(data_folder, highres=False)
depth_map_lowres = file_io.read_depth(data_folder, highres=False)
rows, cols = 1, 4
cb_shrink = 0.7
fig = plt.figure(figsize=(20, 4))
plt.suptitle("%s:%s (%s)" % (params["category"].title(),
params["scene"].title(),
"x".join(str(i) for i in list(np.shape(light_field)))))
plt.subplot(rows, cols, 1)
plt.title("Center View")
plt.imshow(light_field[4, 4, :, :, :])
plt.subplot(rows, cols, 2)
plt.title("Depth Map (%dx%d)" % np.shape(depth_map_lowres))
cc = plt.imshow(depth_map_lowres, cmap=cm.viridis, interpolation="none")
plt.colorbar(cc, shrink=cb_shrink)
plt.subplot(rows, cols, 3)
plt.title("Disparity Map (%dx%d)" % np.shape(disp_map_lowres))
cc = plt.imshow(disp_map_lowres, cmap=cm.viridis, interpolation="none")
plt.colorbar(cc, shrink=cb_shrink)
plt.subplot(rows, cols, 4)
plt.title("Disparity Map (%dx%d)" % np.shape(disp_map_highres))
cc = plt.imshow(disp_map_highres, cmap=cm.viridis, interpolation="none")
plt.colorbar(cc, shrink=cb_shrink)
fig_name = os.path.join(data_folder, "scene.png")
plt.savefig(fig_name, dpi=200, bbox_inches='tight')
fig.clf()
plt.close(fig)
if __name__ == '__main__':
data_folders = util.parse_options()
for data_folder in data_folders:
print "visualizing: %s" % data_folder
visualize_scene(data_folder)