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

Luis Ibanez luis.ibanez at kitware.com
Tue Nov 4 12:29:16 EST 2008


Hi David,


If by "SetDirection()" you are referring to the methods
in the Line Iterator and the Slice Iterator, then: Yes.
The order will impact your  performance.


If you were referring to the "image::SetDirection()" method,
then: No. The direction cosines of the image will not impact
the iterators performance, as Dan pointed out.


When you set a line iterator to walk along the direction "1"
instead of the direction "0", it will take longer to go through
the image.


If your algorithm give you the option of walking an image in
one direction  or another then you should select the "0" first.


    Regards,


       Luis


---------------------
David Fuentes wrote:
> Dan, Thank you very much for the reply.
> 
>> See the documentation in itkImage.h:
>>
>> * The data in an image is arranged in a 1D array as 
>> [][][][slice][row][col]
>> * with the column index varying most rapidly.  The Index type reverses
>> * the order so that with Index[0] = col, Index[1] = row, Index[2] = 
>> slice,
>> * ...
>>
>>> which value for
>>>
>>>  SetDirection()
>>>
>>> should be used to give the best performance?
>>
>>
>> From my understanding, SetDirection(..) has no impact on iterator
>> performance. SetDirection(..) changes the direction cosines, which are
>> used by TransformPhysicalPointToIndex(..),
>> TransformContinuousIndexToPhysicalPoint(..), and others in
>> itk::OrientatedImage (although in ITK 3.10, which is about to be
>> released, the direction cosines can be used in itk::Image, deprecating
>> itk::OrientatedImage).
>>
> 
> 
> 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?
> 
> 
> 
> df
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
> 


More information about the Insight-developers mailing list