[Insight-developers] ImageRandomConstIteratorWithIndex

Joshua Cates cates@sci.utah.edu
Thu, 20 Feb 2003 15:00:42 -0700 (MST)


Hi Luis,

We could still use it as a reverse iterator as long as SetToEnd() 
and IsAtBegin() were modified.  I think all that needs doing is 

void SetToEnd()
{
  m_NumberOfSamplesDone = m_NumberOfSamplesRequested +1;
}
bool IsAtBegin()
{
 return (m_NumberOfSamplesDone == 0);
}
void operator--()
{
 m_NumberOfSamplesDone -= 2;
 return ++(*this);
}

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


On Thu, 20 Feb 2003, Luis Ibanez wrote:

> 
> 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
>