View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010029ITKpublic2009-12-11 07:432011-06-26 20:48
ReporterStefan Klein 
Assigned Tokentwilliams 
PrioritynormalSeveritymajorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product VersionITK-3-14 
Target VersionFixed in Version 
Summary0010029: BSplineDeformableTransform::InsideValidRegion icm with even spline orders and ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
Description
The itk::BSplineDeformableTransform::InsideValidRegion seems to be incorrect (see below). It always returns true if ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY is turned ON, in combination with an even spline order.


template<class TScalarType, unsigned int NDimensions, unsigned int VSplineOrder>
bool
BSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>
::InsideValidRegion(
  const ContinuousIndexType& index ) const
{
  bool inside = true;

#ifndef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
  if( !m_ValidRegion.IsInside( index ) )
    {
    inside = false;
    }
#endif

  if ( inside && m_SplineOrderOdd )
    {
    typedef typename ContinuousIndexType::ValueType ValueType;
    for( unsigned int j = 0; j < SpaceDimension; j++ )
      {
      if ( index[j] >= static_cast<ValueType>( m_ValidRegionLast[j] ) )
        {
        inside = false;
        break;
        }
#ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
      if ( index[j] < static_cast<ValueType>( m_ValidRegionFirst[j] ) )
        {
        inside = false;
        break;
        }
#endif
      }
    }

  return inside;
}

Additional InformationI have a fix and will do an experimental build soon to test it.
TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Fileszip file icon bsplinevalidregionfix.zip [^] (27,171 bytes) 2011-03-27 14:10

 Relationships

  Notes
(0022804)
Hans Johnson (developer)
2010-11-02 13:57

Stefan,

Is this still a bug? I am assuming that it is not. Please confirm the status of this bug report. I will close assuming that it was fixed if I do not hear back from you shortly.

Hans
(0023745)
Rupert Brooks (reporter)
2010-12-06 15:40

This is still a bug - it just bit me today. It actually appears to be worse in the git repository as the part

#ifndef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
  if( !m_ValidRegion.IsInside( index ) )
    {
    inside = false;
    }
#endif

is gone. So for even ordered transforms, it never works.
(0025903)
Hans Johnson (developer)
2011-03-25 11:32

Stefan,

Have you every found a work around for this? I'd really like to apply this patch and get this ticket closed.

Thanks,
Hans
(0025917)
Hans Johnson (developer)
2011-03-27 14:09

On 3/26/11 6:34 PM, "Stefan Klein" <s.klein@erasmusmc.nl> wrote:

Hi Hans,
Please find attached a fix.

I modified the itk3.20 files of the BSplineDeformableTransform. The
original files are included in a subdir so that you can do a diff. That
should show the relevant changes at once.

I also included a little test program, bsplinefix.cxx, which tests the
code for a given spline order.
it makes a 1D bspline transform, with a grid of 4 control points, i.e.
at 0,1,2, and 3. Then it sets all bspline parameters to 10, such that
the transform adds a constant displacement of 10 within the valid
region. Then it loops from x=-1 to x=4, calls TransformPoint(x) and
prints the result. Outside the valid region, outputpoint=inputpoint.
Inside the valid region, outputpoint=inputpoint+10. I tested it for
spline orders 0,1,2,3, and it gives correct results.

While I was testing this, I found another major bug, which occurred only
with spline order 0. In the itkBSplineInterpolationWeightFunction.txx,
the expression SplineOrder - 1 becomes infinity because SplineOrder is
an unsigned int. I added a static_cast to solve this.

I hope it's useful. If you agree with the fix, could you commit it to
the repository?

Cheers,
Stefan
(0025918)
Hans Johnson (developer)
2011-03-27 14:21

Kent,

Please work through the process of making a patch for ITKv3.20 and ITKv4 with the proposed changes supplied in this patch.

Hans
(0026244)
kentwilliams (developer)
2011-04-22 16:14

I see the changes you propose for ITK 3.20, but it appears that the current ITK4 version has been substantially reworked.

Hans it looks like most of the re-writing is stuff you did in commit 3c2d558cc3fa0383c4c34f41b87dedee12a2d946

Since the code is completely rearranged and I am not familiar enough with the internal workings of this transform, I don't feel qualified to evaluate whether this bug has been resolved or not.
(0026981)
Hans Johnson (developer)
2011-06-26 20:48

Kent please make a patch just for ITKv3.20 and submit to Gerrit.

 Issue History
Date Modified Username Field Change
2009-12-11 07:43 Stefan Klein New Issue
2010-11-02 13:56 Hans Johnson Status new => assigned
2010-11-02 13:56 Hans Johnson Assigned To => Hans Johnson
2010-11-02 13:57 Hans Johnson Note Added: 0022804
2010-12-06 15:40 Rupert Brooks Note Added: 0023745
2011-03-25 11:32 Hans Johnson Note Added: 0025903
2011-03-27 14:09 Hans Johnson Note Added: 0025917
2011-03-27 14:10 Hans Johnson File Added: bsplinevalidregionfix.zip
2011-03-27 14:21 Hans Johnson Assigned To Hans Johnson => kentwilliams
2011-03-27 14:21 Hans Johnson Note Added: 0025918
2011-04-22 16:14 kentwilliams Note Added: 0026244
2011-04-22 16:14 kentwilliams Assigned To kentwilliams => Hans Johnson
2011-06-26 20:48 Hans Johnson Assigned To Hans Johnson => kentwilliams
2011-06-26 20:48 Hans Johnson Note Added: 0026981


Copyright © 2000 - 2018 MantisBT Team