[Insight-users] add subregions to an image

Ming Chao mingchao2005 at gmail.com
Wed Jun 14 16:08:32 EDT 2006


Hi,

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:


typedef float PixelType;
typedef itk::Image< PixelType, Dimension >        ImageType;

typedef itk::RegionOfInterestImageFilter<ImageType, ImageType> newImageType;
typedef itk::ImageRegionIterator<ImageType> newIterator;

 newImageType::Pointer newImage = newImageType::New();

 newImageType::RegionType region[NumberOfRegions];
 for ( int i = 0; i< NumberOfRegions; i++) {
  region[i].SetIndex( indexStart[i] );
  region[i].SetSize( indexSize );
 }

 for ( int i = 0; i< NumberOfRegions; i++) {
  newIterator it( newImage, region[i] );
  it.GoToBegin();
  while( !it.IsAtEnd() ) {
   it.Set( pixelvalues of the region??????????????  );
   ++it;
  }

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.

Cheers,

Ming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060614/e1558d66/attachment.html


More information about the Insight-users mailing list