[ITK] [ITK-users] Set image pixel type and dimension through IOBase methods

Javier Juan Albarracín javij1 at gmail.com
Thu Jun 2 11:39:08 EDT 2016


Hello,

I have to read a NIfTI file and I don't know which pixel type has (int, 
double, char, etc). Thus, I am using an ImageIOBase object to retrieve 
the image information before loading it. I have followed the code of the 
ITK examples, which is something similar to

// NIfTI IO Factory
itk::NiftiImageIOFactory::RegisterOneFactory();

// Typedefs
typedef itk::ImageIOBase::IOComponentType PixelType;
itk::ImageIOBase::Pointer imageIO = 
itk::ImageIOFactory::CreateImageIO(filename, 
itk::ImageIOFactory::ReadMode);

imageIO->SetFileName(argv[1]);
imageIO->ReadImageInformation();

Here I know the pixel type and the image dimensio through 
"imageIO->GetComponentType()"  and "imageIO->GetDimensions()". Hence, I 
wan to declare an image type with this parameters to work with it on my 
methods.
I would know if there is some way to declare the image without 
performing a long "switch - case double, case int, case ..." code to 
declare the image type, i.e. something similar to this:

// I know this do not compile and it is wrong but something similar
typedef itk::Image<imageIO->GetComponentType(), 
imageIO->GetDimensions()>  ImageType;

Thank you.
Regards.
Javier.

_____________________________________
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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list