[Insight-users] Apply Transform

Oscar Esteban Sanz-Dranguet oesteban at die.upm.es
Mon Jun 29 14:31:28 EDT 2009


Hi again,

I have to add some information. All transforms seem to be working as 
spected. When I compute the transformation for the center point, it 
returns the same point (no matter the rotation axis, so OK).

Could it be a bug on itk::ResampleImageFilter< ImageType, ImageType > or 
itk::ImageFileWriter< ImageType > ?
Am I calling the filters correctly?

Thanks,
Oscar Esteban

Oscar Esteban Sanz-Dranguet escribió:
> Hi,
>
> I try to apply a rigid transform to some mri images. After SetCenter, 
> only rotation about Y axis seems to use this center. Why I don't get 
> the correct center of rotation about X and Z axis? (code at the end)
>
> Best Regards,
> Oscar Esteban
>
>
> <<<<<<<<<<<<<<<<< CODE >>>>>>>>>>>>>>>>>>>>>>
> int main( int argc, char *argv[] )
>  {
>  if ( argc < 8 )
>    {
>    std::cerr << "Missing Parameters " << std::endl;
>    std::cerr << "Usage: " << argv[0];
>    std::cerr << " inputImageFile outputImageFile";
>    std::cerr << " traslationX traslationY traslationZ";
>    std::cerr << " rotationX rotationY rotationZ";
>    std::cerr << std::endl;
>    return 1;
>    }
>
>  typedef itk::ImageFileReader< ImageType > ImageReaderType;
>
>  typedef itk::Euler3DTransform< double > TransformType;
>
>  // Read images
>  ImageReaderType::Pointer  imageReader  = ImageReaderType::New();
>  imageReader->SetFileName( argv[1] );
>  imageReader->Update();
>  ImageType::Pointer  image =  imageReader->GetOutput();
>  ImageType::SpacingType spacing = image->GetSpacing();
>  ImageType::IndexType pixelCenter = { 128, 128, 58 };
>
>  image->SetPixel( pixelCenter, 255);
>
>  TransformType::Pointer      transform     = TransformType::New();
>
>  TransformType::InputPointType center;
>  center[0] = 128.5 * spacing[0];
>  center[1] = 128.5 * spacing[1];
>  center[2] = 58.5 *  spacing[2];
>  transform->SetCenter( center );
>
>  TransformType::OutputVectorType translation;
>  translation[0] = atof( argv[3] ) * spacing[0];
>  translation[1] = atof( argv[4] ) * spacing[1];
>  translation[2] = atof( argv[5] ) * spacing[2];
>
>  transform->SetRotation( deg2rad( atof( argv[6] ) ), deg2rad( atof( 
> argv[7] ) ), deg2rad( atof( argv[8] ) ) );
>  transform->SetTranslation( translation );
>
>  transform->Print(std::cout, 3);
>
>  typedef itk::ResampleImageFilter< ImageType, ImageType >    
> ResampleFilterType;
>  ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>
>  resampler->SetTransform( transform );
>  resampler->SetInput( image );
>  resampler->SetReferenceImage( image );
>  resampler->UseReferenceImageOn( );
>  resampler->Update();
>
>  typedef itk::ImageFileWriter< ImageType >  WriterType;
>  WriterType::Pointer writer =  WriterType::New();
>  writer->SetFileName( argv[2] );
>  writer->SetInput( resampler->GetOutput() );
>  writer->Update();
>
>  return EXIT_SUCCESS;
>  }
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: 
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list