]> Creatis software - cpPlugins.git/blob - plugins/cpPluginsImageFilters/ExtractImageFilter.cxx
More plugins added
[cpPlugins.git] / plugins / cpPluginsImageFilters / ExtractImageFilter.cxx
1 #include <cpPluginsImageFilters/ExtractImageFilter.h>
2 #include <cpPlugins/Image.h>
3 #include <cpPlugins_ITKInstances/ImageFilters.h>
4
5 #include <itkExtractImageFilter.h>
6 #include <itkExtractImageFilter.hxx>
7 #include <itkImageAlgorithm.hxx>
8
9 // -------------------------------------------------------------------------
10 cpPluginsImageFilters::ExtractImageFilter::
11 ExtractImageFilter( )
12   : Superclass( )
13 {
14   this->_AddInput( "Input" );
15   this->_AddOutput< cpPlugins::Image >( "Output" );
16   this->m_Parameters.ConfigureAsBool( "ReduceDimension" );
17   this->m_Parameters.SetBool( "ReduceDimension", false );
18
19   /* TODO
20      std::vector< std::string > choices;
21      choices.push_back( "float" );
22      choices.push_back( "double" );
23      this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
24      this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
25      this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
26      this->m_Parameters.ConfigureAsUint( "InsideValue" );
27      this->m_Parameters.ConfigureAsUint( "OutsideValue" );
28
29      this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
30      this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
31      this->m_Parameters.SetReal( "InsideValue", 1 );
32      this->m_Parameters.SetReal( "OutsideValue", 0 );
33   */
34 }
35
36 // -------------------------------------------------------------------------
37 cpPluginsImageFilters::ExtractImageFilter::
38 ~ExtractImageFilter( )
39 {
40 }
41
42 // -------------------------------------------------------------------------
43 std::string cpPluginsImageFilters::ExtractImageFilter::
44 _GenerateData( )
45 {
46   auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
47   std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
48   return( r );
49 }
50
51 // -------------------------------------------------------------------------
52 template< class _TImage >
53 std::string cpPluginsImageFilters::ExtractImageFilter::
54 _GD0( _TImage* image )
55 {
56   typedef
57     itk::Image< typename _TImage::PixelType, _TImage::ImageDimension - 1 >
58     _TOutImage;
59   typedef itk::ExtractImageFilter< _TImage, _TOutImage > _TFilter;
60
61   if( image == NULL )
62     return(
63       "ImageFilters::ExtractImageFilter: No valid input image."
64       );
65
66
67   // Configure filter
68   typename _TImage::RegionType reg;
69
70   _TFilter* filter = this->_CreateITK< _TFilter >( );
71   filter->SetInput( image );
72   filter->SetExtractionRegion( reg );
73
74   // Connect output
75   this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
76   return( "" );
77 }
78
79 // eof - $RCSfile$