[ITK] [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/community/attachments/20160703/48a05c08/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list