[vtkusers] grid reslice
David Gobbi
david.gobbi at gmail.com
Mon Feb 2 09:10:46 EST 2015
Hi Ryan,
After looking at the code, I think that the reason that it isn't working is
that
you are applying the transform in the wrong direction, it should be this:
reslice.SetResliceTransform(grid.GetInverse())
The way that transforms work with vtkImageReslice is that, for each output
voxel, the transform is applied to the (x,y,z) location of that voxel to
compute
an (x',y',z') location in the input volume that corresponds to the output
voxel.
In other words, the transform is a coordinate mapping from output to input.
However, even after inverting the transform, I don't think you will get a
good
result. In order for a grid transform to work nicely, it should be smooth
(in
mathematical terms, it should be a diffeomorphism.)
The following VTK Journal article has some diagrams that might do a better
job of explaining the issues:
http://www.vtkjournal.org/browse/publication/790
- David
On Wed, Jan 28, 2015 at 5:59 PM, Young, Ryan <
Ryan.Young at seattlechildrens.org> wrote:
>
> Hey.
>
> 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.
>
> 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.
>
> I created a repo with two scripts that show this. Its at
> https://bitbucket.org/youngre/vtk_grid_transform/
>
> Thanks again,
> Ryan
>
>
>
> ------------------------------
> *From:* David Gobbi [david.gobbi at gmail.com]
> *Sent:* Tuesday, January 27, 2015 1:49 PM
>
> *To:* Young, Ryan
> *Cc:* vtkusers at vtk.org
> *Subject:* Re: [vtkusers] grid reslice
>
> Hi Ryan,
>
> 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?
>
> - David
>
> On Tue, Jan 27, 2015 at 2:33 PM, Young, Ryan <
> Ryan.Young at seattlechildrens.org> wrote:
>
>>
>>
>> Sure. I used a slight larger (15 voxel in the x direction) deformation
>> so that the effect is drastic.
>>
>> Thanks again,
>> Ryan
>>
>> ------------------------------
>> *From:* David Gobbi [david.gobbi at gmail.com]
>> *Sent:* Monday, January 26, 2015 6:18 PM
>> *To:* Young, Ryan
>> *Cc:* vtkusers at vtk.org
>> *Subject:* Re: [vtkusers] grid reslice
>>
>> Hi Ryan,
>>
>> Can you attach your image both with and _without_ deformation?
>> I looked at the image but couldn't make any sense of it.
>>
>> - David
>>
>>
>> On Mon, Jan 26, 2015 at 6:29 PM, Young, Ryan <
>> Ryan.Young at seattlechildrens.org> wrote:
>>
>>> Hello,
>>>
>>> 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.
>>>
>>> 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.
>>>
>>> Thanks in advanced
>>> Ryan
>>>
>>> grid=vtk.vtkGridTransform()
>>> grid.SetDisplacementGrid(defImporter.GetOutput())
>>> grid.SetInterpolationModeToLinear()
>>>
>>> reslice=vtk.vtkImageReslice()
>>> reslice.SetWrap(1)
>>> reslice.SetResliceTransform(grid)
>>> reslice.SetInterpolationModeToLinear()
>>> reslice.SetOutputSpacing(1,1,1)
>>> reslice.SetOutputOrigin(0,0,0)
>>> reslice.SetInputConnection(volImporter.GetOutputPort())
>>> 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.
>>>
>>>
>> 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.
>>
>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150202/010ff314/attachment.html>
More information about the vtkusers
mailing list