[Insight-users] Reading an mhd file with unknown pixel type

David Doria daviddoria at gmail.com
Thu Dec 2 08:35:09 EST 2010


On Wed, Dec 1, 2010 at 8:13 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
> Hi David,
>
> On way to deal with image whose number of components
> are not known until run time is to use the class.
>
>                     itk::VectorImage
>
> This image class allows you to set the number of components
> at run time.
>
>
>      Luis

Arnaud, Luis,

That enum lets you check the pixel type manually (in a loop, comparing
the GetComponentType() result to all of the entires in the enum, but
can you do something more like this?

  const ScalarPixelType pixelType = imageIO->GetComponentType();
  const int numberOfComponents = imageIO->GetNumberOfComponents();

  typedef itk::VectorImage<pixelType, 2> ImageType;
  image->SetNumberOfComponentsPerPixel(numberOfComponents);

Of course it is complaining because the enum value in pixelType is not
equivalent to the actual word 'float' which would need to be passed as
the template parameter.

David


More information about the Insight-users mailing list