[Insight-developers] ImageRandomConstIteratorWithIndex

Lydia Ng lng@insightful.com
Thu, 20 Feb 2003 14:08:32 -0800


Dear Josh and Luis,

For the metric I only have use:

      it.GoToBegin();
	while(!it.IsAtEnd())
        {
        ++it;
        }

I remember went Luis made this we weren't quite sure as to how to treat
the operator--. For consistency we went something that works properly
for

      it.GoToEnd();
      while (!it.IsAtBegin() )
         {
         --it;
         }


Making operator-- decrement the m_NumberOfSamplesDone would be a good
tool.
So I don't mind the change. Just make sure the documentation say that
the above scenario does not work.

- Lydia

> -----Original Message-----
> From: Joshua Cates [mailto:cates@sci.utah.edu]
> Sent: Thursday, February 20, 2003 2:01 PM
> To: Luis Ibanez
> Cc: Insight-Developers; Lydia Ng
> Subject: Re: [Insight-developers] ImageRandomConstIteratorWithIndex
>=20
> Hi Luis,
>=20
> We could still use it as a reverse iterator as long as SetToEnd()
> and IsAtBegin() were modified.  I think all that needs doing is
>=20
> void SetToEnd()
> {
>   m_NumberOfSamplesDone =3D m_NumberOfSamplesRequested +1;
> }
> bool IsAtBegin()
> {
>  return (m_NumberOfSamplesDone =3D=3D 0);
> }
> void operator--()
> {
>  m_NumberOfSamplesDone -=3D 2;
>  return ++(*this);
> }
>=20
> Josh.
> ______________________________
>  Josh Cates
>  School of Computer Science
>  University of Utah
>  Email: cates@sci.utah.edu
>  Phone: (801) 587-7697
>  URL:   http://www.sci.utah.edu/~cates
>=20
>=20
> On Thu, 20 Feb 2003, Luis Ibanez wrote:
>=20
> >
> > Hi Josh,
> >
> > We can probably go either way,
> > and it will be more a matter of convention.
> >
> > Actually, some weeks ago a user suggested that
> > we modify the MutualInformation metric to keep
> > generating samples until all of them where
> > inside the overlap region.
> >
> > It happens that this behaviour could be easily
> > implemented with the ++ and -- operators iff
> > the numberOfSamples where decremented as you
> > just suggested.
> >
> > The original reason for incrementing samples in
> > the -- operator was to make possible for the
> > iterator to behave like a reverse iterator, but...
> > probably nobody is in need of such functionality
> > at this point.
> >
> > I'm ok with changing the behavior on the operator--.
> >
> > Lydia may have a deeper insight on this issue
> > since this will affect mostly the MutualInformation
> > metric.
> >
> >
> >     Luis
> >
> >
> > ----------------------------------
> > Joshua Cates wrote:
> > > Hi,
> > >
> > > In the implementation of ImageRandomConstIteratorWithIndex, the
member
> > > variable m_NumerOfSamplesDone is incremented in both operator++
and
> > > operator--.  This works fine for common cases of iteratation in
one
> > > "direction" through the whole random sample set because IsAtBegin,
> > > IsAtEnd are defined appropriately.
> > >
> > > But for cases where you might want to reverse iteration direction
in a
> > > loop, or go back a few random samples, (for example, an it++
followed
> by a
> > > conditional it--), this implementation will fail.  Is there any
reason
> not
> > > to modify this class so that operator-- decrements
> m_NumberOfSamplesDone?
> > >
> > > Josh.
> > > ______________________________
> > >  Josh Cates
> > >  School of Computer Science
> > >  University of Utah
> > >  Email: cates@sci.utah.edu
> > >  Phone: (801) 587-7697
> > >  URL:   http://www.sci.utah.edu/~cates
> > >
> > >
> > > _______________________________________________
> > > Insight-developers mailing list
> > > Insight-developers@public.kitware.com
> > > http://public.kitware.com/mailman/listinfo/insight-developers
> > >
> > >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> >