[Insight-developers] m_EndContinuousIndex[j] vs m_EndIndex[j]

Tom Vercauteren tom.vercauteren at gmail.com
Thu May 28 16:03:38 EDT 2009


Hi Michel,

Indeed, there is a slight inconsistency here. When I wrote my first
version of this patch based on Simon's proposal, there was still no
consensus on what the rounding functions should do with half-integers.
Now it's clear (round half-integers upward) and we should make
IsInsideBuffer really consistent.

An alternative fix to the one you proposed would be to replace
  if( index[j] > m_EndContinuousIndex[j] )
by
  if( index[j] >= m_EndContinuousIndex[j] )
if ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY is on.

Cheers,
Tom

On Thu, May 28, 2009 at 21:37, Michel Audette
<michel.audette at kitware.com> wrote:
> Hi Luis,
>
> I'm wondering about the logic that we implemented below in
> itkImageFunction.txx...
> void
> ImageFunction<TInputImage, TOutput, TCoordRep>
> ::SetInputImage(
>   const InputImageType * ptr )
> ...
>       m_EndIndex[j] = m_StartIndex[j] + static_cast<IndexValueType>( size[j]
> ) - 1;
> #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
>       m_StartContinuousIndex[j] = static_cast<CoordRepType>( m_StartIndex[j]
> - 0.5 );
>       m_EndContinuousIndex[j]   = static_cast<CoordRepType>( m_EndIndex[j] +
> 0.5 );
> #else
>       m_StartContinuousIndex[j] = static_cast<CoordRepType>( m_StartIndex[j]
> );
>       m_EndContinuousIndex[j]   = static_cast<CoordRepType>( m_EndIndex[j]
> );
> #endif
>
> I'm seeing failing tests where the following function is called: in
> itkImageFunction.h...
> 155   virtual bool IsInsideBuffer( const ContinuousIndexType & index ) const
>  156     {
>  157     for( unsigned int j = 0; j < ImageDimension; j++ )
>  158       {
>  159       if( index[j] < m_StartContinuousIndex[j] )
>  160         {
>  161         return false;
>  162         }
>  163       if( index[j] > m_EndContinuousIndex[j] )
>  164         {
>  165         return false;
>  166         }
>  167       }
>  168     return true;
>  169     }
>
> with an index[j] of 63.5 when m_EndContinuousIndex[j] is exactly 63.5, given
> that we round everything at half upwards. Proceding this way means that
> everything at 1/2 pixel at the upper end of each dimension is seen as
> inside, even if it corresponds to 1 index more.
>
> Not surprisingly, the parts of the image that trigger failing tests are
> never on the lower side of the image dimension, only on the upper side.
>
> Would it not be better to have
>       m_EndContinuousIndex[j]   = static_cast<CoordRepType>( m_EndIndex[j] +
> 0.5 - FLT_MIN );
>
> or something to that effect, so that something with 1/2 pixel spacing sees
> the value m_EndIndex[j] + 0.5 declared outside?
>
> Currently, and unless we make this change, our logic is allowing in an extra
> row and column as "inside", which is probably not what we had in mind in
> going to pixel-centered coordinates.
>
> Copy to ITK community: anyone can chime in!
>
> Cheers,
>
> Michel
>
>
>
> --
> Michel Audette, Ph.D.
> R & D Engineer,
> Kitware Inc.,
> Chapel Hill, N.C.
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
>


More information about the Insight-developers mailing list