# Extracting displacement fields from rigid registration

**URL:** https://discourse.itk.org/t/extracting-displacement-fields-from-rigid-registration/4834
**Category:** Beginner Questions
**Tags:** registration, python, itkv5
**Created:** [February 25, 2022, 11:03pm UTC](https://discourse.itk.org/t/extracting-displacement-fields-from-rigid-registration/4834 "2022-02-25T23:03:39Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![edgar](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@edgar](https://discourse.itk.org/u/edgar)
#### Post date: [April 13, 2022, 5:17pm UTC](https://discourse.itk.org/t/extracting-displacement-fields-from-rigid-registration/4834/13 "2022-04-13T17:17:22Z")

</div>

Great, thanks. Paraphrasing from the docs:

> This method can be used to specify an image from which to copy the [output information (SetOutputSpacing, Origin, and Direction)]. UseReferenceImageOn must be set

So I did:

```
displ_filt = itk.TransformToDisplacementFieldFilter[
    itk.Image[itk.Vector[itk.F, 3], 3], itk.D].New()
displ_filt.SetTransform(registr_transform)
displ_filt.SetReferenceImage(fixed_image)
displ_filt.UseReferenceImageOn()
displ_filt.Update()
displ_field_out = displ_filt.GetOutput()

```

and

```
itk.imwrite(displ_field_out, displ_field_vtk)

```

It runs well now 🙂 .

The (VTK) output shows up in ParaView as a block with the size of my `fixed_image`, completely full of little glyphs in the same direction. This makes me think that I will have to do this with a _moving window_ (an area smaller than the full image) whose position I will move iteratively to get the displacements at each point, correct? This is possibly what @matt.mccormick was trying to say:

> [@Extracting vectors from displacement field](https://discourse.itk.org/t/extracting-vectors-from-displacement-field/417/2):
>
> The displacement vector value at specific locations can be probed with the `GetPixel()` method

---

_[View the full topic](https://discourse.itk.org/t/extracting-displacement-fields-from-rigid-registration/4834)._
