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

Gelas, Arnaud Joel Florent Arnaud_Gelas at hms.harvard.edu
Wed Dec 1 19:02:23 EST 2010


David,

what about using itk::ImageIOBase::GetPixelType() which returns one itk::ImageIOBase::IOPixelType?

see below the definition of itk::ImageIOBase::IOPixelType

enum { UNKNOWNPIXELTYPE, SCALAR, RGB, RGBA, OFFSET, VECTOR,
             POINT, COVARIANTVECTOR, SYMMETRICSECONDRANKTENSOR,
             DIFFUSIONTENSOR3D, COMPLEX, FIXEDARRAY, MATRIX }  IOPixelType;

HTH,
Arnaud

________________________________________
From: insight-users-bounces at itk.org [insight-users-bounces at itk.org] On Behalf Of David Doria [daviddoria at gmail.com]
Sent: Wednesday, December 01, 2010 12:23 PM
To: ITK
Subject: Re: [Insight-users] Reading an mhd file with unknown pixel type

GetNumberOfComponents() was the function I was looking for. Now that I
have the component type and the number of them, I want to construct a
:

typedef itk::CovariantVector<pixelType, numberOfComponents> ImageType;

However, the compiler won't allow this, I'm assuming because pixelType
and numberOfComponents are not known at compile time. Is there a
better way than a giant switch statement with every possible pixel
type:

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

  if(pixelType == itk::ImageIOBase::DOUBLE && numberOfComponents == 4)
    {
    typedef itk::CovariantVector<double, 4> ImageType;
    }
  else if(numberOfComponents == 5)
....

And this construction also assumes that I know I wanted an
itk::CovariantVector - what if I have no idea about the type?

Thanks,

David
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list