[Insight-users] Runtime typed ImageFileReader ...

Marc Traina Marc.Traina@sophia.inria.fr
Fri, 28 Mar 2003 15:49:46 +0100


Thanks Luis,

Your precise explanations was very helpful.

1) In fact I have use the "ImageIOFactory::CreateImageIO(...)" static 
method to get an "ImageIOBase" and pre-read the image information before 
the declaration of the reader and the writer.

itk::ImageIOBase::Pointer ioBase = 
itk::ImageIOFactory::CreateImageIO(inputFilename, 
itk::ImageIOFactory::ReadMode);
if (ioBase.IsNotNull()) {
ioBase->SetFileName(inputFilename);
ioBase->ReadImageInformation();
.../...
.../...ioBase->GetNumberOfDimensions(); .../...
.../...ioBase->GetPixelType(); .../...
}


2) I have found a very interesting plug-in mechanism already implemented 
in the ObjectFactoryBase. I have understand that this mechanism loads 
dynamic libraries found in the "ITK_AUTOLOAD_PATH" environment variable 
and register the inside factories.
a) Does a precise documentation exist on how to write a pluggable 
library for that mechanism ?
b) Does this mechanism is supported by ITK ? In other words, can I base 
my application architecture on this mechanism ?

3) Does the Insight Consortium plan to develop a DICOM writer ?
And when ??? ;-)


NB : ITK and its associated products are really a model of design. Good 
job !


Luis Ibanez wrote:

>
> Hi Marc,
>
> 1) There are two concepts of 'InputImageType'
> in this program. One is the type in which
> the data is actually stored in the image file.
> The other is the type that will be used to
> store the image as soon as it is loaded in
> memory.
>
> The first type can only be know after the
> image has been read. (unless you manually
> peek in to the image file header :-)
>
> The second type is your choice. It is a
> decision based on the expected file type
> of your image file and the specific application
> of your code (e.g. mamography, CT, fluoroscopy,
> ultrasound...). This second type is the one
> you use to instantiate the ImageFileReader.
>
> e.g.
>
> typedef
> itk::ImageFileReader<
> itk::Image< short, 3 > > ReaderType;
>
> 2) If you want to write a generic converter,
> here are some points you may want to consider:
>
> a) Use the highest possible type for the
> image file reader. This will ensure that
> you can read your data without lossing
> information.
> (Note that color images, and multicomponent
> data will need additional treatement)
>
> this will probably be float or double...
>
> typedef
> itk::ImageFileReader<
> itk::Image< double, 3 > > ReaderType;
>
> b) The dimension in ITK is fixed at compile
> time. This surprise many people when they
> look at the tookit as a generic library....
> but reassure many people when they consider
> that they will be developing image guided
> surgery applications, and in general applications
> that will be embedded in medical devices.
>
> In medical applications you want minimum
> flexibility at run time. (read 'fexibility' as
> variability, or as 'oportunity for error and
> miss-use')
>
> c) In your generic file converter,
> You create the file reader, pass the filename,
> and execute it by invoking Update().
>
> After Update() has returned, the file reader
> will have a valid ImageIO object inside.
> You can get access to it with the method
> reader->GetImageIO();
>
> d) Once you get the pointer to the ImageIO you
> can interrogate it and get information
> like original pixel type in the image file,
> endianness, number of components...
>
> Please look at the man page of the ImageIOBase
> class, for all the methods that you can use
> in order to retrieve information about the
> image file.
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageIOBase.html
>
>
> In particular you may want to look at
>
>
> - GetPixelType()
> - GetComponentType()
> - GetNumberOfDimensions()
> - GetOrigin()
> - GetSpacing()
> - GetNumberOfComponents()
>
>
>
>
> Regards,
>
>
> Luis
>
>
>
> ---------------------------------
> Marc Traina wrote:
>
>> Hi,
>>
>> In the software guide, the ImageReadWrite example program is 
>> described as a simple file format converter.
>>
>> The problem is that the output file pixel type and dimension are 
>> fixed in the source code.
>> I would like to keep unchanged those image characteristics from the 
>> input image to the output image.
>>
>> For that, I need to "switch case" on the input image pixel type and 
>> dimension to create the right typed pipeline 
>> ImageFileReader->ImageFileWriter.
>>
>> How can I get simply the input image characteristics : pixel type and 
>> dimension?
>>
>> Thanks,
>>
>> Marc
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users@public.kitware.com
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>