StatisticalRegularization.hpp

00001 // This file is part of the imaging2 class library.
00002 //
00003 // University of Innsbruck, Infmath Imaging, 2009.
00004 // http://infmath.uibk.ac.at
00005 //
00006 // All rights reserved.
00007 
00008 
00009 #ifndef STATISTICAL_REGULARIZATION_H
00010 #define STATISTICAL_REGULARIZATION_H
00011 
00012 #include <shape/ShapeEnergyInterface.hpp>
00013 #include <shape/ShapeStatistics.hpp>
00014 
00015 
00016 namespace imaging
00017 {
00033   template <class shape_t>
00034   class StatisticalRegularization : public ShapeEnergyInterface<shape_t>
00035   {
00036     ShapeEnergyInterface<shape_t> & _energy;
00037     ShapeStatistics<shape_t> & _statistics;
00038     float_t _statistics_coefficient;
00039     
00040     ublas::vector<float_t> _current_argument;
00041     float_t _current_energy;
00042     
00043   public:
00045     StatisticalRegularization(ShapeEnergyInterface<shape_t> & energy, ShapeStatistics<shape_t> & statistics, float_t alpha)
00046       : _energy(energy), _statistics(statistics), _statistics_coefficient(alpha), _current_argument(ublas::scalar_vector<float_t>(energy.dimension(), 0.0))
00047     {
00048       if(_statistics.dimension() != _energy.dimension())
00049         throw Exception("Exception: dimensions of energy and statistics do not agree in StatisticalRegularization::StatisticalRegularization().");
00050       set_argument();
00051     }
00052     
00053     ublas::vector<float_t> & current_argument()
00054     {
00055       return _current_argument;
00056     }
00057     
00058     void set_argument()
00059     {
00060       float_t squared_distance;
00061       
00062       _statistics.shape_vector(_current_argument, _energy.current_argument(), squared_distance);
00063       _energy.set_argument();
00064       _current_energy = _energy.current_energy() + _statistics_coefficient * squared_distance;
00065       
00066 //       std::cout << current_energy() << " " << _energy.current_energy() << " " << squared_distance << std::endl;
00067 //       std::cout << _current_argument << std::endl;
00068 //       std::cout << _energy.current_argument() << std::endl;
00069     }
00070     
00071     
00072     float_t current_energy() const
00073     {
00074       return _current_energy;
00075     }
00076     
00077     std::size_t dimension() const
00078     {
00079       return _energy.dimension();
00080     }
00081     
00082     const shape_t & current_shape() const
00083     {
00084       return _energy.current_shape();
00085     }
00086     
00087     
00088 
00089   };
00090 }
00091 
00092 #endif

Generated on Tue Feb 10 10:01:30 2009 for imaging2 by  doxygen 1.5.5