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://oncora1.lyon.fnclcc.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 clitkCalculateTREGenericFilter_cxx
19 #define clitkCalculateTREGenericFilter_cxx
21 /* =================================================
22 * @file clitkCalculateTREGenericFilter.cxx
28 ===================================================*/
30 #include "clitkCalculateTREGenericFilter.h"
37 //-----------------------------------------------------------
39 //-----------------------------------------------------------
40 CalculateTREGenericFilter::CalculateTREGenericFilter()
47 //-----------------------------------------------------------
49 //-----------------------------------------------------------
50 void CalculateTREGenericFilter::Update()
52 // Read the Dimension and PixelType
53 int Dimension, Components;
54 std::string PixelType;
55 ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
59 if(Dimension==2) ReadVectorFields<2,2>();
60 else if(Dimension==3) ReadVectorFields<3,3>();
61 else if (Dimension==4)ReadVectorFields<4,3>();
64 std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
71 //-----------------------------
73 //-----------------------------
76 CalculateTREGenericFilter::ProcessVectorFields<4,3>(std::vector<itk::Image<itk::Vector<float, 3>, 4>::Pointer > dvfs, char** filenames )
79 typedef itk::Vector<float,3> PixelType;
80 typedef itk::Image<PixelType, 4> InputImageType;
81 typedef itk::Image<PixelType, 3> OutputImageType;
84 InputImageType::Pointer input=dvfs[0];
85 std::vector<itk::Image<itk::Vector<float, 3>, 3>::Pointer > new_dvfs;
88 typedef itk::ExtractImageFilter<InputImageType,OutputImageType> FilterType;
89 unsigned int splitDimension=3;
91 // Make new file names
92 std::vector<std::string> new_filenames;
93 std::string base = filenames[0];
95 // Set the extract region
96 InputImageType::SizeType size=input->GetLargestPossibleRegion().GetSize();
97 size[splitDimension]=0;
98 InputImageType::RegionType extracted_region;
99 extracted_region.SetSize(size);
100 InputImageType::IndexType index=input->GetLargestPossibleRegion().GetIndex();
104 for (unsigned int i=0;i<input->GetLargestPossibleRegion().GetSize()[splitDimension];i++)
108 if (m_ArgsInfo.skip_given && i==(unsigned int) m_ArgsInfo.skip_arg) continue;
111 FilterType::Pointer filter= FilterType::New();
112 filter->SetInput(input);
113 index[splitDimension]=i;
114 extracted_region.SetIndex(index);
115 filter->SetExtractionRegion(extracted_region);
117 new_dvfs.push_back(filter->GetOutput());
120 std::ostringstream number_dvf;
122 std::string number = number_dvf.str();
123 new_filenames.push_back(base+"_"+number);
127 this->UpdateWithDim<3>(new_dvfs, new_filenames);
137 #endif //#define clitkCalculateTREGenericFilter_cxx