]> Creatis software - clitk.git/blob - tools/clitkSetBackgroundGenericFilter.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / tools / clitkSetBackgroundGenericFilter.cxx
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 clitkSetBackgroundGenericFilter_cxx
19 #define clitkSetBackgroundGenericFilter_cxx
20
21 /* =================================================
22  * @file   clitkSetBackgroundGenericFilter.cxx
23  * @author
24  * @date
25  *
26  * @brief
27  *
28  ===================================================*/
29
30 #include "clitkSetBackgroundGenericFilter.h"
31
32
33 namespace clitk
34 {
35
36
37 //-----------------------------------------------------------
38 // Constructor
39 //-----------------------------------------------------------
40 SetBackgroundGenericFilter::SetBackgroundGenericFilter()
41 {
42   m_Verbose=false;
43   m_InputFileName="";
44 }
45
46
47 //-----------------------------------------------------------
48 // Update
49 //-----------------------------------------------------------
50 void SetBackgroundGenericFilter::Update()
51 {
52   // Read the Dimension and PixelType
53   int Dimension, Components;
54   std::string PixelType;
55   //ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
56   ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
57
58   if (Dimension > 4) {
59     std::cout<<"Error, Only for 2 , 3 or 4 Dimensions!!!"<<std::endl ;
60     return;
61   }
62   
63   if (Components > 3) {
64     std::cout<<"Error, Only 1, 2, or 3-component images are supported!!!"<<std::endl ;
65     return;
66   }
67
68   if (Components > 1 && PixelType != "float") {
69     std::cout<<"Error, Only float multi-component images are supported!!!"<<std::endl ;
70     return;
71   }
72
73   switch (Components) {
74     case 1:
75       // Call UpdateWithDim
76       if(Dimension==2) UpdateWithDim<2>(PixelType);
77       else if(Dimension==3) UpdateWithDim<3>(PixelType);
78       else if (Dimension==4)UpdateWithDim<4>(PixelType);
79       break;
80     case 2:
81     {
82       typedef itk::Vector<float, 2> TPixelType;
83       if(Dimension==2) UpdateWithDimAndPixelType<2, TPixelType>();
84       else if(Dimension==3) UpdateWithDimAndPixelType<3, TPixelType>();
85       else if (Dimension==4)UpdateWithDimAndPixelType<4, TPixelType>();
86       break;
87     }
88     case 3:
89     {
90       typedef itk::Vector<float, 3> TPixelType;
91       if(Dimension==2) UpdateWithDimAndPixelType<2, TPixelType>();
92       else if(Dimension==3) UpdateWithDimAndPixelType<3, TPixelType>();
93       else if (Dimension==4)UpdateWithDimAndPixelType<4, TPixelType>();
94       break;
95     }
96   }
97 }
98
99
100 } //end clitk
101
102 #endif  //#define clitkSetBackgroundGenericFilter_cxx