/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/include/MRBalloonForce.h

Go to the documentation of this file.
00001 //===========================================================================
00002 // The Level-Set Segmentation Library (LSSEG)
00003 //
00004 //
00005 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway.
00006 //
00007 // This program is free software; you can redistribute it and/or          
00008 // modify it under the terms of the GNU General Public License            
00009 // as published by the Free Software Foundation version 2 of the License. 
00010 //
00011 // This program is distributed in the hope that it will be useful,        
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00014 // GNU General Public License for more details.                           
00015 //
00016 // You should have received a copy of the GNU General Public License      
00017 // along with this program; if not, write to the Free Software            
00018 // Foundation, Inc.,                                                      
00019 // 59 Temple Place - Suite 330,                                           
00020 // Boston, MA  02111-1307, USA.                                           
00021 //
00022 // Contact information: e-mail: tor.dokken@sintef.no                      
00023 // SINTEF ICT, Department of Applied Mathematics,                         
00024 // P.O. Box 124 Blindern,                                                 
00025 // 0314 Oslo, Norway.                                                     
00026 // 
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //
00033 //===========================================================================
00034 //===========================================================================
00035 //                                                                           
00036 // File: MRBalloonForce.h                                                    
00037 //                                                                           
00038 // Created: Fri Feb 24 13:35:56 2006                                         
00039 //                                                                           
00040 // Author: Odd A. Andersen <Odd.Andersen@sintef.no>
00041 //                                                                           
00042 // Revision: $Id: MRBalloonForce.h,v 1.7 2006/11/13 02:29:25 oan Exp $
00043 //                                                                           
00044 // Description:
00048 //                                                                           
00049 //===========================================================================
00050 
00051 #ifndef _MRBALLOONFORCE_H
00052 #define _MRBALLOONFORCE_H
00053 
00054 #include "Image.h"
00055 #include "Mask.h"
00056 #include "simple_tools.h"
00057 #include "LevelSetFunction.h"
00058 #include "ForceGenerator.h" // only documentation
00059 #include "errormacros.h"
00060 #include <assert.h>
00061 #include <vector>
00062 
00063 namespace lsseg {
00064 
00065 //===========================================================================
00076 class MRBalloonForce : public ForceGenerator
00077 //===========================================================================
00078 {
00079 public:
00089     MRBalloonForce(double fac, const LevelSetFunction& phi) 
00090         : fac_(fac) { update(phi); }
00091     
00093     virtual ~MRBalloonForce() {}
00094 
00110     virtual void init(const Image<double>* img, const Mask* mask) {
00111         MESSAGE("Warning: neither 'img' nor 'm' used in MRBalloonForce::init()");
00112     }
00113 
00114     virtual void update(const LevelSetFunction& phi) {
00115         double tmp = negative_ratio(phi); 
00116         cur_force_ = (tmp > 0) ? fac_ / tmp : 0;
00117     }
00118     virtual double force2D(int x, int y) const { return cur_force_;}
00119     virtual double force3D(int x, int y, int z) const {return cur_force_;}
00120     virtual double force(size_t ix) const {return cur_force_;}
00121     virtual void force(LevelSetFunction& phi, const Mask* mask = 0) const {
00122         phi = cur_force_;
00123     }
00124     
00125 private:
00127     const double fac_;
00128 
00130     double cur_force_;
00131 
00132     inline void report() const;
00133 };
00134 
00135 
00136 }; //end namespace lsseg
00137 #endif // _MRBALLOONFORCE_H
00138 

Generated on Tue Nov 28 18:35:47 2006 for lsseg by  doxygen 1.4.7