WG: [Insight-users] Copy one pointer's content to another pointer

Luis Ibanez luis.ibanez at kitware.com
Tue Jul 20 12:47:32 EDT 2004


Hi Jiang,

>> I don’t know how to set the other parameters for ShiftScaleImageFilter. 
>> It is not easy to find example from


mmm, you haven't tried hard enough   :-)


The ShiftScale filter is described in the SoftwareGuide

     http://www.itk.org/ItkSoftwareGuide.pdf

Section 6.2   "Casting and Intensity Mapping"
Section 6.2.1 "Linear Mappings", pdf-page 146.


The coding example is in

      Insight/Examples/Filtering/
                  CastingImageFilters.cxx




The Doxygen documentation page for this filter is at
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ShiftScaleImageFilter.html




Regards,



     Luis



------------------
Jiang wrote:

>  
> 
>  
> 
> -----Ursprüngliche Nachricht-----
> *Von:* Jiang [mailto:jiang at ti.uni-trier.de]
> *Gesendet:* Montag, 19. Juli 2004 22:02
> *An:* 'Miller, James V (Research)'
> *Betreff:* AW: [Insight-users] Copy one pointer's content to another pointer
> 
>  
> 
> Many thanks for your reply.
> 
> I use your first method to copy image, since I’m familiar with it. For 
> second method, I tried it, but failed.
> 
> I don’t know how to set the other parameters for ShiftScaleImageFilter. 
> It is not easy to find example from
> 
> the documentation.
> 
>  
> 
> Anyway your answer helps me to solve this problem
> 
>  
> 
>  
> 
> Best regards,
> 
>  
> 
> Jiang
> 
>  
> 
>  
> 
> -----Ursprüngliche Nachricht-----
> *Von:* Miller, James V (Research) [mailto:millerjv at crd.ge.com]
> *Gesendet:* Montag, 19. Juli 2004 15:48
> *An:* 'Jiang'; ITK
> *Betreff:* RE: [Insight-users] Copy one pointer's content to another pointer
> 
>  
> 
> The line
> 
>  
> 
> tmp->SetPixelContainer(pointer1->GetPixelContainer());
> 
>  
> 
> copies a reference (pointer) from pointer1 to tmp.  This is a shallow 
> copy of the pixel data.  So any changes you make to the pixel data in 
> tmp is actually modifying the same pixel data from pointer1.
> 
>  
> 
> Instead of copying the pixel container, you'll need to call Allocate() 
> on tmp and then use iterators to copy the data from pointer1 to tmp.
> 
>  
> 
> Another option is to run you image through a filter, setting the 
> parameters of the filter to do nothing.  For instance, you could use the 
> ShiftScaleImageFilter and set the Shift to zero and the Scale to one.  
> This is not the most efficient way to copy an image (since some trivial 
> math is done) but is a simple way to create a copy of an image.
> 
>  
> 
> Jim
> 
>  
> 
>  
> 
>     -----Original Message-----
>     *From:* Jiang [mailto:jiang at TI.Uni-Trier.DE]
>     *Sent:* Monday, July 19, 2004 9:27 AM
>     *To:* ITK
>     *Subject:* [Insight-users] Copy one pointer's content to another pointer
> 
>     Hi ITK users,
> 
>     I want to copy one ITK pointer’s content to another ITK pointer, so
>     that the operation
> 
>     performed on the second pointer will not influence the first pointer.
> 
>     I do it as follow:
> 
>        WriteImageType::Pointer pointer1 already exists and has some content
> 
>        WriteImageType::Pointer tmp = WriteImageType::New();//copy
>     pointer1’s content to tmp
> 
>         tmp->SetRequestedRegion( pointer1->GetRequestedRegion() );
> 
>         tmp->SetBufferedRegion( pointer1->GetBufferedRegion() );
> 
>         tmp->SetLargestPossibleRegion( pointer
>     ->GetLargestPossibleRegion() );
> 
>         tmp->SetPixelContainer(pointer1->GetPixelContainer() );
> 
>         tmp->CopyInformation( pointer1 );
> 
>      
> 
>      
> 
>     Now I can operate the tmp’s content. However it still affect
>     pointer1. It seems that all operations
> 
>     performed on tmp are same as performed on pointer1.
> 
>      
> 
>     How can I copy one pointer totally to another one?
> 
>      
> 
>      
> 
>     Thanks!
> 
>      
> 
>      
> 
>     Jiang
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list