[Insight-developers] extracting components of vector image

Luis Ibanez luis . ibanez at kitware . com
Fri, 09 Aug 2002 07:48:41 -0400


Hi Tessa,

The compiler is complaining about line 82:

void SetIndex(unsigned int i) { this->GetFunctor()->SetIndex(i); }

because GetFunctor() returns a reference (not a pointer) to
the Functor. So you are not allowed to use the "->" operator after
GetFunctor(). You should use the normal invokation:

    this->GetFunctor().SetIndex( i );

The version of your filter that is checked in on Insight/BasicFilters
has the correct code:

void SetIndex(unsigned int i) { this->GetFunctor().SetIndex(i); }


As Jim pointed out, the same can be achieved by combining the
AdaptImageFilter and the itkNthElementPixelAccessor.

However this class seem to have the same notation problem that
you are experiencing with your filter:

     AccessorType& GetAccessor()
       { return this->GetFunctor()->GetAccessor(); };

It probably should be:

     AccessorType& GetAccessor()
       { return this->GetFunctor().GetAccessor(); };

It seems that a test is missing for this filter...


--

The major difference between using your implementation and
using the AdaptImageFilter will be on how the user selects
the index of the vector to be accessed.

In your filter it will be:

    myFilter.SetIndex( n );

while with the AdaptImageFilter it will be something like:

    myFilter.GetAccessor().SetElementNumber( n );

Maybe we could talk briefly about this on the Tcon.



    Luis




==================================================================
Tessa Sundaram wrote:
> Dear ITK gurus,
> 
> I'm trying to write a filter to extract one component of a vector image
> (for use with displacement fields, etc.).  I've tried modifying the
> CastImageFilter to create a VectorIndexSelectionCastImageFilter.
> However, I keep getting errors when I try to access the functor as
> this->GetFunctor()  within the filter:
> 
> C:\itk\Insight\Code\BasicFilters\itkVectorIndexSelectionCastImageFilter.h(82) 
> 
> : error C2819: type 'itk::Functor::VectorIndexSelectionCast<class
> itk::Vector<double,2>,float>' does not have an overloaded member
> 'operator ->'
>        
> C:\itk\Insight\Code\BasicFilters\itkVectorIndexSelectionCastImageFilter.h(82) 
> 
> : while compiling class-template member function 'void __thiscall
> itk::VectorIndexSelectionCastImageFilter<class itk::Image<class
> itk::Vector<double,2>,2>,class itk::Image<float,2> >::SetIndex(unsigned
> int)'
> C:\itk\Insight\Code\BasicFilters\itkVectorIndexSelectionCastImageFilter.h(82) 
> 
> : error C2227: left of '->SetIndex' must point to class/struct/union
>