# "Requested region is (at least partially) outside the largest possible region. Aborted (core dumped)" when calling Update/UpdateLargestPossibleRegion

**URL:** https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732
**Category:** Engineering
**Created:** [December 24, 2020, 6:02pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732 "2020-12-24T18:02:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [December 24, 2020, 6:02pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/1 "2020-12-24T18:02:47Z")

</div>

Hello everyone!

I am new to ITK and I am trying to create a custom registration filter, but I keep running into following error message:

```
what(): /home/stefan/itk/Modules/Core/Common/src/itkDataObject.cxx:393:
Requested region is (at least partially) outside the largest possible region.
Aborted (core dumped)

```

Basically, code fails right after I call **Update()** method. I’ve tried to search for similar issues but nothing seems to be working. I’ve tried using **UpdateLargestPossibleRegion()** as well, and results (i.e. error) are still the same.

Whats funny is that for some cases my filter **DOES** work, and for some it **DOES NOT**. For example, here are baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively, for which filter DOES work:

```
Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [-291.155, 7036.16]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [-94.5187, 4305.86]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

```

Here are now baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively, for which filter **DOES NOT** work and where produces error mentioned above:

```
Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [-113.235, 6368.84]; orient = RPI

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [-125.684, 6891.19]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

```

To me image information seems pretty similar. What could be causing this issue? What am I missing?

Appreciate the help! Thanks!

---

<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: [December 24, 2020, 6:12pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/2 "2020-12-24T18:12:06Z")

</div>

You could step through [this code](https://github.com/InsightSoftwareConsortium/ITK/blob/344e9bc58e69ed921f540c67d87dbb66fee4c466/Modules/Core/Common/include/itkImageToImageFilter.hxx#L188-L221) using a debugger to see exactly what is happening. If the culprit is not here, use the debugger to figure out where does the problem arise.

---

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [December 24, 2020, 6:17pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/3 "2020-12-24T18:17:26Z")

</div>

Hi @dzenanz, thanks for fast reply!

Couple of things I’ve forgot to mention:

1. I am using ITK 4.6 version

2. I’ve already tried debugging it, but not exactly sure how to interpret the problem. Basically, here are some interesting logs from debugger:

---

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [January 12, 2021, 11:32pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/4 "2021-01-12T23:32:39Z")

</div>

@dzenanz Hi Dzenan! Sorry to bother you, but after further debugging. I’ve deduced the following:

First of all. I would like to mention that I am subclassing `ImageToImage` filter in order to make a Registration filter (_which takes multiple inputs: Baseline image, Baseline Mask, Follow up image, Follow up mask_). Now, my filter raises

> “Requested region is (at least partially) outside the largest possible region”

If and only if Baseline image has bigger dimensions (in my case specifically Z-axis) than Follow-up image. Error is being raised in ITK’s function `VerifyInputRegion()` during `Update()` method (Note that I’ve tried `UpdateLargestInputRegion` instead, same thing). Here is the code where error is raised:

```
template< unsigned int VImageDimension >
bool
ImageBase< VImageDimension >
::VerifyRequestedRegion()
{
  bool retval = true;
  unsigned int i;

  // Is the requested region within the LargestPossibleRegion?
  // Note that the test is indeed against the largest possible region
  // rather than the buffered region; see DataObject::VerifyRequestedRegion.
  const IndexType & requestedRegionIndex = this->GetRequestedRegion().GetIndex();
  const IndexType & largestPossibleRegionIndex =
    this->GetLargestPossibleRegion().GetIndex();

  const SizeType & requestedRegionSize = this->GetRequestedRegion().GetSize();
  const SizeType & largestPossibleRegionSize =
    this->GetLargestPossibleRegion().GetSize();

  for ( i = 0; i < VImageDimension; i++ )
    {
    if ( ( requestedRegionIndex[i] < largestPossibleRegionIndex[i] )
         || ( ( requestedRegionIndex[i] + static_cast< OffsetValueType >( requestedRegionSize[i] ) )
              > ( largestPossibleRegionIndex[i] + static_cast< OffsetValueType >( largestPossibleRegionSize[i] ) ) ) )
      {
      retval = false;
      }
    }

  return retval;
}

```

Here are now baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively,

```auto
Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [-113.235, 6368.84]; orient = RPI

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [-125.684, 6891.19]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

```

This is because for some reason when calling `Update` (or `UpdateLargestPossibleRegion`) method on the filter, it treats follow up image as the LARGEST POSSIBLE REGION at one point, and BL as REQUESTED REGION. Since BL has bigger dimension than FU image, error is raised.

How can I make sure that from all inputs to the filter, Update method chooses the input with biggest dimensions as the one for Largest Possible region?

Hope you understand what I mean. Thanks in advance!

---

<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 15, 2021, 11:05pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/5 "2021-01-15T23:05:44Z")

</div>

I think you need to familiarize yourself better with the [image processing pipeline](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch3.html#x39-420003.5), more concretely [How To Write A Filter](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch8.html). You probably need to override `PropagateRequestedRegion()` or something similar.

---

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [January 17, 2021, 3:48pm UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/6 "2021-01-17T15:48:19Z")

</div>

Alright! Thanks for reply. I will give it a try 🙂

---

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [January 21, 2021, 9:42am UTC](https://discourse.itk.org/t/requested-region-is-at-least-partially-outside-the-largest-possible-region-aborted-core-dumped-when-calling-update-updatelargestpossibleregion/3732/7 "2021-01-21T09:42:45Z")

</div>

I’ve managed to solve my issue by overriding `GetRequestedInputRegion()` method from `itk::ImageToImage` class. Thanks for the help!
