# Resampling a displacement-field transformed image

**URL:** https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884
**Category:** Algorithms
**Created:** [May 16, 2019, 3:41pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884 "2019-05-16T15:41:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Nino](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@Nino](https://discourse.itk.org/u/Nino)
#### Post date: [May 16, 2019, 3:41pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/1 "2019-05-16T15:41:58Z")

</div>

Hi guys,  
I am using a DisplacementField transformation and resample the image with the ResampleImageFilter. Everything is working great! Now I am wondering how the resample method is working? Does it invoke the InverseDisplacementFieldImageFilter to compute the inverse transformation to make use of the backward mapping method or is there another method used?

Would really appreciate a short feedback! Thanks a lot!  
Nino

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 16, 2019, 5:10pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/2 "2019-05-16T17:10:36Z")

</div>

Welcome to the community Nino!

In ITK, transforms directly provide mapping from moving image to the fixed image, so no inversion is necessary to apply a DisplacementField. And it is done this way precisely so no inversion is necessary for the resampling of the source image to the target image grid.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [May 19, 2019, 2:04pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/3 "2019-05-19T14:04:08Z")

</div>

Note that you still need to invert the resampling transform to transform points, lines, surface meshes, etc. It would be great if ITK had dynamic inverse computation as VTK has (VTK can compute inverse transforms at arbitrary points - without computing a full inverse field - using an iterative scheme and smooth boundary constraint; as described [here](https://www.sciencedirect.com/science/article/abs/pii/S0895611102000915)).

---

<div class="post-metadata">

### Author: ![Nino](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@Nino](https://discourse.itk.org/u/Nino)
#### Post date: [May 19, 2019, 3:13pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/4 "2019-05-19T15:13:19Z")

</div>

Hi Andras, thanks for the link. If I find some time I would be happy to contribute that to the ITK community 🙂

---

<div class="post-metadata">

### Author: ![Nino](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/b9bd4f/32.png) [@Nino](https://discourse.itk.org/u/Nino)
#### Post date: [May 19, 2019, 3:16pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/5 "2019-05-19T15:16:02Z")

</div>

Thanks a lot for the fast reply Dzenan.! I truly forgot that a transform in a resampling operation defines _the transform from the output space to the input space_ .

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [May 19, 2019, 5:00pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/6 "2019-05-19T17:00:02Z")

</div>

> [@Nino](#):
>
> If I find some time I would be happy to contribute that to the ITK community

Note that it is already implemented in VTK, so you just need to port it to the ITK transforms framework.

---

<div class="post-metadata">

### Author: ![Bartolomejka](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@Bartolomejka](https://discourse.itk.org/u/Bartolomejka)
#### Post date: [October 14, 2020, 3:00pm UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/7 "2020-10-14T15:00:21Z")

</div>

Hi guys!  
I am not following history of ITK but there is already InverseDisplacementFieldImageFilter for inversion of DisplacementField. But back to the implementation of various inversions, is there any progress in the implementation of GetInverseTransform() in DisplacementFieldTransform and also in BSplineTransform in ITK? It is already in VTK and it is working like a charm in Slicer which I am using for checking my results and planning new things, but I am lacking it in ITK. Is anybody working on it or what is the plan since this functionality is really missing? Last note: My registration app simply crashes when I am trying to get the inverse of BSplineTransform inside CompositeTransform.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)
#### Post date: [January 4, 2021, 12:55am UTC](https://discourse.itk.org/t/resampling-a-displacement-field-transformed-image/1884/8 "2021-01-04T00:55:38Z")

</div>

A workaround that you can use in Slicer to create a transform that ITK can use is to convert the transform to a grid transform (in Slicer’s transform module, Convert section). The created grid transform contains everything that is in the composite transform (all transform types, all inversions).

I agree that VTK’s transform pipeline architecture is truly amazing and ITK should have it, too. If not the pipeline then at least the dynamically computed inverse computation and the ability to specify direction in the transformation file (“fixed to moving” or “moving to fixed”).
