1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkVFConvertGenericFilter_txx
19 #define clitkVFConvertGenericFilter_txx
21 /* =================================================
22 * @file clitkVFConvertGenericFilter.txx
28 ===================================================*/
34 //-------------------------------------------------------------------
35 // Update with the number of dimensions
36 //-------------------------------------------------------------------
37 template<unsigned int Dimension>
39 VFConvertGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
41 if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D with "<< Components <<" components of "<< PixelType<<"..."<<std::endl;
45 if (PixelType == "double"){
46 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
47 UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 2> >();
50 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
51 UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 2> >();
54 else if (Components==3)
56 if (PixelType == "double"){
57 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
58 UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 3> >();
61 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
62 UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
65 else if (Components==4)
67 if (PixelType == "double"){
68 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
69 UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 4> >();
72 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
73 UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 4> >();
76 else std::cerr<<"Only 2,3 and 4 components!"<<std::endl;
80 //-------------------------------------------------------------------
81 // Update with the number of dimensions and the pixeltype
82 //-------------------------------------------------------------------
83 template <unsigned int Dimension, class PixelType>
85 VFConvertGenericFilter::UpdateWithDimAndPixelType()
89 typedef itk::Image<PixelType, Dimension> InputImageType;
90 typedef itk::Image<PixelType, Dimension> OutputImageType;
93 typedef itk::ImageFileReader<InputImageType> InputReaderType;
94 typename InputReaderType::Pointer reader = InputReaderType::New();
95 reader->SetFileName( m_InputFileName);
97 typename InputImageType::Pointer input= reader->GetOutput();
100 typedef itk::ImageFileWriter<OutputImageType> WriterType;
101 typename WriterType::Pointer writer = WriterType::New();
102 writer->SetFileName(m_ArgsInfo.output_arg);
103 writer->SetInput(input);
111 #endif //#define clitkVFConvertGenericFilter_txx