]> Creatis software - clitk.git/commitdiff
preliminary fixes for multi-component images
authorschaerer <schaerer>
Mon, 8 Feb 2010 15:45:17 +0000 (15:45 +0000)
committerschaerer <schaerer>
Mon, 8 Feb 2010 15:45:17 +0000 (15:45 +0000)
common/clitkCommonGenericFilter.h
common/clitkImageToImageGenericFilter.h
common/clitkImageToImageGenericFilter.txx
filters/clitkImageArithmGenericFilter.cxx
filters/clitkSplitImageGenericFilter.cxx

index 751a7262a63b1a97122658ccb93eba3c441e8de1..a1bb8a353d59debfc6c3adc9c0592ca802427389 100644 (file)
@@ -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 <joel.schaerer@creatis.insa-lyon.fr>
              David Sarrut <david.sarrut@creatis.insa-lyon.fr>
 
@@ -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<class FilterType, unsigned int Dim, class PixelType>
+  template<class FilterType, class InputImageType>
   class GenericFilterFunctorWithDimAndPixelType: public GenericFilterFunctorBase<FilterType> {
   public:
     GenericFilterFunctorWithDimAndPixelType(FilterType * f): GenericFilterFunctorBase<FilterType>(f) {}
-    virtual void DoIt() {       
-      //GenericFilterFunctorBase<FilterType>::mFilter->template UpdateWithDimAndPixelType<Dim,PixelType>();
-      typedef itk::Image<PixelType,Dim> InputImageType;
+    virtual void Execute() {       
       GenericFilterFunctorBase<FilterType>::mFilter->template UpdateWithInputImageType<InputImageType>();
     }
   };
@@ -66,20 +64,29 @@ namespace clitk {
   class ImageTypesManager  {
   public:
     typedef std::map<std::string, GenericFilterFunctorBase<FilterType>*> MapOfPixelTypeToFunctionType;
-    std::map<int, MapOfPixelTypeToFunctionType> mMapOfImageTypeToFunction;
+    typedef std::map<unsigned int, MapOfPixelTypeToFunctionType> MapOfImageComponentsToFunctionType;
+    std::map<unsigned int, MapOfImageComponentsToFunctionType> 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<unsigned int Dim, class Pixeltype>
+    template<unsigned int Dim, unsigned int NComp, class PixelType>
     void AddNewDimensionAndPixelType() {
-      // std::cout << "Adding Dim=" << Dim << " and PT = " << GetTypeAsString<Pixeltype>() << std::endl;
-      mFilter->AddImageType(Dim, GetTypeAsString<Pixeltype>());
-      mMapOfImageTypeToFunction[Dim][ GetTypeAsString<Pixeltype>() ] = 
-        new GenericFilterFunctorWithDimAndPixelType<FilterType, Dim, Pixeltype>(mFilter);
+        mFilter->AddImageType(Dim, GetTypeAsString<PixelType>());
+        typedef itk::Image<itk::Vector<PixelType,NComp>,Dim> InputImageType;
+        mMapOfImageTypeToFunction[Dim][NComp][ GetTypeAsString<PixelType>() ] = 
+            new GenericFilterFunctorWithDimAndPixelType<FilterType, InputImageType>(mFilter);
+    }
+    /// Specialization for NComp == 1
+    template<unsigned int Dim, class PixelType>
+    void AddNewDimensionAndPixelType() {
+        mFilter->AddImageType(Dim, GetTypeAsString<PixelType>());
+        typedef itk::Image<PixelType,Dim> InputImageType;
+        mMapOfImageTypeToFunction[Dim][1][ GetTypeAsString<PixelType>() ] = 
+            new GenericFilterFunctorWithDimAndPixelType<FilterType, InputImageType>(mFilter);
     }
     FilterType * mFilter;
   };
index 90869c53d1af3e7500bcbc9fd331d756d528cebe..64ac2396869e1ed462b1bbe5c63fe2d9651ddafa 100644 (file)
@@ -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 <joel.schaerer@creatis.insa-lyon.fr>
              David Sarrut <david.sarrut@creatis.insa-lyon.fr>
 
@@ -152,6 +152,7 @@ namespace clitk {
 
   // #define ADD_IMAGE_DIMENSION(DIM) Initialize<DIM>();
 
+#define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType<DIM,COMP, PT>();
 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType<DIM, PT>();
 
 
index 6343c8b600863bd578fa408d8eb55fc68224240b..253d421d0f4bfd37112f06fd63cc5134cb1a6cc0 100644 (file)
@@ -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 <joel.schaerer@creatis.insa-lyon.fr>
              David Sarrut <david.sarrut@creatis.insa-lyon.fr>
 
@@ -78,7 +78,7 @@ bool clitk::ImageToImageGenericFilter<FilterType>::Update() {
   }
 
   // Go ! Call the right templatized function
-  mImageTypesManager->DoIt(mDim, mPixelTypeName);
+  mImageTypesManager->DoIt(mDim, mNbOfComponents, mPixelTypeName);
   return true;
 }
 //--------------------------------------------------------------------
index 044bb7cba294e066ba1c311eeba9b9102b051542..fb33c2b7a133eb4b606ce96d347f7cae53bad83e 100644 (file)
@@ -89,7 +89,6 @@ void clitk::ImageArithmGenericFilter::UpdateWithInputImageType() {
 
   // Write results
   this->SetNextOutput<ImageType>(outputImage);
-  //clitk::writeImage<ImageType>(outputImage, mOutputFilename, mIOVerbose);
 }
 //--------------------------------------------------------------------
 
index 97480583d0b10283c98208481c4cf1a2024fe3fe..f0dba703f59f68a216542e46567e5a2cedf9bd50 100644 (file)
@@ -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<float, Dim> DVF;
-  ADD_IMAGE_TYPE(Dim, DVF);
+  //ADD_IMAGE_TYPE(Dim, float);
+  ADD_VEC_IMAGE_TYPE(Dim, 3,float);
 }
 //--------------------------------------------------------------------