Created
June 4, 2019 20:51
-
-
Save lifangda01/93ac8d77f5209b9fcd92cada7c5a35c4 to your computer and use it in GitHub Desktop.
Convert 3D numpy array to vti format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pyevtk | |
np_data = np.load('/Users/fangdali/Code/DEBATR/results/wFBP/freect/bag_no_5' | |
'/whole_bag.npz')['arr_0'] | |
print np_data.shape | |
w, h, l = np_data.shape | |
x = np.arange(0, w + 1) | |
y = np.arange(0, h + 1) | |
z = np.arange(0, l + 1) | |
pyevtk.hl.imageToVTK('/Users/fangdali/Code/DEBATR/results/wFBP/freect/bag_no_5' | |
'/whole_bag', cellData={'data': np_data}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment