[Insight-users] template at runtime

Corinne Mattmann mattmaco at ee.ethz.ch
Tue, 30 Mar 2004 14:45:18 -0700


Hi,

I would like to write an application for two different image types. This
means that I get an image - in my case from vtk - and then I would like
to define an itkImageType depending on this image
(vtkImageData->GetScalarType()). I tried to use the switch command:

  switch(aimReader_Image1->GetOutput()->GetScalarType()){
  case VTK_CHAR:
    typedef itk::Image<char, Dimension> ImageType;
    break;
  case VTK_SHORT:
    typedef itk::Image<short, Dimension> ImageType;
    break;
  default:
    typedef itk::Image<short, Dimension> ImageType;
    break;
  }

But this results in the following error:

error C2371: 'ImageType' : redefinition; different basic types


How can I solve this problem?
Thanks,
Corinne