[Insight-users] AffineTransform: Rotate3D

André Huisman ahuisman at cs.uu.nl
Fri Dec 10 09:18:09 EST 2004


Dear ITK-users,

I simply want to rotate a 3D (!) image around its center. I found several
postings about this topic. I use a CenteredAffineTransform and use the method
Rotate3D to do the transformation.
Here is my code (extracted from my application). The image is computed
somewhere
else.


typedef itk::CenteredAffineTransform< double, Dimension> TransformType;
typedef itk::ResampleImageFilter<BinaryImageType, BinaryImageType>
RotateFilterType;
RotateFilterType::Pointer rotatefilter = RotateFilterType::New();
TransformType::Pointer transform = TransformType::New();

rotatefilter->SetTransform(transform);
size = image->GetLargestPossibleRegion().GetSize();

rotatefilter->SetInput(image);
TransformType::InputPointType center;
center[0] = size[0] / 2.0;
center[1] = size[1] / 2.0;
center[2] = size[2] / 2.0;

transform->SetCenter(center);
const double degreesToRadians = atan(1.0) / 45.0;
const double angle = 270 * degreesToRadians;
TransformType::OutputVectorType axis;
axis[0] = 1;
axis[1] = 0;
axis[2] = 0;

transform->ComputeOffset();
transform->Rotate3D( axis, angle, false );

rotatefilter->SetDefaultPixelValue( 100 );
rotatefilter->SetSize( size );
rotatefilter->Update();
image=rotatefilter->GetOutput();

Finally I write one slice of the 3D image to disk and what I see is just an
image with grey-values of 100.

What is the problem here and how can I solve this?

Thank you very much,

Andre Huisman


More information about the Insight-users mailing list