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 clitkImageStatisticsGenericFilter_cxx
19 #define clitkImageStatisticsGenericFilter_cxx
21 /* =================================================
22 * @file clitkImageStatisticsGenericFilter.cxx
28 ===================================================*/
30 #include "clitkImageStatisticsGenericFilter.h"
37 //-----------------------------------------------------------
39 //-----------------------------------------------------------
40 ImageStatisticsGenericFilter::ImageStatisticsGenericFilter()
47 //-----------------------------------------------------------
49 //-----------------------------------------------------------
50 void ImageStatisticsGenericFilter::Update()
52 // Read the Dimension and PixelType
53 int Dimension, Components;
54 std::string PixelType;
55 ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
57 if (m_ArgsInfo.channel_arg < -1 || m_ArgsInfo.channel_arg >= Components) {
58 std::cout << "Invalid image channel" << std::endl;
62 if (m_ArgsInfo.mask_given) {
63 int maskDimension, maskComponents;
64 std::string maskPixelType;
65 ReadImageDimensionAndPixelType(m_ArgsInfo.mask_arg, maskDimension, maskPixelType, maskComponents);
66 if (!(maskDimension == Dimension || maskDimension == (Dimension - 1))) {
67 std::cout << "Dimension of label mask must be equal to the (d)imension of the input image or d-1." << std::endl;
77 UpdateWithDim<2,1>(PixelType);
80 UpdateWithDim<2,2>(PixelType);
83 UpdateWithDim<2,3>(PixelType);
86 std::cout << "Unsupported number of channels" << std::endl;
90 else if (Dimension==3) {
93 UpdateWithDim<3,1>(PixelType);
96 UpdateWithDim<3,2>(PixelType);
99 UpdateWithDim<3,3>(PixelType);
102 std::cout << "Unsupported number of channels" << std::endl;
106 else if (Dimension==4) {
107 switch (Components) {
109 UpdateWithDim<4,1>(PixelType);
112 UpdateWithDim<4,2>(PixelType);
115 UpdateWithDim<4,3>(PixelType);
118 std::cout << "Unsupported number of channels" << std::endl;
123 std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
131 #endif //#define clitkImageStatisticsGenericFilter_cxx