[Insight-developers] Minor omission in SegmentationLevelSetFunction?

Zachary Pincus zpincus at stanford.edu
Mon Feb 21 23:50:28 EST 2005


Hello,

I think that there might be a minor error in the 
SegmentationLevelSetFunction class that will cause inaccuracies when 
custom speed and edge advection images are set by a user.

As a review, the SegmentationLevelSetFunction class maintains speed and 
advection field images, and returns the appropriate value for these 
images (at a continuous index) when requested by the finite difference 
solver. Interpolators are used to find the appropriate value at this 
index.

Unfortunately, these interpolators are only connected to the speed and 
advection images in the functions AllocateSpeedImage() and 
AllocateAdvectionImage(). If a user has called 
AutoGenerateSpeedAdvectionOff() on the LevelSetSegmentationImageFilter 
class that they are using, and provided custom or pre-computed speed 
and advection images, then these allocators are (correctly) never 
called.

Because the allocators are never called, the interpolators are never 
given any input. This bug probably slipped through because there is a 
"fall back" path where the interpolator isn't used if the requested 
continuous index isn't inside the image -- this path just returns the 
nearest pixel from the speed or advection image. If no input to the 
interpolator has been set, then it will report that all points are 
outside the buffer, and the "fall back" path will always be used.

So, basically, when people use custom speed and advection images, they 
get nearest-neighbor (well, not really, it's roundoff-neighbor) 
interpolation instead of linear interpolation of these images.

I'm not sure how serious this issue is, but I assume it should be 
remedied. The fix is easy and simple -- just connect the images to the 
interpolators in the Set functions, not the Allocate functions. A patch 
is included. I assume this won't break the dashboard, but I'm not sure 
if any tests were calibrated against the erroneous interpolation.

Zach

zpincus% diff -w 
Insight/Code/Common/itkSegmentationLevelSetFunction-orig.h 
Insight/Code/Common/itkSegmentationLevelSetFunction.h
96,97c96
<   void SetSpeedImage( ImageType *s )
<   { m_SpeedImage = s; }
---
 >   void SetSpeedImage( ImageType *s );
102,103c101
<   void SetAdvectionImage( VectorImageType *s )
<   { m_AdvectionImage = s; }
---
 >   void SetAdvectionImage( VectorImageType *s );

zpincus% diff -w 
Insight/Code/Common/itkSegmentationLevelSetFunction-orig.txx 
Insight/Code/Common/itkSegmentationLevelSetFunction.txx
23a24,39
 > template <class TImageType, class TFeatureImageType>
 > void SegmentationLevelSetFunction<TImageType, TFeatureImageType>
 > ::SetSpeedImage( ImageType *s );
 > {
 >   m_SpeedImage = s;
 >   m_Interpolator->SetInputImage(m_SpeedImage);
 > }
 >
 > template <class TImageType, class TFeatureImageType>
 > void SegmentationLevelSetFunction<TImageType, TFeatureImageType>
 > ::SetAdvectionImage( VectorImageType *s );
 > {
 >   m_AdvectionImage = s;
 >   m_VectorInterpolator->SetInputImage(m_AdvectionImage);
 > }
 >



More information about the Insight-developers mailing list