/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/include/LevelSetFunction.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: LevelSetFunction.h                                                  
00037 //                                                                           
00038 // Created: Fri Feb 17 13:29:58 2006                                         
00039 //                                                                           
00040 // Author: Odd A. Andersen <Odd.Andersen@sintef.no>
00041 //                                                                           
00042 // Revision: $Id: LevelSetFunction.h,v 1.12 2006/11/16 06:38:21 oan Exp $
00043 //                                                                           
00044 // Description:
00049 //                                                                           
00050 //===========================================================================
00051 
00052 #ifndef _LEVELSETFUNCTION_H
00053 #define _LEVELSETFUNCTION_H
00054 
00055 #include "errormacros.h"
00056 #include "Image.h"
00057 #include "Mask.h"
00058 
00059 namespace lsseg {
00060 
00061 //===========================================================================
00070 class LevelSetFunction : public Image<double>
00071 //===========================================================================
00072 {
00073 public:
00078     LevelSetFunction() : Image<double>(0, 0, 0, 1) {}
00079     LevelSetFunction(int x, int y, int z = 1, double val = 0) 
00080         : Image<double>(x, y, z, 1, val) {}
00081     virtual  ~LevelSetFunction() {}
00082 
00084     LevelSetFunction(const LevelSetFunction& rhs) : Image<double>(rhs) {};
00085     
00093     LevelSetFunction(const LevelSetFunction& rhs, bool copy) 
00094         : Image<double>(rhs, copy) {}
00095 
00097     virtual Image<double>& operator=(const Image<double>& rhs) {
00098         single_channel_assert(rhs.numChannels());
00099         return Image<double>::operator=(rhs);
00100     }
00101 
00103     virtual LevelSetFunction& operator=(const double& val)
00104     {
00105         std::fill(data_.begin(), data_.end(), val);
00106         return *this;
00107     }
00108 
00111     void resize(const LevelSetFunction& rhs)
00112     {
00113         resize(rhs.dimx(), rhs.dimy(), rhs.dimz(), 1);
00114     }
00115 
00124     virtual void resize(int x, int y, int z= 1, int channels = 1) {
00125         single_channel_assert(channels);
00126         Image<double>::resize(x, y, z, channels);
00127     }
00128     
00133     virtual void swap(Image<double>& rhs) {
00134         single_channel_assert(rhs.numChannels());
00135         Image<double>::swap(rhs);
00136     }
00137     
00151     virtual void permute(const int* const perm) {
00152         ALWAYS_ERROR_IF(perm[3] != 3, 
00153                         "cannot permute the 'channel' of a LevelSetFunction");
00154         Image<double>::permute(perm);
00155     }    
00156 
00162     virtual void read(std::istream& is, bool binary=true) {
00163         LevelSetFunction tmp;
00164         tmp.Image<double>::read(is, binary);
00165         single_channel_assert(tmp.numChannels());
00166         swap(tmp);
00167     }
00168 
00169     //======================================================================
00170     //  Functions purely proper to the LevelSetFunction (not to be found in
00171     //  the Image<double> object).
00172     //======================================================================
00173 
00178     inline double gradientNorm2D(int x, int y) const;
00179 
00182     inline double gradientNorm3D(int x, int y, int z) const;
00183 
00186     inline double curvature2D(int x, int y) const;
00187     
00190     inline double curvature3D(int x, int y, int z) const;
00191 
00203     inline void curvature2D(Image<double>& target, Mask* mask = 0) const;
00204 
00214     inline void curvature3D(Image<double>& target, Mask* mask = 0) const;
00215 
00229     inline void curvatureTimesGrad2D(Image<double>& target, Mask* mask = 0) const;
00230 
00234     inline double curvatureTimesGrad2D(int x, int y) const;
00235 
00238     inline double curvatureTimesGrad3D(int x, int y, int z) const;
00239 
00252     inline void curvatureTimesGrad3D(Image<double>& target, Mask* mask = 0) const;
00253 
00265     inline void gradientNorm2D(Image<double>& target, Mask* mask = 0) const;
00266 
00276     inline void gradientNorm3D(Image<double>& target, Mask* mask = 0) const;
00277 
00290     void reinitialize2D(const Mask* mask = 0);
00291 
00303     void reinitialize3D(const Mask* mask = 0);
00304     
00305 private:
00312     void single_channel_assert(int num_chan) {
00313         ALWAYS_ERROR_IF(num_chan != 1, "Single channel assert failed.");
00314     }
00315 
00317     mutable double cached_;
00318 };
00319 
00320 }; // end namespace lsseg
00321 
00322 #include "LevelSetFunction_implementation.h"
00323 
00324 #endif // _LEVELSETFUNCTION_H
00325 

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