[Insight-users] to combine two affine transformations

Henry nyhenry at gmail.com
Mon Dec 3 16:15:08 EST 2007

Hi all,
I am confused by the results of combination of two transformations. I
need to apply affine transform1(Matrix1, Offset1) first and then
affine transform2 (Matrix2, Offset2).

Should the result transform3(Matrix3, Offset3) be like

Matrix3 = Matrix2*Matrix1
Matrix3 = Matrix2*Offset1 + Offset2 ?

I apply the transform3 and compare the image with apply two separate
(transform1 and then transform2),  and found the rotations are the
same but the offset/translation of the two results are different.
Any idea why this happens?


//my program looks like this:

  typedef itk::AffineTransform<double,3> AffineTransformType;
  AffineTransformType::Pointer affine = AffineTransformType::New();
  itk::TransformFileReader::Pointer transformreader1;
  itk::TransformFileReader::Pointer transformreader2;
  transformreader1 = itk::TransformFileReader::New();
  transformreader2 = itk::TransformFileReader::New();
  transformreader1->SetFileName( argv[1] );
  transformreader2->SetFileName( argv[2] );


//I read in two .tfm files and do the following:

	transform->SetMatrix( affine_read2->GetMatrix()*affine_read1->GetMatrix());

//and then write the final results

  itk::TransformFileWriter::Pointer writer;
  writer = itk::TransformFileWriter::New();
  writer->SetFileName( argv[3] );

More information about the Insight-users mailing list