[vtkusers] vtkImageReslice rotation when not about center of image.

Richard Frank rickfrank at me.com
Wed Oct 26 13:54:24 EDT 2016

Thanks David,

That's what I was doing at first, and it seemed to have the same issues  :>/

But perhaps I did something incorrectly, and I will take another look at the first approach.



On Oct 26, 2016, at 11:52 AM, David Gobbi <david.gobbi at gmail.com> wrote:

Hi Rick,

I cannot recommend using SetResliceAxesOrigin() to set the center of rotation.  Instead, it's best to build the 4x4 matrix that does the transformation that you need, and call SetResliceAxes(matrix).

For rotation around a point, you need a matrix that translates the center-of-rotation to (0,0,0), applies a rotation about (0,0,0), and then translates back again.

 - David

On Tue, Oct 25, 2016 at 10:30 AM, Richard Frank <rickfrank at me.com> wrote:


I'm trying to modify the vtkExample to use vtkImageReslice about a point not at the center of the volume.

A link to my code is below, which is the Cxx folder from the Imaging Examples, with modifications to the ImageSlicing sub project.


Also, here is a link to my input data, a small mha file which is easy to see:


if you load the file, you will see an axial view. The volume has an origin of (0,0,0). I compute the center of the volume, and then position the actor on that center point (actors are positioned by the center point).

This is analogous to what our application under development does - we position the slice actor in world coordinates using the DICOM Image Position Patient at the top left (depending on orientation) + center offset of the volume.

In my example code, when you load up for the first time and left click, and "rotate" with the mouse, I draw an angle widget for your convenience whose joint is on the center of rotation. I compute the matrix for the rotation, and set that in the reslice matrix, followed by  the origin. This works perfectly, and the slice rotates about its center.

If you right click, you will change the ctr of rotation in world coordinates.
ImageReslice->SetResliceAxesOrigin(rotationCenter[0], rotationCenter[1], rotationCenter[2]);

When you then rotate with left mouse, the angle widget joint is in the correct place in the view but  the the image rotates about a point which I can't quite determine.

The new center of rotation that the reslice uses seem to be proportionally related to how far away from the center of the image that is right clicked on - the closer to the center of the slice clicked, the less the center of rotation moves away from the click.

It seems like there's something I'm missing about how the center of rotation works.

Any help appreciated.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/a1a45a3e/attachment.html>

More information about the vtkusers mailing list