Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.35 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. struct MyITKPipelineInterface
  2. {
  3.   virtual void setParam(int param) = 0;
  4.   virtual void update() = 0;
  5. };
  6.  
  7. template<typename TPixel, unsigned int VImageDimension>
  8. struct MyITKPipeline : public MyITKPipelineInterface
  9. {
  10.   typedef itk::Image<TPixel, VImageDimension> ImageType;
  11.   itk::Filter1<ImageType>::Pointer firstFilter;
  12.   ...
  13.   itk::Filter5<ImageType>::Pointer lastFilter;
  14.  
  15.   MyITKPipeline() { ... initialize stuff and connect pipeline ... }
  16.  
  17.   void setParam(int param) {
  18.     firstFilter->setParam(param);
  19.   }
  20.  
  21.   void update() {
  22.     lastFilter->Update();
  23.   }
  24. };
  25.  
  26. class CalculateSomething
  27. {
  28.  
  29. public:
  30.  
  31. void CreateSegmenation()
  32. {
  33.   AccessByItk(mitkImage, InvokeITKPipeline)
  34. }
  35.  
  36. private:
  37.  
  38. std::map<std::string, MyITKPipelineInterface*> typeToPipelineMap;
  39.  
  40. template<typename TPixel, unsigned int VImageDimension>
  41. void InvokeITKPipeline(itk::Image<TPixel, VImageDimension>* itkImage)
  42. {
  43.   std::stringstream key;
  44.   key << typeid(TPixel).name() << VImageDimension;
  45.  
  46.   MyITKPipelineInterface* myPipeline = typeToPipelineMap[key];
  47.   if (myPipeline == 0)
  48.   {
  49.     MyITKPipeline<TPixel, VImageDimension>* pipeline = new MyITKPipeline<TPixel, VImageDimension>();
  50.     pipeline->firstFilter.SetInput(itkImage);
  51.     myPipeline = pipeline;
  52.     typeToPipelineMap[key] = myPipeline;
  53.     // get the output pointer and save it in some mitk::Image
  54.   }
  55.  
  56.   myPipeline->setParam(4);
  57.   myPipeline->update();
  58. }
  59.  
  60. };