[ITK-users] How to determine PixelType of itk::Image

Lambert Zijp ljzijp at gmail.com
Tue Mar 15 13:09:08 EDT 2016


I'm still not sure how to handle vector images. Dženan gave an example of
an RGB image. That would be a 3-vector unsigned char pixeltype.
Would I have to write out in those *'if  **(**typeid(ValueType) == ???)'*
statements all permutations of the number of vectors and the type? Or is
there a way to separate the number of vectors and the pixeltype?
How are vector images stored in memory in ITK. In an RGB image for example,
are the pixels consecutive triplets, or is the image stored as three
consecutive color planes?
I'm particular interested in 3D displacement vector fields, that are the
result of deformable registration.


On Tue, Mar 15, 2016 at 5:22 PM, Bill Lorensen <bill.lorensen at gmail.com>
wrote:

> This example may help
> http://www.vtk.org/Wiki/ITK/Examples/IO/ReadUnknownImageType
> On Mar 15, 2016 8:44 AM, "Dženan Zukić" <dzenanz at gmail.com> wrote:
>
>> Of course it complained, switch statement is for integral types (if I
>> remember correctly).
>>
>> Regards
>>
>> On Tue, Mar 15, 2016 at 11:39 AM, Lambert Zijp <ljzijp at gmail.com> wrote:
>>
>>> Hi Dženan,
>>>
>>> Thank you very much!
>>> Visual Studio 9 does not recognize decltype(), but typeid() worked
>>> fine. At least, when you make separate if statements, like you did in your
>>> example. When tried to use it in a switch statement, the compiler
>>> complained.
>>>
>>> Greetings,
>>> Lambert
>>>
>>>
>>> On Tue, Mar 15, 2016 at 2:47 PM, Dženan Zukić <dzenanz at gmail.com> wrote:
>>>
>>>> Hi Lambert,
>>>>
>>>> the classic way is using a bunch of if-else's.
>>>>
>>>> if (decltype(ValueType)==decltype(int))
>>>> {
>>>> //int specific processing
>>>> }
>>>> else if (decltype(ValueType)==decltype(itk::RGB<char>))
>>>> {
>>>> //RGB<char> specific processing
>>>> }
>>>> ​else if ...​
>>>>
>>>> ​If you can't use C++11's decltype then use typeid from <typeinfo>​
>>>> header.
>>>>
>>>> Regards,
>>>> Dženan
>>>>
>>>> On Tue, Mar 15, 2016 at 5:48 AM, Lambert Zijp <ljzijp at gmail.com> wrote:
>>>>
>>>>> I want to write a function that converts an arbitrary ITK image to
>>>>> another format (AVS in my case).
>>>>> It has been suggested that following functionprototype could de the
>>>>> job:
>>>>> template<typename ValueType,unsigned int Dimension>
>>>>> int ItkToAvs(AVSfield** ppAvs, typename
>>>>> itk::Image<ValueType,Dimension>::Pointer pItkImage);
>>>>>
>>>>> Now I want to know whether ValueType equals unsigned char or short or
>>>>> int etc. Also whether the pixels are single numbers or vectors. How does
>>>>> one do that?
>>>>>
>>>>> Greetings,
>>>>> Lambert
>>>>>
>>>>>
>>>>>
>>>>> _____________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Kitware offers ITK Training Courses, for more information visit:
>>>>> http://www.kitware.com/products/protraining.php
>>>>>
>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>>>
>>>>>
>>>>
>>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160315/d9d17300/attachment.html>


More information about the Insight-users mailing list