[Insight-users] Re: writing filter results back to an image buffer

Michael G michaelguiliametti at hotmail.com
Wed, 18 Feb 2004 19:27:17 +0000


Hi All,

I believe I got the answer to copying the result of a filter to an external 
image buffer:

    InputImageType::PixelContainerPointer pixContainer;

    pixContainer = filter->GetOutput()->GetPixelContainer();
    ImageType::PixelType * pixels = pixContainer->GetImportPointer();

    memcpy( my_buf, pixels, ((width * height) * sizeof(PixelType)));

It seems to be working now, but is this the correct method?

Thank you for all your help,

Sincerely,
Michael


>From: "Michael G" <michaelguiliametti at hotmail.com>
>To: luis.ibanez at kitware.com
>CC: insight-users at itk.org
>Subject: Re: [Insight-users] writing ImageRegistration1 results back to an 
>image buffer
>Date: Tue, 17 Feb 2004 20:05:08 +0000
>
>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/
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users

_________________________________________________________________
Watch high-quality video with fast playback at MSN Video. Free! 
http://click.atdmt.com/AVE/go/onm00200365ave/direct/01/