[Insight-users] pixel type -- slcalar or non-scalar?

Julien Jomier jjomier at cs.unc.edu
Wed Dec 8 14:04:24 EST 2004


Hi Patrick,

If you want to check the pixel type at compile time, the simple answer 
if that you cannot do it. That's why ITK has different filters for 
vector images and scalar images.

If you want to check it at runtime you can use RTTI
(typeid(mypixeltype)).

Julien

Peng (Patrick) Cheng wrote:
> Hi Julien,
> 
> I still have a question:
> How do I check if the PixelType is a scalar or non-scalar?
> Do you have an example for that?
> 
> Thanks
> 
> Patrick
> 
> Julien Jomier wrote:
> 
>> Hi Patrick,
>>
>> This is correct. ITK doesn't have a general way of initializing both 
>> scalar and vector type at this point. You can initialize scalar and 
>> RGBPixel in the same function, but you have to create a separate 
>> function/class for images of vectors.
>>
>> Hope that helps,
>>
>> Julien
>>
>> Peng (Patrick) Cheng wrote:
>>
>>> hi all,
>>> I have following code:
>>>
>>>  InputPixelType p;
>>>  if(InputPixelType::GetNumberOfComponents()>1){
>>>    p.Fill(0);
>>>  }
>>>  else{
>>>    p = NumericTraits<InputPixelType>::Zero;
>>>  }
>>>
>>> When I pass the scalar pixel to this, it doesn't work.  Is that 
>>> becasue of scalar type don't have GetNumberOfComponents() method?
>>>
>>> How to rewrite this code?
>>>
>>> Thanks
>>>
>>> Patrick
>>>
>>
> 


More information about the Insight-users mailing list