]> Creatis software - cpPlugins.git/blob - plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx
224aa877e7377973e2ff78e50ef0cf27ecf184fb
[cpPlugins.git] / plugins / cpPluginsImageFilters / MultiScaleGaussianImageFilter.cxx
1 #include <cpPluginsImageFilters/MultiScaleGaussianImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_Instances/GaussianImageFilters.h>
4
5 /*
6   #include <cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h>
7   #include <cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx>
8   #include <itkGradientRecursiveGaussianImageFilter.hxx>
9   #include <itkImageAdaptor.hxx>
10   #include <itkImageToImageFilter.hxx>
11   #include <itkInPlaceImageFilter.hxx>
12   #include <itkUnaryFunctorImageFilter.hxx>
13   #include <itkRecursiveGaussianImageFilter.hxx>
14   #include <itkImageConstIteratorWithIndex.hxx>
15   #include <itkRecursiveSeparableImageFilter.hxx>
16   #include <itkBinaryFunctorImageFilter.hxx>
17   #include <itkImageRegionConstIterator.hxx>
18   #include <itkImageScanlineIterator.hxx>
19   #include <itkImageSource.hxx>
20   #include <itkImageRegionIteratorWithIndex.hxx>
21   #include <itkImageScanlineConstIterator.hxx>
22   #include <itkImageRegionIterator.hxx>
23   #include <itkSimpleDataObjectDecorator.hxx>
24   #include <itkImageRegionConstIteratorWithIndex.hxx>
25   #include <itkNthElementPixelAccessor.h>
26   #include <itkImageBase.hxx>
27 */
28
29 // -------------------------------------------------------------------------
30 cpPluginsImageFilters::MultiScaleGaussianImageFilter::
31 MultiScaleGaussianImageFilter( )
32   : Superclass( )
33 {
34   this->_AddInput( "Input" );
35   this->_AddOutput< cpPlugins::Image >( "Output" );
36
37   this->m_Parameters.ConfigureAsRealList( "Sigmas" );
38
39   std::vector< std::string > choices;
40   choices.push_back( "float" );
41   choices.push_back( "double" );
42   this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
43   this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
44 }
45
46 // -------------------------------------------------------------------------
47 cpPluginsImageFilters::MultiScaleGaussianImageFilter::
48 ~MultiScaleGaussianImageFilter( )
49 {
50 }
51
52 // -------------------------------------------------------------------------
53 std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
54 _GenerateData( )
55 {
56   auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
57   std::string   cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
58   if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
59   return( r );
60 }
61
62 // -------------------------------------------------------------------------
63 template< class _TImage >
64 std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
65 _GD0( _TImage* image )
66 {
67   if( image != NULL )
68   {
69     auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" );
70     if( choice == "float" )
71       return( this->_GD1< _TImage, float >( image ) );
72     else if( choice == "double" )
73       return( this->_GD1< _TImage, double >( image ) );
74     else return( "MultiScaleGaussianImageFilter: no valid scalar type." );
75   }
76   else
77     return(
78       "MultiScaleGaussianImageFilter: No valid input image."
79       );
80 }
81
82 // -------------------------------------------------------------------------
83 template< class _TImage, class _TScalar >
84 std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
85 _GD1( _TImage* image )
86 {
87   typedef itk::CovariantVector< _TScalar, _TImage::ImageDimension > _TVector;
88   typedef itk::Image< _TVector, _TImage::ImageDimension > _TGradient;
89   typedef
90     cpExtensions::Algorithms::MultiScaleGaussianImageFilter< _TImage, _TGradient >
91     _TFilter;
92
93   auto sigmas = this->m_Parameters.GetRealList( "Sigmas" );
94   if( sigmas.size( ) == 0 )
95     return(
96       "MultiScaleGaussianImageFilter: No given sigmas."
97       );
98
99   // Configure filter
100   _TFilter* filter = this->_CreateITK< _TFilter >( );
101   filter->SetInput( image );
102   for( auto sIt = sigmas.begin( ); sIt != sigmas.end( ); ++sIt )
103     filter->AddScale( *sIt );
104   filter->Update( );
105
106   // Connect output
107   this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
108   return( "" );
109 }
110
111 // eof - $RCSfile$