[Insight-users] Setting image region index to 0 possible
John
dbgtjp at hotmail.com
Thu May 22 15:28:37 EDT 2008
hi,
I just wrote a filter which is changing the image size and therefor I overloaded
the GenerateOutputInformation(). Additionally I would like to set the index of
the largest possible region of the output image to zero.
Is that possible? If I use the index of the input region for the output region
I have got no problem. But if I have a output index filled with 0, my filter
isn't working.
It always gives me:
terminate called after throwing an instance of 'itk::InvalidRequestedRegionError'
what(): /opt/itk-src/Code/Common/itkDataObject.cxx:397:
Requested region is (at least partially) outside the largest possible region.
Aborted
*** Exited with status: 134 ***
What am I doing wrong?
Thats the not working GenerateOutputInformation:
template < typename TImage >
void StraighteningFilter< TImage >
::GenerateOutputInformation()
{
Superclass::GenerateOutputInformation();
ImageConstPointer inputImage = this->GetInput();
ImagePointer outputImage = this->GetOutput();
if ( !inputImage || !outputImage )
{
return;
}
RegionType inputRegion = inputImage->GetLargestPossibleRegion();
IndexType inputStart = inputRegion.GetIndex();
SizeType inputSize = inputRegion.GetSize();
IndexType outputStart;
outputStart.Fill(0);
SizeType outputSize;
outputSize[0] = inputSize[0];
outputSize[1] = m_BelowISOS + 1 + m_AboveISOS;
RegionType outputRegion;
outputRegion.SetIndex(outputStart);
outputRegion.SetSize(outputSize);
outputImage->SetLargestPossibleRegion(outputRegion);
outputImage->SetSpacing(inputImage->GetSpacing());
outputImage->SetDirection(inputImage->GetDirection());
outputImage->SetOrigin(inputImage->GetOrigin());
}
Thank you for any help.
John
More information about the Insight-users
mailing list