[Insight-developers] Interpolation support in itk::ImageFunction

Luis Ibanez luis.ibanez at kitware.com
Wed Feb 20 09:46:31 EST 2008


Hi Ivan,


I'm not sure I'm interpreting your suggestion correctly.


It seems that you are proposing that the ImageFunction class
should implement the EvaluateAtIndex() method by using the
code of the LinearInterpolateImageFunction.


Is that right ?

 From looking at the current code, here is what I gather:


0) itk::ImageFunction has defined a pure virtual method
    EvaluateAtIndex()

1) itk::InterpolateImageFunction (a class that derives
    from itk::ImageFunction) has an implementation of the method
    EvaluateAtIndex() with the following code:


   virtual outputtype evaluateatindex( const indextype & index ) const
     {
     return ( static_cast<realtype>(
        this->getinputimage()->getpixel( index ) ) );
     }


2) itk::LinearInterpolateImageFunction (a class that derives
    from itk::InterpolateImageFunction) does not have an
    implementation of the EvaluateAtIndex() method. (e.g.
    relies on the implementation in the superclass (1)).



I don't quite see the reason for moving the implementation
of EvaluateAtIndex() up to the itk::ImageFunction.

Shouldn't the right solution be that instead of you deriving
your new class from the itk::ImageFunction, you should derive
it from the itk::InterpolateImageFunction or from the
itk::LinearInterpolateImageFunction ?


Please help us understand the  reasons why a different
derivation would not solve the problem.


     Thanks


        Luis


------------------
Iván Macía wrote:
> Hi,
> 
>  
> 
> Some time ago I implemented some image functions in a contribution to 
> the Insight Journal.
> 
>  
> 
> http://www.insight-journal.org/InsightJournalManager/view_reviews.php?back=publications.php%3Fjournalid%3D9%26order%3Drating%26revision_display%3Dcombined&pubid=179 
> <http://www.insight-journal.org/InsightJournalManager/view_reviews.php?back=publications.php%3Fjournalid%3D9%26order%3Drating%26revision_display%3Dcombined&pubid=179>
> 
>  
> 
> The code uses nearest neighbour interpolation in the Evaluate() method 
> as this interpolation mode is trivial to implement.
> 
>  
> 
> However, in order to use linear interpolation I had to add a flag to my 
> ImageFunction-derived class and copy some code from 
> LinearInterpolateImageFunction. What I do is copy the corresponding code 
> from itk::LinearInterpolateImageFunction and replace the call
> 
>  
> 
> this->GetInputImage()->GetPixel( neighIndex )
> 
>  
> 
> to get the image valur of each neighbour with the call
> 
>  
> 
> this->EvaluateAtIndex( neighIndex )
> 
>  
> 
> as the values are not yet calculated inside the ImageFunction.
> 
>  
> 
> In my opinion such functionality should be in the ImageFunction 
> superclass itself but I wasn’t able to find any support for this. I 
> wanted to know if there is any built-in support to do this in 
> ImageFunction and otherwise what would be the best way to do it (using 
> an enum? a template parameter? reusing interpolation image functions? ).
> 
>  
> 
> Thanks in advance
> 
>  
> 
> Iván Macía
> 
>  
> 
> 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date: 
> 03/02/2008 17:49
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list