[Insight-users] Iterate on image columns

Emmanuel Christophe emmanuel.christophe at gmail.com
Wed Oct 10 08:11:41 EDT 2007


Hi Luis,

One of the motivation to use the itk::ImageSliceConstIteratorWithIndex
was to benefit from the SetFirstDirection() and SetSecondDirection()
functions.

I had an algorithm which was doing a processing privileging one
direction on the image. The idea was to be able to do a
SetDirection(1) on all iterators of the program to get the same
algorithm privileging the other direction. This is when I first tried
to replace the itk::ImageRegionIterator into
itk::ImageSliceIteratorWithIndex and run into problems with the loops.

Wouldn't it be possible to include the NextLine() into the ++ and
still have a working IsAtEndOfLine()?

Another solution to my problem would have been simply to transpose the
image, but that wouldn't have been efficient in term of memory.

Anyway, I managed to go around my problem modifying the loops. What
are the trade-off compared with the traditional
itk::ImageRegionConstIterator?

I have seen that itk::ImageBase has a direction member. However, it
does not seem to do what I was looking for: I tried to change it for
an anti-diagonal matrix but it does not seem to influence iterators.

One thing I'm still looking for is a solution to introduce this
transposition in directions in the itk::NeighborhoodIterator.

Regards,
Emmanuel


2007/10/8, Luis Ibanez <luis.ibanez at kitware.com>:
>
> 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