greedy.hh

00001 // Copyright (C) 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_SNAKES_GREEDY_HH
00029 # define OLENA_SNAKES_GREEDY_HH
00030 
00031 #include <oln/snakes/snakes_base.hh>
00032 #include <oln/snakes/energies.hh>
00033 #include <mlc/array/2d.hh>
00034 
00035 namespace oln {
00036 
00037   namespace snakes {
00038 
00046     template <int N, class I, template<typename> class external_energy = dummy_energy>
00047     class greedy
00048     {
00049     public:
00050       typedef I                                                  image_type;
00051       typedef typename I::point_type                             point_type;
00052       typedef mlc::array2d<mlc::array2d_info<N,N>, ntg::float_s> store_type;
00053       // FIXME: why only 2d?
00054 
00055     public:
00056       greedy(ntg::float_s alpha,
00057              ntg::float_s beta,
00058              ntg::float_s gamma,
00059              ntg::float_s khi);
00060 
00061     public:
00062       inline
00063       int
00064       update_snake(const I& gradient, snake<greedy>& s);
00066 
00067       void
00068       converge(const I& gradient, snake<greedy>& s);
00069 
00070 
00071     private:
00072       inline
00073       int
00074       update_segment(const I& gradient, segment<I>& s);
00075 
00076       inline
00077       bool
00078       update_node(const I& gradient,
00079                   const node<I>& prev, node<I>& n, const node<I>& next);
00080 
00081     private:
00082       template <class energy_functor>
00083       inline
00084       store_type
00085       compute_and_normalize_energy
00086       (const typename energy_functor::image_type& gradient,
00087        const node<typename energy_functor::image_type>& prev,
00088        const node<typename energy_functor::image_type>& current,
00089        const node<typename energy_functor::image_type>& next,
00090        energy_functor functor);
00091 
00092     private:
00093       ntg::float_s average_dist;
00095 
00096       inline
00097       ntg::float_s
00098       compute_average_dist(const segment<I>& s);
00099 
00100     private:
00101       continuity_energy<I>      continuity_e;
00102       curvature_energy<I>       curvature_e;
00103       image_energy<I>           image_e;
00104       external_energy<I>        external_e;
00105 
00106     private:
00108       ntg::float_s alpha; 
00109       ntg::float_s beta;  
00110       ntg::float_s gamma; 
00111       ntg::float_s khi;   
00112 
00113     private:
00114       static const int  threshold;
00115       // FIXME: think about a real stop condition.
00116     private:
00117       static window2d   neighborhood;
00118       // FIXME: better write an iterator on arrays.
00119     };
00120 
00121   } // end snakes
00122 
00123 } // end oln
00124 
00125 #include <oln/snakes/greedy.hxx>
00126 
00127 #endif // !OLENA_SNAKES_GREEDY_HH

Generated on Thu Apr 15 20:13:10 2004 for Olena by doxygen 1.3.6-20040222