[Insight-users] writing ImageRegistration1 results back to an image buffer

Luis Ibanez luis.ibanez at kitware.com
Wed, 18 Feb 2004 23:17:41 -0500


Hi Michael,


The code that you are using is fine.

The "buffer" variable is simply taking the
pointer to the actuall buffer where the
image pixel data is stored.  There is no
need to copy anything.  The image will now
"mummify" the buffer (that is, it will not
delete the buffer when the image is destroyed).

You are taking ownership of the image buffer.

It is now *YOUR* responsibility to delete the
buffer whenever you are done with it.

That is, at some point you have to call:


     delete []  buffer;


in order to avoid memory leaks.




Regards,


    Luis


------------------
Michael G wrote:

> Hi Luis,
> 
> Thanks for pointing me to the tutorial material - I read through 
> GettingStarted-V - Mummifying the Buffer because that seems like what 
> I'm trying to do. The end of the example ends with setting 'buffer' 
> equal to the PixelContainer pointer. Will buffer now be filled with the 
> data from the container? I included the end of my code below,
> 
> {
>    ...
>    unsigned int * my_buf = new unsigned int[ width * height ];
> 
>    OutputImageType::PixelContainer *container = 
> resample->GetOutput()->GetPixelContainer();
>    container->SetContainerManageMemory( false );
>    my_buf = container->GetImportPointer();
> 
>    ... do stuff with my_buf.. is it filled correctly with the results 
> from *container?
> 
>    return 0;
> }
> 
> 
> Thank you Luis,
> 
> Michael
> 
> 
> 
>> From: Luis Ibanez <luis.ibanez at kitware.com>
>> To: Michael G <michaelguiliametti at hotmail.com>
>> CC: insight-users at itk.org
>> Subject: Re: [Insight-users] writing ImageRegistration1 results back 
>> to an image buffer
>> Date: Tue, 17 Feb 2004 01:34:59 -0500
>>
>>
>> Hi Michael,
>>
>> The methods for passing data between an application and
>> an ITK filter are described in detail on the tutorial
>> presentations
>>
>> http://www.itk.org/HTML/Tutorials.htm
>>
>> In particular in
>> http://www.itk.org/CourseWare/Training/GettingStarted-V.pdf
>>
>>
>> Regards,
>>
>>
>>    Luis
>>
>>
>> ------------------
>> Michael G wrote:
>>
>>> Hello All,
>>>
>>> I've just got reading from image buffers for use with itk motion 
>>> register functions working ok. I wanted to inquire about writing the 
>>> results of the registration back to an image buffer as opposed to a 
>>> file as in ImageRegistration1 - I have set this up:
>>>
>>> // motion registration has already been performed at this point
>>> // the resampler's input gets the data from the image buffer ok
>>> resample->SetInput( movedItkBuffer->GetOutput() );
>>>
>>> // the caster's input is the image buffer
>>> caster->SetInput( resample->GetOutput() );
>>>
>>> // here how could i go about writing the result of caster
>>> // to a buffer - or is 'movedItkBuffer' being overwritten
>>> // with the resampled data already because it was set as
>>> // the input of 'resample' in the first place?
>>>
>>> // ImageRegistration1 simply writes it out with an image writer
>>> writer->SetInput( caster->GetOutput() );
>>> writer->Update();
>>>
>>> // I would like to do something like
>>> movedItkBuffer->SetInput( caster->GetOuput() );
>>> movedItkBuffer->Update();
>>> // but that is illegal
>>>
>>>
>>> Thank you for your time and any pointers,
>>> Michael.
>>>
>>> _________________________________________________________________
>>> Create your own personal Web page with the info you use most, at My 
>>> MSN. http://click.atdmt.com/AVE/go/onm00200364ave/direct/01/
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> _________________________________________________________________
> Get fast, reliable access with MSN 9 Dial-up. Click here for Special 
> Offer! http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/
> 
>