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 clitkImageToVectorImageGenericFilter_txx
19 #define clitkImageToVectorImageGenericFilter_txx
21 /* =================================================
22 * @file clitkImageToVectorImageGenericFilter.txx
28 ===================================================*/
29 #if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
30 # include "itkCompose3DVectorImageFilter.h"
32 # include "itkComposeImageFilter.h"
38 //-------------------------------------------------------------------
39 // Update with the number of dimensions
40 //-------------------------------------------------------------------
41 template<unsigned int Dimension>
43 ImageToVectorImageGenericFilter::UpdateWithDim(std::string PixelType)
45 if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
47 if(PixelType == "short"){
48 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
49 UpdateWithDimAndPixelType<Dimension, signed short>();
51 // else if(PixelType == "unsigned_short"){
52 // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
53 // UpdateWithDimAndPixelType<Dimension, unsigned short>();
56 else if (PixelType == "unsigned_char"){
57 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
58 UpdateWithDimAndPixelType<Dimension, unsigned char>();
61 // else if (PixelType == "char"){
62 // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
63 // UpdateWithDimAndPixelType<Dimension, signed char>();
66 if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
67 UpdateWithDimAndPixelType<Dimension, float>();
72 //-------------------------------------------------------------------
73 // Update with the number of dimensions and the pixeltype
74 //-------------------------------------------------------------------
75 template <unsigned int Dimension, class PixelType>
77 ImageToVectorImageGenericFilter::UpdateWithDimAndPixelType()
81 typedef itk::Image<PixelType, Dimension> InputImageType;
82 typedef itk::Image<itk::Vector<PixelType,3>, Dimension> OutputImageType;
85 #if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
86 typedef itk::Compose3DVectorImageFilter<InputImageType,OutputImageType> ComposeFilterType;
88 typedef itk::ComposeImageFilter<InputImageType,OutputImageType> ComposeFilterType;
90 typename ComposeFilterType::Pointer composeFilter=ComposeFilterType::New();
93 typedef itk::ImageFileReader<InputImageType> InputReaderType;
94 for (unsigned int i=0; i<3;i++)
96 typename InputReaderType::Pointer reader = InputReaderType::New();
97 reader->SetFileName( m_ArgsInfo.inputs[i]);
99 composeFilter->SetInput(i, reader->GetOutput());
101 composeFilter->Update();
102 typename OutputImageType::Pointer output = composeFilter->GetOutput();
105 typedef itk::ImageFileWriter<OutputImageType> WriterType;
106 typename WriterType::Pointer writer = WriterType::New();
107 writer->SetFileName(m_ArgsInfo.output_arg);
108 writer->SetInput(output);
116 #endif //#define clitkImageToVectorImageGenericFilter_txx