Hi,<br><br>This is a question for all you linear algebra and VTK experts:<br><br>Again, I have a vtkImageReslice that outputs 2D slices and has a vtkTransform parameter. I have extended the vtkImageReslice object, so that I have access to the index matrix that helps me map output data to reslicer input data.
<br><br>Now, earlier I just had scaling on the inout image and I was doing look up through the vtkImageReslice object. This was workign fantastic!<br><br>I had it as follows:<br><br>// This function was returning the image pixel from the display x, y, z
<br>void DisplayToImageSpace(int x, int y, int z, double out[4])<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This would get the index matrix...<br>&nbsp;&nbsp;&nbsp; vtkMatrix4x4 * mat = m_slicer-&gt;GetLookupMatrix();<br>&nbsp;&nbsp;&nbsp; if (mat)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double in[4] = {(double)x, (double)y, (double)z, 
0.0};<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mat-&gt;MultiplyPoint(in, out);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>// This function was returning the image pixel from the display coordinates<br>void ImageToDisplaySpace(double x, double y, double z, double out[4])<br>
{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkMatrix4x4 * mat = m_slicer-&gt;GetLookupMatrix();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double in[4] = {x, y, z, 0.0};<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // inverse the matrix<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mat-&gt;Invert(mat, m_indexInv);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_indexInv-&gt;MultiplyPoint(in, out);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>This was working fantastic. I was happy!<br><br>Now, I have rotation on the slices:<br><br>The rotation is implemented using the vtkTransform.
<br><br>So, I tried to implement the DisplayToImageSpace function as follows and set my cursor...<br><br>void TestTransformation(double x, double y, double z)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // First transform the display point using the vtkTransform object
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double * transformed = m_transform-&gt;TransformPoint(x, y, z);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkMatrix4x4 * mat = m_slicer-&gt;GetLookupMatrix();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mat)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Now pass the transformed point through the look up matrix..&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double out [4] = {0.0, 0.0, 0.0, 0.0};<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double in[4] = {transformed[0], transformed[1], transformed[2], 0.0};<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mat-&gt;Invert(mat, m_indexInv);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_indexInv-&gt;MultiplyPoint(in, out);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double currentXPos, currentYPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetCurrentPosition(currentXPos, currentYPos);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetCursorPosition(out[0] + currentXPos, out[1] + currentYPos);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>However, this does not return the correct values. I have 2 issues:<br><br>- Once the image is rotated, how to calculate the correct actor2D position? The image is always displayed in the center and I think I have to calculate the offset from the lower left corner of the image. With only scaling it was pretty easy...
<br><br>- Second, I wonder if I am doing this transformation correctly. Can someone tell me, for example, how I can map a particular coordinate from the original image to the transformed (rotated) image and vice-versa. <br>
<br>Hope I made the question clear enough. I have been racking my brains for 2 days over this now. I would really appreciate some help. <br><br>Please help!<br><br>Thanks,<br>Anja<br><br><br><br>