[Insight-users] How to write CovariantVector Threshold Accessor with ITK?
Melanie Uks
meluks2010 at googlemail.com
Wed Jul 6 08:57:42 EDT 2011
Hi all,
I wanted to write a threshold accessor for vector pixels. I wanted to give
back a zero vector if one of the vector components, specified by the index,
is smaller than zero. Otherwise I wanted to give back the original vector. I
never worked with accessors but I checked the SoftwareGuide. So far I could
start a (non-working) example for this (see below). Can anybody tell me if
this is the right way to do such a thresholding with ITK and if yes how to
correct my example. At the moment I become the following error:
error C2440: 'static_cast' : cannot convert from
'itk::CovariantVector<T,NVectorDimension>' to 'float'
Thanks a lot!
Cheers,
Melanie
class ThresholdVectorPixelAccessor
{
public:
typedef itk::CovariantVector<float,3> InternalType;
typedef float InternalPixelType;
typedef itk::CovariantVector<float,3> ExternalType;
void operator=( const ThresholdVectorPixelAccessor & vpa )
{
m_Index = vpa.m_Index;
}
ExternalType Get( const InternalType & input ) const
{
if(static_cast<InternalPixelType>( input[ m_Index ] ) < 0)
{
ExternalType empty;
for(int i = 0; i < 3; i++)
empty[i]=0;
return empty;
}
else
return static_cast<ExternalType>( input);
}
void SetIndex( unsigned int index )
{
m_Index = index;
}
private:
unsigned int m_Index;
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110706/a370472c/attachment.htm>
More information about the Insight-users
mailing list