[Insight-users] Problem with image size propagation in pipeline

Emmanuel Christophe emmanuel.christophe at gmail.com
Wed Oct 3 05:28:15 EDT 2007


Hi,

When I use the same filter to process images of different size, I
encounter an error if the second image is smaller than the first one.
I wasn't succesfull either trying to call the
UpdateOutputInformation() manually.

Is there a necessary step to be able to do that ?

I'm using ITK 3.2.0 on a linux 64 bits plateform.

Here is a code example:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkGradientMagnitudeImageFilter.h"

int main(int argc, char ** argv)
{

  typedef float InputPixelType;
  const unsigned int Dimension = 2;

  typedef itk::Image< InputPixelType, Dimension > ImageType;

  typedef itk::ImageFileReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();

  typedef itk::GradientMagnitudeImageFilter< ImageType, ImageType> GradientType;
  GradientType::Pointer gradient = GradientType::New();

  const char * filenamereader = argv[1];
  const char * filenamereader2 = argv[2];

  reader->SetFileName( filenamereader );
  gradient->SetInput(reader->GetOutput());
  gradient->Update();

  reader->SetFileName( filenamereader2 );
  gradient->SetInput(reader->GetOutput());
  gradient->Update();

}


Which give the following error message if the second image is smaller
than the first one:
terminate called after throwing an instance of
'itk::InvalidRequestedRegionError'
  what():  /home/christop/OTB/trunk/OTB/Utilities/ITK/Code/Common/itkDataObject.cxx:397:
Requested region is (at least partially) outside the largest possible region.
Aborted

Any suggestion?

Emmanuel


More information about the Insight-users mailing list