X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageStatisticsGenericFilter.cxx;h=3d9bea5041106e5d2e6afdd40f5636fcdb29757e;hb=706d7e2dc69e12b3823cfae2f3be3f903e4d3c80;hp=3779698ea7c7f82ef29223f03e82be0a2737ab77;hpb=a26cd8a19e1b9ad8344ab501436045f171a73713;p=clitk.git diff --git a/tools/clitkImageStatisticsGenericFilter.cxx b/tools/clitkImageStatisticsGenericFilter.cxx old mode 100755 new mode 100644 index 3779698..3d9bea5 --- a/tools/clitkImageStatisticsGenericFilter.cxx +++ b/tools/clitkImageStatisticsGenericFilter.cxx @@ -1,9 +1,9 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,22 +14,12 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef clitkImageStatisticsGenericFilter_cxx #define clitkImageStatisticsGenericFilter_cxx -/* ================================================= - * @file clitkImageStatisticsGenericFilter.cxx - * @author - * @date - * - * @brief - * - ===================================================*/ - #include "clitkImageStatisticsGenericFilter.h" - namespace clitk { @@ -42,6 +32,7 @@ namespace clitk m_Verbose=false; m_InputFileName=""; } + //----------------------------------------------------------- //----------------------------------------------------------- @@ -50,20 +41,79 @@ namespace clitk void ImageStatisticsGenericFilter::Update() { // Read the Dimension and PixelType - int Dimension; + int Dimension, Components; std::string PixelType; - ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType); + ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components); + + if (m_ArgsInfo.channel_arg < -1 || m_ArgsInfo.channel_arg >= Components) { + std::cout << "Invalid image channel" << std::endl; + return; + } + + if (m_ArgsInfo.mask_given) { + int maskDimension, maskComponents; + std::string maskPixelType; + ReadImageDimensionAndPixelType(m_ArgsInfo.mask_arg, maskDimension, maskPixelType, maskComponents); + if (!(maskDimension == Dimension || maskDimension == (Dimension - 1))) { + std::cout << "Dimension of label mask must be equal to the (d)imension of the input image or d-1." << std::endl; + return; + } + } + - // Call UpdateWithDim - if(Dimension==2) UpdateWithDim<2>(PixelType); - else if(Dimension==3) UpdateWithDim<3>(PixelType); - // else if (Dimension==4)UpdateWithDim<4>(PixelType); - else - { - std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<(PixelType); + break; + case 2: + UpdateWithDim<2,2>(PixelType); + break; + case 3: + UpdateWithDim<2,3>(PixelType); + break; + default: + std::cout << "Unsupported number of channels" << std::endl; + break; + } + } + else if (Dimension==3) { + switch (Components) { + case 1: + UpdateWithDim<3,1>(PixelType); + break; + case 2: + UpdateWithDim<3,2>(PixelType); + break; + case 3: + UpdateWithDim<3,3>(PixelType); + break; + default: + std::cout << "Unsupported number of channels" << std::endl; + break; + } + } + else if (Dimension==4) { + switch (Components) { + case 1: + UpdateWithDim<4,1>(PixelType); + break; + case 2: + UpdateWithDim<4,2>(PixelType); + break; + case 3: + UpdateWithDim<4,3>(PixelType); + break; + default: + std::cout << "Unsupported number of channels" << std::endl; + break; } + } + else { + std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<