[vtkusers] vtkImageReslace + vtkTransform - Rotate Image

David Gobbi david.gobbi at gmail.com
Wed Mar 5 15:27:59 EST 2008


Hi Paulo,

The "bounds" have six values.  Also, to be safe, remember to call
image.GetOutput().Update() before GetBounds().

To get the center of the bounds,

center = [0.5*(bounds[0] + bounds[1]), 0.5*(bounds[2] + bounds[3]),
0.5*(bounds[4] + bounds[5])]

To transform, use this:

transform.PostMultiply()
transform.Translate((-center[0], -center[1], -center[2]))
transform.RotateY(90)
transform.Translate((center[0], center[1], center[2]))

Try changing to PreMultiply() if that doesn't work.  I'm sure that
it's one or the other...

    David


On Wed, Mar 5, 2008 at 3:03 PM, Paulo Henrique Junqueira Amorim
<paulojamorim at gmail.com> wrote:
> Hello All,
>
> I have the need to rotate the image, but the image is only in accordance
> with the rotational axis Z.
>
> Code ok with Z axis:
>
> bounds = self.image.GetOutput().GetBounds()
>  center = -1.0*bounds[0], -1.0*bounds[1], -1.0*bounds[2]
>
> reslice = vtkImageReslice()
> transform = vtkTransform()
> transform.RotateZ(90)
> # exemple: transform.RotateY(90) Not working
> reslice.SetInput(self.img_ant)
>  reslice.SetResliceTransform(transform)
> transform.Translate(center)
>
>
>  When rotate in the X or Y axis, the image is empty.
>
> Someone has already gone through this??
>
>
> Regards,
> Paulo Henrique J. Amorim
>
>
> _______________________________________________
>  This is the private VTK discussion list.
>  Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>  Follow this link to subscribe/unsubscribe:
>  http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list