[Insight-users] Getting a reference to a pixel from an iterator
    David Doria 
    daviddoria at gmail.com
       
    Mon Feb 28 08:47:24 EST 2011
    
    
  
I often find myself doing:
itk::ImageRegionIterator<ImageType> imageIterator =
itk::ImageRegionIterator<ImageType>(image, region);
  while(!imageIterator.IsAtEnd())
    {
    PixelType pixel = image->GetPixel(imageIterator.GetIndex());
    // changing 'pixel' changes the actual pixel in the image since GetPixel
returns a reference
    }
Is there a reason that the iterator can't return a reference like this? That
is,
    PixelType pixel = imageIterator->Get();
    // changing 'pixel' does NOT change the actual pixel in the image since
Get does NOT return a reference
Even this doesn't work:
     PixelType* pixel = &(imageIterator->Get());
because it complains "warning: taking the address of a temporary" (and it is
correct, it doesn't not work correctly).
Any thoughts on this?
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110228/400beae0/attachment.htm>
    
    
More information about the Insight-users
mailing list