[Insight-developers] Using ConstantPadImageFilter on vector images

Luis Ibanez ibanez@choroid.cs.unc.edu
Fri, 28 Dec 2001 11:45:45 -0500 (EST)


Hi Lydia,

I tried the following in Linux and seems to work ok.
It remains to be seen how it will behave in other 
platform.



1) Change NumericTraits<>::Zero from being a static
   var to be a static function NumericTraits<>::Zero();

2) in NumericTraits add a generic trait for Vector, but
   templated over Type and Dimension. Like:


template <class Type, unsigned int Dimension>
class NumericTraits< Vector<Type, Dimension> > :
      public ITK_NUMERIC_LIMITS<  Vector<Type, Dimension> > {
public:
  typedef Vector< Type, Dimension > VectorType;
  typedef VectorType ValueType;
  typedef VectorType AbsType;
  typedef VectorType AccumulateType;
 
  static VectorType Zero( void ) { VectorType t; t.Fill(0); return t; }
  //.... etc
};
                          



3) use it as :

  VectorType ll;

  ll = itk::NumericTraits< VectorType >::Zero();



One of the drawbacks of using a static function instead
of a static variable is that it will be slower for simple 
basic types like: int, char...

A Similar change will have to be applied to NumericTraits<>::One
to convert it into:     NumericTraits<>::One();



  Luis




=====================

On Thu, 27 Dec 2001, Lydia Ng wrote:

> Hi All,
> 
> I would like to use ConstantPadImageFilter
> on vector images (i.e. where the image pixel is
> of type itk::Vector<someScalar,vectorDimension>).
> 
> The existing implementation does not work because as
> it requires the used of NumericsTraits<PixelType>::Zero
> to initialize the padding value to "zero".
> Currently, NumericsTraits for itk::Vector's are not defined.
> 
> I am not sure how to go about defining a generic
> NumericsTraits for Vector. Does one have to explicitly
> specialize NumericsTraits for every combination
> of *someScalar* and *vectorDimension*?
> 
> My other option is to create a vector version
> of the filter (i.e. a VectorConstantPadImageFilter) but
> that seems to be an awful lot of code duplication.
> 
> Any suggestions?
> 
> Cheers,
> Lydia
> 
> 
> 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
> 

-- 
Luis Ibanez                                      CB#:   7060
Research Assistan Professor                      phone: (919) 843 5436
Division of Neurosurgery                         fax:   (919) 966 6627
University of North Carolina at Chapel Hill      email: ibanez@cs.unc.edu
Chapel Hill, NC 27599-7060                       http://www.cs.unc.edu/~ibanez