# Why ResampleImageFilter is slow?

**URL:** <https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217>\
**Category:** Uncategorized\
**Created:** [August 21, 2018, 1:23pm UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217 "2018-08-21T13:23:34Z")\
**Posts on this page:** 7\
**Page:** 3

<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:** [October 23, 2018, 3:46pm UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/41 "2018-10-23T15:46:04Z")

</div>

We should take this one issue at a time.

It would be very convenient to me if there was a pull request which demonstrated the issue, so that I could easily reproduce the problematic scenario.

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [October 23, 2018, 3:46pm UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/42 "2018-10-23T15:46:17Z")

</div>

> [@grothausmann.roman](#):
>
> I get `The input filter's BufferedRegion is not contained by LargestPossibleRegion` and the RequestedRegion size is empty [0, 0].

Sometimes this error can be avoided by calling `UpdateLargestPossibleRegion()` instead of `Update()`.

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [October 24, 2018, 10:29am UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/43 "2018-10-24T10:29:06Z")

</div>

Many thanks Matt and Brad for your replies. I created a PR ([#82](https://github.com/InsightSoftwareConsortium/ITK/pull/82)) but it seems to fail on some test I did not touch. I’m also not sure how to contribute the result MHAs/MD5s in conjunction with a GH PR. What are the instructions for that?  
@blowekamp Would you prefer a separate PR for the test branch (test\_RSI-SDI) without the contributions to `itkResampleImageFilter`?  
@matt.mccormick I also tried `streamer->UpdateLargestPossibleRegion()` but that did not change the output of the monitor filter, i.e. make the test succeed. I can’t see why it is not working where as it does in `itkWarpImageFilterTest2.cxx`, which I used as an exemplary base.

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [October 24, 2018, 10:42pm UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/44 "2018-10-24T22:42:26Z")

</div>

@grothausmann.roman

It looks like the PR builds are failing because of the missing testing data.

Please try out this testing data script, and let us know how it goes:

[http://review.source.kitware.com/#/c/23829/](http://review.source.kitware.com/#/c/23829/)

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [October 25, 2018, 10:26am UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/45 "2018-10-25T10:26:31Z")

</div>

Many thanks @matt.mccormick for the script. It worked with a GIRDER\_API\_KEY (it was not able to authenticate with username and password). I added the `*.sha512` and removed the `*.md5` and sqaushed, rebased and force pushed all to GH.  
Does it matter that the MHAs are not listed under `ITK/ITKTestingData/4.13.1/Modules/Filtering/ImageGrid/test/Baseline` on [data.kitware.com](http://data.kitware.com)?  
Anyway, circleci now gets further and fails on some test one of which is `itkResampleImageTest7` (as expected).  
@blowekamp For better understanding the ITK GH workflow: In what way is it helpful for you to have a PR in this case? So far I was only considering to create PRs in the case all is basically ready for merging and tests work out on the local machine.

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [October 25, 2018, 11:27am UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/46 "2018-10-25T11:27:30Z")

</div>

Thanks for the testing and feedback!

> [@grothausmann.roman](#):
>
> It worked with a GIRDER\_API\_KEY (it was not able to authenticate with username and password).

Interesting.

> [@grothausmann.roman](#):
>
> I added the `*.sha512` and removed the `*.md5` and sqaushed, rebased and force pushed all to GH.

Nice work.

We will have the script remove likely invalid `*.md5` content links automatically.

> [@grothausmann.roman](#):
>
> Does it matter that the MHAs are not listed under `ITK/ITKTestingData/4.13.1/Modules/Filtering/ImageGrid/test/Baseline` on [data.kitware.com](http://data.kitware.com)?

No, they can be anywhere, including your personal folder. This helps keep the red tape down. We will have an automated script upload merged testing into the ITK/ITKTestingData/Nightly folder, and at releases we will distribute the data to additional data storage locations.

---

<div class="post-metadata">

**Author:** ![grothausmann.roman](https://discourse.itk.org/user_avatar/discourse.itk.org/grothausmann.roman/32/582_2.png) [@grothausmann.roman](https://discourse.itk.org/u/grothausmann.roman)\
**Post date:** [October 25, 2018, 12:25pm UTC](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/47 "2018-10-25T12:25:29Z")

</div>

I created a separate PR for the branch with just the new tests ([https://github.com/InsightSoftwareConsortium/ITK/pull/84](https://github.com/InsightSoftwareConsortium/ITK/pull/84)), which nicely shows that there only `itkResampleImageTest7` fails. So the other failures in [https://github.com/InsightSoftwareConsortium/ITK/pull/82](https://github.com/InsightSoftwareConsortium/ITK/pull/82) are due to the changes to the `itkResampleImageFilter`.  
So far I could not make out the reason for the change in the output extent which sometimes appears when streaming `itkResampleImageFilter`. Could there be some code that increases the demanded output extent when streaming?

[Previous page](https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217.md?page=2)
