<div>Hi,</div>
<div> </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 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> </div>
<div>
<p>typedef float PixelType;<br>typedef itk::Image< PixelType, Dimension > ImageType;</p>
<p>typedef itk::RegionOfInterestImageFilter<ImageType, ImageType> newImageType;<br>typedef itk::ImageRegionIterator<ImageType> newIterator;</p>
<p> newImageType::Pointer newImage = newImageType::New();</p>
<p> newImageType::RegionType region[NumberOfRegions];<br> for ( int i = 0; i< NumberOfRegions; i++) {<br> region[i].SetIndex( indexStart[i] );<br> region[i].SetSize( indexSize ); <br> }</p>
<p> for ( int i = 0; i< NumberOfRegions; i++) {<br> newIterator it( newImage, region[i] );<br> it.GoToBegin(); <br> while( !it.IsAtEnd() ) {<br> it.Set( pixelvalues of the region?????????????? );<br> ++it;<br>
}</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>