[Insight-users] Re: Importing image data from a byte array

Andinet Enquobahrie andinet.enqu at kitware.com
Wed Sep 7 18:55:32 EDT 2005


Chris Farmer wrote:

>This makes perfect sense.  I was trying this since others suggested the
>ImportImageFilter as a way to get PNG data into an itk image.  Now I'm
>back to square one... is there a straightforward way to get PNG data (or
>some other non-raw image format) from a byte array into an itk Image?
>
>
>  
>
All you need is

typedef itk::Image<PixelType, Dimension> ImageType;
typedef itk::ImageFileReader <ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader.SetFilename(inputFilename);
reader->Update();

// The ImageFileReader class determines the image format from the file 
extension and then points to the approrpriate ImageIO

There is a whole chapter on data representation  in the ITK software 
guide. You might want to take a look at that for detailed explanation.

http://www.itk.org/ItkSoftwareGuide.pdf

and there are several IO examples in the main source tree

Insight/Examples/IO

-Andinet



More information about the Insight-users mailing list