[Insight-users] guest image pixel type

Bill Lorensen bill.lorensen at gmail.com
Wed Nov 25 08:41:11 EST 2009


Use the code I sent earlier.

On Wed, Nov 25, 2009 at 8:38 AM, Lic. José M. Rodriguez Bacallao
<jmrbcu at gmail.com> wrote:
> but, if I don't know in advance what kind of image (CT, MR, PET, etc)
> I will load, the only thing I know is that the image is a dicom image,
> what is the simplest way to know the right pixel type
>
> On 11/24/09, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> For MR/CT images, I always use short for the output of the readers.
>> WHat are your modalities? If you have PET or SPECT they may be
>> floating point.
>>
>> Bill
>>
>> On Tue, Nov 24, 2009 at 5:06 PM, Lic. José M. Rodriguez Bacallao
>> <jmrbcu at gmail.com> wrote:
>>> but I will need to manage all pixel type that I need to handle no?
>>>
>>> On Tue, Nov 24, 2009 at 5:00 PM, Bill Lorensen <bill.lorensen at gmail.com>
>>> wrote:
>>>> Then I would use the itk readers. itk has better support for image
>>>> reading and processing.
>>>>
>>>>
>>>> On Tue, Nov 24, 2009 at 4:38 PM, Lic. José M. Rodriguez Bacallao
>>>> <jmrbcu at gmail.com> wrote:
>>>>> in fact I need to use both, vtk for visualization and itk for processing
>>>>>
>>>>> On Tue, Nov 24, 2009 at 4:15 PM, Bill Lorensen <bill.lorensen at gmail.com>
>>>>> wrote:
>>>>>> It is up to you. If you are using vtk, then use vtk for reading.
>>>>>>
>>>>>> On Tue, Nov 24, 2009 at 4:01 PM, Lic. José M. Rodriguez Bacallao
>>>>>> <jmrbcu at gmail.com> wrote:
>>>>>>> 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
>>>>>>> -----------------------------------------------------------------
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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
>>>>> -----------------------------------------------------------------
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> 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
>>> -----------------------------------------------------------------
>>>
>>
>
>
> --
> 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