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