]> Creatis software - cpPlugins.git/blob - plugins/ITKUnaryFunctorFilters/UnaryBooleanImageFilter.cxx
...
[cpPlugins.git] / plugins / ITKUnaryFunctorFilters / UnaryBooleanImageFilter.cxx
1 #include <ITKUnaryFunctorFilters/UnaryBooleanImageFilter.h>
2 #include <cpInstances/Image.h>
3
4 #include <itkNotImageFilter.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsITKUnaryFunctorFilters::UnaryBooleanImageFilter::
8 UnaryBooleanImageFilter( )
9   : Superclass( )
10 {
11   typedef cpInstances::Image _TImage;
12
13   this->_ConfigureInput< _TImage >( "Input", true, false );
14   this->_ConfigureOutput< _TImage >( "Output" );
15
16   std::vector< std::string > choices;
17   choices.push_back( "Not" );
18   this->m_Parameters.ConfigureAsChoices( "Operator", choices );
19 }
20
21 // -------------------------------------------------------------------------
22 cpPluginsITKUnaryFunctorFilters::UnaryBooleanImageFilter::
23 ~UnaryBooleanImageFilter( )
24 {
25 }
26
27 // -------------------------------------------------------------------------
28 void cpPluginsITKUnaryFunctorFilters::UnaryBooleanImageFilter::
29 _GenerateData( )
30 {
31   auto o = this->GetInputData( "Input" );
32   cpPlugins_Demangle_Image_IntPixels_AllDims_1( o, _GD0 )
33     this->_Error( "Invalid input image." );
34 }
35
36 // -------------------------------------------------------------------------
37 template< class _TImage >
38 void cpPluginsITKUnaryFunctorFilters::UnaryBooleanImageFilter::
39 _GD0( _TImage* image )
40 {
41   typedef itk::NotImageFilter< _TImage, _TImage > _TFilter;
42
43   auto filter = this->_CreateITK< _TFilter >( );
44   filter->SetInput( image );
45   filter->Update( );
46   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
47 }
48
49 // eof - $RCSfile$