[Insight-developers] Histogram::GetIndex() boundary conditions

Miller, James V (Research) millerjv at crd.ge.com
Tue Apr 26 15:39:46 EDT 2005


I was recently looking through the code for itk::Histogram and noticed blocks of code like

    if (tempMeasurement < m_Min[dim][begin])
      {
      // one of measurement is below the minimum
      m_TempIndex[dim] = (long) m_Size[dim] ;
      itkWarningMacro(<<"One of the measurement components is below the minimum");
      }

and 

    if (tempMeasurement < m_Min[dim][begin])
      {
      // one of measurement is below the minimum
      index[dim] = (long) m_Size[dim] ;
      return false;
      }

and similar code for when the index exceeds the maximum bounds.

The first block of code was from GetIndex(const MeasurementVectorType& measurement) and the second was from GetIndex(const MeasurementVectorType & measurement, IndexType & index).

In the former case, a component of the index is set and the procedure continues along it way.  In the second case, a component is set and the routine returns.

Should the latter return before it has the opportunity to set the rest of the components of the index?

Is the index component value correct for these cases?  In both exceeding the minimum and maximum bounds, the index component is set to m_Size[dim].  I am assuming this indicates a bin that is outside the histogram.  I would have guessed that specifying a measurement that was below the first bin would put that measurement in the first bin and that specifying a measurement that is above the last bin would put that measurement in the last bin.

Jim




Jim Miller 
_____________________________________
Visualization & Computer Vision
GE Research
Bldg. KW, Room C218B
1 Research Circle, Schenectady NY 12309-1027

millerjv at reserch.ge.com <mailto:millerjv at reserch.ge.com>
(518) 387-4005, Dial Comm: 8*833-4005
Cell: (518) 505-7065, Fax: (518) 387-6981




More information about the Insight-developers mailing list