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