Difference between revisions of "Plugin IO mechanisms"

From KitwarePublic
Jump to navigationJump to search
 
Line 3: Line 3:
ITK provides a very flexible ImageIO mechanism supporting factories.  This allows for a single reader class and a single writer class that can input/output a variety of file formats.  When ImageFileReader begins to read a file, it queries the ObjectFactory system for any factory that can supply an ImageIOBase.  This subset of factories is queried in turn to locate a factory that can understand the format of the requested file.
ITK provides a very flexible ImageIO mechanism supporting factories.  This allows for a single reader class and a single writer class that can input/output a variety of file formats.  When ImageFileReader begins to read a file, it queries the ObjectFactory system for any factory that can supply an ImageIOBase.  This subset of factories is queried in turn to locate a factory that can understand the format of the requested file.


New image file formats can be added to ITK by deriving a class from ImageIOBase that will support reading/writing that file format.  The file format can be added to the factory mechanism by creating a subclass of ObjectFactoryBase for the specific for this ImageIO class.
New image file formats can be added to ITK by deriving a class from ImageIOBase that will support reading/writing the new file format.  The file format can be added to the factory mechanism by creating a subclass of ObjectFactoryBase for this new ImageIO class. This subclass of ObjectFactoryBase will create an override in the factory mechanism indicating it can create an ImageIOBase.  This is done in the constructor of the subclass of ObjectFactoryBase for the new image format:
 
MyImageIOFactory::MyImageIOFactory()
{
 
  this->RegisterOverride("itkImageIOBase",
                        "itkMyImageIO",
                        "My Image IO",
                        1,
                        CreateObjectFunction<MyImageIO>::New());
}
 
== Registering a factory ==
 
For the factory mechanism to use factory for the new image format, the new factory must be "registered" with the factory mechanism.  A stock set of such factories are registered automatically by ImageIOFactory. To register additional factories,

Revision as of 07:43, 30 April 2005

Plugin IO mechanisms

ITK provides a very flexible ImageIO mechanism supporting factories. This allows for a single reader class and a single writer class that can input/output a variety of file formats. When ImageFileReader begins to read a file, it queries the ObjectFactory system for any factory that can supply an ImageIOBase. This subset of factories is queried in turn to locate a factory that can understand the format of the requested file.

New image file formats can be added to ITK by deriving a class from ImageIOBase that will support reading/writing the new file format. The file format can be added to the factory mechanism by creating a subclass of ObjectFactoryBase for this new ImageIO class. This subclass of ObjectFactoryBase will create an override in the factory mechanism indicating it can create an ImageIOBase. This is done in the constructor of the subclass of ObjectFactoryBase for the new image format:

MyImageIOFactory::MyImageIOFactory()
{
 this->RegisterOverride("itkImageIOBase",
                        "itkMyImageIO",
                        "My Image IO",
                        1,
                        CreateObjectFunction<MyImageIO>::New()); 
}

Registering a factory

For the factory mechanism to use factory for the new image format, the new factory must be "registered" with the factory mechanism. A stock set of such factories are registered automatically by ImageIOFactory. To register additional factories,