<div dir="ltr">Hi Ryan,<div><br></div><div>After looking at the code, I think that the reason that it isn't working is that</div><div>you are applying the transform in the wrong direction, it should be this:</div><div><br></div><div>reslice.SetResliceTransform(grid.GetInverse())<br></div><div><br></div><div>The way that transforms work with vtkImageReslice is that, for each output</div><div>voxel, the transform is applied to the (x,y,z) location of that voxel to compute</div><div>an (x',y',z') location in the input volume that corresponds to the output voxel.</div><div>In other words, the transform is a coordinate mapping from output to input.</div><div><br></div><div>However, even after inverting the transform, I don't think you will get a good</div><div>result. In order for a grid transform to work nicely, it should be smooth (in</div><div>mathematical terms, it should be a diffeomorphism.)</div><div><br></div><div>The following VTK Journal article has some diagrams that might do a better</div><div>job of explaining the issues:</div><div><a href="http://www.vtkjournal.org/browse/publication/790">http://www.vtkjournal.org/browse/publication/790</a><br></div><div><br></div><div> - David</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 28, 2015 at 5:59 PM, Young, Ryan <span dir="ltr"><<a href="mailto:Ryan.Young@seattlechildrens.org" target="_blank">Ryan.Young@seattlechildrens.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><br>
Hey.<br>
<br>
I made a little pdf to hopefully clear things ups. Just to summarize, I have a vector field that is the displace of a volume. The test case is just a vector pointing 15 units in the x direction . It is only define for voxels within the volume. I am using
a vtkGridTransform and vtkImageReslice to apply this transformation. The result should a the volume unchanged, but centred 15 voxels to the right. What I am seeing is that the left half of the volume is missing.<br>
<br>
If I define the transformation to exist every voxel, not just within the volume, it works as expect and the volume is moved to the rigth 15 units.
<br>
<br>
I created a repo with two scripts that show this. Its at <a href="https://bitbucket.org/youngre/vtk_grid_transform/" target="_blank">https://bitbucket.org/youngre/vtk_grid_transform/</a><br>
<br>
Thanks again,<br>
Ryan<br>
<br>
<span title="vtkusers@vtk.org"></span><br>
<br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>From:</b> David Gobbi [<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>]<br>
<b>Sent:</b> Tuesday, January 27, 2015 1:49 PM<div><div class="h5"><br>
<b>To:</b> Young, Ryan<br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
<b>Subject:</b> Re: [vtkusers] grid reslice<br>
</div></div></font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">Hi Ryan,
<div><br>
</div>
<div>I still don't know what I'm looking at. Especially when the two images are at completely different scales (the deformed image is ridiculously small). Maybe you can annotate them?</div>
<div><br>
</div>
<div> - David</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Jan 27, 2015 at 2:33 PM, Young, Ryan <span dir="ltr">
<<a href="mailto:Ryan.Young@seattlechildrens.org" target="_blank">Ryan.Young@seattlechildrens.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><br>
<br>
Sure. I used a slight larger (15 voxel in the x direction) deformation so that the effect is drastic.<br>
<br>
Thanks again,<br>
Ryan <br>
<br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma"><b>From:</b> David Gobbi [<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>]<br>
<b>Sent:</b> Monday, January 26, 2015 6:18 PM<br>
<b>To:</b> Young, Ryan<br>
<b>Cc:</b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
<b>Subject:</b> Re: [vtkusers] grid reslice<br>
</font><br>
</div>
<div>
<div>
<div></div>
<div>
<div dir="ltr">
<div>Hi Ryan,</div>
<div><br>
</div>
<div>Can you attach your image both with and _without_ deformation?</div>
<div>I looked at the image but couldn't make any sense of it.</div>
<div><br>
</div>
<div> - David</div>
<br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Jan 26, 2015 at 6:29 PM, Young, Ryan <span dir="ltr">
<<a href="mailto:Ryan.Young@seattlechildrens.org" target="_blank">Ryan.Young@seattlechildrens.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hello,<br>
<br>
I have a vector field that has the displacement vector for each voxel in a volume. I am trying to apply this deformation and visualize the results. The difficulty I am have is that the deformation only exist for the voxels inside the volume, not globally
in the whole space. If I set the displacement to zeros outside the volume I get poor results.<br>
<br>
My toy example is just do to a 10 voxel shift in the x direction The volume is padded with zeros so there is plenty of room. The result is an image missing about ten voxels. See attached picture. If I make a similar deformation that exist at all voxels,
the result is as expect. Any advice. Also, a code snippet is below.<br>
<br>
Thanks in advanced<br>
Ryan<br>
<br>
grid=vtk.vtkGridTransform()<br>
grid.SetDisplacementGrid(defImporter.GetOutput())<br>
grid.SetInterpolationModeToLinear()<br>
<br>
reslice=vtk.vtkImageReslice()<br>
reslice.SetWrap(1)<br>
reslice.SetResliceTransform(grid)<br>
reslice.SetInterpolationModeToLinear()<br>
reslice.SetOutputSpacing(1,1,1)<br>
reslice.SetOutputOrigin(0,0,0)<br>
reslice.SetInputConnection(volImporter.GetOutputPort())<br>
</div>
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information protected by law. Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
</div>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information protected by law. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div><div><div class="h5">
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information protected by law. Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
</div></div></div>
</blockquote></div><br></div>