---
milena/mln/algebra/quat.hh | 25 +++++++
milena/mln/canvas/morpho/connected_filter.hh | 9 ---
milena/mln/core/concept/gpoint.hh | 2 +-
milena/mln/core/point.hh | 96 +++++++++++++-------------
milena/mln/fun/x2v/bilinear.hh | 8 +-
milena/mln/fun/x2v/trilinear.hh | 6 +-
milena/mln/fun/x2x/rotation.hh | 6 +-
milena/mln/registration/icp.hh | 42 ++++++------
8 files changed, 104 insertions(+), 90 deletions(-)
diff --git a/milena/mln/algebra/quat.hh b/milena/mln/algebra/quat.hh
index 33e7d07..8784883 100644
--- a/milena/mln/algebra/quat.hh
+++ b/milena/mln/algebra/quat.hh
@@ -162,6 +162,11 @@ namespace mln
/// Explicit conversion to a 4D algebra::vec.
const algebra::vec<4,float>& to_vec() const;
+ /// Implicit conversion to a 4D algebra::vec.
+ operator const algebra::vec<4,float>&() const;
+ operator const algebra::vec<4,float>&();
+ operator algebra::vec<4,float>() const;
+ operator algebra::vec<4,float>();
/// Give the scalar part.
float s() const;
@@ -340,6 +345,26 @@ namespace mln
}
inline
+ quat::operator const algebra::vec<4,float>&() const
+ {
+ return this->v_;
+ }
+
+ inline
+ quat::operator const algebra::vec<4,float>&()
+ {
+ return this->v_;
+ }
+
+ inline
+ quat::operator algebra::vec<4,float>()
+ {
+ return this->v_;
+ }
+
+
+
+ inline
float
quat::s() const
{
diff --git a/milena/mln/canvas/morpho/connected_filter.hh
b/milena/mln/canvas/morpho/connected_filter.hh
index f6e852e..beec8e4 100644
--- a/milena/mln/canvas/morpho/connected_filter.hh
+++ b/milena/mln/canvas/morpho/connected_filter.hh
@@ -74,11 +74,8 @@ namespace mln {
void take_as_init_fastest (trait::accumulator::when_pix::use_none, A& accu,
const I& input, const unsigned p)
{
-<<<<<<< HEAD:milena/mln/canvas/morpho/connected_filter.hh
(void)input;
(void)p;
-=======
->>>>>>> Merge leveling and algebraic filters into connected
filter.:milena/mln/canvas/morpho/connected_filter.hh
accu.take_as_init ();
}
@@ -86,10 +83,7 @@ namespace mln {
void take_as_init (trait::accumulator::when_pix::use_p, A& accu,
const I& input, const P& p)
{
-<<<<<<< HEAD:milena/mln/canvas/morpho/connected_filter.hh
(void)input;
-=======
->>>>>>> Merge leveling and algebraic filters into connected
filter.:milena/mln/canvas/morpho/connected_filter.hh
accu.take_as_init (p);
}
@@ -97,10 +91,7 @@ namespace mln {
void take_as_init (trait::accumulator::when_pix::use_none, A& accu,
const I& input, const P& p)
{
-<<<<<<< HEAD:milena/mln/canvas/morpho/connected_filter.hh
(void)input;
-=======
->>>>>>> Merge leveling and algebraic filters into connected
filter.:milena/mln/canvas/morpho/connected_filter.hh
accu.take_as_init (p);
}
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 12f1b38..40a2420 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -281,7 +281,7 @@ namespace mln
typedef mln_grid(E) grid;
typedef mln_delta(E) delta;
typedef mln_vec(E) vec;
- const vec& (E::*m)() const = & E::to_vec;
+ vec (E::*m)() const = & E::to_vec;
m = 0;
}
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index a661fe5..1d618cc 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -61,22 +61,6 @@ namespace mln
/// \}
- namespace internal
- {
-
- // Helper point_to_.
-
- template <typename G, typename C>
- struct point_to_
- {
- typedef algebra::vec<G::dim, C> metal_vec;
- typedef mln::algebra::h_vec<G::dim, C> h_vec;
- };
-
- } // end of namespace mln::internal
-
-
-
/// Generic point class.
///
/// Parameters are \c n the dimension of the space and \c C the
@@ -108,10 +92,10 @@ namespace mln
typedef C coord;
/// Algebra vector (vec) associated type.
- typedef algebra::vec<G::dim, C> vec;
+ typedef algebra::vec<G::dim, float> vec;
/// Algebra hexagonal vector (hvec) associated type.
- typedef algebra::h_vec<G::dim, C> h_vec;
+ typedef algebra::h_vec<G::dim, float> h_vec;
/// Read-only access to the \p i-th coordinate value.
/// \param[in] i The coordinate index.
@@ -171,23 +155,17 @@ namespace mln
/// Shifting by \p the inverse of dp.
point<G,C>& operator-=(const delta& dp);
- /// Hook to coordinates.
- operator typename internal::point_to_<G, C>::metal_vec () const;
- /* FIXME: Seems highly non-generic! Moreover, causes
- overloading/duplicate errors with the previous operator when
- C == float. Disable it for the moment.
-
+ /* FIXME: Seems highly non-generic!
This (non documented change, even in ChangeLog) change was
introduce by revision 1224, see
https://trac.lrde.org/olena/changeset/1224#file2
https://www.lrde.epita.fr/pipermail/olena-patches/2007-October/001592.html
*/
-#if 0
operator algebra::vec<G::dim, float> () const;
-#endif
+ operator algebra::vec<G::dim, float> ();
/// Explicit conversion towards mln::algebra::vec.
- const vec& to_vec() const;
+ vec to_vec() const;
/// Transform to point in homogene coordinate system.
h_vec to_h_vec() const;
@@ -214,7 +192,8 @@ namespace mln
template <typename G, typename C, typename E>
struct subject_point_impl< point<G,C>, E >
{
- const typename point<G,C>::vec& to_vec() const;
+ typename point<G,C>::vec to_vec() const;
+ operator algebra::vec<G::dim, float>() const;
private:
const E& exact_() const;
@@ -281,7 +260,11 @@ namespace mln
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
- coord_ = v;
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ coord_[i] = v[j++];
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ coord_[i-j] = v[j];
}
template <typename G, typename C>
@@ -406,30 +389,33 @@ namespace mln
template <typename G, typename C>
inline
- point<G,C>::operator typename internal::point_to_<G, C>::metal_vec ()
const
+ point<G,C>::operator algebra::vec<G::dim,float> () const
{
- return coord_; // FIXME: Is it OK?
+ return to_vec();
}
- // FIXME: See declaration of this member above.
-#if 0
template <typename G, typename C>
inline
- point<G,C>::operator algebra::vec<G::dim, float> () const
+ point<G,C>::operator algebra::vec<G::dim,float> ()
{
- algebra::vec<dim, float> tmp;
- for (unsigned int i = 0; i < dim; ++i)
- tmp[i] = coord_[i];
- return tmp;
+ return to_vec();
}
-#endif
+
template <typename G, typename C>
inline
- const typename point<G,C>::vec&
+ typename point<G,C>::vec
point<G,C>::to_vec() const
{
- return coord_;
+ algebra::vec<G::dim, float> tmp;
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ tmp[j++] = coord_[i];
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ tmp[j] = coord_[i-j];
+
+ return tmp;
}
template <typename G, typename C>
@@ -437,9 +423,15 @@ namespace mln
typename point<G,C>::h_vec
point<G,C>::to_h_vec() const
{
- algebra::h_vec<G::dim, C> tmp;
- for (unsigned i = 0; i < dim; ++i)
- tmp[i] = coord_[i];
+ algebra::h_vec<G::dim, float> tmp;
+
+ unsigned j = 0;
+ for (unsigned i = dim - 2; i < dim; ++i)
+ tmp[j++] = coord_[i];
+
+ for (unsigned i = 2; i < dim; ++i, ++j)
+ tmp[j] = coord_[i-j];
+
tmp[G::dim] = 1;
return tmp;
}
@@ -476,20 +468,27 @@ namespace mln
template <typename G, typename C, typename E>
inline
- const typename point<G,C>::vec&
+ typename point<G,C>::vec
subject_point_impl< point<G,C>, E >::to_vec() const
{
return exact_().get_subject().to_vec();
}
+ template <typename G, typename C, typename E>
+ inline
+ subject_point_impl< point<G,C>, E >::operator algebra::vec<G::dim,
float>() const
+ {
+ return exact_().get_subject();
+ }
+
} // end of namespace mln::internal
template <typename G, typename C>
inline
- const algebra::vec<point<G,C>::dim - 1, C>&
+ algebra::vec<point<G,C>::dim - 1, C>
cut_(const point<G,C>& p)
{
- return *(const algebra::vec<point<G,C>::dim - 1, C>*)(& p.to_vec());
+ return *(algebra::vec<point<G,C>::dim - 1, C>*)(& p.to_vec());
}
template <typename C>
@@ -502,7 +501,8 @@ namespace mln
}
# endif // ! MLN_INCLUDE_ONLY
-
+
+
} // end of namespace mln
diff --git a/milena/mln/fun/x2v/bilinear.hh b/milena/mln/fun/x2v/bilinear.hh
index e264462..1daefa8 100644
--- a/milena/mln/fun/x2v/bilinear.hh
+++ b/milena/mln/fun/x2v/bilinear.hh
@@ -79,7 +79,7 @@ namespace mln
template <typename I>
bilinear<I>::bilinear(const I& ima) : ima(ima)
{
- //mlc_bool(I::psite::dim == 2)::check();
+ mlc_or(mlc_bool(I::psite::dim == 2), mlc_bool(I::psite::dim == 3))::check();
}
template <typename I>
@@ -141,14 +141,14 @@ namespace mln
// | | |
// q11----r1----q21
- double x = v[1];
- double y = v[2];
+ double x = v[0];
+ double y = v[1];
double x1 = std::floor(x);
double x2 = std::floor(x) + 1;
double y1 = std::floor(y);
double y2 = std::floor(y) + 1;
- def::coord z = math::round<float>()(v[0]);
+ def::coord z = math::round<float>()(v[3]);
//Following access are supposed valid.
vsum q11 = ima(point3d(z, static_cast<unsigned>(x1),
static_cast<unsigned>(y1)));
diff --git a/milena/mln/fun/x2v/trilinear.hh b/milena/mln/fun/x2v/trilinear.hh
index 3015502..2a1d594 100644
--- a/milena/mln/fun/x2v/trilinear.hh
+++ b/milena/mln/fun/x2v/trilinear.hh
@@ -86,9 +86,9 @@ namespace mln
{
typedef mln_sum(mln_value(I)) vsum;
- double x = v[1]; // row
- double y = v[2]; // col
- double z = v[0]; // sli
+ double x = v[0]; // row
+ double y = v[1]; // col
+ double z = v[2]; // sli
math::round<double> f;
unsigned x1 = f(std::floor(x));
diff --git a/milena/mln/fun/x2x/rotation.hh b/milena/mln/fun/x2x/rotation.hh
index 9addb50..cbe1dd2 100644
--- a/milena/mln/fun/x2x/rotation.hh
+++ b/milena/mln/fun/x2x/rotation.hh
@@ -197,10 +197,9 @@ namespace mln
inline
rotation<n,C>::rotation(const algebra::quat& q)
{
- mln_precondition(q.is_unit());
-
// FIXME: Should also work for 2d.
- mln_precondition(n == 3);
+ mlc_bool(n == 3)::check();
+ mln_precondition(q.is_unit());
float
w = q.to_vec()[0],
@@ -221,6 +220,7 @@ namespace mln
axis_[0] = x;
axis_[1] = y;
axis_[2] = z;
+ axis_.normalize();
}
diff --git a/milena/mln/registration/icp.hh b/milena/mln/registration/icp.hh
index de763ea..3fc54c0 100644
--- a/milena/mln/registration/icp.hh
+++ b/milena/mln/registration/icp.hh
@@ -229,17 +229,18 @@ namespace mln
mln_site(I) operator()(const vec3d_f& v) const
{
- vec3d_f best_x = convert::to<vec3d_f>(X_[0].to_vec());
+ vec3d_f best_x = X_[0];
float best_d = norm::l2_distance(v, best_x);
mln_piter(X_t) X_i(X_);
for_all(X_i)
{
- float d = norm::l2_distance(v, convert::to<vec3d_f>(X_i));
+ vec3d_f X_i_vec = X_i;
+ float d = norm::l2_distance(v, X_i_vec);
if (d < best_d)
{
best_d = d;
- best_x = X_i.to_vec();
+ best_x = X_i_vec;
}
}
return best_x;
@@ -266,11 +267,11 @@ namespace mln
mln_piter(p_array<P>) p(kept);
for_all(p)
- ext_result(qR.rotate(p.to_vec()) + qT) = literal::green;
+ ext_result(qR.rotate(p) + qT) = literal::green;
mln_piter(p_array<P>) p2(removed);
for_all(p2)
- ext_result(qR.rotate(p2.to_vec()) + qT) = literal::red;
+ ext_result(qR.rotate(p2) + qT) = literal::red;
io::ppm::save(slice(ext_result,0), "registered-2.ppm");
}
@@ -289,7 +290,7 @@ namespace mln
mln_piter(p_array<P>) p(P_);
for_all(p)
{
- vec3d_f Pk_i = pair.first.rotate(p.to_vec()) + pair.second;
+ vec3d_f Pk_i = pair.first.rotate(p) + pair.second;
vec3d_f Yk_i = closest_point(Pk_i).to_vec();
// yk_i - pk_i
e_k_accu.take(Yk_i - Pk_i);
@@ -317,8 +318,8 @@ namespace mln
for_all(p)
{
- vec3d_f Pk_i = pair.first.rotate(p.to_vec()) + pair.second;
- vec3d_f Yk_i = closest_point(Pk_i).to_vec();
+ vec3d_f Pk_i = pair.first.rotate(p) + pair.second;
+ vec3d_f Yk_i = closest_point(Pk_i);
int d_i = closest_point.dmap_X_(Pk_i);
if (d_i >= d_min && d_i <= d_max)
@@ -399,7 +400,7 @@ namespace mln
for_all(p)
{
vec3d_f Pk_i = pair.first.rotate(p.to_vec()) + pair.second;
- vec3d_f Yk_i = closest_point(Pk_i).to_vec();
+ vec3d_f Yk_i = closest_point(Pk_i);
int d_i = closest_point.dmap_X_(Pk_i);
if (d_i >= d_min && d_i <= d_max)
@@ -440,31 +441,27 @@ namespace mln
const std::pair<algebra::quat,mln_vec(P)>& pair,
const std::string& period, const value::rgb8& c)
{
-# ifndef NDEBUG
data::fill(out, literal::black);
data::fill((out | X).rw(), literal::white);
-# endif // !NDEBUG
mln_piter(p_array<P>) p1(P_);
for_all(p1)
{
- vec3d_f Pk_i = pair.first.rotate(p1.to_vec()) + pair.second;
+ vec3d_f Pk_i = pair.first.rotate(p1) + pair.second;
out(Pk_i) = literal::red;
}
mln_piter(p_array<P>) p2(P_sub);
for_all(p2)
{
- vec3d_f Pk_i = pair.first.rotate(p2.to_vec()) + pair.second;
+ vec3d_f Pk_i = pair.first.rotate(p2) + pair.second;
out(Pk_i) = c;
}
-# ifndef NDEBUG
std::ostringstream ss;
ss << prefix << "_" << r << "_"
<< period << ".ppm";
io::ppm::save(slice(out,0), ss.str());
-# endif // ! NDEBUG
}
@@ -483,8 +480,9 @@ namespace mln
for_all(p)
{
// yk_i - pk+1_i
- vec3d_f Pk_i = qR_old.rotate(p.to_vec()) + qT_old;
- vec3d_f Pk_1_i = qR.rotate(p.to_vec()) + qT;
+ vec3d_f P_i = p;
+ vec3d_f Pk_i = qR_old.rotate(P_i) + qT_old;
+ vec3d_f Pk_1_i = qR.rotate(P_i) + qT;
accu.take(closest_point(Pk_i).to_vec() - Pk_1_i);
}
return accu.to_result();
@@ -508,9 +506,9 @@ namespace mln
// FIXME: could we use an accu?
for_all(p)
{
- vec3d_f P_i = p.to_vec();
- vec3d_f Pk_i = qR.rotate(p.to_vec()) + qT;
- vec3d_f Yk_i = closest_point(Pk_i).to_vec();
+ vec3d_f P_i = p;
+ vec3d_f Pk_i = qR.rotate(P_i) + qT;
+ vec3d_f Yk_i = closest_point(Pk_i);
Spx += make::mat(P_i - mu_P) * trans(make::mat(Yk_i - mu_Yk));
}
Spx /= P_.nsites();
@@ -564,7 +562,7 @@ namespace mln
{
// yk_i - pk_i
vec3d_f Pk_i = qR.rotate(p.to_vec()) + qT;
- vec3d_f Yk_i = closest_point(Pk_i).to_vec();
+ vec3d_f Yk_i = closest_point(Pk_i);
mu_yk.take(Yk_i);
e_k_accu.take(Yk_i - Pk_i);
}
@@ -641,7 +639,7 @@ namespace mln
image3d<value::rgb8> tmp_ = duplicate(debug);
mln_piter(p_array<P>) p_dbg(P_);
for_all(p_dbg)
- tmp_(qR_old.rotate(p_dbg.to_vec()) + qT_old) = literal::green;
+ tmp_(qR_old.rotate(p_dbg) + qT_old) = literal::green;
std::ostringstream ss;
ss << "tmp_0";
if (k < 10)
--
1.5.6.5