[Insight-users] AffineTransform: Rotate3D

Ghassan Hamarneh hamarneh at gmail.com
Mon Dec 13 04:08:43 EST 2004


I believe you need something like:
origin = image->GetOrigin;
center[0] = origin[0] + size[0] / 2.0;
center[1] = origin[1] + size[1] / 2.0;
center[2] = origin[2] + size[2] / 2.0;

/Ghassan


On Fri, 10 Dec 2004 15:18:09 +0100 (CET), André Huisman
<ahuisman at cs.uu.nl> wrote:
> 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
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list