[Insight-users] itkImageSource for block of memory

Daniel Blezek Blezek.Daniel at mayo.edu
Sat Jun 27 19:19:48 EDT 2009


Hi,

  Allocate will check that the memory size you gave it is correct and will
use the block.  If it is different, it will ignore what you gave it and
allocate a block.

-dan


On 6/26/09 9:11 AM, "Koen Vermeer" <koen at vermeer.tv> wrote:

> 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
> 
> 

-- 
Daniel Blezek, PhD
Medical Imaging Informatics Innovation Center

P 127 or (77) 8 8886
T 507 538 8886
E blezek.daniel at mayo.edu

Mayo Clinic
200 First St. S.W.
Harwick SL-44
Rochester, MN 55905
mayoclinic.org




More information about the Insight-users mailing list