]> Creatis software - clitk.git/blob - tools/clitkSumGenericFilter.txx
Increase number of decimal for fusion and overlay
[clitk.git] / tools / clitkSumGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
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
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkSumGenericFilter_txx
19 #define clitkSumGenericFilter_txx
20
21 // itk include
22 #include <itkSumProjectionImageFilter.h>
23 #include <clitkCommon.h>
24
25 namespace clitk
26 {
27
28 //--------------------------------------------------------------------
29 template<class args_info_type>
30 SumGenericFilter<args_info_type>::SumGenericFilter():
31   ImageToImageGenericFilter<Self>("Sum")
32 {
33   InitializeImageType<3>();
34   InitializeImageType<4>();
35 }
36 //--------------------------------------------------------------------
37
38
39 //--------------------------------------------------------------------
40 template<class args_info_type>
41 template<unsigned int Dim>
42 void SumGenericFilter<args_info_type>::InitializeImageType()
43 {
44   ADD_DEFAULT_IMAGE_TYPES(Dim);
45 }
46 //--------------------------------------------------------------------
47
48
49 //--------------------------------------------------------------------
50 template<class args_info_type>
51 void SumGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
52 {
53   mArgsInfo=a;
54   this->SetIOVerbose(mArgsInfo.verbose_flag);
55   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
56
57   if (mArgsInfo.input_given) {
58     this->SetInputFilename(mArgsInfo.input_arg);
59   }
60   if (mArgsInfo.output_given) {
61     this->SetOutputFilename(mArgsInfo.output_arg);
62   }
63 }
64 //--------------------------------------------------------------------
65
66 //--------------------------------------------------------------------
67 // Update with the number of dimensions and the pixeltype
68 //--------------------------------------------------------------------
69 template<class args_info_type>
70 template<class InputImageType>
71 void
72 SumGenericFilter<args_info_type>::UpdateWithInputImageType()
73 {
74
75   // Reading input
76   typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
77
78   // Main filter
79   typedef typename InputImageType::PixelType PixelType;
80   const int Dim = InputImageType::ImageDimension;
81   typedef itk::Image<PixelType,Dim> ImageType;
82   typedef itk::Image<PixelType,Dim-1> OutputImageType;
83
84   // Filter
85   typedef itk::SumProjectionImageFilter<ImageType,OutputImageType> FilterType;
86   typename FilterType::Pointer filter = FilterType::New();
87   filter->SetProjectionDimension(mArgsInfo.dimension_arg);
88   filter->SetInput(input);
89   filter->Update();
90   this->template SetNextOutput<OutputImageType>(filter->GetOutput());
91 }
92 //--------------------------------------------------------------------
93
94
95 }//end clitk
96
97 #endif //#define clitkSumGenericFilter_txx