[ITK-users] ImageI iterators same walk order simultaneously

Javier Juan Albarracín javij1 at gmail.com
Sat Jun 18 19:59:34 EDT 2016


Hello,

I want to traverse an image that points to an intra-cranial mask, and 
perform an operation on other image only in the voxels where the 
intra-cranial mask are true. I wrote the following code:

itk::ImageRegionConstIterator<MaskType> iteratorMask(mask, 
mask->GetLargestPossibleRegion());
itk::ImageRegionIterator<MapType> iteratorMap(map, 
map->GetLargestPossibleRegion());

iteratorMask.GoToBegin();
iteratorMap.GoToBegin();
while (!iteratorMask.IsAtEnd())
{
      if (iteratorMask.Get())
      {
          iteratorMap.Set(i);
           ++i;
       }
       ++iteratorMask;
       ++iteratorMap;

}

My question is: can I be sure that, with this implementation both 
iterators point to the same voxel of the image simultaneously? Or should 
I use itk::ImageRegionConstIteratorWithIndex on "mask" and modify "map" 
through the "SetPixel" method? I have read that "SetPixel" and 
"GetPixel" methods are slow and not preferred against iterators. It is 
possible to implement this operation only with iterators?

Thank you very much

Regards.

Javier.




More information about the Insight-users mailing list