1 #include <cpPlugins/Plugins/ImageWriter.h>
2 #include <cpPlugins/Interface/Image.h>
6 #define ITK_MANUAL_INSTANTIATION
9 #include <itkCovariantVector.h>
10 #include <itkDiffusionTensor3D.h>
12 #include <itkRGBPixel.h>
13 #include <itkRGBAPixel.h>
14 #include <itkSymmetricSecondRankTensor.h>
15 #include <itkVector.h>
17 #undef ITK_MANUAL_INSTANTIATION
18 #include <itkImageFileWriter.h>
20 // -------------------------------------------------------------------------
21 cpPlugins::Plugins::ImageWriter::
25 this->m_ClassName = "cpPlugins::ImageWriter";
26 this->m_ClassCategory = "ImageWriter";
27 this->SetNumberOfInputs( 1 );
29 using namespace cpPlugins::Interface;
30 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
31 this->m_Parameters = this->m_DefaultParameters;
34 // -------------------------------------------------------------------------
35 cpPlugins::Plugins::ImageWriter::
40 // -------------------------------------------------------------------------
41 std::string cpPlugins::Plugins::ImageWriter::
44 cpPlugins::Interface::Image* image =
45 this->_Input< cpPlugins::Interface::Image >( 0 );
47 return( "ImageWriter: No input image." );
49 itk::DataObject* itk_image = NULL;
51 cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
52 2, image, itk_image, r, _RealGD
54 else cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
55 3, image, itk_image, r, _RealGD
57 else cpPlugins_Image_Input_Demangle_Dimension_AllTypes(
58 4, image, itk_image, r, _RealGD
60 else cpPlugins_Image_Input_Demangle(
61 itk::DiffusionTensor3D< float >, 3, image, itk_image, r, _RealGD
63 else cpPlugins_Image_Input_Demangle(
64 itk::DiffusionTensor3D< double >, 3, image, itk_image, r, _RealGD
66 else r = "ImageWriter: Input image type not supported.";
71 // -------------------------------------------------------------------------
73 std::string cpPlugins::Plugins::ImageWriter::
74 _RealGD( itk::DataObject* image )
76 typedef itk::ImageFileWriter< I > _W;
79 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
80 _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
83 this->m_RealProcessObject = _W::New( );
84 writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) );
87 writer->SetFileName( fname );
88 writer->SetInput( dynamic_cast< I* >( image ) );
93 catch( itk::ExceptionObject& err )
95 return( "ImageWriter: " + std::string( err.GetDescription( ) ) );