<div>Hi,</div>
<div>&nbsp;</div>
<div>I want to select only some regions from an existing image and create a new image with these regions (with the proper pixel values, of course). It is not difficult to create these regions, namely, define index and size. However, how do I&nbsp;assign them into the new image? I tried to use itk::ImageRegionIterator and make a loop over the regions, but it did not work. I am sure I didn't use the iterator properly. The other question is how to set the right pixel values for each region. The following is part of the code:
</div>
<div>&nbsp;</div>
<div>
<p>typedef float PixelType;<br>typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageType;</p>
<p>typedef itk::RegionOfInterestImageFilter&lt;ImageType, ImageType&gt; newImageType;<br>typedef itk::ImageRegionIterator&lt;ImageType&gt; newIterator;</p>
<p>&nbsp;newImageType::Pointer newImage = newImageType::New();</p>
<p>&nbsp;newImageType::RegionType region[NumberOfRegions];<br>&nbsp;for ( int i = 0; i&lt; NumberOfRegions; i++) {<br>&nbsp;&nbsp;region[i].SetIndex( indexStart[i] );<br>&nbsp;&nbsp;region[i].SetSize( indexSize );&nbsp;<br>&nbsp;}</p>
<p>&nbsp;for ( int i = 0; i&lt; NumberOfRegions; i++) {<br>&nbsp;&nbsp;newIterator it( newImage, region[i] );<br>&nbsp;&nbsp;it.GoToBegin();&nbsp;<br>&nbsp;&nbsp;while( !it.IsAtEnd() ) {<br>&nbsp;&nbsp;&nbsp;it.Set( pixelvalues of the region??????????????&nbsp; );<br>&nbsp;&nbsp;&nbsp;++it;<br>
&nbsp;&nbsp;}</p>
<p>Since I don't have a clear picture how to assemble these pieces, I would greatly appreciate it if somebody can have a look and give any hints.</p>
<p>Cheers,</p>
<p>Ming</p></div>