[Insight-users] Re: Importing image data from a byte array
Chris Farmer
cfarmer at scitegic.com
Wed Sep 7 18:09:12 EDT 2005
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
--
Click on the link below to report this email as spam
https://www.mailcontrol.com/sr/TT8yKDeUSQHKLr5jBlIo48m8DzY4V9FCvz+TQRx21
lGVaEwcgzixYX2mLnFF4DXnjkrNsFZennyEVSVl2ga7FbH3LQ0r5zWOdk6E6nv7YTtwLOIqk
sy58FNxpjt8UGVMf6nA9iofWWy9kYS+5GTOqLa7Dv5z5rc4XuBGI263SbiOheCPh!DseHmCN
5WQ4MeCbCZnVXlp8mgdjkLOiMXYLmMR8EnaTthk
More information about the Insight-users
mailing list