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: NormalDistributionForce.h 00037 // 00038 // Created: Tue Feb 21 12:02:43 2006 00039 // 00040 // Author: Odd A. Andersen <Odd.Andersen@sintef.no> 00041 // 00042 // Revision: $Id: NormalDistributionForce.h,v 1.14 2006/11/25 20:08:23 oan Exp $ 00043 // 00044 // Description: 00048 // 00049 //=========================================================================== 00050 00051 #ifndef _NORMALDISTRIBUTIONFORCE_H 00052 #define _NORMALDISTRIBUTIONFORCE_H 00053 00054 #include "Mask.h" 00055 #include "LevelSetFunction.h" 00056 #include "ForceGenerator.h" // only documentation 00057 00058 namespace lsseg { 00059 00060 //=========================================================================== 00074 class NormalDistributionForce : public ForceGenerator 00075 //=========================================================================== 00076 { 00077 public: 00091 NormalDistributionForce(bool multireg_mode = false) 00092 : img_(0), mask_(0), multi_region_mode_(multireg_mode) {} // must be initialized first 00093 00111 NormalDistributionForce(const Image<double>* img, 00112 Mask* mask = 0, 00113 bool multireg_mode = false); 00114 00115 virtual ~NormalDistributionForce() {} 00116 00117 virtual void init(const Image<double>* img, const Mask* mask = 0); 00118 virtual void update(const LevelSetFunction& phi); 00119 virtual double force2D(int x, int y) const; 00120 virtual double force3D(int x, int y, int z) const ; 00121 virtual double force(size_t ix) const; 00122 virtual void force(LevelSetFunction&, const Mask* mask = 0) const; 00123 00124 private: 00125 00127 const Image<double>* img_; 00128 00131 const Mask* mask_; 00132 00136 const bool multi_region_mode_; // set to true if intended for use in a multiregion setting 00137 00139 std::vector<double> mu_in_; 00140 00142 std::vector<double> mu_out_; 00143 00146 std::vector<double> inv_sigma_in_; 00147 00150 std::vector<double> inv_sigma_out_; 00151 00155 std::vector<double> precalc_log_; // precalculated the quantity log(s1/s2) = log(s2_inv/s1_inv) 00156 00157 00158 inline void report() const; 00159 00162 inline void compute_averages(const LevelSetFunction&); 00163 00167 inline void compute_deviations(const LevelSetFunction&); 00168 }; 00169 00170 00171 00172 }; // end namespace lsseg 00173 00174 #endif // _NORMALDISTRIBUTIONFORCE_H