-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
26 lines (18 loc) · 922 Bytes
/
convert.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
import numpy as np
with open('/home/memi/Desktop/SPIMNET/new_costspace/cost_16x16_220951_003373_2x.npy', 'rb') as f:
cost_volume = np.load(f)
left_cost_volume = np.transpose(cost_volume, (2, 0, 1))
left_cost_volume.shape
ndisp = left_cost_volume.shape[0]
height = left_cost_volume.shape[1]
width = left_cost_volume.shape[2]
right_cost_volume = np.zeros([ndisp, height, width], dtype=np.float32)
for d in range(ndisp):
right_cost_volume[d, :, :width-d] = left_cost_volume[d, :, d:]
left_cost_volume = np.transpose(left_cost_volume, (1, 2, 0))
right_cost_volume = np.transpose(right_cost_volume, (1, 2, 0))
print(right_cost_volume.shape)
with open('/home/memi/Desktop/SPIMNET/costspace_for_torch/220951_003373/left_003373.npy', 'wb') as f:
np.save(f, left_cost_volume)
with open('/home/memi/Desktop/SPIMNET/costspace_for_torch/220951_003373/right_003373.npy', 'wb') as f:
np.save(f, right_cost_volume)