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> // This would get the index matrix...<br> vtkMatrix4x4 * mat = m_slicer->GetLookupMatrix();<br> if (mat)<br> {<br> double in[4] = {(double)x, (double)y, (double)z,
0.0};<br> mat->MultiplyPoint(in, out);<br> }<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> vtkMatrix4x4 * mat = m_slicer->GetLookupMatrix();<br> if (mat)<br> {<br> double in[4] = {x, y, z, 0.0};<br> // inverse the matrix<br> mat->Invert(mat, m_indexInv);
<br> m_indexInv->MultiplyPoint(in, out);<br> }<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> // First transform the display point using the vtkTransform object
<br> double * transformed = m_transform->TransformPoint(x, y, z);<br> <br> vtkMatrix4x4 * mat = m_slicer->GetLookupMatrix();<br> if (mat)<br> {<br> // Now pass the transformed point through the look up matrix..
<br> double out [4] = {0.0, 0.0, 0.0, 0.0};<br> double in[4] = {transformed[0], transformed[1], transformed[2], 0.0};<br> mat->Invert(mat, m_indexInv);<br> m_indexInv->MultiplyPoint(in, out);
<br> <br> double currentXPos, currentYPos;<br> GetCurrentPosition(currentXPos, currentYPos); <br> SetCursorPosition(out[0] + currentXPos, out[1] + currentYPos);
<br> }<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>