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 clitkVectorImageToImageGenericFilter_txx
19 #define clitkVectorImageToImageGenericFilter_txx
21 /* =================================================
22 * @file clitkVectorImageToImageGenericFilter.txx
28 ===================================================*/
34 //-------------------------------------------------------------------
35 // Update with the number of dimensions
36 //-------------------------------------------------------------------
37 template<unsigned int Dimension>
39 VectorImageToImageGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
41 if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
45 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float..." << std::endl;
46 UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
48 else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
52 //-------------------------------------------------------------------
53 // Update with the number of dimensions and the pixeltype
54 //-------------------------------------------------------------------
55 template <unsigned int Dimension, class PixelType>
57 VectorImageToImageGenericFilter::UpdateWithDimAndPixelType()
60 typedef itk::Image<PixelType, Dimension> InputImageType;
61 typedef typename PixelType::ComponentType ComponentType;
62 typedef itk::Image<ComponentType, Dimension> OutputImageType;
65 typedef itk::ImageFileReader<InputImageType> InputReaderType;
66 typename InputReaderType::Pointer reader = InputReaderType::New();
67 reader->SetFileName( m_InputFileName);
69 typename InputImageType::Pointer input= reader->GetOutput();
72 typedef clitk::VectorImageToImageFilter<InputImageType, OutputImageType> FilterType;
73 typename FilterType::Pointer filter=FilterType::New();
74 filter->SetInput(input);
75 filter->SetComponentIndex(m_ArgsInfo.componentIndex_arg);
77 typename OutputImageType::Pointer output=filter->GetOutput();
80 typedef itk::ImageFileWriter<OutputImageType> WriterType;
81 typename WriterType::Pointer writer = WriterType::New();
82 writer->SetFileName(m_ArgsInfo.output_arg);
83 writer->SetInput(output);
91 #endif //#define clitkVectorImageToImageGenericFilter_txx