[Insight-developers] interpolaters/image functions and coord rep type

Luis Ibanez luis.ibanez@kitware.com
Tue, 19 Feb 2002 21:05:47 -0500


Adding the representation type to the FunctionBase class  seems to be
the best option. Overloading Evaluate() n-times will be confusing for
people adding new Interpolators.

I agree with the need of adding casting classes for converting
Point<double,N> to Point<float,N> and back in an efficient way.

Adding that at the itk::Array level could help to factorize code
but will also break the encapsulation and allow a Point<> to be
assigned to a Vector<>, which will not be a good thing.

It looks like another use for the Partial Specialization method
that Brad designed.

It could be an utility class, something like:


template< typename A, typename B>
class PointCast< A, B > {
public:
   template <unsigned int N>
   void Convert( const Point<A,N> & a, Point<B,N> & b) const
    {
     for(unsigned int i=0; i<N; i++) b[i] = static_cast<B>( a[i] );
    }
};



  Luis


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


Lydia Ng wrote:

>Hi,
>
>At the meeting I think it was agreed that coordinate represenation type
>for itk::Point and itk::ContinuousIndex was to remain and template
>parameter.
>
>Currently the interpolators/image functions hard-wires the 
>coord rep to double as follows:
>
>template<class TInputImage, class TOutput>
>class ImageFunction ::
>  public FunctionBase<Point<double,TInputImage::ImageDimension>,double>
>{
>
>  // other stuff snipped
>
>  typedef Point<double,ImageDimension> PointType;
>  typedef ContinuousIndex<double,ImageDimension> ContinousIndexType;
>
>  // There are 3 versions of Evaluate
>  virtual double Evaluate( const PointType& point ) const;
>  virtual double Evaluate( const ContinuousIndexType& cindex ) const;
>  virtual double Evaluate( const IndexType & index ) const;
>
>};
>
>
>The image functions API need to be extended to handle cases
>when coord rep is not double.
>
>I think two options were discussed at the meeting:
>
>[1] add an extra template parameter to ImageFunction
> e.g. template<class TInputImage, class TCoordRep = float>
>
>or
>
>[2] have 4 different version of Evaluate
>virtual double Evaluate( const Point<double,ImageDimension>& ) const;
>virtual double Evaluate( const Point<float,ImageDimension>& ) const;
>virtual double Evaluate( const ContinuousIndex<double, ImageDimension>&
>) const;
>virtual double Evaluate( const ContinuousIndex<float,ImageDimension>& )
>const;
>
>----------------------
>I have concerns about [2] because it was awkward enough that each
>subclass has to decide how it was going to support 3 different versions
>of Evaluate. With [2] the function needs to now support 5.
>
>Also we would need utility functions that converts double Point to
>float Point and indexes both double Point and float Points etc ...
>
>At this stage I prefer [1]. 
>Anybody has comments/suggestions on this?
>
>- Lydia 
>
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers@public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-developers
>