[Insight-users] itkImageSource for block of memory

Koen Vermeer koen at vermeer.tv
Fri Jun 26 10:11:41 EDT 2009


On Fri, 2009-06-19 at 08:38 -0500, Daniel Blezek wrote: 
> On 6/19/09 6:38 AM, "Koen Vermeer" <koen at vermeer.tv> wrote:
> > Cool! What about the other way around, like itkExportImageFilter? It
> > seems that I cannot find it, but maybe something similar exists with a
> > different name?
> We do exactly the same thing as you, i.e. use ITK from a different
> application.  For the output, to avoid duplicating memory, we do something
> like this:
> // Allocate output ImageBuffer
> ImageBuffer = new T[NumberOfPixels];
> itkImage = filter->GetOutput()
> itkImage->GetPixelContainer()->SetImportPointer ( (T*)ImageBuffer,
>     NumberOfPixels, false );
> itkImage->Allocate();
> This creates the buffer, and asks ITK to use it.

Thanks for your reply! It's almost clear... What I'm wondering is this:
ImageBuffer is already allocated by 'new'. What does the
itkImage->Allocate() do in that case? Will it allocate the memory again?
Or will it just set some internal flag in itkImage to tell that the
memory is allocated in some other way?

Best,
Koen




More information about the Insight-users mailing list