/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/include/ParzenDistributionForce.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: ParzenDistributionForce.h                                          
00037 //                                                                           
00038 // Created: Wed Feb 22 21:10:10 2006                                         
00039 //                                                                           
00040 // Author: Odd A. Andersen <Odd.Andersen@sintef.no>
00041 //                                                                           
00042 // Revision: $Id: ParzenDistributionForce.h,v 1.5 2006/11/25 20:08:23 oan Exp $
00043 //                                                                           
00044 // Description:
00048 //                                                                           
00049 //===========================================================================
00050 
00051 #ifndef _PARZENDISTRIBUTIONFORCE_H
00052 #define _PARZENDISTRIBUTIONFORCE_H
00053 
00054 #include "ForceGenerator.h" // base class
00055 #include "Image.h"
00056 #include "Mask.h"
00057 #include "LevelSetFunction.h"
00058 #include "Histogram.h"
00059 #include <vector>
00060 #include <iostream>
00061 
00062 namespace lsseg {
00063 
00064 //===========================================================================
00084 class ParzenDistributionForce : public ForceGenerator
00085 //===========================================================================
00086 {
00087 public:
00100     ParzenDistributionForce(bool multireg_mode = false) : 
00101         multi_region_mode_(multireg_mode), 
00102         num_force_bins_(256),
00103         img_(0), 
00104         mask_(0)
00105     {} // must be initialized before use
00106 
00124     explicit ParzenDistributionForce(const Image<double>* img, 
00125                                       Mask* mask = 0, 
00126                                       bool multireg_mode = false) ;
00127 
00128     virtual ~ParzenDistributionForce() {} 
00129 
00130     virtual void init(const Image<double>* img, const Mask* mask = 0);
00131 
00132     virtual void update(const LevelSetFunction& phi);
00133     virtual double force2D(int x, int y) const;
00134     virtual double force3D(int x, int y, int z) const ;
00135     virtual double force(size_t ix) const;
00136     virtual void force(LevelSetFunction&, const Mask* mask = 0) const;
00137 
00145     void saveChannelDistribution(int channel, std::ostream& os, bool inside) const;
00146 
00156     void fixChannelDistributionTo(int channel, std::istream& is, bool inside);
00157 
00166     void fixDistributionToUniform(int channel, bool inside);
00167 
00174     void unfixChannelDistribution(int channel, bool inside);
00175 
00177     const Image<double>* const baseImage() const {return img_;}
00178 
00179 private:
00180 
00184     const bool multi_region_mode_;
00185 
00197     const int num_force_bins_; // number of bins for the precalculated force, must not
00198                                // be confused with the invidivual number of bins for the
00199                                // histograms.
00200 
00202     const Image<double>* img_;
00203 
00206     const Mask* mask_;
00207 
00210     std::vector<std::pair<bool, bool> > is_fixed_;
00211 
00215     std::vector<std::pair<Histogram, Histogram> > hist_; // histogram inside / outside
00216 
00220     std::vector<std::pair<double, double> > channel_ranges_;
00221 
00229     std::vector<double> force_bin_factor_;
00230 
00238     std::vector<std::vector<double> > precalc_force_;
00239 
00240 
00241     inline void report() const;
00242 
00248     inline int getForceBin(double val, int channel) const; 
00249 
00262     void precompute_force(int channel,
00263                           const Histogram& ihist,
00264                           const Histogram& ohist,
00265                           std::vector<double>& forcevec);
00266     
00272     double getCenterBinValue(int channel,int ix);
00273 
00285     inline void get_histogram(int channel, 
00286                               const LevelSetFunction& phi,
00287                               Histogram& inside_hist,
00288                               Histogram& outside_hist) const;
00289     
00292     Histogram makeDefaultHistogram(int channel) const ;
00293 };
00294 
00295 }; // end namespace lsseg
00296 
00297 #endif // _PARZENDISTRIBUTIONFORCE_H
00298 

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