[vtkusers] Re: Rotation does not happen about the center of the image
Anja Ende
anja.ende at googlemail.com
Mon Sep 18 15:05:57 EDT 2006
I tried turning the vtkImageChangeInformation off and the rotation behaves
exactly the same...
You see a translation towards the upper right corner of the display and it
gradually comes back as you rotate through 360 degrees...
I used the vtkImagePlaneWidget and the rotations are perfect. I think that
translates, rotates and translates back....
However, I just am not sure why this should not work...
Just to give a bit more info on the code... I set the reslice axes cosines
for the reslicer for the XY plane as well.... I am really stumped as to why
the scaling is fine and rotations are not....
Again, would really appreciate it if someone could provide some help.
Thanks,
Anja
On 18/09/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Ok, here is basically what I do...
>
> I have just tried to get the code that might be relevant here to
> demonstrate the problem.
>
> // Read the image
> vtkDICOMImageReader * reader = vtkDICOMImageReader::New();
> reader->SetDirectoryName("/home/anja/data/dicom/11088");
> reader->Update();
>
> // Apply the vtkImageChangeInformation filter
> vtkImageChangeInformation * imageChangeInformation =
> vtkImageChangeInformation::New();
> imageChangeInformation->SetInput(reader->GetOutput());
> imageChangeInformation->CenterImageOn(); // Centered the image here....
> imageChangeInformation->Update();
>
> vtkImageReslice * reslice = vtkImageReslice::New();
> reslice->SetOutputDimensionality(2);
> vtkTransform * transform = vtkTransform::New();
> transform->Identity();
> reslice->SetResliceTransform(transform);
>
> reslice->SetInput(imageChangeInformation->GetOutput());
>
> // Assume that the origin and spacing are set from the input data...num is
> the Z slice index that
> // we want to show
>
> this->m_slicer->SetResliceAxesOrigin(0, 0, origin[2] + num * spacing[2]);
>
> Now if I tell the transform to rotate along the z axes, it should rotate
> about the center, right?
>
> transform->RotateZ();
>
> However, this rotation does not seem to be happening about the center...
>
> Stangely though,
>
> transform->Scale(factor, factor, 1.0);
>
> scales correctly...i.e. the scaling is applied uniformly from the
> center...
>
> I have a pretty urgent requirement and I need to fix this as soon as
> possible. So, any help would be really appreciated.
>
> Thanks,
>
> Anja
>
>
> On 18/09/06, Anja Ende <anja.ende at googlemail.com> wrote:
> >
> > Hi,
> >
> > This is kinda bizarre. I verified that the zooming (scaling in the
> > transform) happens around the center but the rotation does not...the
> > rotation happens as if the vtkImageChangeInformation filter has not been
> > applied at all...
> >
> > Did anyone else notice this ?? is there something special I have to do
> > for rotations???
> >
> > Cheers,
> > Anja
> >
> >
> > On 18/09/06, Anja Ende < anja.ende at googlemail.com> wrote:
> > >
> > > Hi everyone,
> > >
> > > I am unsable to have the rotations at the center of the image.
> > >
> > > So, I have a 3D volume and I pass it through the
> > > vtkImageChangeInformation filter. The CenterImageOn() function si called.
> > >
> > > The output of this filter is passed to a vtkImageReslice which has a
> > > transformation object that does the scaling and rotation. The scaling works
> > > fine but when I rotate the image I can see the center being shifyted. I
> > > thought that the vtkTransform should do these operations around the image
> > > center.
> > >
> > > I printed the vtkImageReslice index matrix and the original matrix is:
> > >
> > > Elements:
> > > 1 0 0 0
> > > 0 1 0 0
> > > 0 0 1 62
> > > 0 0 0 1
> > >
> > > And after a rotation of one degree:
> > >
> > > 0.999848 -0.0174524 0 0.0776696
> > > 0.0174524 0.999848 0 -4.44969
> > > 0 0 1 62
> > > 0 0 0 1
> > >
> > > I was hoping that the center would remain stationary....
> > >
> > > If anyone can cast some light on how I can manage this, I would be
> > > really grateful.
> > >
> > > Thanks,
> > > Anja
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060918/c456d53a/attachment.htm>
More information about the vtkusers
mailing list