[vtkusers] vtkTransform again....transforming a point does not work as expected...simple example

Anja Ende anja.ende at googlemail.com
Sat Sep 23 07:05:32 EDT 2006


So, trying to use the reslice transform and reslice axes as suggested by
David:

I have an image with the following dimesnions: 256 X 256 X 62. It has been
centered using vtkImageChangeInformation...

It has been scaled using the vtkTransform object by a factor of 2 in the X
and Y direction..

So, the transform matrix looks like this:

  0.5 0 0 0
  0 0.5 0 0
  0 0 1 0
  0 0 0 1


So, I click on the center of the image and I expect that the transformation
back should give me the imnage coordinates in the original input image. So,
I do the following:

Input :255: 255: 62 (in pixels). Ignore the Z value... always 62

vtkImageData * in = reinterpret_cast<vtkImageData
*>(this->m_slicer->GetInput());
in->UpdateInformation();

double origin[3];
double spacing[3];
in->GetOrigin(origin);
in->GetSpacing(spacing);

// x = 255, y = 255, z = 62
// converting to world coordinates
double xt = origin[0] + spacing[0] * x;
double yt = origin[1] + spacing[1] * y;
double zt = origin[2] + spacing[2] * z;

// Now transform the points....
double * tp = m_transform->TransformPoint(xt, yt, zt);

// Reslice axes of my reslicer
vtkMatrix4x4 * resliceMat = this->m_slicer->GetResliceAxes();

// converting the transformed points back to display coordinates
double bx = (tp[0]  - origin[0]) / spacing[0];
double by = (tp[1]  - origin[1]) / spacing[1];
double bz = (tp[2]  - origin[2]) / spacing[2];

double inout[4] = {bx, by, bz, 0.0};
resliceMat->MultiplyPoint(inout, inout);

Now, I expected this to return:

127.5: 127.5: 62...center of the data...

Instead it returns:

191.75: 191.25: 62 :((((

I know I am making some fundamental errors here...so if someone could please
help me sort it out... I would be really grateful

Best,

Anja


On 22/09/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Yes, I, unfortunately, could not get any other way to work... As I said, I
> am trying to get the TransformPoints method to work, but with little success
> so far.
>
> Could you point an example as to how to use the ResliceTransform and the
> ResliceMatrix??
>
> Cheers and thanks,
>
> Anja
>
> On 22/09/06, David Gobbi <dgobbi at atamai.com> wrote:
> >
> > I should point out that the IndexMatrix is not a public member of the
> > class... and if you have a special version of vtkImageReslice that makes
> > this member public, you are using vtkImageReslice in a way that other
> > people don't.
> >
> > Why not just use the ResliceTransform and ResliceMatrix?
> >
> > - David
> >
> >
> >
> > Anja Ende wrote:
> > > Forgot to mention...
> > >
> > > I am using the index matrix in the vtkImageReslice class to do the
> > > input->output mapping and vice versa (by using the inverse of the
> > > matrix).
> > >
> > > Anja
> > >
> > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > 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
> > >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060923/42f5cbe9/attachment.htm>


More information about the vtkusers mailing list