# iterative inverse displacement filter in ITK

**URL:** https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952
**Category:** Beginner Questions
**Tags:** inverse-deformation
**Created:** [June 10, 2019, 5:59am UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952 "2019-06-10T05:59:38Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [June 10, 2019, 5:59am UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/1 "2019-06-10T05:59:38Z")

</div>

Are there any examples (code) where this filter is used?

---

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [June 12, 2019, 9:20am UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/2 "2019-06-12T09:20:15Z")

</div>

I found that the code for inverse deformation field is available in C:\ITK\Modules\Compatibility\Deprecated\include  
After building it, I tried executing the file ITKDisplacementFieldTestDriver.exe. it gives a list of options to select . When i select one, it has to wait for me to give input . But it terminates.

 ![image](https://discourse.itk.org/uploads/default/original/1X/f75f707550ba3ec575eb048eab10d131adf0cf57.png)

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [June 12, 2019, 1:10pm UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/3 "2019-06-12T13:10:00Z")

</div>

@EE18D504_SINDHURA_C : The executable you tried to run is a test driver. To run the actual test, you should type `ctest NAME_OF_THE_TEST`. This will run the executable with the appropriate arguments.

Also, there are several filters that allow you to compute the inverse of a displacement fields. You can check which one gives you a better result. One that gave me good results in the past was actually an ITK remote module ( [ITKFixedPointInverseDisplacementField](https://github.com/InsightSoftwareConsortium/ITKFixedPointInverseDisplacementField)) which is available in ITK when setting the CMake variable `Module_FixedPointInverseDisplacementField` to ON.

---

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [June 12, 2019, 5:13pm UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/4 "2019-06-12T17:13:40Z")

</div>

Do you mean I should write `ctest itkIterativeInverseFieldImageFilterTest` ?Im still getting errors saying that “unable to create process”

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [June 12, 2019, 6:57pm UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/5 "2019-06-12T18:57:57Z")

</div>

What you want to do is `ctest -R itkIterativeInverseDisplacementFieldImageFilterTest` (with ITKv5). But it really depents what you want to do. Why are you trying to run this test? Just to verify that it works?

---

<div class="post-metadata">

### Author: ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)
#### Post date: [June 13, 2019, 12:35am UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/6 "2019-06-13T00:35:38Z")

</div>

I have deformation field obtained after registration of two images. I want to find inverse deformation field for that using iterative method.

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [June 13, 2019, 7:27am UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/7 "2019-06-13T07:27:35Z")

</div>

I usually use a fixed point method to invert displacement fields, something like this.

```
WarpImageFilter Filter = new WarpImageFilter();
Image inverse = new Image(displacementImage.GetSize(), PixelIDValueEnum.swigToEnum(displacementImage.GetPixelIDValue()));
inverse.CopyInformation(displacementImage);
Image mI = -displacementImage;

for (int i = 0; i < iterations; i++)
{
  inverse = Filter.Execute(mI, inverse); 
}

```

Its a simple approach but it works surprisingly well in many cases.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [June 13, 2019, 12:16pm UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/8 "2019-06-13T12:16:01Z")

</div>

As I recall that is essentially what the [FixedPointInverseDisplacementFieldImageFilter](https://github.com/InsightSoftwareConsortium/ITKFixedPointInverseDisplacementField/blob/master/include/itkFixedPointInverseDisplacementFieldImageFilter.hxx#L100-L125) does, but your version is parallel.

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [June 13, 2019, 12:34pm UTC](https://discourse.itk.org/t/iterative-inverse-displacement-filter-in-itk/1952/9 "2019-06-13T12:34:09Z")

</div>

Yes I figured there would be a filter for it.
