[ITK] [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.


_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list