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 (PixelType == "unsigned_char")
46 UpdateWithDimAndPixelType<Dimension, itk::Vector<unsigned char, 3> >();
49 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float..." << std::endl;
50 UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
53 else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
57 //-------------------------------------------------------------------
58 // Update with the number of dimensions and the pixeltype
59 //-------------------------------------------------------------------
60 template <unsigned int Dimension, class PixelType>
62 VectorImageToImageGenericFilter::UpdateWithDimAndPixelType()
65 typedef itk::Image<PixelType, Dimension> InputImageType;
66 typedef typename PixelType::ComponentType ComponentType;
67 typedef itk::Image<ComponentType, Dimension> OutputImageType;
70 typedef itk::ImageFileReader<InputImageType> InputReaderType;
71 typename InputReaderType::Pointer reader = InputReaderType::New();
72 reader->SetFileName( m_InputFileName);
74 typename InputImageType::Pointer input= reader->GetOutput();
77 typedef clitk::VectorImageToImageFilter<InputImageType, OutputImageType> FilterType;
78 typename FilterType::Pointer filter=FilterType::New();
79 filter->SetInput(input);
80 filter->SetComponentIndex(m_ArgsInfo.componentIndex_arg);
82 typename OutputImageType::Pointer output=filter->GetOutput();
85 typedef itk::ImageFileWriter<OutputImageType> WriterType;
86 typename WriterType::Pointer writer = WriterType::New();
87 writer->SetFileName(m_ArgsInfo.output_arg);
88 writer->SetInput(output);
96 #endif //#define clitkVectorImageToImageGenericFilter_txx