[Insight-users] Copying an Image Object

Luis Ibanez luis.ibanez@kitware.com
Fri, 14 Mar 2003 10:46:43 -0500


Hi Puja,


    im2->CopyInformation( im1 );

Will copy the following data from one
image to another:

1) LargestPossibleRegion
2) Origin
3) Spacing

This seems to be the method you need.

Note that there is no memory allocation
done here. So you may want to do something
like

m2->SetRegions( m1->GetLargestPossibleRegion() );
m2->Allocate();
m2->CopyInformation( m1 );

It is arguably if the first of these lines
should use GetBufferedRegion() instead of
GetLargestPossibleRegion().


Please let us know if you have further questions


Thanks



   Luis


------------------------
Puja Malik wrote:
> Hello,
> I have a basic question.  I would like to copy the information from one 
> image object to another.  Is this the purpose for the 
> "CopyInformation()" function?
> 
> For Instance:
> 
> typedef itk::Image<PixelType, DIM> ImageType;
> 
> ImageType::Pointer im1 = ImageType::New();
> //...here im1 acquires some data
> 
> //...now I want to copy the information from im1 to im2 so i can do some 
> of my
> //own processing on the first image, without losing information.
> ImageType::Pointer im2 = ImageType::New();
> 
> Thanks for any help!
> 
> Puja
> 
> -- 
> ---------------------------------------
> Puja Malik
> Surgical Instruments Group
> MEM Research Center for Orthopaedic Surgery
> Institute for Surgical Technology and Biomechanics 
> University of Bern
> Murtenstrasse 35, P.O. Box 8354
> 3010 Bern, Switzerland
> Phone: +41-31-632-8730
> Fax: +41-31-632-4951
> Email: Puja.Malik@MEMcenter.unibe.ch
> http://www.MEMcenter.unibe.ch
> ---------------------------------------
> 
>