https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: continue to revamp registration.
* jardonnet/test/registration.cc: Make use of lazy_image.
* jardonnet/registration/final_qk.hh: Remove use of size_t.
* jardonnet/registration/cloud.hh,
* jardonnet/registration/save.hh,
* jardonnet/registration/update_qk.hh,
* jardonnet/registration/registration.hh: Replace quat7 by generique T.
* jardonnet/registration/tools.hh,
* jardonnet/registration/quat7.hh,
* jardonnet/registration/rotation.hh: Remove Whitespace.
* jardonnet/virtual/access.hh: Minor fix.
registration/cloud.hh | 12 ++++++------
registration/final_qk.hh | 18 +++++++++---------
registration/quat7.hh | 2 +-
registration/registration.hh | 11 ++++-------
registration/rotation.hh | 1 +
registration/save.hh | 6 +++---
registration/tools.hh | 6 +++---
registration/update_qk.hh | 15 +++++++++------
test/registration.cc | 6 +++---
9 files changed, 39 insertions(+), 38 deletions(-)
Index: jardonnet/test/registration.cc
--- jardonnet/test/registration.cc (revision 2447)
+++ jardonnet/test/registration.cc (working copy)
@@ -5,8 +5,9 @@
#include <mln/io/ppm/save.hh>
#include <mln/convert/to_p_array.hh>
#include <mln/norm/l2.hh>
+#include <mln/core/image/lazy_image.hh>
-#include <sandbox/jardonnet/registration/icp.hh>
+#include <sandbox/jardonnet/registration/registration.hh>
#include <sandbox/jardonnet/registration/tools.hh>
#include <sandbox/jardonnet/registration/final_qk.hh>
#include <mln/geom/bbox.hh>
@@ -52,8 +53,7 @@
closest_point<mln_psite_(image2db)> fun(x, working_box);
// * Use real lazy image
- //lazy_image< closest_point<mln_psite_(image2db)> > map(fun);
- p_array<point2d> map;
+ lazy_image<image2d<bool>, closest_point<mln_psite_(image2db)>, box2d
> map(fun, fun.domain());
quat7<2> qk ;//= registration::icp(c, map, q, e, x);
#ifndef NDEBUG
Index: jardonnet/virtual/access.hh
Index: jardonnet/registration/final_qk.hh
--- jardonnet/registration/final_qk.hh (revision 2447)
+++ jardonnet/registration/final_qk.hh (working copy)
@@ -17,7 +17,7 @@
std::vector<float> length(c.nsites());
mean = 0;
- for (size_t i = 0; i < c.nsites(); i++)
+ for (unsigned i = 0; i < c.nsites(); i++)
{
float f = norm::l2(convert::to< algebra::vec<P::dim,int> > (c[i] -
map(c[i])));
length[i] = f;
@@ -27,7 +27,7 @@
//standar variation
stddev = 0;
- for (size_t i = 0; i < c.nsites(); i++)
+ for (unsigned i = 0; i < c.nsites(); i++)
stddev += (length[i] - mean) * (length[i] - mean);
stddev /= c.nsites();
stddev = math::sqrt(stddev);
@@ -42,12 +42,12 @@
float nstddev)
{
p_array<P> newc;
- algebra::vec<3,float> mu_newc(literal::zero);
+ algebra::vec<P::dim,float> mu_newc(literal::zero);
- for (size_t i = 0; i < c.nsites(); ++i)
+ for (unsigned i = 0; i < c.nsites(); ++i)
{
- algebra::vec<3,float> ci = c[i];
- algebra::vec<3,float> xki = map(c[i]);
+ algebra::vec<P::dim,float> ci = c[i];
+ algebra::vec<P::dim,float> xki = map(c[i]);
if (norm::l2(ci - xki) < nstddev)
{
@@ -74,11 +74,11 @@
float nstddev)
{
//mu_Xk = center map(Ck)
- algebra::vec<3,float> mu_Xk(literal::zero);
- algebra::vec<3,float> mu_C(literal::zero);
+ algebra::vec<P::dim,float> mu_Xk(literal::zero);
+ algebra::vec<P::dim,float> mu_C(literal::zero);
float nb_point = 0;
- for (size_t i = 0; i < c.nsites(); ++i)
+ for (unsigned i = 0; i < c.nsites(); ++i)
{
algebra::vec<P::dim,float> xki = map(c[i]);
algebra::vec<P::dim,float> ci = c[i];
Index: jardonnet/registration/save.hh
--- jardonnet/registration/save.hh (revision 2447)
+++ jardonnet/registration/save.hh (working copy)
@@ -9,7 +9,7 @@
# include <mln/core/alias/window2d.hh>
# include <string>
-# include "quat7.hh"
+//# include "quat7.hh"
# include "tools.hh"
# include "power_it.hh"
# include "center.hh"
@@ -38,8 +38,8 @@
namespace registration
{
- template<typename P, typename M>
- void save_(const quat7<3>& qk,
+ template<typename P, typename M, typename T>
+ void save_(const T& qk,
const p_array<P>& c,
const p_array<P>& x,
const M& map,
Index: jardonnet/registration/rotation.hh
--- jardonnet/registration/rotation.hh (revision 2447)
+++ jardonnet/registration/rotation.hh (working copy)
@@ -26,6 +26,7 @@
return (q * algebra::quat(0. ,p) * q.inv()).v();
}
+
//FIXME : check if correct with n != 3
template <unsigned n>
bool check_rotation(const algebra::mat<n,n,float>& mat,
Index: jardonnet/registration/tools.hh
--- jardonnet/registration/tools.hh (revision 2447)
+++ jardonnet/registration/tools.hh (working copy)
@@ -6,7 +6,7 @@
# include <mln/algebra/mat.hh>
# include <mln/core/site_set/p_array.hh>
-# include "quat7.hh"
+//# include "quat7.hh"
namespace mln
@@ -110,7 +110,7 @@
#endif
};
-
+ /*
// FIXME: Should be a morpher ?
// we could acces domain of a lazy map, iterator etc...
template < typename F >
@@ -147,7 +147,7 @@
mutable image3d<bool> is_known;
const F& fun;
};
-
+ */
// Box
Index: jardonnet/registration/quat7.hh
--- jardonnet/registration/quat7.hh (revision 2447)
+++ jardonnet/registration/quat7.hh (working copy)
@@ -127,7 +127,7 @@
const algebra::vec<P::dim,float>& mu_C,
const p_array<P>& Ck,
const M& map,
- size_t c_length)
+ unsigned c_length)
{
//mu_Xk = center map(Ck)
algebra::vec<P::dim,float> mu_Xk(literal::zero);
Index: jardonnet/registration/cloud.hh
--- jardonnet/registration/cloud.hh (revision 2447)
+++ jardonnet/registration/cloud.hh (working copy)
@@ -11,7 +11,7 @@
# include <mln/core/site_set/p_array.hh>
# include <mln/norm/l2.hh>
-#include "quat7.hh"
+//#include "quat7.hh"
namespace mln
{
@@ -64,9 +64,9 @@
return tmp;
}
- template <typename P, typename M>
+ template <typename P, typename M, typename T>
float rms(const p_array<P>& a1,
- quat7<P::dim>& qk,
+ const T& qk,
const M& map,
const size_t length)
{
@@ -82,12 +82,12 @@
return f / length;
}
- template <typename P, typename M>
+ template <typename P, typename M, typename T>
float rms(const p_array<P>& a1,
M& map,
const size_t length,
- quat7<P::dim>& q1,
- quat7<P::dim>& q2)
+ const T& q1,
+ const T& q2) // FIXME : transformation T can be diff ?
{
assert(length <= a1.nsites());
Index: jardonnet/registration/registration.hh
--- jardonnet/registration/registration.hh (revision 2447)
+++ jardonnet/registration/registration.hh (working copy)
@@ -37,7 +37,6 @@
# include <string>
# include <cmath>
-# include <mln/algebra/quat.hh>
# include <mln/algebra/vec.hh>
# include <mln/make/w_window.hh>
# include <mln/make/w_window3d.hh>
@@ -48,11 +47,9 @@
# include <mln/level/fill.hh>
# include <mln/io/ppm/save.hh>
-
# include "tools.hh"
# include "cloud.hh"
-# include "quat7.hh"
# include "update_qk.hh"
# include "chamfer.hh"
@@ -83,18 +80,18 @@
namespace impl
{
- template <typename P, typename M>
+ template <typename P, typename M, typename T>
inline
void
registration_(const p_array<P>& C,
const M& map,
- quat7<P::dim>& qk,
+ const T& qk,
const unsigned c_length,
const float epsilon = 1e-3)
{
trace::entering("registration::impl::registration_");
- buffer<4,quat7<P::dim> > buf_qk;
+ buffer<4,T> buf_qk;
buffer<3,float> buf_dk;
float d_k = 10000;
@@ -140,7 +137,7 @@
// FIXME: Make it works in 3d *AND* 2d
template <typename P, typename M>
inline
- quat7<P::dim>
+ quat7<P::dim> // what is it suposed to return tr(rot()), rot(tr()) or something
else ...
registration(p_array<P>& cloud,
const M& map,
const p_array<P>& x)
Index: jardonnet/registration/update_qk.hh
--- jardonnet/registration/update_qk.hh (revision 2447)
+++ jardonnet/registration/update_qk.hh (working copy)
@@ -2,12 +2,14 @@
# define MLN_UPDATE_QK_HH
#include "interpolation.hh"
-#include "quat7.hh"
+//#include "quat7.hh"
namespace mln
{
- float arc(quat7<3> dqk, quat7<3> dqk_1)
+ // FIXME: T different ?
+ template <typename T>
+ float arc(const T& dqk, const T& dqk_1)
{
float res = 0.0;
for (int i = 0; i < 7; i++)
@@ -17,12 +19,13 @@
}
- quat7<3> update_qk(const quat7<3> qk[4],
+ template <typename T>
+ T update_qk(const T qk[4],
const float dk[3])
{
- quat7<3> dqk_2 = qk[2] - qk[3];
- quat7<3> dqk_1 = qk[1] - qk[2];
- quat7<3> dqk = qk[0] - qk[1];
+ T dqk_2 = qk[2] - qk[3];
+ T dqk_1 = qk[1] - qk[2];
+ T dqk = qk[0] - qk[1];
float tetak_1 = arc(dqk_1, dqk_2);
float tetak = arc(dqk, dqk_1);