<div dir="ltr"><div>Hi Clément,</div><div><br></div><div>The basic formula for the transformation in vtkImageReslice is as follows:</div><div><br></div><div>    p_in = T A p_out</div><div><br></div><div>where T is ResliceTransform, A is ResliceAxes, p_out is "output data coords", and p_in is "input data coords".  In most cases, p_out is also "world coords".</div><div><br></div><div>The documentation says "T is applied to the resampling grid that has been defined by A", which is just another way of saying that "T is applied after A".  As shown in the above equation, T is associated with p_in, not with p_out.</div><div><br></div><div>In other words, you cannot use T to perform a transformation in world coords.</div><div><br></div><div>Instead, the code would be something like this:</div><div><br></div><div># define the desired translation in output (i.e. world) coords</div><div>t_world = (1.0, 0.0, 0.0, 0.0)</div><div># convert to data coords</div><div>A = slice.GetResliceAxes()</div><div>t_data = A.MultiplyPoint(t_world)</div><div># create a transformation for data coords</div><div>T.Translate(t_data[0:3])</div><div>slice.SetResliceTransform(T)</div><div><br></div><div> - David</div><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 28, 2017 at 10:12 AM, Clément D. <span dir="ltr"><<a href="mailto:clement.douarre@gmail.com" target="_blank">clement.douarre@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello everyone, new to VTK, etc etc.<br><br></div>I wish to extract a  2D slice from a 3D volume, and then translate this slicing in the volume, following the axis of the slice<br><div><div><br>So say I declare my slice this way (code is in Python) :<br><br>------------------------------<wbr>-------------<br>oblique = vtk.vtkMatrix4x4()<br></div><div>#Some oblique matrix, vectors are in fact normalised but here I just put random numbers for this example<br></div><div>oblique.DeepCopy((0.3, 0   , 0   , 10,<br>                  0  , 0.28, 0   , 10,<br>                  0.8, 0   , 0.97, 10,<br></div><div>                  0  , 0   , 0   , 1)) <br></div><div><br>slice=vtk.vtkImageReslice() #create the slice object<br>slice.SetOutputExtent(0, 5, 0, 5, 0, 0)<br>slice.SetOutputOrigin(-0.5 * 5, -0.5 * 5, 0)<br><br>slice.SetResliceAxes(oblique) #set the resliceAxes matrix to it<br>------------------------------<wbr>-----------------<br><br></div><div>So far so good, I get a slice oriented along the oblique matrix. It gets trickier when I want to translate it.<br></div><div>Bear in mind that I would like a translation *along the axis of the oblique matrix* and not in world coordinates.<br></div><div>I.E. i would like to translate along vectors (0.3,0,0.8), (0,0.28,0) and (0,0,0.97) (vectors of the oblique matrix)<br><br></div><div>So if I do this :<br></div><div><br>------------------------------<wbr>-------------<br>transformation = vtk.vtkTransform();<br>slice.SetResliceTransform(<wbr>transformation)<br>transformation.Translate(1,0,<wbr>0)<br>slice.Update()<br>------------------------------<wbr>-------------<br><br></div><div>I would expect reading documentation on setResliceTransform that my slice would move along one of these axis (the Z axis here).<br></div><div>Because my understanding of setResliceTransform and setResliceAxes being used together is that the latter is used to set up a grid upon which the former will then act (so translating will "slide" along the axes of setResliceAxes)<br></div><div>However, I do not observe this behaviour (I don't really how the slice is moving, but certainly not in the axes of oblique), did I get something wrong ?<br><br></div><div>Many thanks,<br></div><div>Clément<br></div></div></div>
</blockquote></div><br></div></div>