[ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"
Iyas Hamdan
iyas.hamdan at gmail.com
Thu Oct 8 07:07:49 EDT 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20151008/8b649a83/attachment.html>
More information about the Insight-users
mailing list