mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-09 11:33:41 +08:00
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:
@@ -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)
|
||||
Reference in New Issue
Block a user