[Insight-users] Iterate on image columns

Luis Ibanez luis.ibanez at kitware.com
Mon Oct 8 09:01:03 EDT 2007


Hi Emmanuel,

Yes, it could be possible to incorporate the IsAtEndOfSlice()
and IsAtEndOfLine() into the operator++, as well, as to
incorporate the NextLine() and NextSlice() calls.

However, when we typically use this Iterator is because we
*need* to know when it reaches the end of line and when it
reaches the end of the slice. The reason is typically that
we are doing some extra processing between reaching the end
of the line and moving to the next line.

Imagine for example the implementation of the FFT algorithm,
where we apply FFTs on every line. In that case, there are
extra processing to be inserted at the end of visiting each
line, e.g. to invoke that subroutines that actually compute
FFT.


-----


What is exactly the processing that you are performing in
the pixels ?

and why are you looking for a particular row and column order
but you are not worry about knowing when you read the end of
the lines and the slices ?


   Please let us know,


      Thanks


         Luis


----------------------------
Emmanuel Christophe wrote:
> Hi all,
> 
> I was looking for an iterator flexible enough to go through an image
> line by line (as usual) but also column by column.
> 
> I found the itk::ImageSliceConstIteratorWithIndex with the method
> SetFirstDirection() and SetSecondDirection() which exactly does that.
> 
> However, when trying to use this iterator as usual:
> 
>   while (!inputIterator.IsAtEnd())
>   {
>         inputIterator.Get();
>         ++inputIterator;
>   }
> 
> I quickly ran into a segfault.
> 
> It appears that this iterator has to be used in a slightly more complicated way:
> 
>   while (!inputIterator.IsAtEnd())
>   {
>     while (!inputIterator.IsAtEndOfSlice())
>     {
>       while(!inputIterator.IsAtEndOfLine())
>       {
>         inputIterator.Get();
>         ++inputIterator;
>       }
>       inputIterator.NextLine();
>     }
>   inputIterator.NextSlice();
>   }
> 
> Wouldn't it be possible to add the IsAtEndOfLine() and
> IsAtEndOfSlice() tests directly into the operator++ ?
> 
> It wouldn't modify the overall complexity as the test has to be done
> anyway in the while loop.
> 
> Regards,
> Emmanuel Christophe
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list