MantisBT - ITK
View Issue Details
0012204ITKITKpublic2011-05-17 17:262011-05-17 17:27
xiaoxiao 
xiaoxiao 
normalminoralways
assignedopen 
ITK-3-20 
ITK-4-A3 
backlog
0012204: wrong behavior of GaussianBlurImageFunction evaluating at a continuous index

When using itk::GaussianBlurImageFunction on a point of an image to get the weighted /interpolated values from its neighbors, if sigma is set to be zero, the GuassianBlurImageFunction should return the original value of the point. It is indeed the case when evaluating using EvaluateAtIndex(), however, when you call EvaluateAtContinousIndex() instead, the return value is zero.


An easy test to repeat this includes the following code (the complete code is attached):
....
gaussianFunction->SetSigma( 0.0 );
gaussianFunction->UseImageSpacingOn();

....

ConstIteratorType it( inputImage, region )

it.GoToBegin();
while( !it.IsAtEnd() )
      {
      out.Set( gaussianFunction->EvaluateAtContinuousIndex(it.GetIndex() ) );
       ++it;
      ++out;
      }
...

The resulting zero-blurred image is zero everywhere.

*****************************************************************

The problem lies in the function itk::GaussianBlurImageFunction::EvaluateAtContinousIndex().

The Gaussian kernel size (line 371) is determined by the input sigma(m_Sigma).
So when sigma is set to be zero, the Gaussian kernel is empty. Therefore, the convolution results with the zero Gaussian kernel is zero.

Also, the kernel size is wrong when the the sigmas are in physical unit, which is true by default. The radius size of the gaussianNeighbood should always be in pixel unit. Therefore, When the image spacing is close to 1.0, the resulting blurred image is not affected much. But when the image spacing is far from 1.0, for example (in one dimension case) : 1) When spacing is 10mm and sigma is 50 mm, then the Gaussian kernel array is a (50 *2 +1)= 101 long vector, which will extremely slowing down the convolution process; 2) When spacing is 0.1mm, and the sigma is 1 mm, the Gaussian kernel is only a 3 vector, which means only the two nearest neighbors are included in the convolution process, resulting in poor blurring results.
--

The testing code is attached (modified from http://www.vtk.org/Wiki/index.php?title=ITK/Examples/Functions/GuassianBlurImageFunction&oldid=38671 [^]
)

The test program GuassianBlurImageFunction can be generated.

To test the zero sigma problem, run :
 GuassianBlurImageFunction <input image> <output image> 0 6

No tags attached.
cxx GuassianBlurImageFunction.cxx (2,078) 2011-05-17 17:27
https://public.kitware.com/Bug/file/3880/GuassianBlurImageFunction.cxx
txt CMakeLists.txt (269) 2011-05-17 17:27
https://public.kitware.com/Bug/file/3881/CMakeLists.txt
Issue History
2011-05-17 17:26xiaoxiaoNew Issue
2011-05-17 17:26xiaoxiaoStatusnew => assigned
2011-05-17 17:26xiaoxiaoAssigned To => xiaoxiao
2011-05-17 17:27xiaoxiaoFile Added: GuassianBlurImageFunction.cxx
2011-05-17 17:27xiaoxiaoFile Added: CMakeLists.txt

There are no notes attached to this issue.