[Insight-users] how to write a single program working for both 2D and 3D cases?
Bing Jian
jbing at ufl . edu
Fri, 21 Nov 2003 16:34:33 -0500
Hello, everyone,
I'm trying to write a single program that can handle
both 2D and 3D cases. First, the program accepts command
line and gets the filename. If it's meta header file,
then we can get the dimension info and pixel type info.
Then in my program, I tried to write something like
if (dim==2)
{
const unsigned int dimension = 2;
}
else if (dim==3)
{
const unsigned int dimension = 3;
}
if (pixeltype == FLOAT)
{
typedef float PixelType;
}
else if (pixeltype = UCHAR)
{
tyepdef unsigned char PixelType;
}
It won't work for several reasons:
(1) Being put inside if{} block, dimension and PixelType
become invisible to other parts of program.
(2) template of class itk::image requires dimension to be const,
so I cannot define it outside and then change it later.
I hope you guys can understand my problems, any suggestions
would be appreciated.
Have a nice weekend!
--
Best wishes
Bing Jian
bjian at cise . ufl . edu