[Insight-users] How to read a new filetype data ????

Gavin Baker gavinb+xtk at cs.mu.OZ.AU
Mon Jul 4 09:25:40 EDT 2005


Hello Chen,

On Sun, Jul 03, 2005 at 08:50:36PM +0800, Chen Hao wrote:
> Hi,
> 
> I have a new type data, and I know how to read it .
> but,  I don't know how to add it into ITK code......
> 
> Can anyone tell me what exactly I must do ?

So you have a file format that isn't supported by ITK, and you want to write
your own file reader?

There is a whole section in the ITK Software Guide, "7: Reading and Writing
Images".  The section on "Pluggable Factories" (page 238 in the Draft)
describes how the Image I/O system in ITK can be extended to handle new
types.

You can obtain the Software Guide from here:

  http://www.itk.org/HTML/Documentation.htm

All the supported file formats use this extensible framework, so you can
browse the source code to see how to add your own, following the same
strategy.  Have a look at Insight/Code/IO.

Basically, you implement a subclass of itk::FileImageIOBase for your file
format.  This acts as an "adaptor" between your file format (or library) and
the ITK IO framework.  But you need to tell ITK about your new file format
too, and this is the job of the factory class.  You create another class,
deriving from itk::ObjectFactoryBase, which is responsible for registering
your new file handler with ITK.

A good description is also available on the wiki:

  http://www.itk.org/Wiki/Plugin_IO_mechanisms

Also, there have been several discussions on writing new importers in the
past, if you check the mailing list archives.

If your file format is generally useful, please consider contributing the
code to ITK.  Be sure to follow the coding guidelines and conventions, and
read 'Part 3: Developers Guide' of the guide.

Regards,

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne


More information about the Insight-users mailing list