]> Creatis software - clitk.git/blob - tools/clitkImageStatisticsGenericFilter.cxx
23cf4df06eb75901590f2f7b9603960b9696ad8f
[clitk.git] / tools / clitkImageStatisticsGenericFilter.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 clitkImageStatisticsGenericFilter_cxx
19 #define clitkImageStatisticsGenericFilter_cxx
20
21 /* =================================================
22  * @file   clitkImageStatisticsGenericFilter.cxx
23  * @author 
24  * @date   
25  * 
26  * @brief 
27  * 
28  ===================================================*/
29
30 #include "clitkImageStatisticsGenericFilter.h"
31
32
33 namespace clitk
34 {
35
36
37   //-----------------------------------------------------------
38   // Constructor
39   //-----------------------------------------------------------
40   ImageStatisticsGenericFilter::ImageStatisticsGenericFilter()
41   {
42     m_Verbose=false;
43     m_InputFileName="";
44   }
45
46
47   //-----------------------------------------------------------
48   // Update
49   //-----------------------------------------------------------
50   void ImageStatisticsGenericFilter::Update()
51   {
52     // Read the Dimension and PixelType
53     int Dimension, Components;
54     std::string PixelType;
55     ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
56     
57     if (m_ArgsInfo.channel_arg != -1 && m_ArgsInfo.channel_arg >= Components) {
58       std::cout << "Invalid image channel" << std::endl;
59       return;
60     }
61
62     
63     // Call UpdateWithDim
64     if (Dimension==2) {
65       switch (Components) {
66         case 1: 
67           UpdateWithDim<2,1>(PixelType);
68           break;
69         case 2: 
70           UpdateWithDim<2,2>(PixelType);
71           break;
72         case 3: 
73           UpdateWithDim<2,3>(PixelType);
74           break;
75         default:
76           std::cout << "Unsupported number of channels" << std::endl;
77           break;
78       }
79     }
80     else if (Dimension==3) {
81       switch (Components) {
82         case 1: 
83           UpdateWithDim<3,1>(PixelType);
84           break;
85         case 2: 
86           UpdateWithDim<3,2>(PixelType);
87           break;
88         case 3: 
89           UpdateWithDim<3,3>(PixelType);
90           break;
91         default:
92           std::cout << "Unsupported number of channels" << std::endl;
93           break;
94       }
95     }
96     else if (Dimension==4) {
97       switch (Components) {
98         case 1: 
99           UpdateWithDim<4,1>(PixelType);
100           break;
101         case 2: 
102           UpdateWithDim<4,2>(PixelType);
103           break;
104         case 3: 
105           UpdateWithDim<4,3>(PixelType);
106           break;
107         default:
108           std::cout << "Unsupported number of channels" << std::endl;
109           break;
110       }
111     }
112     else {
113       std::cout<<"Error, Only for 2 or 3  Dimensions!!!"<<std::endl ;
114       return;
115     }
116   }
117
118
119 } //end clitk
120
121 #endif  //#define clitkImageStatisticsGenericFilter_cxx