[Insight-users] guest image pixel type
Bill Lorensen
bill.lorensen at gmail.com
Tue Nov 24 13:36:05 EST 2009
Here's what we do in Slicer3:
#include "itkPluginUtilities.h"
...
itk::ImageIOBase::IOPixelType pixelType;
itk::ImageIOBase::IOComponentType componentType;
try
{
itk::GetImageType (fileName, pixelType, componentType);
}
// This filter handles all types on input, but only produces
// signed types
switch (componentType)
{
case itk::ImageIOBase::UCHAR:
case itk::ImageIOBase::CHAR:
return DoIt( argc, argv, static_cast<char>(0));
break;
case itk::ImageIOBase::USHORT:
case itk::ImageIOBase::SHORT:
return DoIt( argc, argv, static_cast<short>(0));
break;
case itk::ImageIOBase::UINT:
case itk::ImageIOBase::INT:
return DoIt( argc, argv, static_cast<int>(0));
break;
case itk::ImageIOBase::ULONG:
case itk::ImageIOBase::LONG:
return DoIt( argc, argv, static_cast<long>(0));
break;
case itk::ImageIOBase::FLOAT:
return DoIt( argc, argv, static_cast<float>(0));
break;
case itk::ImageIOBase::DOUBLE:
return DoIt( argc, argv, static_cast<double>(0));
break;
case itk::ImageIOBase::UNKNOWNCOMPONENTTYPE:
default:
std::cout << "unknown component type" << std::endl;
break;
}
}
catch( itk::ExceptionObject &excep)
{
std::cerr << argv[0] << ": exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Where itkPluginUtilities.h is here:
http://viewvc.slicer.org/viewcvs.cgi/trunk/Base/CLI/itkPluginUtilities.h?rev=5669&view=markup
For an example of a complete program see:
http://viewvc.slicer.org/viewcvs.cgi/trunk/Applications/CLI/Add.cxx?rev=10441&view=markup
More information about the Insight-users
mailing list