[Insight-users] Runtime typed ImageFileReader ...

Luis Ibanez luis.ibanez@kitware.com
Wed, 26 Mar 2003 08:00:29 -0500


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
>