I often find myself doing:<div><br><div>itk::ImageRegionIterator<ImageType> imageIterator = itk::ImageRegionIterator<ImageType>(image, region);</div><div><div> while(!imageIterator.IsAtEnd())</div><div> {</div>
<div> PixelType pixel = image->GetPixel(imageIterator.GetIndex());</div><div> // changing 'pixel' changes the actual pixel in the image since GetPixel returns a reference</div><div> }</div><div><br></div>
<div>Is there a reason that the iterator can't return a reference like this? That is,</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"> PixelType pixel = imageIterator->Get();</div>
<div> // changing 'pixel' does NOT change the actual pixel in the image since Get does NOT return a reference</div><div><br></div><div>Even this doesn't work:</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"> PixelType* pixel = &(imageIterator->Get());</div>
<div><br></div><div>because it complains "warning: taking the address of a temporary" (and it is correct, it doesn't not work correctly).</div><div><br></div>Any thoughts on this?<br><br>David<br>
</div></div>