]> Creatis software - cpPlugins.git/blob - plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.cxx
...
[cpPlugins.git] / plugins / ITKImageInterpolators / BSplineInterpolateImageFunction.cxx
1 #include <ITKImageInterpolators/BSplineInterpolateImageFunction.h>
2 #include <cpInstances/DataObjects/Image.h>
3 #include <itkImage.h>
4 #include <itkBSplineInterpolateImageFunction.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
8 BSplineInterpolateImageFunction( )
9   : Superclass( )
10 {
11   this->m_Parameters.ConfigureAsUint( "SplineOrder", 3 );
12   this->m_Parameters.ConfigureAsBool( "UseImageDirection", true );
13 }
14
15 // -------------------------------------------------------------------------
16 cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
17 ~BSplineInterpolateImageFunction( )
18 {
19 }
20
21 // -------------------------------------------------------------------------
22 void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
23 CreateInterpolator(
24   itk::LightObject* image, const std::string& precision_type
25   )
26 {
27   this->m_PrecisionType = precision_type;
28   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( image, _GD0 )
29     this->_Error( "Invalid input image." );
30 }
31
32 // -------------------------------------------------------------------------
33 void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
34 _GenerateData( )
35 {
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
41 _GD0( _TImage* image )
42 {
43   if( this->m_PrecisionType == "float" )
44     this->_GD1< _TImage, float >( image );
45   else if( this->m_PrecisionType == "double" )
46     this->_GD1< _TImage, double >( image );
47 }
48
49 // -------------------------------------------------------------------------
50 template< class _TImage, class _TScalar >
51 void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
52 _GD1( _TImage* image )
53 {
54   typedef itk::BSplineInterpolateImageFunction< _TImage, _TScalar, _TScalar > _TFunction;
55
56   auto function = this->_CreateITK< _TFunction >( );
57   function->SetSplineOrder( this->m_Parameters.GetUint( "SplineOrder" ) );
58   function->SetUseImageDirection( this->m_Parameters.GetBool( "UseImageDirection" ) );
59   this->GetOutput( "Output" )->SetITK( function );
60 }
61
62 // eof - $RCSfile$