[Insight-developers] performance of image iterators and pixel buffer storage

kent williams norman-k-williams at uiowa.edu
Fri Nov 7 11:03:39 EST 2008


There are a lot of different 'iterators' in ITK, and they're not all
implemented in the same way.  Their implementation is as efficient as the
ITK developer community has been able to make them, given their varied
purposes.  No small amount of time has been spent on this process.

In the most common case, which I'd judge to be the one covered by the
itk::ImageRegionConstIterator itk::ImageRegionIterator classes, pixels
adjacent in memory are accessed by simple pointer arithmetic.  There is a
little overhead, because at the end of each span of adjacent pixels some
arithmetic has to take place in order to move the pixel pointer to the
beginning of the next span.

There's no special abstraction needed -- first you work on this pixel, then
you work on the next pixel, and the simplest way to do this -- increment a
pointer, check if you have to move to the next contiguous pixel span -- is
also the most cache coherent.

There are other types of iterators -- NeighborhoodIterators, for example --
that efficiently work on a region around a particular pixel. All of the
iterator classes are pretty close to the theoretical limit for efficiency,
given the constraints on what they're asked to do.

The efficiency question is probably one you should only worry about if
performance is a problem, and the iterator you're using is the bottleneck.
You're not likely to gain enough performance by grabbing the raw buffer
pointer for the image data and rolling your own to make it worthwhile.

But of course you always have that option.

Personally, I think ITK might benefit from an image iterator like



On 11/4/08 12:13 PM, "David Fuentes" <fuentesdt at gmail.com> wrote:
> 
> A little confused.
> B/C of the memory storage setup, wouldn't you expect a significant cache
> performance difference if you iterate over row's vs iterating over columns?
> Are you saying that ITK iterators have some special abstraction to avoid
> this?
> 



Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.




More information about the Insight-developers mailing list