-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreadImage.py
More file actions
39 lines (29 loc) · 1.31 KB
/
readImage.py
File metadata and controls
39 lines (29 loc) · 1.31 KB
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
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2012-2016 ###
### ###
### University of California at San Francisco (UCSF), USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import vtk
import myVTKPythonLibrary as myVTK
########################################################################
def readImage(
filename,
verbose=1):
myVTK.myPrint(verbose, "*** readImage: " + filename + " ***")
if ('vtk' in filename):
image_reader = vtk.vtkImageDataReader()
elif ('vti' in filename):
image_reader = vtk.vtkXMLImageDataReader()
else:
assert 0, "File must be .vtk or .vti. Aborting."
image_reader.SetFileName(filename)
image_reader.Update()
image = image_reader.GetOutput()
if (verbose):
print "n_points = " + str(image.GetNumberOfPoints())
return image