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