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