[Insight-developers] fast image allocation
Miller, James V (CRD)
millerjv@crd.ge.com
Wed, 6 Mar 2002 17:16:55 -0500
Bill already added a fast allocate method. Actually what he did was
add a method to set all the regions in one call by passing in a
Size.
TImageType::Pointer sourceImage = TImageType::New();
TImageType::SizeType sourceSize = {{20, 20, 20}};
sourceImage->SetRegions( sourceSize );
sourceImage->Allocate();
I do not want to have a FastAllocate() that takes in a size since it
would unclear as to what region was being set to that size (just the
BufferedRegion, all the regions, etc.). This is why Bill put in the
SetRegions() methods (one that takes a region and one that takes a size).
In any event FastAllocate() would be wrong name since I would infer
that FastAllocate() used a different allocator (bypass the default
C++ new/delete) or perhaps allocated but skipped some initialization
step.
-----Original Message-----
From: Damion Shelton
To: Insight Developers
Sent: 3/6/2002 3:58 PM
Subject: [Insight-developers] fast image allocation
Hi...
Any objections to adding a FastAllocate(unsigned long* size) method to
itk::Image?
The idea is to reduce the following block of code:
unsigned long sourceImageSize[] = { 20,20,20 };
// Image typedef
typedef itk::Image< unsigned char, dim > TImageType;
// Creates the sourceImage (but doesn't set the size or allocate
memory)
TImageType::Pointer sourceImage = TImageType::New();
// Create a size object native to the sourceImage type
TImageType::SizeType sourceImageSizeObject;
// Set the size object to the array defined earlier
sourceImageSizeObject.SetSize( sourceImageSize );
// Create a region object native to the sourceImage type
TImageType::RegionType largestPossibleRegion;
// Resize the region
largestPossibleRegion.SetSize( sourceImageSizeObject );
// Set the largest legal region size (i.e. the size of the whole
sourceImage) to what we just defined
sourceImage->SetLargestPossibleRegion( largestPossibleRegion );
// Set the buffered region
sourceImage->SetBufferedRegion( largestPossibleRegion );
// Set the requested region
sourceImage->SetRequestedRegion( largestPossibleRegion );
// Now allocate memory for the sourceImage
sourceImage->Allocate();
To:
unsigned long sourceImageSize[] = { 20,20,20 };
// Image typedef
typedef itk::Image< unsigned char, dim > TImageType;
// Creates the sourceImage (but doesn't set the size or allocate
memory)
TImageType::Pointer sourceImage = TImageType::New();
sourceImage->FastAllocate(sourceImageSize);
Comments?
-Damion-
_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers