]> Creatis software - cpPlugins.git/blob - plugins/cpPluginsImageFilters/IsoImageSlicer.cxx
942a6e4eab93ac0d80d72bfcd3cef099b1967dfa
[cpPlugins.git] / plugins / cpPluginsImageFilters / IsoImageSlicer.cxx
1 #include <cpPluginsImageFilters/IsoImageSlicer.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_ITKInstances/ImageFilters.h>
4
5 #include <cpExtensions/Algorithms/IsoImageSlicer.h>
6 #include <cpExtensions/Algorithms/IsoImageSlicer.hxx>
7 #include <itkAffineTransform.hxx>
8 #include <itkMatrixOffsetTransformBase.hxx>
9 #include <itkVariableLengthVector.hxx>
10 #include <itkDiffusionTensor3D.hxx>
11 #include <itkOptimizerParameters.hxx>
12 /*
13   #include <itkIsoImageSlicer.h>
14   #include <itkIsoImageSlicer.hxx>
15   #include <itkUnaryFunctorImageFilter.hxx>
16 */
17
18 // -------------------------------------------------------------------------
19 cpPluginsImageFilters::IsoImageSlicer::
20 IsoImageSlicer( )
21   : Superclass( )
22 {
23   this->_AddInput( "Input" );
24   this->_AddOutput< cpPlugins::Image >( "Output" );
25
26   std::vector< std::string > choices;
27   choices.push_back( "float" );
28   choices.push_back( "double" );
29   this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
30   this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
31   /* TODO
32      this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" );
33      this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
34      this->m_Parameters.ConfigureAsUint( "InsideValue" );
35      this->m_Parameters.ConfigureAsUint( "OutsideValue" );
36
37      this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
38      this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
39      this->m_Parameters.SetReal( "InsideValue", 1 );
40      this->m_Parameters.SetReal( "OutsideValue", 0 );
41   */
42 }
43
44 // -------------------------------------------------------------------------
45 cpPluginsImageFilters::IsoImageSlicer::
46 ~IsoImageSlicer( )
47 {
48 }
49
50 // -------------------------------------------------------------------------
51 std::string cpPluginsImageFilters::IsoImageSlicer::
52 _GenerateData( )
53 {
54   auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
55   std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
56   return( r );
57 }
58
59 // -------------------------------------------------------------------------
60 template< class _TImage >
61 std::string cpPluginsImageFilters::IsoImageSlicer::
62 _GD0( _TImage* image )
63 {
64   if( image != NULL )
65   {
66     auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
67     if( choice == "float" )
68       return( this->_GD1< _TImage, float >( image ) );
69     else if( choice == "double" )
70       return( this->_GD1< _TImage, double >( image ) );
71     else return( "IsoImageSlicer: no valid scalar type." );
72   }
73   else
74     return(
75       "ImageFilters::IsoImageSlicer: No valid input image."
76       );
77 }
78
79 // -------------------------------------------------------------------------
80 template< class _TImage, class _TScalar >
81 std::string cpPluginsImageFilters::IsoImageSlicer::
82 _GD1( _TImage* image )
83 {
84   typedef
85     cpExtensions::Algorithms::IsoImageSlicer< _TImage, _TScalar >
86     _TFilter;
87   typedef typename _TFilter::TVector _TVector;
88   typedef typename _TFilter::TMatrix _TMatrix;
89
90   // Configure filter
91   _TFilter* filter = this->_CreateITK< _TFilter >( );
92   filter->SetInput( image );
93   filter->SetInterpolator( NULL );
94   filter->SetTranslation( _TVector( ) );
95   filter->SetRotation( _TMatrix( ) );
96   filter->SetSize( 1 );
97   /* TODO
98      filter->SetLowerThreshold( lower_val );
99      filter->SetUpperThreshold( upper_val );
100      filter->SetInsideValue( in_val );
101      filter->SetOutsideValue( out_val );
102      filter->Update( );
103   */
104
105   // Connect output
106   this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
107   return( "" );
108 }
109
110 #include <cpExtensions/Algorithms/BezierCurveFunction.h>
111 #include <cpExtensions/Algorithms/BezierCurveFunction.hxx>
112
113 template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< float, 3 > >;
114 template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< double, 3 > >;
115
116 // eof - $RCSfile$