[ITK] [ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"
Timothee Evain
tevain at telecom-paristech.fr
Thu Oct 8 09:26:34 EDT 2015
Hello Iyas
I think you problem is coming from the fact you are using the filter in place ("extracter->InPlaceOn();")
When you run your filter once, that's good, but you are replacing the full image data (the input) with the small neighborhood.
So basically after your first iteration, you are requesting the next neighborhood regarding the full image, which is outbound regarding the previous neighborhood.
HTH
Tim
----- Mail original -----
De: "Iyas Hamdan" <iyas.hamdan at gmail.com>
À: insight-users at itk.org
Envoyé: Jeudi 8 Octobre 2015 13:07:49
Objet: [ITK] [ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"
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
_______________________________________________
Community mailing list
Community at itk.org
http://public.kitware.com/mailman/listinfo/community
_____________________________________
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