[Insight-users] Addition of two DeformationFields

Luis Ibanez luis.ibanez at kitware.com
Fri Aug 13 11:43:47 EDT 2004


Hi Monica,

Thanks for posting the error messages.

What happens is that the AddImageFilter uses a
NumericTrait type for accepting the result of
the sum.  Those NumericTraits<> were never created
for Vector types due to the deficiency of Visual
Studio 6 for supporting partial specialization.


The simple solution in your case is to define this
Numeric Trait in your application for the particular
type of your Vector type.

Please use the following code:

------------------------------------------------
#include "itkAddImageFilter.h"
#include "itkImage.h"
#include "itkVector.h"

typedef itk::Vector< float, 3 >   VectorPixelType;


// THIS IS THE NUMERIC TRAIT THAT YOU NEED
namespace itk {
   template <>
   class NumericTraits<VectorPixelType> {
   public:
     typedef VectorPixelType AccumulateType;
     };
   }
// END OF THE NUMERIC TRAIT


int main()
{
   typedef itk::Image< VectorPixelType, 3 > ImageType;

   typedef itk::AddImageFilter< ImageType,
                                ImageType,
                                ImageType >   FilterType;

   FilterType::Pointer filter = FilterType::New();

   return 0;
}
---------------------------------------------------------


Regards,


   Luis



-----------------------
Monica Lumbardi wrote:

> Hi Luis,
> Thanks for you advices. I've tried the AddImageFilter, but it doesn't 
> work for Vector images.
>  
> Here is my code:
>  
> typedef itk::Vector<float,3> vectortype;
> typedef itk::Image<vectortype, 3> deformationFieldType;
> 
> typedef itk::AddImageFilter <deformationFieldType, deformationFieldType, 
> deformationFieldType> addtype;
> 
> addtype::Pointer addFilter = addtype::New();
>  
> And when I compile, I get the following errors:
>  
> C:\ITK\itk\Code\BasicFilters\itkAddImageFilter.h(66): error C2440: 
> 'initializing' : cannot convert from 'const 
> itk::Image<TPixel,VImageDimension>::PixelType' to 'const 
> itk::Functor::Add2<TInput1,TInput2,TOutput>::AccumulatorType'
>         with
>         [
>             TPixel=VectorType,
>             VImageDimension=3
>         ]
>         and
>         [
>             TInput1=itk::Image<VectorType,3>::PixelType,
>             TInput2=itk::Image<VectorType,3>::PixelType,
>             TOutput=itk::Image<VectorType,3>::PixelType
>         ]
....





More information about the Insight-users mailing list