Ok, I have finally managed to get something working that works for normal transformation to the image->Display and vice versa...<br><br>However, it returns bogus values when a slice is rotated along an axis...<br><br>-------------------------------------------------------------------------------------------------------
<br>Display ->Image Space...<br><br>// x, y, z are display coordinates<br><br>vtkMatrix4x4 * resliceMat = this->m_slicer->GetResliceAxes();<br>double axesTransform[4] = {x, y, z, 0.0};<br>resliceMat->MultiplyPoint(axesTransform, axesTransform);
<br>double * tp = m_transform->TransformPoint(axesTransform[0], axesTransform[1], axesTransform[2]);<br><br>// Out will contain the image coordinates<br><br>out[0] = tp[0];<br>out[1] = tp[1];<br>out[2] = tp[2];<br>out[3] =
0.0;<br><br>--------------------------------------------------------------------------------<br>// Image->Display Space<br>This function works if the slice is not rotated...However, if the slice is rotated then the values are incorrect... I do not understand why as the rotation is reflected in the transformation matrix.
<br><br>// x, y, z are image coordinates<br>// out will contain the values in the display space... or so I hoped!<br><br>double * tp = m_transform->GetLinearInverse()->TransformPoint(x, y, z);<br>vtkMatrix4x4 * resliceMat = this->m_slicer->GetResliceAxes();
<br>out[0] = tp[0];<br>out[1] = tp[1];<br>out[2] = tp[2];<br>out[3] = 0.0; <br>resliceMat->Invert(resliceMat, m_indexInv);<br>m_indexInv->MultiplyPoint(out, out);<br>---------------------------------------------------------------------------------------------
<br><br>I am really struggling with this, so any help would be really nice!<br><br>Thanks,<br>Anja<br><br><div><span class="gmail_quote">On 23/09/06, <b class="gmail_sendername">Anja Ende</b> <<a href="mailto:anja.ende@googlemail.com">
anja.ende@googlemail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">So, trying to use the reslice transform and reslice axes as suggested by David:
<br><br>I have an image with the following dimesnions: 256 X 256 X 62. It has been centered using vtkImageChangeInformation...<br><br>It has been scaled using the vtkTransform object by a factor of 2 in the X and Y direction..
<br><br>So, the transform matrix looks like this:<br><br> 0.5 0 0 0<br> 0 0.5 0 0<br> 0 0 1 0<br> 0 0 0 1<br><br><br>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:
<br><br>Input :255: 255: 62 (in pixels). Ignore the Z value... always 62<br><br>vtkImageData * in = reinterpret_cast<vtkImageData *>(this->m_slicer->GetInput());<br>in->UpdateInformation();<br><br> double origin[3];
<br>double spacing[3];<br>in->GetOrigin(origin);<br>in->GetSpacing(spacing);<br><br>// x = 255, y = 255, z = 62<br>// converting to world coordinates<br>double xt = origin[0] + spacing[0] * x;<br>double yt = origin[1] + spacing[1] * y;
<br>double zt = origin[2] + spacing[2] * z;<br><br>// Now transform the points....<br>double * tp = m_transform->TransformPoint(xt, yt, zt);<br><br>// Reslice axes of my reslicer <br>vtkMatrix4x4 * resliceMat = this->m_slicer->GetResliceAxes();
<br><br>// converting the transformed points back to display coordinates<br>double bx = (tp[0] - origin[0]) / spacing[0];<br>double by = (tp[1] - origin[1]) / spacing[1];<br>double bz = (tp[2] - origin[2]) / spacing[2];
<br><br>double inout[4] = {bx, by, bz, 0.0};<br>resliceMat->MultiplyPoint(inout, inout);<br><br>Now, I expected this to return:<br><br>127.5: 127.5: 62...center of the data...<br><br>Instead it returns:<br><br>191.75:
191.25: 62 :((((<br><br>I know I am making some fundamental errors here...so if someone could please help me sort it out... I would be really grateful<br> <br>Best,<br><br>Anja<br> <br><br><div>
<span class="gmail_quote">
On 22/09/06, <b class="gmail_sendername">Anja Ende</b> <<a href="mailto:anja.ende@googlemail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">anja.ende@googlemail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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. <br><br>Could you point an example as to how to use the ResliceTransform and the ResliceMatrix??
<br><br>Cheers and thanks,<br><span><br>Anja</span><div><span><br><br><div><span class="gmail_quote">On 22/09/06, <b class="gmail_sendername">David Gobbi</b> <<a href="mailto:dgobbi@atamai.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
dgobbi@atamai.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I should point out that the IndexMatrix is not a public member of the<br>class... and if you have a special version of vtkImageReslice that makes<br>this member public, you are using vtkImageReslice in a way that other<br>
people don't.<br><br>Why not just use the ResliceTransform and ResliceMatrix?<br><br> - David<br><br><br><br>Anja Ende wrote:<br>> Forgot to mention...<br>><br>> I am using the index matrix in the vtkImageReslice class to do the
<br>> input->output mapping and vice versa (by using the inverse of the<br>> matrix).<br>><br>> Anja<br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________
<br>> This is the private VTK discussion list.<br>> Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>> Follow this link to subscribe/unsubscribe:
<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>><br><br></blockquote></div><br>
</span></div></blockquote></div><br>
</blockquote></div><br>