[Insight-users] Read a 2D and 3D image in itk::ImageFileReader

Haiyong Xu haiyeong at gmail.com
Fri Apr 15 09:36:11 EDT 2011


Hi there,

A simple question:
My program read an image using itk::ImageFileReader. The input image
can be 2D (a jpeg file) or 3D (a nrrd file). My question is how to
typedef the ImageType in ImageFileReader?

For 2D input image:
typedef itk::Image< float, 2 > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;


For 3D input image:
typedef itk::Image< float, 3 > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;

How to combine them in one program? Need "Traits"?

I search files in Examples/IO, but the image dimension in all examples
are hard-coded as either 2 or 3. Hope a new example will be added to
handle this situation.

Thanks!

Haiyong Xu
from Wake Forest University


More information about the Insight-users mailing list