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_ENERGIES_HH
00029 # define OLENA_SNAKES_ENERGIES_HH
00030
00031 # include "node.hh"
00032 # include <ntg/float.hh>
00033
00034 namespace oln {
00035
00036 namespace snakes {
00037
00040 template <class I>
00041 class energy
00042 {
00043 public:
00044 energy() {}
00045 energy(void *) {}
00046
00047 public:
00053 ntg::float_s
00054 compute(const I&, const node<I>&, const node<I>&, const node<I>&)
00055 {
00056
00057
00058
00059
00060 user_defined_external_energy_functor::compute();
00061 return 0.f;
00062 }
00063
00064 public:
00066 static void* cookie() { return 0; };
00067
00068 private:
00069 struct user_defined_external_energy_functor{};
00070 };
00071
00072
00081 template <class I>
00082 class continuity_energy : public energy<I>
00083 {
00084 public:
00085 typedef I image_type;
00086
00087 public:
00088 continuity_energy(ntg::float_s* average_dist) :
00089 average_dist(average_dist) {}
00090
00091 public:
00092 inline
00093 ntg::float_s
00094 compute(const I&,
00095 const node<I>& prev,
00096 const node<I>& current,
00097 const node<I>&);
00098
00099 private:
00100 ntg::float_s* average_dist;
00101 };
00102
00103
00111 template <class I>
00112 class curvature_energy : public energy<I>
00113 {
00114 public:
00115 typedef I image_type;
00116
00117 public:
00118 curvature_energy(void *) {}
00119
00120 public:
00121 static inline
00122 ntg::float_s
00123 compute(const I&,
00124 const node<I>& prev,
00125 const node<I>& current,
00126 const node<I>& next);
00127 };
00128
00129
00135 template <class I>
00136 class image_energy : public energy<I>
00137 {
00138 public:
00139 typedef I image_type;
00140
00141 public:
00142 image_energy(void*) {}
00143
00144 public:
00145 static inline
00146 ntg::float_s
00147 compute(const I& gradient,
00148 const node<I>&,
00149 const node<I>& current,
00150 const node<I>&);
00151 };
00152
00153
00158 #define oln_snakes_define_external_energy(Energy, Gradient, PrevNode, CurrentNode, NextNode) \
00159 \
00160 template<class I> \
00161 class Energy : public energy<I> \
00162 { \
00163 public: \
00164 typedef I image_type; \
00165 \
00166 public: \
00167 Energy(void*) {} \
00168 \
00169 public: \
00170 ::ntg::float_s \
00171 compute(const I& gradient, \
00172 const ::oln::snakes::node<I>&, \
00173 const ::oln::snakes::node<I>&, \
00174 const ::oln::snakes::node<I>&); \
00175 }; \
00176 \
00177 template<class I> \
00178 ::ntg::float_s \
00179 Energy<I>::compute(const I& Gradient, \
00180 const ::oln::snakes::node<I>& PrevNode, \
00181 const ::oln::snakes::node<I>& CurrentNode, \
00182 const ::oln::snakes::node<I>& NextNode)
00183
00184
00186 oln_snakes_define_external_energy(dummy_energy,,,,)
00187 {
00188 return 0;
00189 }
00190
00191 }
00192
00193 }
00194
00195 #include <oln/snakes/energies.hxx>
00196
00197 #endif // !OLENA_SNAKES_ENERGIES_HH