[Insight-developers] sizing problem resolved

Damion Shelton dmsst59+@pitt.edu
Thu, 10 May 2001 18:46:28 -0400


I managed to figure out my earlier sizing problem - this info might be
useful to others.

The code fragment:

  // Create a region object native to the image type
  TImageType::RegionType largestPossibleRegion;
  // Resize the region
  largestPossibleRegion.SetSize( size );
  // Set the largest legal region size (i.e. the size of the whole image) to
what we just defined
  image->SetLargestPossibleRegion( largestPossibleRegion );
  // Set the buffered region
  image->SetBufferedRegion( largestPossibleRegion );
  // Set the requested region
  image->SetRequestedRegion( largestPossibleRegion );
  // Now allocate memory for the image
  image->Allocate();

creates, sizes, and allocates a new image.

BUT....failing to include the line "image->SetBufferedRegion(
largestPossibleRegion );" creates an image which appears to have the
requested and largestpossible regions set correctly, but in reality doesn't
persist when the pointer is tossed around between classes. In retrospect I
suppose this makes sense, but I failed to include this in my earlier
"itkHelloWorld" example.

-Damion-