[ITK] [ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Oct 8 08:25:29 EDT 2015


Hello Iyas,

I would try to remote the "InPlace" option.

You are not showing your full pipeline specifically how the input is created. The inplace options can steal the input image's buffer. When you run it a second time, if the buffer is missing and there is no way to regenerate it this exception can occur.

HTH,
Brad

On Oct 8, 2015, at 7:07 AM, Iyas Hamdan <iyas.hamdan at gmail.com> wrote:

> Hello ITK users, 
> 
> I have a problem using the itk::ExtractImageFilter. 
> 
> What I'm trying to do is, from a 3D volume, I want to extract a small 3D neighborhood around each pixel of this volume.
> 
> So I'm using the ExtractImageFilter more than once and I guess that is where it fails. 
> 
> The error I get is the following: 
> 
> itk::InvalidRequestedRegionError
> Location: itk::DataObject::PropagateRequestedRegion(void)
> File:itkDataObject.cxx
> Line: 393
> Description: Requested region is (at least partially) outside the largest possible region. 
> 
> 
> I've looked on several answers to the same issue here in the mailing list and what they propose is just to replace the Update() by an UpdateLargestPossibleRegion(). And I did that but I'am still getting the same error. 
> 
> 
> Here is the code I'm using: 
> 
> FixedImageType::RegionType RegionFixed = this->m_FixedImage->GetLargestPossibleRegion();
>  FixedImageType::SizeType     F_Size = RegionFixed.GetSize();
>  FixedImageType::IndexType   F_Start = RegionFixed.GetIndex();
> 
> /// here I set the F_Size and F_Start to the desired values
> /// and I make sure that the region is always in the largest possible region! 
> /// with Patch_Size being the size of the neighborhood to be extracted around the pixel in each dimension
>         
> for (int dim = 0; dim < 3; dim++) 
>  {
>             if (FixedIndex[dim] < Patch_Size)
>                 F_Start[dim] = 0;
> 
>             else
>             {
>                 if (FixedIndex[dim] > (RegionFixed.GetSize()[dim] - Patch_Size - 1))
>                     F_Start[dim] = RegionFixed.GetSize()[dim] - (2 * Patch_Size + 1);
>                 else
>                     F_Start[dim] = FixedIndex[dim] - Patch_Size;
>             }
> 
>             F_Size[dim] = 2 * Patch_Size + 1;
>         }
> 
> FixedImageType::RegionType  F_Region;
> F_Region.SetSize(F_Size);
> F_Region.SetIndex(F_Start);
> 
>  typedef itk::ExtractImageFilter< FixedImageType, FixedImageType > FilterExtractType;
>  FilterExtractType::Pointer extracter = FilterExtractType::New();
>  extracter->InPlaceOn();
>  extracter->SetDirectionCollapseToSubmatrix();
> 
>  extracter->SetExtractionRegion(F_Region);
>  extracter->SetInput(this->m_FixedImage);
>         
> try
> {
>      extracter->UpdateLargestPossibleRegion();
> }
> catch (itk::ExceptionObject & err)
> {
>      std::cout << "Exception caught during extracting the volume!" << std::endl;
>       std::cout << err << std::endl;
> }
> 
> 
> 
> Any help would be really appreciated. 
> 
> Thanks
> 
> Iyas Hamdan
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users

_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list