]> Creatis software - cpPlugins.git/blob - plugins/cpPluginsImageFilters/AndImageFilter.cxx
e8057985407f337ad610992000a7cdcb39c781f7
[cpPlugins.git] / plugins / cpPluginsImageFilters / AndImageFilter.cxx
1 #include <cpPluginsImageFilters/AndImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances/BitwiseImageFilters.h>
4
5 // -------------------------------------------------------------------------
6 cpPluginsImageFilters::AndImageFilter::
7 AndImageFilter( )
8   : Superclass( )
9 {
10   this->_AddInput( "Input0" );
11   this->_AddInput( "Input1" );
12   this->_AddOutput< cpPlugins::Image >( "Output" );
13 }
14
15 // -------------------------------------------------------------------------
16 cpPluginsImageFilters::AndImageFilter::
17 ~AndImageFilter( )
18 {
19 }
20
21 // -------------------------------------------------------------------------
22 std::string cpPluginsImageFilters::AndImageFilter::
23 _GenerateData( )
24 {
25   auto image = this->GetInputData( "Input0" )->GetITK< itk::DataObject >( );
26   std::string   cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 2 );
27   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 3 );
28   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 1 );
29   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 4 );
30   return( r );
31 }
32
33 // -------------------------------------------------------------------------
34 template< class _TImage >
35 std::string cpPluginsImageFilters::AndImageFilter::
36 _GD0( _TImage* image0 )
37 {
38   typedef itk::AndImageFilter< _TImage, _TImage > _TFilter;
39   if( image0 != NULL )
40   {
41     auto image1 = this->GetInputData( "Input1" )->GetITK< _TImage >( );
42     if( image1 != NULL )
43     {
44       // Configure filter
45       auto filter = this->_CreateITK< _TFilter >( );
46       filter->SetInput( 0, image0 );
47       filter->SetInput( 1, image1 );
48       filter->Update( );
49
50       // Connect output
51       this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
52       return( "" );
53     }
54     else
55       return(
56         "ImageFilters::AndImageFilter: No valid second input image."
57         );
58   }
59   else
60     return(
61       "ImageFilters::AndImageFilter: No valid first input image."
62       );
63 }
64
65 // eof - $RCSfile$