[ITK-users] Reading an image from a file object with SimpleITK+Python
Jameson Merkow
jmerkow at gmail.com
Sun Jul 3 16:36:38 EDT 2016
Hello all,
Is there a way to read an image with SimpleITK+Python from a file object
(as opposed to a string/filename)? I cannot find anything in the Doxygen or
otherwise to do this.
Here is a toy example:
import cStringIO
import SimpleITK as sitk
dcmfn="test.dcm"
with open(dcmfn,'rb') as data:
body = data.read()
strio=cStringIO.StringIO(body)
img=sitk.ReadImage(strio)
strio.close()
--Jameson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160703/48a05c08/attachment.html>
More information about the Insight-users
mailing list