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

Luis Ibanez luis.ibanez at kitware.com
Mon Oct 8 09:06:08 EDT 2007


Hi Emmanuel,

When you are in situations where you run a pipeline a first
time with a given image input, and then you run the pipeline
a second time with a different image input or with parameters
that will change the size of any of the intermediate images
in the pipeline, then you should use in the last filter of
the pipeline the method:

         UpdateLargestPossibleRegion()

instead of the typical method

         Update()


Update() doesn't repeat all the pipeline negotiations related
to image size, while UpdateLargestPossibleRegion() does.



   Regards,


      Luis


---------------------------
Emmanuel Christophe wrote:
> 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
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list