Jerome Piovano

Research in Medical Imaging and Computer Vision

/home/jpiovano/src/Odyssee++/trunk/Libs/LevelSet/src/SegmentationModule/SegmentationModule.h

Go to the documentation of this file.
00001 
00009 #ifndef SEGMENTATIONMODULE_H
00010 #define SEGMENTATIONMODULE_H
00011 
00012 #include <LevelSet.h>
00013 
00014 using namespace Images;
00015 using namespace levelset;
00016 
00017 namespace segmentation {
00018 
00019 
00020 //TODO coder modules pour GVF,
00021 //TODO multiphase,
00022 //TODO multichannel
00023 //TODO (shapespriors literature trop grande). 
00024 //TODO SOBOLEV + JOSE GOMES => les 2 peuvent etre vus comme une extension apres avoir calcule la vitesse. (1 lissage, 2 extension vitesse, normale. (genre apres speed computation mais avant update. !!!ATTENTION courbure estimee si bande pas reinitialisee tres mauvaise !!!!))
00025 
00035         template<unsigned DIM, typename Pixel = float>
00036         class SegmentationModule 
00037         {
00038         public:
00039 
00040                 typedef          LevelSet<DIM, Pixel>   LevelSet;
00041                 typedef typename LevelSet::Index        Index;
00042                 typedef          Schemes<DIM,Pixel>     Schemes;
00043                 
00046 
00048                 SegmentationModule(float _weight = 1.f,        
00049                                    bool  _adaptive = true      
00050                                    );
00051 
00053                 virtual ~SegmentationModule();
00054 
00056 
00058 
00060                 void set_weight(float _weight);
00062                 void set_image_weight(BaseImage<DIM, float> * _weight);
00064                 float weight(const Index & ind);
00066                 bool adaptive();
00067 
00069 
00071 
00073                 virtual float value(const LevelSet & phi, const Index & ind) = 0;
00075                 virtual float energy(const LevelSet & phi, const Index & ind) = 0;
00077                 virtual void measures(const LevelSet & phi, const Index & ind, float meas[]) { }
00079                 virtual void init(const LevelSet & phi);
00081                 virtual void update(const LevelSet & phi){ }
00083                 virtual void save_result(const LevelSet & phi, std::string evodir, int iter){ }
00084 
00086 
00088 
00089         protected:      
00090 
00091                 float                       m_weight;        
00092                 BaseImage<DIM, float>     * m_image_weight;  
00093                 bool                        m_adaptive;      
00094 
00096 
00097         };
00098 
00099 
00101         // Constructors - Destructor
00102 
00103 
00104         template <unsigned DIM, typename Pixel>
00105                 SegmentationModule<DIM, Pixel>::SegmentationModule(float _weight, bool _adaptive)
00106                 :m_weight(_weight), m_image_weight(NULL), m_adaptive(_adaptive) 
00107         { }
00108 
00109         template <unsigned DIM, typename Pixel>
00110                 SegmentationModule<DIM, Pixel>::~SegmentationModule() 
00111         { }
00112 
00113 
00115         //  Access/Modif member data
00116 
00117 
00118         template <unsigned DIM, typename Pixel>
00119                 void SegmentationModule<DIM, Pixel>::set_weight(float _weight)
00120         {
00121                 m_weight = _weight;
00122         }
00123  
00124         template <unsigned DIM, typename Pixel>
00125                 void SegmentationModule<DIM, Pixel>::set_image_weight(BaseImage<DIM, float> * _weight)
00126         {
00127                 m_image_weight = _weight;
00128         }
00129 
00130         template <unsigned DIM, typename Pixel>
00131                 float SegmentationModule<DIM, Pixel>::weight(const Index & ind)
00132         {
00133                 if (m_image_weight != NULL)
00134                         return (*m_image_weight)(ind);
00135                 return m_weight;
00136         }
00137 
00138         template <unsigned DIM, typename Pixel>
00139                 bool SegmentationModule<DIM, Pixel>::adaptive()
00140         {
00141                 return m_adaptive;
00142         }
00143 
00144 
00146         //  Access/Modif member data
00147 
00148 
00149         template <unsigned DIM, typename Pixel>
00150                  void SegmentationModule<DIM, Pixel>::init(const LevelSet & phi)
00151         {
00152                 if ((m_image_weight != NULL) && (m_image_weight->shape() != phi.shape())) {
00153                         std::cerr << "Error : Shape of the image weight and shape of the LevelSet don't match"  << std::endl;
00154                         exit(1);
00155                 }
00156         }
00157 }
00158 
00159 #endif // SEGMENTATIONMODULE_H

For further information, please contact Jerome Piovano - Last update 2008-02-08