# Fix CentralDifferenceImageFunction for non-integer Point and ContinuousIndex

Michael Stauffer
2011-11-30
Fix CentralDifferenceImageFunction non-integer behavior. The methods Evaluate and EvaluateAtContinuousIndex in CentralDifferenceImageFunction were rounding the input point and continuous-index, respectively, to integer index values. This commit changes that behavior to evaluate them at continuous points and indecies, respectively.

The API has not changed. The purpose of this migration guide entry is to alert the user that regression tests may fail.

Image::TransformPhysicalPointToLocalPoint was added to compliment Image::TransformLocalPointToPhysicalPoint, for use in CentralDifferenceImageFunction::Evaluate when the flag m_UseImageDirection is false.

Image::m_InverseDirection was added, with automatic calculation in Image::SetDirection, for use in Image::TransformPhysicalPointToLocalPoint.

The baseline images for these tests have been updated to reflect the output of the modified methods:

ImageRegistration4Test2 ImageRegistration2Test DeformableRegistration12Test2 DeformableRegistration12Test1 DeformableRegistration12Test4 DeformableRegistration12Test3 DeformableRegistration13Test2 DeformableRegistration13Test1 DeformableRegistration13Test4 DeformableRegistration13Test3

This table below shows that by a cross-correlation measure with the fixed image, this change provides slightly better registration preformance than before.

CC image similarity of previous baseline and new output with fixed image:

Baseline New output Test 0.397664 0.400048 ImageRegistration4Test2 0.393323 0.394073 ImageRegistration2Test 0.845327 0.848734 DeformableRegistration12Test1 0.845327 0.848227 DeformableRegistration12Test2 0.845327 0.848649 DeformableRegistration12Test3 0.845327 0.848126 DeformableRegistration12Test4 0.845006 0.848648 DeformableRegistration13Test1 0.845006 0.848648 DeformableRegistration13Test2 0.845006 0.848648 DeformableRegistration13Test3 0.845006 0.848648 DeformableRegistration13Test4

Profiling test:

The new method is just slightly slower than the old method, probably within measurement error. Mac OSX 10.6, MacBook Pro Core 2 Duo @ 2.4 GHz Release build. Run using Example/Registration/ImageRegistration2, consisting of 200 iterations of GradientDescentOptimizer with MutualInformationImageToImageMetric. Profiled via unix &apos;time&apos; command on complete registration example. &apos;user&apos; + &apos;sys&apos; time in seconds, average of 3 runs: Old: 22.45 New: 22.54

I772a657451645222c69cdc9e1d87fa2e4acd0f19
Examples/Registration/test/Baseline/DeformableRegistration12Test.png.md5 Examples/Registration/test/Baseline/DeformableRegistration13Test.png.md5 Examples/Registration/test/CMakeLists.txt Modules/Core/Common/include/itkImageBase.h Modules/Core/Common/include/itkImageBase.hxx Modules/Core/Common/include/itkPhasedArray3DSpecialCoordinatesImage.h Modules/Core/Common/test/itkImageTest.cxx Modules/Core/ImageAdaptors/include/itkImageAdaptor.h Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.h Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.hxx Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx Modules/Registration/Common/test/CMakeLists.txt Modules/Registration/Common/test/itkImageRegistrationMethodTest_14.cxx Testing/Data/Baseline/Registration/ImageRegistration2Test.png.md5 Testing/Data/Baseline/Registration/ImageRegistration4Test.png.md5