[Insight-developers] ImageLinearIteratorWithIndex advice requested

Luis Ibanez luis.ibanez at kitware.com
Fri Oct 12 18:08:11 EDT 2007


Hi Richard,

It might be worth writing this variation, and specially it will be
interesting to profile its performance in comparison with the
ImageLinearIteratorWithIndex.


The performance (computation time) of the Iterator should double
when walking inside the line, because instead of two additions in
the operator++() you will only need one:


The current code:

   inline Self & operator++()
   {
     this->m_PositionIndex[m_Direction]++;
     this->m_Position += m_Jump;
     return *this;
   }


will become:


   inline Self & operator++()
   {
     this->m_Position += m_Jump;
     return *this;
   }


You will have to change the implementation of IsAtEndOfLine() and
IsAtEndOfSlice() since now you won't have the PositionIndex. You
can actually precompute what the target m_Position should be for
the end of line, and use that in the IsAtEndOfLine().


That will make an interesting paper for the Insight Journal   :-)



      Luis


----------------------
Richard Beare wrote:
> Hi,
> I've used ImageLinearIteratorWithIndex in some filters where the index
> is used rarely, if at all. I was wondering whether it was worth
> writing a version without the Index tracking. However I thought I had
> better check whether anyone had a reason to suspect that the
> difference in performance might be especially small in this case,
> perhaps because the same information is essential to track lines
> anyway.
> 
> Thanks
> _______________________________________________
> 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