I often find myself doing:<div><br><div>itk::ImageRegionIterator&lt;ImageType&gt; imageIterator = itk::ImageRegionIterator&lt;ImageType&gt;(image, region);</div><div><div>  while(!imageIterator.IsAtEnd())</div><div>    {</div>
<div>    PixelType pixel = image-&gt;GetPixel(imageIterator.GetIndex());</div><div>    // changing &#39;pixel&#39; 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&#39;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-&gt;Get();</div>
<div>    // changing &#39;pixel&#39; does NOT change the actual pixel in the image since Get does NOT return a reference</div><div><br></div><div>Even this doesn&#39;t work:</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8">     PixelType* pixel = &amp;(imageIterator-&gt;Get());</div>
<div><br></div><div>because it complains &quot;warning: taking the address of a temporary&quot; (and it is correct, it doesn&#39;t not work correctly).</div><div><br></div>Any thoughts on this?<br><br>David<br>
</div></div>