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

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 1 20:13:54 EST 2010


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


------------------------
On Wed, Dec 1, 2010 at 12:23 PM, David Doria <daviddoria at gmail.com> wrote:
> 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