[Insight-developers] Bug in ResampleImageFilter and OptResampleImageFilter

Luca Antiga luca.antiga at gmail.com
Sat Nov 15 05:29:47 EST 2008


Hi,
  I just found a bug in itkResampleImageFilter and  
itkOptResampleImageFilter that prevents code to build if TInputImage  
and TOutputImage are not the same and SetReferenceImage is used.

More specifically, the following code fails to build

#include "itkImage.h"
#include "itkResampleImageFilter.h"

int main (int argc, char* argv[])
{
   typedef itk::Image<double,3> InputImageType;
   typedef itk::Image<signed short,3> ReferenceImageType;

   InputImageType::Pointer inputImage = InputImageType::New();
   ReferenceImageType::Pointer referenceImage =  
ReferenceImageType::New();

   typedef itk::ResampleImageFilter<InputImageType,OutputImageType>  
ResampleFilterType;

   ResampleFilterType::Pointer resample = ResampleFilterType::New();
   resample->SetInput(inputImage);
   resample->SetReferenceImage(referenceImage);

   return 1;
}

because of the following lines
Insight/Code/BasicFilters/itkResampleImageFilter.txx:554
Insight/Code/Review/itkOptResampleImageFilter.txx:839

if( image != static_cast<const TOutputImage *>(this->GetInput( 1 )) )
   {
   ...

which should be instead

if( image != static_cast<const TOutputImage *>(this- 
 >ProcessObject::GetInput( 1 )) )
    {
    ...

because this->GetInput(1) returns a TInputImage*, which can't be  
casted to a TOutputImage*,
which is the reference image type.
In the other hand, this->ProcessObject::GetInput(1) returns a  
itk::DataObject*, which is castable
to TOutputImage*.

I'll file a bug report and fix the bug if that's ok with everybody.

Cheers


Luca



More information about the Insight-developers mailing list