[Insight-users] guest image pixel type

Lic. José M. Rodriguez Bacallao jmrbcu at gmail.com
Tue Nov 24 16:01:31 EST 2009


so, if U need to do all those things to read an image(s) with itk, why
U doesn't use vtk and gdcm for reading?

On 11/24/09, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> 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
>


-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-----------------------------------------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-----------------------------------------------------------------


More information about the Insight-users mailing list