[Insight-users] problems on Euler2DTransform

Ñî´ºÀ¼ lanlanny at bit.edu.cn
Thu Nov 18 23:54:44 EST 2004


I want to know whether Euler2DTransform sets the origin of physical coordinate as
the rotation center? and how to translate ? what's wrong with my code as
following?
/************************************************************/
 const     unsigned int   Dimension = 2;
  typedef   unsigned char  InputPixelType;
  typedef   unsigned char  OutputPixelType;

  typedef itk::Image< InputPixelType,  Dimension >   InputImageType;
  typedef itk::Image< OutputPixelType, Dimension >   OutputImageType;

  typedef itk::ImageFileReader< InputImageType  >  ReaderType;
  typedef itk::ImageFileWriter< OutputImageType >  WriterType;

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

  reader->SetFileName( argv[1] );
  writer->SetFileName( argv[2] );

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

  FilterType::Pointer filter = FilterType::New();
  typedef itk::Euler2DTransform<double> TransformType;
  TransformType::Pointer transform = TransformType::New();
  typedef itk::LinearInterpolateImageFunction< 
                       InputImageType, double >  InterpolatorType;
  InterpolatorType::Pointer interpolator = InterpolatorType::New();
 
  filter->SetInterpolator( interpolator );

  filter->SetDefaultPixelValue( 0 );
  reader->Update();
  const InputImageType::SpacingType&
    spacing = reader->GetOutput()->GetSpacing();
  const InputImageType::PointType&
    origin  = reader->GetOutput()->GetOrigin();
  InputImageType::SizeType size = 
      reader->GetOutput()->GetLargestPossibleRegion().GetSize();
  filter->SetOutputOrigin( origin );
  filter->SetOutputSpacing( spacing );
  filter->SetSize( size );
 filter->SetInput( reader->GetOutput() );
  writer->SetInput( filter->GetOutput() );

  double angle = atoi(argv[3]);
  transform->SetRotation(angle);

  TransformType::OffsetType offset(2);
  offset[0]=atoi(argv[4]);
  offset[1]=atoi(argv[5]);

  transform->Translate(offset);
  filter->SetTransform(transform);

  filter->Update();
try 
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception catched !" << std::endl;
    std::cerr << excep << std::endl;
    }




More information about the Insight-users mailing list