[Insight-users] Simultaneous iterators

David Doria daviddoria at gmail.com
Wed Dec 15 07:48:32 EST 2010


I have identified a bottleneck in my program to be a function
(PatchDifference()). The callgraph is here:
http://rpi.edu/~doriad/callgraph.jpg

The function looks like this:

  itk::ImageRegionConstIterator<TImage> queryPatchIterator(image, queryRegion);
  itk::ImageRegionConstIterator<TMask> queryMaskIterator(mask, queryRegion);

  itk::ImageRegionConstIterator<TImage> currentPatchIterator(image,
currentRegion);
  itk::ImageRegionConstIterator<TMask> currentMaskIterator(mask, currentRegion);

  while(!queryPatchIterator.IsAtEnd())
    {
    // Do a small computation with the 4 pixels here

    ++queryPatchIterator;
    ++currentPatchIterator;
    ++queryMaskIterator;
    ++currentMaskIterator;
    }

You can see that almost 20% of the total program time is spent in each
of these iterator ++ functions. Is there a faster way to do this?

Thanks,

David


More information about the Insight-users mailing list