# SimpleITK: demons registration filter requere the size of fixed/moving image to be the same

**URL:** https://discourse.itk.org/t/simpleitk-demons-registration-filter-requere-the-size-of-fixed-moving-image-to-be-the-same/4335
**Category:** Beginner Questions
**Created:** [August 15, 2021, 12:50pm UTC](https://discourse.itk.org/t/simpleitk-demons-registration-filter-requere-the-size-of-fixed-moving-image-to-be-the-same/4335 "2021-08-15T12:50:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.itk.org/user_avatar/discourse.itk.org/zhang-qiang-github/32/1183_2.png) [@zhang-qiang-github](https://discourse.itk.org/u/zhang-qiang-github)
#### Post date: [August 15, 2021, 12:50pm UTC](https://discourse.itk.org/t/simpleitk-demons-registration-filter-requere-the-size-of-fixed-moving-image-to-be-the-same/4335/1 "2021-08-15T12:50:04Z")

</div>

I want to use the demons registration method of SimpleITK between two images with different image size. For example, a 64X64X64 (moving image) and 128X128X128 (fixed image).

```auto
import SimpleITK as sitk
import numpy as np
fixedImg = sitk.GetImageFromArray(np.random.random(size=[128, 128, 128]))
movingImg = sitk.GetImageFromArray(np.random.random(size=[64, 64, 64]))
demons_filter = sitk.FastSymmetricForcesDemonsRegistrationFilter()
demons_filter.SetNumberOfIterations(20)
# Regularization (update field - viscous, total field - elastic).
demons_filter.SetSmoothDisplacementField(True)
demons_filter.SetStandardDeviations(2.0)

displacement_field = demons_filter.Execute(fixedImg,
                                           movingImg)

```

However, a bug is reported:

```auto
Traceback (most recent call last):
  File "C:/Users/MLoong/Desktop/medpro/Demo/test.py", line 12, in <module>
    movingImg)
  File "D:\Anaconda3\envs\gitlab_medpro\lib\site-packages\SimpleITK\SimpleITK.py", line 25809, in Execute
    return _SimpleITK.FastSymmetricForcesDemonsRegistrationFilter_Execute(self, *args)
RuntimeError: Exception thrown in SimpleITK FastSymmetricForcesDemonsRegistrationFilter_Execute: D:\a\1\sitk\Code\BasicFilters\src\sitkImageFilter.cxx:63:
sitk::ERROR: Input "movingImage" for "FastSymmetricForcesDemonsRegistrationFilter" has size of [64, 64, 64] which does not match the primary input's size of [128, 128, 128]!

```

Should I resample the `moving` image to be the same size of `fixed` image before `demons_filter.Execute`?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [August 15, 2021, 3:29pm UTC](https://discourse.itk.org/t/simpleitk-demons-registration-filter-requere-the-size-of-fixed-moving-image-to-be-the-same/4335/2 "2021-08-15T15:29:31Z")

</div>

Hello @zhang-qiang-github,

Yes, you need to resample. Please see “Warning” in the [FastSymmetricForcesDemonsRegistrationFilter documentation](https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1FastSymmetricForcesDemonsRegistrationFilter.html#details).
