# Set values for a displacement field

**URL:** <https://discourse.itk.org/t/set-values-for-a-displacement-field/586>\
**Category:** Algorithms\
**Created:** [January 12, 2018, 5:55pm UTC](https://discourse.itk.org/t/set-values-for-a-displacement-field/586 "2018-01-12T17:55:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ray](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@Ray](https://discourse.itk.org/u/Ray)\
**Post date:** [January 12, 2018, 5:55pm UTC](https://discourse.itk.org/t/set-values-for-a-displacement-field/586/1 "2018-01-12T17:55:59Z")

</div>

Hello!

I want to set values for a displacement field. If the position is on a grid point, i.e. something like [2,3,4], I will just use SetPixel(). However, sometimes the position is not on a grid point, like [0.5, 1.7, 3.5]. It looks SetPixel() only supports integers for voxel location. After the vector values are set, I will interpolate the displacement field to make sure every grid point has a value.

What’s the best way to perform the value setup and interpolation?

Thanks!  
-Ray

---

<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:** [January 12, 2018, 7:01pm UTC](https://discourse.itk.org/t/set-values-for-a-displacement-field/586/2 "2018-01-12T19:01:40Z")

</div>

Maybe you want to use [DisplacementFieldTransform](https://itk.org/Doxygen/html/classitk_1_1DisplacementFieldTransform.html) instead of manually doing it? Or some other filter from that [module](https://itk.org/Doxygen43/html/group__ITKDisplacementField.html)?
