]> Creatis software - FrontAlgorithms.git/blob - plugins/Plugins/SimpleImageNeighborhood.cxx
3d3e9436873e9785817632190b91f013424c795e
[FrontAlgorithms.git] / plugins / Plugins / SimpleImageNeighborhood.cxx
1 #include <Plugins/SimpleImageNeighborhood.h>
2 #include <cpInstances/Image.h>
3 #include <cpInstances/Image_Demanglers.h>
4
5 #include <itkImage.h>
6 #include <fpa/Image/Functors/SimpleNeighborhood.h>
7
8 // -------------------------------------------------------------------------
9 fpaPlugins::SimpleImageNeighborhood::
10 SimpleImageNeighborhood( )
11   : Superclass( )
12 {
13   typedef cpPlugins::BaseObjects::DataObject _TData;
14   typedef cpInstances::Image _TImage;
15
16   this->_ConfigureInput< _TImage >( "Input", true, false );
17   this->_ConfigureOutput< _TData >( "Output" );
18
19   this->m_Parameters.ConfigureAsUint( "Order", 1 );
20 }
21
22 // -------------------------------------------------------------------------
23 fpaPlugins::SimpleImageNeighborhood::
24 ~SimpleImageNeighborhood( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void fpaPlugins::SimpleImageNeighborhood::
30 _GenerateData( )
31 {
32   auto o = this->GetInputData( "Input" );
33   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
34     this->_Error( "Invalid input image." );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TImage >
39 void fpaPlugins::SimpleImageNeighborhood::
40 _GD0( _TImage* image )
41 {
42   typedef fpa::Image::Functors::SimpleNeighborhood< _TImage > _TFunctor;
43   auto out = this->GetOutput( "Output" );
44   auto f = out->GetITK< _TFunctor >( );
45   if( f == NULL )
46   {
47     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
48     f = ptr_f.GetPointer( );
49     out->SetITK( f );
50
51   } // fi
52   f->SetOrder( this->m_Parameters.GetUint( "Order" ) );
53 }
54
55 // eof - $RCSfile$