From: schaerer Date: Mon, 8 Feb 2010 15:45:17 +0000 (+0000) Subject: preliminary fixes for multi-component images X-Git-Tag: v1.2.0~818 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9a84e9fdff8cd9daf405009ad716aadf2073ca8f;p=clitk.git preliminary fixes for multi-component images --- diff --git a/common/clitkCommonGenericFilter.h b/common/clitkCommonGenericFilter.h index 751a726..a1bb8a3 100644 --- a/common/clitkCommonGenericFilter.h +++ b/common/clitkCommonGenericFilter.h @@ -3,8 +3,8 @@ Program: clitk Module: $RCSfile: clitkCommonGenericFilter.h,v $ Language: C++ - Date: $Date: 2010/01/29 08:48:42 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/02/08 15:45:17 $ + Version: $Revision: 1.2 $ Author : Joel Schaerer David Sarrut @@ -45,18 +45,16 @@ namespace clitk { class GenericFilterFunctorBase { public: GenericFilterFunctorBase(FilterType * f) { mFilter = f; } - virtual void DoIt()= 0; + virtual void Execute()= 0; FilterType * mFilter; }; //-------------------------------------------------------------------- - template + template class GenericFilterFunctorWithDimAndPixelType: public GenericFilterFunctorBase { public: GenericFilterFunctorWithDimAndPixelType(FilterType * f): GenericFilterFunctorBase(f) {} - virtual void DoIt() { - //GenericFilterFunctorBase::mFilter->template UpdateWithDimAndPixelType(); - typedef itk::Image InputImageType; + virtual void Execute() { GenericFilterFunctorBase::mFilter->template UpdateWithInputImageType(); } }; @@ -66,20 +64,29 @@ namespace clitk { class ImageTypesManager { public: typedef std::map*> MapOfPixelTypeToFunctionType; - std::map mMapOfImageTypeToFunction; + typedef std::map MapOfImageComponentsToFunctionType; + std::map mMapOfImageTypeToFunction; ImageTypesManager(FilterType * f) { mFilter = f; } - virtual void DoIt(int dim, std::string pixelname) { + virtual void DoIt(int dim, int ncomp, std::string pixelname) { // std::cout << "ImageTypesManager DoIt " << dim << " " << pixelname << std::endl; - if (mMapOfImageTypeToFunction[dim][pixelname]) - mMapOfImageTypeToFunction[dim][pixelname]->DoIt(); + if (mMapOfImageTypeToFunction[dim][ncomp][pixelname]) + mMapOfImageTypeToFunction[dim][ncomp][pixelname]->Execute(); } - template + template void AddNewDimensionAndPixelType() { - // std::cout << "Adding Dim=" << Dim << " and PT = " << GetTypeAsString() << std::endl; - mFilter->AddImageType(Dim, GetTypeAsString()); - mMapOfImageTypeToFunction[Dim][ GetTypeAsString() ] = - new GenericFilterFunctorWithDimAndPixelType(mFilter); + mFilter->AddImageType(Dim, GetTypeAsString()); + typedef itk::Image,Dim> InputImageType; + mMapOfImageTypeToFunction[Dim][NComp][ GetTypeAsString() ] = + new GenericFilterFunctorWithDimAndPixelType(mFilter); + } + /// Specialization for NComp == 1 + template + void AddNewDimensionAndPixelType() { + mFilter->AddImageType(Dim, GetTypeAsString()); + typedef itk::Image InputImageType; + mMapOfImageTypeToFunction[Dim][1][ GetTypeAsString() ] = + new GenericFilterFunctorWithDimAndPixelType(mFilter); } FilterType * mFilter; }; diff --git a/common/clitkImageToImageGenericFilter.h b/common/clitkImageToImageGenericFilter.h index 90869c5..64ac239 100644 --- a/common/clitkImageToImageGenericFilter.h +++ b/common/clitkImageToImageGenericFilter.h @@ -3,8 +3,8 @@ Program: clitk Module: $RCSfile: clitkImageToImageGenericFilter.h,v $ Language: C++ - Date: $Date: 2010/02/03 13:08:52 $ - Version: $Revision: 1.4 $ + Date: $Date: 2010/02/08 15:45:17 $ + Version: $Revision: 1.5 $ Author : Joel Schaerer David Sarrut @@ -152,6 +152,7 @@ namespace clitk { // #define ADD_IMAGE_DIMENSION(DIM) Initialize(); +#define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType(); #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType(); diff --git a/common/clitkImageToImageGenericFilter.txx b/common/clitkImageToImageGenericFilter.txx index 6343c8b..253d421 100644 --- a/common/clitkImageToImageGenericFilter.txx +++ b/common/clitkImageToImageGenericFilter.txx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: clitkImageToImageGenericFilter.txx,v $ Language: C++ - Date: $Date: 2010/01/29 08:48:42 $ - Version: $Revision: 1.1 $ + Date: $Date: 2010/02/08 15:45:17 $ + Version: $Revision: 1.2 $ Author : Joel Schaerer David Sarrut @@ -78,7 +78,7 @@ bool clitk::ImageToImageGenericFilter::Update() { } // Go ! Call the right templatized function - mImageTypesManager->DoIt(mDim, mPixelTypeName); + mImageTypesManager->DoIt(mDim, mNbOfComponents, mPixelTypeName); return true; } //-------------------------------------------------------------------- diff --git a/filters/clitkImageArithmGenericFilter.cxx b/filters/clitkImageArithmGenericFilter.cxx index 044bb7c..fb33c2b 100644 --- a/filters/clitkImageArithmGenericFilter.cxx +++ b/filters/clitkImageArithmGenericFilter.cxx @@ -89,7 +89,6 @@ void clitk::ImageArithmGenericFilter::UpdateWithInputImageType() { // Write results this->SetNextOutput(outputImage); - //clitk::writeImage(outputImage, mOutputFilename, mIOVerbose); } //-------------------------------------------------------------------- diff --git a/filters/clitkSplitImageGenericFilter.cxx b/filters/clitkSplitImageGenericFilter.cxx index 9748058..f0dba70 100644 --- a/filters/clitkSplitImageGenericFilter.cxx +++ b/filters/clitkSplitImageGenericFilter.cxx @@ -39,9 +39,8 @@ void clitk::SplitImageGenericFilter::InitializeImageType() { ADD_IMAGE_TYPE(Dim, unsigned char); ADD_IMAGE_TYPE(Dim, short); ADD_IMAGE_TYPE(Dim, int); - ADD_IMAGE_TYPE(Dim, float); - typedef itk::Vector DVF; - ADD_IMAGE_TYPE(Dim, DVF); + //ADD_IMAGE_TYPE(Dim, float); + ADD_VEC_IMAGE_TYPE(Dim, 3,float); } //--------------------------------------------------------------------