00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
00116 private:
00117 static window2d neighborhood;
00118
00119 };
00120
00121 }
00122
00123 }
00124
00125 #include <oln/snakes/greedy.hxx>
00126
00127 #endif // !OLENA_SNAKES_GREEDY_HH