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

Brian Eastwood beastwoo at email.unc.edu
Wed Sep 7 20:48:37 EDT 2005


Hi Chris,

Once you have loaded image data through one of ITK's readers into an 
itk::Image object, it is no longer specifically PNG data--it's just 
image data.  For example, you could do all sorts of processing of the 
data using an ITK pipeline; you could grab the image data at any point 
in the pipeline and display it (e.g. using Qt or VTK); you could 
transfer the data buffer to another image library format and do 
something there--for example, ImageMagick.  For all of this, there is no 
need to write intermediary image data to disk.  Maybe you can mention a 
bit more about what your application is supposed to do, and it's likely 
someone on the list has done something similar, or would know the 
components to tie together.

Cheers,
Brian

>Date: Wed, 7 Sep 2005 15:09:12 -0700
>From: "Chris Farmer" <cfarmer at scitegic.com>
>Subject: RE: [Insight-users] Re: Importing image data from a byte
>	array
>To: <insight-users at itk.org>
>Message-ID:
>	<830D8D4719112B418ABBC3A0EBA958128FA56B at webmail.scitegic.com>
>Content-Type: text/plain;	charset="US-ASCII"
>
>
>
>Hi.  I've seen all the ImageFileReader stuff, but I don't have a file,
>and I'd prefer not to create one.  Ever.  I've built the source tree and
>have run many of the examples, and I can certainly get my example PNG
>files into an itk Image and back out again in any of various formats
>using the standard reader/writer classes.  Maybe I'm pre-optimizing
>unnecessarily here, but it seemed reasonable to me to expect that I
>could just use my in-memory representation of a PNG in one way or
>another.  In the application I'm trying to put together, throughput is
>probably the most important factor, so writing a potentially large
>buffer to a file just so I can read it again into some other buffer
>seems quite wasteful.
>
>Thanks,
>Chris
>
>
> 
>
>-----Original Message-----
>From: Andinet Enquobahrie [mailto:andinet.enqu at kitware.com] 
>Sent: Wednesday, September 07, 2005 3:56 PM
>To: Chris Farmer
>Cc: insight-users at itk.org
>Subject: Re: [Insight-users] Re: Importing image data from a byte array
>
>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