[ITK-users] Reading an image from a file object with SimpleITK+Python

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Tue Jul 5 09:33:18 EDT 2016


Hello,

SimpleITK does not currently support this low level interface. I am not aware of an ITK ImageIO that directly support reading am image from a C FILE object either.

You may find a lower level IO library such as GDCM or jpeg which can support this type of feature, but I have not tried it myself.

HTH,
Brad

> On Jul 3, 2016, at 4:36 PM, Jameson Merkow <jmerkow at gmail.com> wrote:
> 
> 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
> _____________________________________
> 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 Insight-users mailing list