[Insight-users] Update() on a Resampling Pipeline does not work

Allon Shahar AShahar at micromri.com
Thu Aug 30 17:54:38 EDT 2007


Hello all,

 

In my application, I'm trying to transform the same image (unionMask)
multiple times, each time with a different set of parameters (previously
collected), and write the result to file. The fixed image is saved fine,
but the loop just generates multiple copies of the same transformed
image. The cout's show that the parameters of invTransform do change in
every iteration, so I'm suspecting that the pipeline doesn't get updated
after the first iteration for some reason. As you can see, I tried
performing an Update() after updating every filter, but the result is
the same. I'd appreciate if someone could point me to whatever step I'm
missing...

 

Thanks,

Allon Shahar

 

------------------------------------------------------------------------
----------------------------

The filters are using are all versions of the common ITK filters:

 

typedef itk::ResampleImageFilter<InImageType, InImageType >
ResampleFilterType;

      ResampleFilterType::Pointer resampler = ResampleFilterType::New();

 

typedef itk::ThresholdImageFilter< InImageType >  ThreshFilterType;

ThreshFilterType::Pointer thresher = ThreshFilterType::New();

 

CastFilterType::Pointer  caster =  CastFilterType::New();

  

typedef itk::ImageFileWriter< OutImageType >  WriterType;

WriterType::Pointer      writer =  WriterType::New();

  

----------------------------------------------------

The problematic pipeline code is:

 

  // Write the union mask to the reference file.

  writer->SetFileName( fixedPrefix+outMaskSuffix );

  caster->SetInput( unionMask );

  writer->SetInput( caster->GetOutput()   );

  writer->Update();

 

  // Inverse transform to the individual test's plane.

  resampler->SetInput( unionMask );

        

  for ( i=0; i<numTests; i++ )

  {     

        for ( j=0; j<numParams; j++ ) finalParameters[j] =
collectParameters[i*numParams+j];

        transform->SetParameters( finalParameters );    

 

        movingPrefix = argv[i+2];

        transform->GetInverse( invTransform );

 

        matrix = invTransform->GetMatrix();

        offset = invTransform->GetOffset();

        std::cout << "Inverse Matrix = " << std::endl << matrix <<
std::endl;

        std::cout << "Inverse Offset = " << std::endl << offset <<
std::endl;

 

        resampler->SetTransform( invTransform );

        //resampler->Update();

        

        thresher->SetInput( resampler->GetOutput() );   

        //thresher->Update();

        

        caster->SetInput( thresher->GetOutput() );

        //caster->Update();

 

        //Write to file

  writer->SetFileName( movingPrefix+outMaskSuffix );

        writer->SetInput( caster->GetOutput()   );

        writer->Update();

  }

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070830/d98cfa15/attachment-0001.html


More information about the Insight-users mailing list