<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hello ITK users, <br><br></div>I have a problem using the itk::ExtractImageFilter. <br><br></div>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.<br><br></div>So I'm using the ExtractImageFilter more than once and I guess that is where it fails. <br><br></div>The error I get is the following: <br><br></div>itk::InvalidRequestedRegionError<br></div>Location: itk::DataObject::PropagateRequestedRegion(void)<br></div>File:itkDataObject.cxx<br></div>Line: 393<br></div>Description: Requested region is (at least partially) outside the largest possible region. <br><br><br></div>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. <br><br><br></div>Here is the code I'm using: <br><br>FixedImageType::RegionType RegionFixed = this->m_FixedImage->GetLargestPossibleRegion();<br> FixedImageType::SizeType     F_Size = RegionFixed.GetSize();<br> FixedImageType::IndexType   F_Start = RegionFixed.GetIndex();<br><br></div><div>/// here I set the F_Size and F_Start to the desired values<br></div><div>/// and I make sure that the region is always in the largest possible region! <br></div><div>/// with Patch_Size being the size of the neighborhood to be extracted around the pixel in each dimension<br></div><div>        <br>for (int dim = 0; dim < 3; dim++) <br> {<br>            if (FixedIndex[dim] < Patch_Size)<br>                F_Start[dim] = 0;<br><br>            else<br>            {<br>                if (FixedIndex[dim] > (RegionFixed.GetSize()[dim] - Patch_Size - 1))<br>                    F_Start[dim] = RegionFixed.GetSize()[dim] - (2 * Patch_Size + 1);<br>                else<br>                    F_Start[dim] = FixedIndex[dim] - Patch_Size;<br>            }<br><br>            F_Size[dim] = 2 * Patch_Size + 1;<br>        }<br><br>FixedImageType::RegionType  F_Region;<br>F_Region.SetSize(F_Size);<br>F_Region.SetIndex(F_Start);<br></div><div><br> typedef itk::ExtractImageFilter< FixedImageType, FixedImageType > FilterExtractType;<br> FilterExtractType::Pointer extracter = FilterExtractType::New();<br> extracter->InPlaceOn();<br> extracter->SetDirectionCollapseToSubmatrix();<br><br> extracter->SetExtractionRegion(F_Region);<br> extracter->SetInput(this->m_FixedImage);<br>        <br>try<br>{<br>     extracter->UpdateLargestPossibleRegion();<br>}<br>catch (itk::ExceptionObject & err)<br>{<br>     std::cout << "Exception caught during extracting the volume!" << std::endl;<br>      std::cout << err << std::endl;<br>}<br><br><br><br></div>Any help would be really appreciated. <br><br></div>Thanks<br><br></div>Iyas Hamdan<br> </div>