At the moment I am doing:
if(dimension == 2) { typedef itk::Image<short, 2> ImageType; typedef itk::Image<unsigned int, 2> IntegralImageType; m_pApp->train<2, ImageType, IntegralImageType>(); } else { typedef itk::Image<short, 3> ImageType; typedef itk::Image<unsigned int, 3> IntegralImageType; m_pApp->train<3, ImageType, IntegralImageType>(); }
But I would like to do:
if (dimension == 2) DIMENSION = 2; else DIMENSION = 3; typedef itk::Image<short, DIMENSION> ImageType; typedef itk::Image<unsigned int, DIMENSION> IntegralImageType; m_pApp->train<DIMENSION, ImageType, IntegralImageType>();
I failed to do this because C ++ requires constant variables to instantiate the template. Is there any way to do this nonetheless?
source share