]> Creatis software - cpPlugins.git/blob - plugins/ImageArithmeticFilters/PowImageFilter.cxx
f0b4c8e09feb8cb8f0cdbd3a4097e347659d6626
[cpPlugins.git] / plugins / ImageArithmeticFilters / PowImageFilter.cxx
1 #include <plugins/ImageArithmeticFilters/PowImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3
4 #include <itkPowImageFilter.h>
5 #include <itkBinaryFunctorImageFilter.hxx>
6
7 // -------------------------------------------------------------------------
8 cpPluginsImageArithmeticFilters::PowImageFilter::
9 PowImageFilter( )
10   : Superclass( )
11 {
12   this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input0", true, false );
13   this->_ConfigureInput< cpPlugins::DataObjects::Image >( "Input1", false, false );
14   this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
15
16   this->m_Parameters.ConfigureAsReal( "Constant" );
17   this->m_Parameters.SetReal( "Constant", 1 );
18 }
19
20 // -------------------------------------------------------------------------
21 cpPluginsImageArithmeticFilters::PowImageFilter::
22 ~PowImageFilter( )
23 {
24 }
25
26 // -------------------------------------------------------------------------
27 void cpPluginsImageArithmeticFilters::PowImageFilter::
28 _GenerateData( )
29 {
30   auto o = this->GetInputData( "Input0" );
31   cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
32   else this->_Error( "Invalid input image." );
33 }
34
35 // -------------------------------------------------------------------------
36 template< class _TImage >
37 void cpPluginsImageArithmeticFilters::PowImageFilter::
38 _GD0( _TImage* image0 )
39 {
40   typedef itk::PowImageFilter< _TImage, _TImage > _TFilter;
41
42   // Configure filter
43   auto filter = this->_CreateITK< _TFilter >( );
44   filter->SetInput1( image0 );
45   auto image1 = this->GetInputData< _TImage >( "Input1" );
46   if( image1 == NULL )
47     filter->SetConstant( this->m_Parameters.GetReal( "Constant" ) );
48   else
49     filter->SetInput2( image1 );
50   filter->Update( );
51
52   // Connect output
53   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
54 }
55
56 // eof - $RCSfile$