ENH: Add SimpleITK IO plugin.

IO plugin for SimpleITK, http://simpleitk.org/

imread and imsave implemented. Tests based off the PIL tests.
This commit is contained in:
Matt McCormick
2013-01-17 09:55:56 +00:00
parent d202cea8a8
commit ad23f203da
3 changed files with 117 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
__all__ = ['imread', 'imsave']
try:
import SimpleITK as sitk
except ImportError:
raise ImportError("SimpleITK could not be found. "
"Please try "
" easy_install SimpleITK "
"or refer to "
" http://simpleitk.org/ "
"for further instructions.")
def imread(fname):
sitk_img = sitk.ReadImage(fname)
return sitk.GetArrayFromImage(sitk_img)
def imsave(fname, arr):
sitk_img = sitk.GetImageFromArray(arr, isVector=True)
sitk.WriteImage(sitk_img, fname)