https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix apps/statues/mesh-segm.
* apps/statues/mesh-segm.cc (main): Actually use a vector of
curv_t (int) instead of a vector of floats.
mesh-segm.cc | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
Index: apps/statues/mesh-segm.cc
--- apps/statues/mesh-segm.cc (revision 2053)
+++ apps/statues/mesh-segm.cc (working copy)
@@ -25,6 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+/// \file apps/statues/mesh-segm.cc
+/// \brief A program performing a WST-based segmentation of the
+/// surface of the (triangle) mesh of a statue.
+
+// FIXME: Factor commons parts between mesh-segm and mesh-skel.
+
#include <cstdlib>
#include <cmath>
@@ -82,10 +88,10 @@
// Computation of the mean curvature on each vertex of the mesh.
mesh.need_curvatures();
/* FIXME: Our implementation of the WST doesn't work well with
- floats. Convert floating point values to a proportional integer
- value for the moment. */
+ floats (yet). Convert floating point values to a proportional
+ integer value for the moment. */
typedef int curv_t;
- std::vector<float> vertex_h_inv(mesh.vertices.size(), 0.f);
+ std::vector<curv_t> vertex_h_inv(mesh.vertices.size(), 0.f);
for (unsigned v = 0; v < mesh.vertices.size(); ++v)
{
float h = (mesh.curv1[v] + mesh.curv2[v]) / 2;
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make sub_image, image_if, and pw::image work again.
* doc/tutorial/examples/sub_image.cc: Augment.
* doc/tutorial/examples/image_if.cc: New.
* mln/trait/image/status.txt: Update.
* mln/trait/image/print.hh: Add default arg.
* mln/trait/images.hh (todo): New; about 'nature'.
(mln_trait_image_io_from_): Rename as...
(mln_internal_trait_image_value_io_from): ...this.
(mln_internal_trait_image_speed_from): New.
(default_image_morpher_): Add size and speed.
* mln/core/internal/site_iterator_base.hh (todo): New.
* mln/core/internal/image_morpher.hh: Typo.
* mln/core/internal/site_set_iterator_base.hh: Layout.
* mln/core/internal/piter_adaptor.hh: Update.
Though this class seems useless.
* mln/core/box_piter.hh: Overload ctor without arg.
* mln/core/sub_image.hh: Typo, layout, and update.
* mln/core/pset_if_piter.hh: Update.
* mln/core/image_if.hh: Fetch impl from base.
Update.
* mln/core/alias.hh: New.
* mln/core/pset_if.hh (trait): New specialization.
(pset_if): Update; remove bbox and npoints.
* mln/core/concept/image.hh (nsites): Deactivate check line.
* mln/core/concept/gpoint.hh: Inherit from Site.
* mln/core/concept/site.hh: New.
* mln/pw/image.hh (trait): Update.
(has): Remove; it is factored.
* mln/fun/internal/selector.hh (point_site): Remove dep.
Use both Site and Pseudo_Site. Yet it is not enough since
many types can be sites.
doc/tutorial/examples/image_if.cc | 23 ++++++++
doc/tutorial/examples/sub_image.cc | 2
mln/core/alias.hh | 43 +++++++++++++++
mln/core/box_piter.hh | 20 ++++++-
mln/core/concept/gpoint.hh | 6 +-
mln/core/concept/image.hh | 7 +-
mln/core/concept/site.hh | 79 ++++++++++++++++++++++++++++
mln/core/image_if.hh | 68 +++++++++++++++++++-----
mln/core/internal/image_morpher.hh | 2
mln/core/internal/piter_adaptor.hh | 57 +++-----------------
mln/core/internal/site_iterator_base.hh | 6 +-
mln/core/internal/site_set_iterator_base.hh | 1
mln/core/pset_if.hh | 56 ++++++-------------
mln/core/pset_if_piter.hh | 78 +++++++++++++++++++--------
mln/core/sub_image.hh | 20 +++----
mln/fun/internal/selector.hh | 7 +-
mln/pw/image.hh | 40 +++++++-------
mln/trait/image/print.hh | 6 +-
mln/trait/image/status.txt | 10 +--
mln/trait/images.hh | 28 +++++++--
20 files changed, 383 insertions(+), 176 deletions(-)
Index: doc/tutorial/examples/sub_image.cc
--- doc/tutorial/examples/sub_image.cc (revision 2049)
+++ doc/tutorial/examples/sub_image.cc (working copy)
@@ -17,4 +17,6 @@
sub_image<I, box2d> sub(ima, box2d(2,3));
debug::println(sub);
+
+ trait::image::print(sub);
}
Index: doc/tutorial/examples/image_if.cc
--- doc/tutorial/examples/image_if.cc (revision 0)
+++ doc/tutorial/examples/image_if.cc (revision 0)
@@ -0,0 +1,23 @@
+# include <mln/core/image2d.hh>
+# include <mln/core/image_if.hh>
+# include <mln/core/alias.hh>
+
+# include <mln/debug/iota.hh>
+# include <mln/debug/println.hh>
+# include <mln/fun/p2b/chess.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<unsigned> I;
+ I ima(3, 5);
+ debug::iota(ima);
+
+ debug::println(ima);
+ debug::println(ima | fun::p2b::chess);
+
+ trait::image::print(ima | fun::p2b::chess);
+}
Index: mln/trait/image/status.txt
--- mln/trait/image/status.txt (revision 2049)
+++ mln/trait/image/status.txt (working copy)
@@ -7,20 +7,20 @@
KO image1d
ok image2d
KO image3d
-KO image_if
-KO image_if_interval
-KO image_if_value
+ ok image_if
+ rm image_if_interval
+ rm image_if_value
KO interpolated
KO line_graph_image
KO mono_obased_rle_image
KO mono_rle_image
KO obased_rle_image
KO plain
-KO pw::image
+ ok pw::image
KO rle_image
KO safe
KO sparse_image
-KO sub_image
+ ok sub_image
KO t_image
KO tr_image
KO translate_image
Index: mln/trait/image/print.hh
--- mln/trait/image/print.hh (revision 2049)
+++ mln/trait/image/print.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -53,10 +53,10 @@
{
template <typename I>
- void print(std::ostream& ostr);
+ void print(std::ostream& ostr = std::cout);
template <typename I>
- void print(const Image<I>& ima, std::ostream& ostr);
+ void print(const Image<I>& ima, std::ostream& ostr = std::cout);
# ifndef MLN_INCLUDE_ONLY
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 2049)
+++ mln/trait/images.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,6 +33,8 @@
* \brief Some base trait types for images.
*
* \todo Split this file into many.
+ *
+ * \todo the 'nature' prop is not set yet in image types.
*/
# include <iostream>
@@ -70,9 +72,20 @@
# define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant
-// for io: I const => read_only, otherwise like I
-# define mln_trait_image_io_from_(I) \
-mlc_if( mlc_is_const(I), mln::trait::image::value_io::read_only, mln_trait_image_value_io(I) )
+// For value_io: I const => read_only, otherwise like I
+
+# define mln_internal_trait_image_value_io_from(I) \
+ \
+ mlc_if( mlc_is_const(I), \
+ mln::trait::image::value_io::read_only, \
+ mln_trait_image_value_io(I) )
+
+
+# define mln_internal_trait_image_speed_from(I) \
+ \
+ mlc_if( mlc_equal( mln_trait_image_speed(I), mln::trait::image::speed::fastest ), \
+ mln::trait::image::speed::fast, \
+ mln_trait_image_speed(I) )
@@ -164,14 +177,15 @@
template <typename D, typename T, typename I>
struct default_image_morpher_ : default_image_<T, I>
{
- // misc => NO delegation
- // for category, speed, and size
+ // misc => delegation except for 'category'
+ typedef typename image_<D>::size size;
+ typedef mln_internal_trait_image_speed_from(D) speed; // un-fastest
// value => delegation
typedef typename image_<D>::value_access value_access;
typedef typename image_<D>::value_storage value_storage;
typedef typename image_<D>::value_browsing value_browsing;
- typedef typename image_<D>::value_io value_io;
+ typedef mln_internal_trait_image_value_io_from(D) value_io; // un-write when D is const
// site => delegation
typedef typename image_<D>::localization localization;
Index: mln/core/internal/site_iterator_base.hh
--- mln/core/internal/site_iterator_base.hh (revision 2049)
+++ mln/core/internal/site_iterator_base.hh (working copy)
@@ -31,6 +31,11 @@
/*! \file mln/core/internal/site_iterator_base.hh
*
* \brief Base class to factor code for site iterator classes.
+ *
+ * \todo Make p_ private and add a p() method that can be overridden
+ * so that a subclass can use some other info than this attribute.
+ * See for instance start_ and next_ in pset_if_piter.hh: we have
+ * both pi_ and p_ to designate the current site.
*/
# include <mln/core/concept/site_iterator.hh>
@@ -61,7 +66,6 @@
mln_site(S),
E >
{
-
/// The associated site type (as a Site_Proxy).
typedef mln_site(S) site;
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2049)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -68,7 +68,7 @@
*/
bool has_data() const;
- /// Convertion to the underlying (morphed) image.
+ /// Conversion to the underlying (morphed) image.
operator I() const; // FIXME: Very dangerous? Remove?
protected:
Index: mln/core/internal/site_set_iterator_base.hh
--- mln/core/internal/site_set_iterator_base.hh (revision 2049)
+++ mln/core/internal/site_set_iterator_base.hh (working copy)
@@ -50,7 +50,6 @@
template <typename S, typename E>
struct site_set_iterator_base : site_iterator_base<S, E>
{
-
/// Give the site set that this iterator browses.
const S& site_set() const;
Index: mln/core/internal/piter_adaptor.hh
--- mln/core/internal/piter_adaptor.hh (revision 2049)
+++ mln/core/internal/piter_adaptor.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,7 +33,7 @@
* \brief Definition of iterators on points of boxes.
*/
-# include <mln/core/internal/site_iterator_base.hh>
+# include <mln/core/internal/site_set_iterator_base.hh>
# include <mln/core/concept/box.hh>
@@ -48,34 +48,21 @@
* parameter E is the exact type.
*/
template <typename Pi, typename E>
- class piter_adaptor_ : public internal::site_iterator_base_< mln_psite(Pi), E >
+ class piter_adaptor_ : public internal::site_set_iterator_base< mln_pset(Pi), E >
{
- typedef internal::site_iterator_base_< mln_psite(Pi), E > super_;
public:
- // Make dim definition from super class available.
- enum { dim = super_::dim };
-
/// Constructor from a point iterator \p piter.
piter_adaptor_(const Pi& piter);
- /// Convertion to point.
- operator mln_point(Pi) () const;
-
- /// Reference to the corresponding point.
- const mln_point(Pi)& to_point() const;
-
- /// Give the i-th coordinate.
- mln_coord(Pi) operator[](unsigned i) const;
-
/// Test the iterator validity.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
+ void invalidate_();
/// Start an iteration.
- void start();
+ void start_();
/// Go to the next point.
void next_();
@@ -95,37 +82,13 @@
piter_adaptor_<Pi,E>::piter_adaptor_(const Pi& piter)
: piter_(piter)
{
- invalidate();
- }
-
- template <typename Pi, typename E>
- inline
- piter_adaptor_<Pi,E>::operator mln_point(Pi) () const
- {
- return piter_;
- }
-
- template <typename Pi, typename E>
- inline
- const mln_point(Pi)&
- piter_adaptor_<Pi,E>::to_point() const
- {
- return piter_.to_point();
- }
-
- template <typename Pi, typename E>
- inline
- mln_coord(Pi)
- piter_adaptor_<Pi,E>::operator[](unsigned i) const
- {
- assert(i < dim);
- return piter_[i];
+ invalidate_();
}
template <typename Pi, typename E>
inline
bool
- piter_adaptor_<Pi,E>::is_valid() const
+ piter_adaptor_<Pi,E>::is_valid_() const
{
return piter_.is_valid();
}
@@ -133,7 +96,7 @@
template <typename Pi, typename E>
inline
void
- piter_adaptor_<Pi,E>::invalidate()
+ piter_adaptor_<Pi,E>::invalidate_()
{
piter_.invalidate();
}
@@ -141,7 +104,7 @@
template <typename Pi, typename E>
inline
void
- piter_adaptor_<Pi,E>::start()
+ piter_adaptor_<Pi,E>::start_()
{
piter_.start();
}
Index: mln/core/box_piter.hh
--- mln/core/box_piter.hh (revision 2049)
+++ mln/core/box_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -58,6 +58,9 @@
// Make definitions from super class available.
enum { dim = P::dim };
+ /// Constructor without argument.
+ box_fwd_piter_();
+
/*! \brief Constructor.
*
* \param[in] b A box.
@@ -102,6 +105,9 @@
// Make definitions from super class available.
enum { dim = P::dim };
+ /// Constructor without argument.
+ box_bkd_piter_();
+
/*! \brief Constructor.
*
* \param[in] b A box.
@@ -136,6 +142,12 @@
template <typename P>
inline
+ box_fwd_piter_<P>::box_fwd_piter_()
+ {
+ }
+
+ template <typename P>
+ inline
box_fwd_piter_<P>::box_fwd_piter_(const box_<P>& b)
{
this->change_target(b);
@@ -187,6 +199,12 @@
template <typename P>
inline
+ box_bkd_piter_<P>::box_bkd_piter_()
+ {
+ }
+
+ template <typename P>
+ inline
box_bkd_piter_<P>::box_bkd_piter_(const box_<P>& b)
{
this->change_target(b);
Index: mln/core/sub_image.hh
--- mln/core/sub_image.hh (revision 2049)
+++ mln/core/sub_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,7 +33,6 @@
*
* \brief Definition of morpher that makes an image become restricted
* given by a point set.
- *
*/
# include <mln/core/internal/image_domain_morpher.hh>
@@ -68,7 +67,8 @@
{
template <typename I, typename S>
- struct image_< sub_image<I,S> > : default_image_morpher_< I, mln_value(I),
+ struct image_< sub_image<I,S> > : default_image_morpher_< I,
+ mln_value(I),
sub_image<I,S> >
{
// private:
@@ -82,8 +82,6 @@
typedef trait::image::ext_value::irrelevant ext_value;
typedef trait::image::ext_io::irrelevant ext_io;
- typedef mln_trait_image_io_from_(I) io; // un-write when I const
-
typedef trait::image::value_storage::disrupted value_storage;
// HOT FIXME: except if S is a Box
};
@@ -95,7 +93,9 @@
// FIXME: Doc!
template <typename I, typename S>
- struct sub_image : public internal::image_domain_morpher_< I, S, sub_image<I,S> >
+ struct sub_image : public internal::image_domain_morpher_< I,
+ S,
+ sub_image<I,S> >
{
/// Skeleton.
typedef sub_image< tag::image_<I>, tag::pset_<S> > skeleton;
@@ -112,7 +112,7 @@
/// Give the definition domain.
const S& domain() const;
- /// Const promotion via convertion.
+ /// Const promotion via conversion.
operator sub_image<const I, S>() const;
};
@@ -120,10 +120,12 @@
template <typename I, typename S>
- sub_image<const I, S> operator|(const Image<I>& ima, const Site_Set<S>& pset);
+ sub_image<const I, S>
+ operator|(const Image<I>& ima, const Site_Set<S>& pset);
template <typename I, typename S>
- sub_image<I, S> operator|(Image<I>& ima, const Site_Set<S>& pset);
+ sub_image<I, S>
+ operator|(Image<I>& ima, const Site_Set<S>& pset);
Index: mln/core/pset_if_piter.hh
--- mln/core/pset_if_piter.hh (revision 2049)
+++ mln/core/pset_if_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,11 +30,12 @@
/*! \file mln/core/pset_if_piter.hh
*
- * \brief Definition of iterators on points of pset_ifes.
+ * \brief Definition of iterators on pset_if<S,F>.
+ *
+ * \todo See todo in site_iterator_base.hh
*/
-# include <mln/core/concept/site_iterator.hh>
-# include <mln/core/internal/piter_adaptor.hh>
+# include <mln/core/internal/site_set_iterator_base.hh>
# include <mln/core/pset_if.hh>
@@ -50,27 +51,34 @@
*/
template <typename S, typename F>
class pset_if_fwd_piter_
- : public internal::piter_adaptor_< mln_fwd_piter(S),
+ : public internal::site_set_iterator_base< pset_if<S,F>,
pset_if_fwd_piter_<S,F> >
{
- typedef mln_fwd_piter(S) adaptee_;
- typedef pset_if_fwd_piter_<S,F> self_;
- typedef internal::piter_adaptor_<adaptee_, self_> super_;
-
public:
- /// Constructor from a subset of points.
- pset_if_fwd_piter_(const pset_if<S,F>& subset);
+ /// Constructor without argument.
+ pset_if_fwd_piter_();
+
+ /// Constructor from a site set.
+ pset_if_fwd_piter_(const pset_if<S,F>& s);
+
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
/// Start an iteration.
- void start();
+ void start_();
/// Go to the next point.
void next_();
+ mln_fwd_piter(S)& hook_pi_() { return pi_; }
+
private:
- const pset_if<S,F>& subset_;
+ mln_fwd_piter(S) pi_;
};
@@ -90,20 +98,44 @@
template <typename S, typename F>
inline
- pset_if_fwd_piter_<S,F>::pset_if_fwd_piter_(const pset_if<S,F>& subset)
- : super_(adaptee_(subset.overset())),
- subset_(subset)
+ pset_if_fwd_piter_<S,F>::pset_if_fwd_piter_()
+ {
+ }
+
+ template <typename S, typename F>
+ inline
+ pset_if_fwd_piter_<S,F>::pset_if_fwd_piter_(const pset_if<S,F>& s)
+ {
+ pi_.change_target(s.overset());
+ this->change_target(s);
+ }
+
+ template <typename S, typename F>
+ inline
+ bool
+ pset_if_fwd_piter_<S,F>::is_valid_() const
+ {
+ return pi_.is_valid();
+ }
+
+ template <typename S, typename F>
+ inline
+ void
+ pset_if_fwd_piter_<S,F>::invalidate_()
{
+ pi_.invalidate();
}
template <typename S, typename F>
inline
void
- pset_if_fwd_piter_<S,F>::start()
+ pset_if_fwd_piter_<S,F>::start_()
{
- this->piter_.start();
- while (this->piter_.is_valid() && ! subset_.pred(this->piter_))
- this->piter_.next();
+ pi_.start();
+ while (pi_.is_valid() && ! this->s_->pred(pi_))
+ pi_.next();
+ if (is_valid_())
+ this->p_ = pi_;
}
template <typename S, typename F>
@@ -112,8 +144,10 @@
pset_if_fwd_piter_<S,F>::next_()
{
do
- this->piter_.next();
- while (this->piter_.is_valid() && ! subset_.pred(this->piter_));
+ pi_.next();
+ while (pi_.is_valid() && ! this->s_->pred(pi_));
+ if (is_valid_())
+ this->p_ = pi_;
}
Index: mln/core/image_if.hh
--- mln/core/image_if.hh (revision 2049)
+++ mln/core/image_if.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,13 +33,12 @@
* \brief Definition of a image which domain is restricted by a
* function.
*
- * \todo FIXME for theo : add image_if_great_than / less_than
+ * \todo Relax Function_p2v into Function_v2v.
*/
-# include <mln/core/internal/image_if_base.hh>
-
-
-# define Super mln::internal::image_if_base_< I, F, image_if<I,F> >
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/pset_if.hh>
+# include <mln/pw/all.hh>
namespace mln
@@ -54,9 +53,12 @@
/// \internal Data structure for \c mln::image_if<I,F>.
template <typename I, typename F>
- struct data_< image_if<I,F> > : data_< Super >
+ struct data_< image_if<I,F> >
{
data_(I& ima, const F& f);
+
+ I ima_;
+ pset_if<mln_pset(I), F> pset_;
};
} // end of namespace mln::internal
@@ -66,8 +68,17 @@
{
template <typename I, typename F>
- struct image_< image_if<I,F> > : trait::image_< Super >
+ struct image_< image_if<I,F> > : default_image_morpher_< I,
+ mln_value(I),
+ image_if<I,F> >
{
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::value_storage::disrupted value_storage;
};
} // end of namespace mln::trait
@@ -78,16 +89,23 @@
*
*/
template <typename I, typename F>
- struct image_if : public Super
+ struct image_if : public internal::image_domain_morpher_< I,
+ pset_if<mln_pset(I), F>,
+ image_if<I, F> >
{
/// Skeleton.
typedef image_if< tag::image_<I>, tag::function_<F> > skeleton;
+ /// Constructor without argument.
+ image_if();
+
/// Constructor from an image \p ima and a predicate \p f.
image_if(I& ima, const F& f);
- /// Constructor without argument.
- image_if();
+ void init_(I& ima, const F& f);
+
+ /// Give the definition domain.
+ const pset_if<mln_pset(I), F>& domain() const;
/// Const promotion via convertion.
operator image_if<const I, F>() const;
@@ -130,9 +148,10 @@
operator | (const Image<I>& ima, const Function_p2b<F>& f);
+
# ifndef MLN_INCLUDE_ONLY
- /// \internal internal::data_
+ // internal::data_< image_if<I,F> >
namespace internal
{
@@ -140,12 +159,14 @@
template <typename I, typename F>
inline
data_< image_if<I,F> >::data_(I& ima, const F& f)
- : data_< Super >(ima, f)
+ : ima_(ima),
+ pset_(ima.domain() | f)
{
}
}
+
// image_if<I,F>
template <typename I, typename F>
@@ -158,7 +179,25 @@
inline
image_if<I,F>::image_if(I& ima, const F& f)
{
- this->init_(ima, f);
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ image_if<I,F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->has_data());
+ this->data_ = new internal::data_< image_if<I,F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ const pset_if<mln_pset(I), F>&
+ image_if<I,F>::domain() const
+ {
+ mln_precondition(this->has_data());
+ return this->data_->pset_;
}
template <typename I, typename F>
@@ -171,6 +210,7 @@
return tmp;
}
+
// Operators.
template <typename I, typename F>
Index: mln/core/alias.hh
--- mln/core/alias.hh (revision 0)
+++ mln/core/alias.hh (revision 0)
@@ -0,0 +1,43 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_ALIAS_HH
+# define MLN_CORE_ALIAS_HH
+
+/*! \file mln/core/alias.hh
+ *
+ * \brief Definition of FIXME
+ */
+
+
+#define mln_alias(Var, Expr) \
+ \
+ typeof(Expr) Var = Expr; \
+ typedef typeof(Expr) Var##_t
+
+
+#endif // ! MLN_CORE_ALIAS_HH
Index: mln/core/pset_if.hh
--- mln/core/pset_if.hh (revision 2049)
+++ mln/core/pset_if.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -45,6 +45,19 @@
template <typename S, typename F> struct pset_if_fwd_piter_;
template <typename S, typename F> struct pset_if_bkd_piter_;
+ namespace trait
+ {
+
+ template <typename S, typename F>
+ struct site_set_< pset_if<S,F> >
+ {
+ typedef trait::site_set::nsites::unknown nsites;
+ typedef trait::site_set::bbox::unknown bbox;
+ typedef trait::site_set::contents::fixed contents;
+ typedef mln_trait_site_set_arity(S) arity;
+ };
+
+ } // end of namespace trait
/*! \brief Restrict a point set \p pset to points that verify \p f.
@@ -71,11 +84,15 @@
typedef internal::site_set_base_<mln_psite(S), self_> super_;
public:
- typedef mln_psite(super_) psite;
+ typedef mln_psite(S) psite;
+
/// Forward Site_Iterator associated type.
typedef pset_if_fwd_piter_<S,F> fwd_piter;
+ /// Site_Iterator associated type.
+ typedef fwd_piter piter;
+
/// Backward Site_Iterator associated type.
typedef mln::internal::fixme bkd_piter;
@@ -90,12 +107,6 @@
/// Test if \p p belongs to the subset.
bool has(const psite& p) const;
- /// Give a bounding box of the subset.
- const box_<mln_point(S)>& bbox() const;
-
- /// Give the number of points of the subset.
- std::size_t npoints() const;
-
/// Give the primary overset.
const S& overset() const;
@@ -138,14 +149,6 @@
template <typename S, typename F>
inline
- const box_<mln_point(S)>&
- pset_if<S,F>::bbox() const
- {
- return pset_.bbox();
- }
-
- template <typename S, typename F>
- inline
const S&
pset_if<S,F>::overset() const
{
@@ -192,25 +195,4 @@
-namespace mln
-{
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename S, typename F>
- std::size_t
- pset_if<S,F>::npoints() const
- {
- std::size_t n = 0;
- fwd_piter p(*this);
- for_all(p)
- ++n;
- return n;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of namespace mln
-
-
#endif // ! MLN_CORE_PSET_IF_HH
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2049)
+++ mln/core/concept/image.hh (working copy)
@@ -126,8 +126,11 @@
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
- std::size_t (E::*m2)() const = & E::nsites;
- m2 = 0;
+
+ // Only some image types feature the 'nsites' method.
+// std::size_t (E::*m2)() const = & E::nsites;
+// m2 = 0;
+
bool (E::*m3)() const = & E::has_data;
m3 = 0;
Index: mln/core/concept/gpoint.hh
--- mln/core/concept/gpoint.hh (revision 2049)
+++ mln/core/concept/gpoint.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Definition of the concept of mln::Gpoint.
*/
-# include <mln/core/concept/object.hh>
+# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
# include <mln/value/concept/scalar.hh>
@@ -78,7 +78,7 @@
template <>
struct Gpoint<void>
{
- typedef Object<void> super;
+ typedef Site<void> super;
};
@@ -90,7 +90,7 @@
* discrete square grid of the 2D plane.
*/
template <typename E>
- struct Gpoint : public Object<E>
+ struct Gpoint : public Site<E>
{
typedef Gpoint<void> category;
Index: mln/core/concept/site.hh
--- mln/core/concept/site.hh (revision 0)
+++ mln/core/concept/site.hh (revision 0)
@@ -0,0 +1,79 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_SITE_HH
+# define MLN_CORE_CONCEPT_SITE_HH
+
+/*! \file mln/core/concept/site.hh
+ *
+ * \brief Definition of the concept of mln::Site.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Site;
+
+
+ /// Site category flag type.
+ template <>
+ struct Site<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for classes that are explicitly sites.
+ */
+ template <typename E>
+ struct Site : public Object<E>
+ {
+ typedef Site<void> category;
+
+ protected:
+ Site();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ Site<E>::Site()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_SITE_HH
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 2049)
+++ mln/pw/image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,6 +31,8 @@
/*! \file mln/pw/image.hh
*
* \brief FIXME.
+ *
+ * \todo Relax Function_p2v into Function_v2v.
*/
# include <mln/core/internal/image_primary.hh>
@@ -81,18 +83,25 @@
struct image_< pw::image<F,S> > : default_image_< mlc_unqualif(mln_result(F)),
pw::image<F,S> >
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::value::fixme value;
-
- typedef trait::image::access::browsing access;
- typedef trait::image::space::fixme_ space;
+ typedef trait::image::speed::fastest speed;
typedef trait::image::size::regular size;
- typedef trait::image::support::fixme_ support;
- typedef trait::image::border::none border;
- typedef trait::image::data::computed data;
- typedef trait::image::io::read_only io;
+ // value
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::value_storage::disrupted value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_only value_io;
+
+ // site / domain
+ typedef /* FIXME: depends on S */ undef localization;
+ typedef /* FIXME: depends on S */ undef dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::none ext_domain;
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
};
} // end of namespace mln::trait
@@ -130,9 +139,7 @@
/// Constructor.
image(const Function_p2v<F>& f, const Site_Set<S>& ps);
-
- /// Test if a pixel value is accessible at \p p.
- bool has(const mln_psite(S)& p) const;
+ // No init_ method here since this image type is not "concrete".
/// Give the definition domain.
const S& domain() const;
@@ -199,13 +206,6 @@
template <typename F, typename S>
inline
- bool image<F,S>::has(const mln_psite(S)& p) const
- {
- return this->data_->pset_.has(p);
- }
-
- template <typename F, typename S>
- inline
const S&
image<F,S>::domain() const
{
Index: mln/fun/internal/selector.hh
--- mln/fun/internal/selector.hh (revision 2049)
+++ mln/fun/internal/selector.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,7 +34,8 @@
*/
# include <mln/core/concept/function.hh>
-# include <mln/core/concept/point_site.hh>
+# include <mln/core/concept/site.hh>
+# include <mln/core/concept/pseudo_site.hh>
# include <mln/metal/unqualif.hh>
# include <mln/metal/if.hh>
# include <mln/metal/is_a.hh>
@@ -160,7 +161,7 @@
template <typename T>
struct tag_
{
- enum { value = mlc_is_a(T, Point_Site)::value
+ enum { value = (mlc_is_a(T, Site)::value || mlc_is_a(T, Pseudo_Site)::value)
? p_
: v_ };
};
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Move the application on the segmentation of statues into Milena.
* apps/: New directory.
* sandbox/levillain/statues/: Move...
* apps/statues/: ...here.
0 files changed
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Sandbox: ICP: clean-up before milena update.
Prepare patch for math and geom modules.
* jardonnet/registration/power_it.hh: Add comment .
* jardonnet/registration/cov.hh: New: clean math::covariance.
* jardonnet/registration/variance.hh: New: clean math::variance.
* jardonnet/registration/exp_val.hh: New: clean math::expected value.
* jardonnet/registration/cross_cov.hh: Update: clean cross covariance.
* jardonnet/registration/center.hh: New: clean geom::center.
Update rendering for seminar.
* jardonnet/registration/save.hh: Update rendering.
* jardonnet/test/img/c5.pbm,
* jardonnet/test/img/x5.pbm: Update images .
registration/center.hh | 73 ++++++++++++++++++++++++++++++++++++++++
registration/cov.hh | 82
++++++++++++++++++++++++++++++++++++++++++++++
registration/cross_cov.hh | 6 +--
registration/exp_val.hh | 77
+++++++++++++++++++++++++++++++++++++++++++
registration/power_it.hh | 3 +
registration/save.hh | 52 ++++++++++++++---------------
registration/variance.hh | 27 +++++++++++++++
test/icp_ref.cc | 2 -
8 files changed, 292 insertions(+), 30 deletions(-)
Index: jardonnet/test/icp_ref.cc
--- jardonnet/test/icp_ref.cc (revision 2044)
+++ jardonnet/test/icp_ref.cc (working copy)
@@ -60,7 +60,7 @@
}
//working box
- const box_< point_<grid::cube, float> > working_box =
enlarge(bigger(c.bbox(),x.bbox()),100);
+ const box_< point_<grid::cube, float> > working_box =
enlarge(bigger(c.bbox(),x.bbox()),50);
// FIXME : TODO : map : vec<3,float> -> point
closest_point< point_<grid::cube, float> > map(x, working_box);
Index: jardonnet/test/img/c5.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: jardonnet/test/img/x5.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: jardonnet/registration/cov.hh
--- jardonnet/registration/cov.hh (revision 0)
+++ jardonnet/registration/cov.hh (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MATH_COV_HH
+# define MLN_MATH_COV_HH
+
+/*! \file mln/math/cov.hh
+ *
+ * \brief Define the covariance (cov) routine.
+ */
+
+# include "exp_val.hh"
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename P>
+ algebra::mat<P::dim,P::dim,float>
+ cov(const p_array<P>& a1,
+ const p_array<P>& a2);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ algebra::mat<P::dim,P::dim,float>
+ cov(const p_array<P>& a1,
+ const p_array<P>& a2)
+ {
+ mln_precondition(a1.npoints() == a2.npoints());
+
+ //centers of mass
+ algebra::vec<P::dim,float> mu_a1 = math::exp_value(a1);
+ algebra::vec<P::dim,float> mu_a2 = math::exp_value(a2);
+
+ //covariance matrix
+ algebra::mat<P::dim,P::dim,float> Mk(literal::zero);
+ for (unsigned i = 0; i < a1.npoints(); ++i)
+ {
+ // FIXME: ugly cast.
+ algebra::vec<P::dim,float> a1i = a1[i];
+ algebra::vec<P::dim,float> a2i = a2[i];
+ Mk += make::mat(a1i - mu_a1) * trans(make::mat(a2i - mu_a2));
+ }
+
+ return Mk / a1.npoints();
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_COV_HH
Index: jardonnet/registration/power_it.hh
--- jardonnet/registration/power_it.hh (revision 2044)
+++ jardonnet/registration/power_it.hh (working copy)
@@ -12,6 +12,9 @@
namespace mln
{
+ /**
+ * Return the biggest eigen vector.
+ */
template <uint n>
algebra::vec<n,float> power_it(algebra::mat<n,n,float>& A)
{
Index: jardonnet/registration/variance.hh
--- jardonnet/registration/variance.hh (revision 0)
+++ jardonnet/registration/variance.hh (revision 0)
@@ -0,0 +1,27 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
Index: jardonnet/registration/save.hh
--- jardonnet/registration/save.hh (revision 2044)
+++ jardonnet/registration/save.hh (working copy)
@@ -5,11 +5,16 @@
# include <mln/io/ppm/save.hh>
# include <mln/io/pbm/save.hh>
# include <mln/draw/all.hh>
+# include <mln/morpho/erosion.hh>
+# include <mln/make/window2d.hh>
# include <string>
# include "quat7.hh"
# include "tools.hh"
# include "power_it.hh"
+# include "center.hh"
+# include "cov.hh"
+
namespace mln
{
@@ -55,17 +60,11 @@
level::fill(out, literal::white);
//plot mu_Ck
- algebra::vec<P::dim,float> mu_Ck = center(ck, ck.npoints());
+ algebra::vec<P::dim,float> mu_Ck = geom::center(ck);
draw::plot(out, point2d(mu_Ck[0], mu_Ck[1]), literal::green);
//Ck orientation
- algebra::mat<P::dim,P::dim,float> Mk(literal::zero);
- for (unsigned i = 0; i < ck.npoints(); ++i)
- {
- algebra::vec<P::dim,float> Cki = ck[i];
- Mk += make::mat(Cki - mu_Ck) * trans(make::mat(Cki - mu_Ck));
- }
- Mk /= c.npoints();
+ algebra::mat<P::dim,P::dim,float> Mk = math::cov(ck,ck);
algebra::vec<3,float> vck = power_it(Mk);
draw::line(out, point2d(mu_Ck[0], mu_Ck[1]),
point2d(mu_Ck[0]+vck[0]*10, mu_Ck[1]+vck[1]*10),
@@ -77,31 +76,16 @@
xk.append(map(ck[i]));
//plot mu_Xk
- algebra::vec<P::dim,float> mu_Xk = center(xk, xk.npoints());
+ algebra::vec<P::dim,float> mu_Xk = geom::center(xk);
draw::plot(out, point2d(mu_Xk[0], mu_Xk[1]), literal::blue);
//Xk orientation
- algebra::mat<P::dim,P::dim,float> Mxk(literal::zero);
- for (unsigned i = 0; i < xk.npoints(); ++i)
- {
- algebra::vec<P::dim,float> Xki = xk[i];
- Mxk += make::mat(Xki - mu_Xk) * trans(make::mat(Xki - mu_Xk));
- }
- Mxk /= c.npoints();
+ algebra::mat<P::dim,P::dim,float> Mxk = math::cov(xk,xk);
algebra::vec<3,float> vxk = power_it(Mxk);
draw::line(out, point2d(mu_Xk[0], mu_Xk[1]),
point2d(mu_Xk[0]+vxk[0]*10, mu_Xk[1]+vxk[1]*10),
literal::red);
-
- //ck in green
- for (unsigned i = 0; i < ck.npoints(); i++)
- {
- point2d p(ck[i][0], ck[i][1]);
- if (out.has(p))
- out(p) = literal::green;
- }
-
//x in black
for (unsigned i = 0; i < x.npoints(); i++)
{
@@ -110,7 +94,7 @@
out(p) = literal::black;
}
- //xk in blue
+ //xk in red
for (unsigned i = 0; i < xk.npoints(); i++)
{
point2d p(xk[i][0], xk[i][1]);
@@ -118,6 +102,22 @@
out(p) = literal::red;
}
+ //ck in green
+ for (unsigned i = 0; i < ck.npoints(); i++)
+ {
+ point2d p(ck[i][0], ck[i][1]);
+ if (out.has(p))
+ out(p) = literal::green;
+ }
+
+ /*
+ FIXME:
+ bool vals[] = {1, 1, 1,
+ 1, 1, 1,
+ 1, 1, 1};
+ morpho::erosion(out, make::window2d(vals));
+ */
+
//save
std::stringstream oss;
oss << "step_" << id++ << ".ppm";
Index: jardonnet/registration/exp_val.hh
--- jardonnet/registration/exp_val.hh (revision 0)
+++ jardonnet/registration/exp_val.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_MATH_EXP_VAL_HH
+# define MLN_MATH_EXP_VAL_HH
+
+/*! \file mln/math/exp_val.hh
+ *
+ * \brief Define the expected value (exp_val) routine.
+ */
+
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename P>
+ algebra::vec<P::dim,float>
+ exp_value(const p_array<P>& a);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ algebra::vec<P::dim,float>
+ exp_value(const p_array<P>& a)
+ {
+ if (a.npoints() == 0)
+ return P();
+
+ algebra::vec<P::dim,float> c(literal::zero);
+ for (unsigned i = 0; i < a.npoints(); ++i)
+ {
+ // FIXME : Ugly.
+ algebra::vec<P::dim,float> ai = a[i];
+ c += ai;
+ }
+
+ return c / a.npoints();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_ABS_HH
Index: jardonnet/registration/cross_cov.hh
--- jardonnet/registration/cross_cov.hh (revision 2044)
+++ jardonnet/registration/cross_cov.hh (working copy)
@@ -1,5 +1,5 @@
-#ifndef MLN_ACCU_CROSS_COV_HH_HH
-# define MLN_ACCU_CROSS_COV_HH_HH
+#ifndef MLN_ACCU_CROSS_COV_HH
+# define MLN_ACCU_CROSS_COV_HH
namespace mln
@@ -15,4 +15,4 @@
}
-#endif // ! MLN_ACCU_CROSS_COV_HH_HH
+#endif // ! MLN_ACCU_CROSS_COV_HH
Index: jardonnet/registration/center.hh
--- jardonnet/registration/center.hh (revision 0)
+++ jardonnet/registration/center.hh (revision 0)
@@ -0,0 +1,73 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_GEOM_CENTER_HH
+# define MLN_GEOM_CENTER_HH
+
+/*! \file mln/math/exp_val.hh
+ *
+ * \brief Define the center routine.
+ */
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ template <typename P>
+ P center(const p_array<P>& a);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ P exp_value(const p_array<P>& a)
+ {
+ if (a.npoints() == 0)
+ return P();
+
+ algebra::vec<P::dim,float> c(literal::zero);
+ for (unsigned i = 0; i < a.npoints(); ++i)
+ {
+ // FIXME : Ugly.
+ algebra::vec<P::dim,float> ai = a[i];
+ c += ai;
+ }
+
+ return algebra::to_point<P>(c / a.npoints());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_ABS_HH