Olena-patches
  Threads by month 
                
            - ----- 2025 -----
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2024 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2023 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2022 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2021 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2020 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2019 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2018 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2017 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2016 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2015 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2014 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2013 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2012 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2011 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2010 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2009 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2008 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2007 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2006 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2005 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 - February
 - January
 - ----- 2004 -----
 - December
 - November
 - October
 - September
 - August
 - July
 - June
 - May
 - April
 - March
 
February 2009
- 12 participants
 - 266 discussions
 
                    
                        	* mln/algebra/quat.hh: use mln_precondition instead of assert.
	* mln/core/image/interpolated.hh: add a fixme.
	* mln/fun/x2x/translation.hh: add a missing accessor to the
	translation vector.
	* mln/transform/internal/closest_point_functor.hh: fix wrong update of
	the closest point image.
---
 milena/ChangeLog                                   |   14 ++++++++++++++
 milena/mln/algebra/quat.hh                         |    2 +-
 milena/mln/core/image/interpolated.hh              |    1 +
 milena/mln/fun/x2x/translation.hh                  |   11 +++++++++++
 .../transform/internal/closest_point_functor.hh    |    2 +-
 5 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 25aa240..8960f74 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,18 @@
 2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+    
+	Small changes in transformation related classes.
+
+	* mln/algebra/quat.hh: use mln_precondition instead of assert.
+
+	* mln/core/image/interpolated.hh: add a fixme.
+
+	* mln/fun/x2x/translation.hh: add a missing accessor to the
+	translation vector.
+
+	* mln/transform/internal/closest_point_functor.hh: fix wrong update of
+	the closest point image.
+
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
 
 	Fix make::h_mat.
 
diff --git a/milena/mln/algebra/quat.hh b/milena/mln/algebra/quat.hh
index 9dee769..33e7d07 100644
--- a/milena/mln/algebra/quat.hh
+++ b/milena/mln/algebra/quat.hh
@@ -410,7 +410,7 @@ namespace mln
     inline
     quat quat::inv() const
     {
-      assert(! is_null());
+      mln_precondition(! is_null());
       float f = norm::l2(v_);
       return conj().to_vec() / (f * f);
     }
diff --git a/milena/mln/core/image/interpolated.hh b/milena/mln/core/image/interpolated.hh
index 5b37eb5..70250f6 100644
--- a/milena/mln/core/image/interpolated.hh
+++ b/milena/mln/core/image/interpolated.hh
@@ -105,6 +105,7 @@ namespace mln
 
 
     /// Constructors.
+    ///FIXME: don't we want a 'const' here?
     interpolated(I& ima);
     interpolated();
 
diff --git a/milena/mln/fun/x2x/translation.hh b/milena/mln/fun/x2x/translation.hh
index 6d1e707..4101d77 100644
--- a/milena/mln/fun/x2x/translation.hh
+++ b/milena/mln/fun/x2x/translation.hh
@@ -75,6 +75,9 @@ namespace mln
         /// Set a net translation vector.
         void set_t(const algebra::vec<n,C>& t);
 
+	/// Return the translation vector.
+	const algebra::vec<n,C>& t() const;
+
       protected:
         void update();
 
@@ -127,6 +130,14 @@ namespace mln
 
       template <unsigned n, typename C>
       inline
+      const algebra::vec<n,C>&
+      translation<n,C>::t() const
+      {
+        return this->t_;
+      }
+
+      template <unsigned n, typename C>
+      inline
       void
       translation<n,C>::update()
       {
diff --git a/milena/mln/transform/internal/closest_point_functor.hh b/milena/mln/transform/internal/closest_point_functor.hh
index 02b3401..eff0e96 100644
--- a/milena/mln/transform/internal/closest_point_functor.hh
+++ b/milena/mln/transform/internal/closest_point_functor.hh
@@ -98,7 +98,7 @@ namespace mln
       inline
       void closest_point_functor<I>::process(const P& p, const P& n)
       {
-	cp_ima(n) = p;
+	cp_ima(n) = cp_ima(p);
       }
 
 # endif // ! MLN_INCLUDE_ONLY
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/make/h_mat.hh: fix wrong loop.
	* tests/make/Makefile.am,
	* tests/make/h_mat.cc: add a missing test.
---
 milena/ChangeLog              |    9 ++++++
 milena/mln/make/h_mat.hh      |   13 ++++----
 milena/tests/make/Makefile.am |    2 +
 milena/tests/make/h_mat.cc    |   65 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+), 6 deletions(-)
 create mode 100644 milena/tests/make/h_mat.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 219f400..25aa240 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
 2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
 
+	Fix make::h_mat.
+
+	* mln/make/h_mat.hh: fix wrong loop.
+
+	* tests/make/Makefile.am,
+	* tests/make/h_mat.cc: add a missing test.
+	
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
 	Fix wrong comments in fun::x2x:composed.
 
 	* mln/fun/x2x/composed.hh: Comments were wrong, they are fixed. The
diff --git a/milena/mln/make/h_mat.hh b/milena/mln/make/h_mat.hh
index 930c133..243278d 100644
--- a/milena/mln/make/h_mat.hh
+++ b/milena/mln/make/h_mat.hh
@@ -78,22 +78,23 @@ namespace mln
     template <typename T, unsigned d>
     inline
     algebra::h_mat<d,T>
-    h_mat(const T (&tab)[(d+1)*(d+1)])
+    h_mat(const T (&tab)[(d)*(d)])
     {
+      std::cout << "plap" << std::endl;
       algebra::h_mat<d,T> tmp;
-      for (unsigned i = 0; i <= d; ++i)
-	tmp(i / (d+1), i % (d+1)) = tab[i];
+      for (unsigned i = 0; i < d; ++i)
+	tmp(i / (d), i % (d)) = tab[i];
       return tmp;
     }
 
 
     template <typename T, unsigned d>
     algebra::h_mat<d,T>
-    h_mat(const T (&tab)[d+1][d+1])
+    h_mat(const T (&tab)[d][d])
     {
       algebra::h_mat<d,T> tmp;
-      for (unsigned i = 0; i <= d; ++i)
-        for (unsigned j = 0; j <= d; ++j)
+      for (unsigned i = 0; i < d; ++i)
+        for (unsigned j = 0; j < d; ++j)
 	  tmp(i, j) = tab[i][j];
       return tmp;
     }
diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am
index 7d0c2f5..913867c 100644
--- a/milena/tests/make/Makefile.am
+++ b/milena/tests/make/Makefile.am
@@ -4,6 +4,7 @@ include $(top_srcdir)/milena/tests/tests.mk
 
 check_PROGRAMS =				\
   dual_neighb					\
+  h_mat 					\
   image2d					\
   image3d					\
   mat						\
@@ -11,6 +12,7 @@ check_PROGRAMS =				\
   w_window_directional
 
 dual_neighb_SOURCES = dual_neighb.cc
+h_mat_SOURCES = h_mat.cc
 image2d_SOURCES = image2d.cc
 image3d_SOURCES = image3d.cc
 mat_SOURCES = mat.cc
diff --git a/milena/tests/make/h_mat.cc b/milena/tests/make/h_mat.cc
new file mode 100644
index 0000000..a8df474
--- /dev/null
+++ b/milena/tests/make/h_mat.cc
@@ -0,0 +1,65 @@
+// Copyright (C) 2009 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.
+
+/// \file tests/make/h_mat.cc
+///
+/// Tests on mln::make::h_mat.
+
+#include <mln/make/h_mat.hh>
+
+
+static const int result[4][4] = { { 2, 3,  4, 0 },
+				  { 5, 6,  7, 0 },
+				  { 8, 9, 10, 0 },
+				  { 0, 0,  0, 1 } };
+
+int main()
+{
+  using namespace mln;
+
+  {
+    int vals[9] = { 2, 3,  4,
+      5, 6,  7,
+      8, 9, 10 };
+    algebra::h_mat<3,int> m = make::h_mat(vals);
+
+    for (unsigned i = 0; i < 4; ++i)
+      for (unsigned j = 0; j < 4; ++j)
+	mln_assertion(m(i,j) == result[i][j]);
+  }
+
+  {
+    int vals[3][3] = { { 2, 3,  4 },
+		       { 5, 6,  7 },
+		       { 8, 9, 10 } };
+    algebra::h_mat<3,int> m = make::h_mat(vals);
+
+    for (unsigned i = 0; i < 4; ++i)
+      for (unsigned j = 0; j < 4; ++j)
+	mln_assertion(m(i,j) == result[i][j]);
+  }
+}
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/fun/x2x/composed.hh: Comments were wrong, they are fixed. The
	template parameter names are also more explicit.
---
 milena/ChangeLog               |    7 ++
 milena/mln/fun/x2x/composed.hh |  146 +++++++++++++++++++--------------------
 2 files changed, 78 insertions(+), 75 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 772b56b..219f400 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
 2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
 
+	Fix wrong comments in fun::x2x:composed.
+
+	* mln/fun/x2x/composed.hh: Comments were wrong, they are fixed. The
+	template parameter names are also more explicit.
+
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
 	Add is_valid() to window and neighborhood.
 
 	* mln/core/internal/neighborhood_base.hh,
diff --git a/milena/mln/fun/x2x/composed.hh b/milena/mln/fun/x2x/composed.hh
index b8df088..1509f1c 100644
--- a/milena/mln/fun/x2x/composed.hh
+++ b/milena/mln/fun/x2x/composed.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 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
@@ -28,10 +29,9 @@
 #ifndef MLN_FUN_X2X_COMPOSED_HH
 # define MLN_FUN_X2X_COMPOSED_HH
 
-/*! \file mln/fun/x2x/composed.hh
- *
- * \brief Definition of a composed transformation.
- */
+/// \file mln/fun/x2x/composed.hh
+///
+/// Definition of a composed transformation.
 
 # include <mln/core/concept/function.hh>
 # include <mln/fun/internal/x2x_linear_impl.hh>
@@ -50,102 +50,99 @@ namespace mln
     namespace x2x
     {
 
-      // Fwd decl.
-      template <typename F, typename G>
+      // Forward declaration.
+      template <typename T2, typename T1>
       struct composed;
 
       namespace internal
       {
-        template <typename F, typename G, typename E, bool is_bij>
+        template <typename T2, typename T1, typename E, bool is_bij>
         struct helper_composed_;
 
 
         /// Helper for describing a bijective composition.
-        template <typename F, typename G, typename E>
-        struct helper_composed_< F, G, E, true>
-          : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+        template <typename T2, typename T1, typename E>
+        struct helper_composed_<T2,T1,E,true>
+          : public fun::internal::x2x_linear_impl_<mln_result(T2), E >,
             public Bijection_x2x<E>
         {
-          typedef fun::internal::x2x_linear_impl_<typename F::result, E > super_;
+          typedef fun::internal::x2x_linear_impl_<typename T2::result, E > super_;
 
           using super_::dim;
 
           /// Constructor without argument.
           helper_composed_();
           /// Constructor with the two transformation to be composed.
-          helper_composed_(const F& f, const G& g);
+          helper_composed_(const T2& f, const T1& g);
 
           using super_::operator();
 
-          /// Set the new first transformation.
-          void set_first(const F& f);
           /// Set the new second transformation.
-          void set_second(const G& g);
+          void set_first(const T2& f);
+          /// Set the new first transformation.
+          void set_second(const T1& g);
 
           /// Type of the inverse function.
-          typedef composed<mln_invert(G),mln_invert(F)> invert;
+          typedef composed<mln_invert(T1),mln_invert(T2)> invert;
           /// Return the inverse function.
           invert inv() const;
 
           //protected:
 
-          F f_;
-          G g_;
+          T2 f_;
+          T1 g_;
         };
 
         /// Helper for describing a non bijective composition.
-        template <typename F, typename G, typename E>
-        struct helper_composed_< F, G, E, false>
-          : public fun::internal::x2x_linear_impl_<mln_result(F), E >,
+        template <typename T2, typename T1, typename E>
+        struct helper_composed_<T2,T1,E,false>
+          : public fun::internal::x2x_linear_impl_<mln_result(T2), E >,
             public Function_x2x<E>
         {
-          typedef fun::internal::x2x_linear_impl_<typename F::result, E > super_;
+          typedef fun::internal::x2x_linear_impl_<typename T2::result, E > super_;
 
           using super_::dim;
 
           /// Constructor without argument.
           helper_composed_();
           /// Constructor with the two transformation to be composed.
-          helper_composed_(const F& f, const G& g);
+          helper_composed_(const T2& f, const T1& g);
 
           using super_::operator();
 
-          /// Set the new first transformation.
-          void set_first(const F& f);
           /// Set the new second transformation.
-          void set_second(const G& g);
+          void set_first(const T2& f);
+          /// Set the new first transformation.
+          void set_second(const T1& g);
 
           //protected:
 
-          F f_;
-          G g_;
+          T2 f_;
+          T1 g_;
         };
 
       } // end of namespace mln::fun::x2x::internal
 
 
-        /*! \brief Represent a composition of two transformations.
-         *
-         */
-      template <typename F, typename G>
+      /// Represent a composition of two transformations.
+      template <typename T2, typename T1>
       struct composed
-        : public internal::helper_composed_<F, G, composed<F,G>,
-                                            mlc_is(F, Bijection_x2x<F>)::value &&
-                                            mlc_is(G, Bijection_x2x<G>)::value>,
-          private metal::and_< metal::bool_<(F::dim == G::dim)>,
-                               metal::is<mln_argument(F), mln_result(G)>
+        : public internal::helper_composed_<T2,T1,composed<T2,T1>,
+                                            mlc_is(T2, Bijection_x2x<T2>)::value &&
+                                            mlc_is(T1, Bijection_x2x<T1>)::value>,
+          private metal::and_< metal::bool_<(T2::dim == T1::dim)>,
+                               metal::is<mln_argument(T2), mln_result(T1)>
                                >::check_t
       {
         /// Constructor without argument.
         composed() {}
 
         /// Constructor with the two transformation to be composed.
-        composed(const F& f, const G& g)
-          : internal::helper_composed_<F, G, composed<F,G>,
-                                       mlc_is(F, Bijection_x2x<F>)::value &&
-                                       mlc_is(G, Bijection_x2x<G>)::value>(f, g)
-                                       {
-                                       }
+        composed(const T2& f, const T1& g)
+          : internal::helper_composed_<T2,T1,composed<T2,T1>,
+                                       mlc_is(T2, Bijection_x2x<T2>)::value &&
+                                       mlc_is(T1, Bijection_x2x<T1>)::value>(f, g)
+        {}
 };
 
 } // end of namespace mln::fun::x2x
@@ -153,15 +150,14 @@ namespace mln
   } // end of namespace mln::fun
 
 
-  /*! \brief Do a composition of two transformations
-   *
-   * \param[in] f The first transformation.
-   * \param[in] g The second transformation.
-   *
-   * \return The composed transformation fog.
-   */
-  template <typename F, typename G>
-  fun::x2x::composed<F,G> compose(F f, G g);
+  /// Do a composition of two transformations
+  ///
+  /// \param[in] f The second transformation.
+  /// \param[in] g The first transformation.
+  ///
+  /// \return The composed transformation fog.
+  template <typename T2, typename T1>
+  fun::x2x::composed<T2,T1> compose(T2 f, T1 g);
 
 # ifndef MLN_INCLUDE_ONLY
 
@@ -176,76 +172,76 @@ namespace mln
 
         // Implementation of the bijective version.
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
-        helper_composed_<F,G,E,true>::helper_composed_()
+        helper_composed_<T2,T1,E,true>::helper_composed_()
         {
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
-        helper_composed_<F,G,E,true>::helper_composed_(const F& f, const G& g)
+        helper_composed_<T2,T1,E,true>::helper_composed_(const T2& f, const T1& g)
           :f_(f),
            g_(g)
         {
           this->m_ = f_.mat() * g_.mat();
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
-        typename helper_composed_<F,G,E,true>::invert
-        helper_composed_<F,G,E,true>::inv() const
+        typename helper_composed_<T2,T1,E,true>::invert
+        helper_composed_<T2,T1,E,true>::inv() const
         {
           return compose(g_.inv(), f_.inv());
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
         void
-        helper_composed_<F,G,E,true>::set_first(const F& f)
+        helper_composed_<T2,T1,E,true>::set_first(const T2& f)
         {
           this->f_ = f;
           this->m_ = this->f_.mat() * this->g_.mat();
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
         void
-        helper_composed_<F,G,E,true>::set_second(const G& g)
+        helper_composed_<T2,T1,E,true>::set_second(const T1& g)
         {
           this->g_ = g;
           this->m_ = this->f_.mat() * this->g_.mat();
         }
 
         // Implementation of the non bijective version.
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
-        helper_composed_<F,G,E,false>::helper_composed_()
+        helper_composed_<T2,T1,E,false>::helper_composed_()
         {
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
-        helper_composed_<F,G,E,false>::helper_composed_(const F& f, const G& g)
+        helper_composed_<T2,T1,E,false>::helper_composed_(const T2& f, const T1& g)
           :f_(f),
            g_(g)
         {
           this->m_ = f_.mat() * g_.mat();
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
         void
-        helper_composed_<F,G,E,false>::set_first(const F& f)
+        helper_composed_<T2,T1,E,false>::set_first(const T2& f)
         {
           this->f_ = f;
           this->m_ = this->f_.mat() * this->g_.mat();
         }
 
-        template <typename F, typename G, typename E>
+        template <typename T2, typename T1, typename E>
         inline
         void
-        helper_composed_<F,G,E,false>::set_second(const G& g)
+        helper_composed_<T2,T1,E,false>::set_second(const T1& g)
         {
           this->g_ = g;
           this->m_ = this->f_.mat() * this->g_.mat();
@@ -257,12 +253,12 @@ namespace mln
 
   } // end of namespace mln::fun
 
-  template <typename F, typename G>
+  template <typename T2, typename T1>
   inline
-  fun::x2x::composed<F,G> compose(F f, G g)
+  fun::x2x::composed<T2,T1> compose(T2 f, T1 g)
   {
     trace::entering("fun::x2x::compose");
-    fun::x2x::composed<F,G> comp(f, g);
+    fun::x2x::composed<T2,T1> comp(f, g);
     trace::exiting("fun::x2x::compose");
     return comp;
   }
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/core/internal/neighborhood_base.hh,
	* mln/core/internal/window_base.hh: add is_valid()
	* mln/accu/transform.hh,
	* mln/accu/transform_diagonal.hh,
	* mln/accu/transform_directional.hh,
	* mln/accu/transform_snake.hh,
	* mln/accu/transform_stop.hh,
	* mln/canvas/distance_front.hh,
	* mln/canvas/distance_geodesic.hh,
	* mln/canvas/labeling.hh,
	* mln/convert/to_image.hh,
	* mln/core/concept/neighborhood.hh,
	* mln/core/concept/window.hh,
	* mln/core/w_window.hh,
	* mln/geom/delta.hh,
	* mln/labeling/background.hh,
	* mln/labeling/foreground.hh,
	* mln/labeling/level.hh,
	* mln/level/median.hh,
	* mln/linear/convolve.hh,
	* mln/morpho/elementary/closing.hh,
	* mln/morpho/elementary/dilation.hh,
	* mln/morpho/elementary/erosion.hh,
	* mln/morpho/elementary/gradient.hh,
	* mln/morpho/elementary/gradient_external.hh,
	* mln/morpho/elementary/gradient_internal.hh,
	* mln/morpho/elementary/laplacian.hh,
	* mln/morpho/elementary/opening.hh,
	* mln/morpho/elementary/top_hat.hh,
	* mln/morpho/general.hh,
	* mln/morpho/tree/compute_parent.hh,
	* mln/morpho/tree/max.hh,
	* mln/transform/distance_front.hh,
	* mln/transform/distance_geodesic.hh,
	* mln/transform/influence_zone_front.hh,
	* mln/transform/influence_zone_geodesic.hh,
	* mln/win/sym.hh: enable preconditions.
---
 milena/ChangeLog                                  |   43 +++++++++++++++++++++
 milena/mln/accu/transform.hh                      |   25 ++++++------
 milena/mln/accu/transform_diagonal.hh             |    5 +-
 milena/mln/accu/transform_directional.hh          |    5 +-
 milena/mln/accu/transform_snake.hh                |    5 +-
 milena/mln/accu/transform_stop.hh                 |   21 +++++-----
 milena/mln/canvas/distance_front.hh               |    5 +-
 milena/mln/canvas/distance_geodesic.hh            |    5 +-
 milena/mln/canvas/labeling.hh                     |    6 +-
 milena/mln/convert/to_image.hh                    |    6 +-
 milena/mln/core/concept/neighborhood.hh           |    2 +-
 milena/mln/core/concept/window.hh                 |   10 ++---
 milena/mln/core/internal/neighborhood_base.hh     |   10 +++++
 milena/mln/core/internal/window_base.hh           |   29 ++++++++++----
 milena/mln/core/w_window.hh                       |    2 +-
 milena/mln/geom/delta.hh                          |    8 ++--
 milena/mln/labeling/background.hh                 |    2 +-
 milena/mln/labeling/foreground.hh                 |    2 +-
 milena/mln/labeling/level.hh                      |    2 +-
 milena/mln/level/median.hh                        |    6 +-
 milena/mln/linear/convolve.hh                     |    6 +-
 milena/mln/morpho/elementary/closing.hh           |   12 +++---
 milena/mln/morpho/elementary/dilation.hh          |    7 ++-
 milena/mln/morpho/elementary/erosion.hh           |    4 +-
 milena/mln/morpho/elementary/gradient.hh          |    4 +-
 milena/mln/morpho/elementary/gradient_external.hh |    7 ++-
 milena/mln/morpho/elementary/gradient_internal.hh |    7 ++-
 milena/mln/morpho/elementary/laplacian.hh         |    5 +-
 milena/mln/morpho/elementary/opening.hh           |   12 +++---
 milena/mln/morpho/elementary/top_hat.hh           |   20 +++++-----
 milena/mln/morpho/general.hh                      |    2 +-
 milena/mln/morpho/tree/compute_parent.hh          |    2 +-
 milena/mln/morpho/tree/max.hh                     |    2 +-
 milena/mln/transform/distance_front.hh            |    4 +-
 milena/mln/transform/distance_geodesic.hh         |    2 +-
 milena/mln/transform/influence_zone_front.hh      |    4 +-
 milena/mln/transform/influence_zone_geodesic.hh   |    2 +-
 milena/mln/win/sym.hh                             |    4 +-
 38 files changed, 189 insertions(+), 116 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5debdb3..772b56b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,47 @@
 2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
+	Add is_valid() to window and neighborhood.
+
+	* mln/core/internal/neighborhood_base.hh,
+	* mln/core/internal/window_base.hh: add is_valid()
+
+	* mln/accu/transform.hh,
+	* mln/accu/transform_diagonal.hh,
+	* mln/accu/transform_directional.hh,
+	* mln/accu/transform_snake.hh,
+	* mln/accu/transform_stop.hh,
+	* mln/canvas/distance_front.hh,
+	* mln/canvas/distance_geodesic.hh,
+	* mln/canvas/labeling.hh,
+	* mln/convert/to_image.hh,
+	* mln/core/concept/neighborhood.hh,
+	* mln/core/concept/window.hh,
+	* mln/core/w_window.hh,
+	* mln/geom/delta.hh,
+	* mln/labeling/background.hh,
+	* mln/labeling/foreground.hh,
+	* mln/labeling/level.hh,
+	* mln/level/median.hh,
+	* mln/linear/convolve.hh,
+	* mln/morpho/elementary/closing.hh,
+	* mln/morpho/elementary/dilation.hh,
+	* mln/morpho/elementary/erosion.hh,
+	* mln/morpho/elementary/gradient.hh,
+	* mln/morpho/elementary/gradient_external.hh,
+	* mln/morpho/elementary/gradient_internal.hh,
+	* mln/morpho/elementary/laplacian.hh,
+	* mln/morpho/elementary/opening.hh,
+	* mln/morpho/elementary/top_hat.hh,
+	* mln/morpho/general.hh,
+	* mln/morpho/tree/compute_parent.hh,
+	* mln/morpho/tree/max.hh,
+	* mln/transform/distance_front.hh,
+	* mln/transform/distance_geodesic.hh,
+	* mln/transform/influence_zone_front.hh,
+	* mln/transform/influence_zone_geodesic.hh,
+	* mln/win/sym.hh: enable preconditions.
+
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
   
 	Cleanup accu::rms.
 
diff --git a/milena/mln/accu/transform.hh b/milena/mln/accu/transform.hh
index f5f9096..b673549 100644
--- a/milena/mln/accu/transform.hh
+++ b/milena/mln/accu/transform.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -47,13 +48,13 @@ namespace mln
 
     template <typename I, typename A, typename W>
     mln_ch_value(I, mln_result(A))
-      transform(const Image<I>& input, 
+      transform(const Image<I>& input,
 		const Accumulator<A>& a,
 		const Window<W>& win);
 
     template <typename I, typename A, typename W>
     mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
-      transform(const Image<I>& input, 
+      transform(const Image<I>& input,
 		const Meta_Accumulator<A>& a,
 		const Window<W>& win);
 
@@ -69,7 +70,7 @@ namespace mln
 
       namespace generic
       {
-	
+
 	template <typename I, typename A, typename W>
 	mln_ch_value(I, mln_result(A))
 	  transform(const Image<I>& input_,
@@ -83,10 +84,10 @@ namespace mln
 	  A a = exact(a_);
 
 	  mln_precondition(input.is_valid());
-	  // mln_precondition(win.is_valid());
+	  mln_precondition(win.is_valid());
 
 	  extension::adjust(input, win);
-	  
+
 	  mln_ch_value(I, mln_result(A)) output;
 	  initialize(output, input);
 
@@ -106,7 +107,7 @@ namespace mln
 
       } // end of namespace mln::accu::impl::generic
 
-	
+
       // Fastest version.
 
       template <typename I, typename A, typename W>
@@ -120,10 +121,10 @@ namespace mln
 	A a = exact(a_);
 
 	mln_precondition(input.is_valid());
-	// mln_precondition(win.is_valid());
+	mln_precondition(win.is_valid());
 
 	extension::adjust(input, win);
-	  
+
 	typedef mln_ch_value(I, mln_result(A)) O;
 	O output;
 	initialize(output, input);
@@ -143,7 +144,7 @@ namespace mln
 	return output;
       }
 
-      
+
     } // end of namespace mln::accu::impl
 
 
@@ -189,7 +190,7 @@ namespace mln
       trace::entering("accu::transform");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
 
       mln_ch_value(I, mln_result(A)) output;
       output = internal::transform_dispatch(input, a, win);
@@ -205,7 +206,7 @@ namespace mln
       trace::entering("accu::transform");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
 
       typedef mln_accu_with(A, mln_value(I)) A_;
       A_ a_ = accu::unmeta(exact(a), mln_value(I)());
diff --git a/milena/mln/accu/transform_diagonal.hh b/milena/mln/accu/transform_diagonal.hh
index 18d396b..c8788e6 100644
--- a/milena/mln/accu/transform_diagonal.hh
+++ b/milena/mln/accu/transform_diagonal.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -90,7 +91,7 @@ namespace mln
 
 	mln_precondition(input.is_valid());
 	mln_precondition(! win.is_empty());
-	// mln_precondition(! win.is_valid());
+	mln_precondition(! win.is_valid());
 
 	(void) input;
 	(void) win;
diff --git a/milena/mln/accu/transform_directional.hh b/milena/mln/accu/transform_directional.hh
index 16f5dd0..6a78fcd 100644
--- a/milena/mln/accu/transform_directional.hh
+++ b/milena/mln/accu/transform_directional.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -88,7 +89,7 @@ namespace mln
 
 	mln_precondition(input.is_valid());
 	mln_precondition(! win.is_empty());
-	// mln_precondition(! win.is_valid());
+	mln_precondition(! win.is_valid());
 
 	(void) input;
 	(void) win;
diff --git a/milena/mln/accu/transform_snake.hh b/milena/mln/accu/transform_snake.hh
index fa3da5b..98bcf93 100644
--- a/milena/mln/accu/transform_snake.hh
+++ b/milena/mln/accu/transform_snake.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -83,7 +84,7 @@ namespace mln
 
 	mln_precondition(input.is_valid());
 	mln_precondition(! win.is_empty());
-	// mln_precondition(! win.is_valid());
+	mln_precondition(! win.is_valid());
 
 	(void) input;
 	(void) win;
diff --git a/milena/mln/accu/transform_stop.hh b/milena/mln/accu/transform_stop.hh
index 1978b32..bfbc3a4 100644
--- a/milena/mln/accu/transform_stop.hh
+++ b/milena/mln/accu/transform_stop.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -65,7 +66,7 @@ namespace mln
 
       namespace generic
       {
-	
+
 	template <typename I, typename A, typename W>
 	mln_ch_value(I, mln_result(A))
 	transform_stop(const Image<I>& input_,
@@ -79,10 +80,10 @@ namespace mln
 	  A a = exact(a_);
 
 	  mln_precondition(input.is_valid());
-	  // mln_precondition(win.is_valid());
+	  mln_precondition(win.is_valid());
 
 	  extension::adjust(input, win);
-	  
+
 	  mln_ch_value(I, mln_result(A)) output;
 	  initialize(output, input);
 
@@ -106,7 +107,7 @@ namespace mln
 
       } // end of namespace mln::accu::impl::generic
 
-	
+
       // Fastest version.
 
       template <typename I, typename A, typename W>
@@ -120,10 +121,10 @@ namespace mln
 	A a = exact(a_);
 
 	mln_precondition(input.is_valid());
-	// mln_precondition(win.is_valid());
+	mln_precondition(win.is_valid());
 
 	extension::adjust(input, win);
-	  
+
 	typedef mln_ch_value(I, mln_result(A)) O;
 	O output;
 	initialize(output, input);
@@ -147,7 +148,7 @@ namespace mln
 	return output;
       }
 
-      
+
     } // end of namespace mln::accu::impl
 
 
@@ -193,7 +194,7 @@ namespace mln
       trace::entering("accu::transform_stop");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
 
       mln_ch_value(I, mln_result(A)) output;
       output = internal::transform_stop_dispatch(input, a, win);
@@ -209,7 +210,7 @@ namespace mln
       trace::entering("accu::transform_stop");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
 
       typedef mln_accu_with(A, mln_value(I)) A_;
       A_ a_ = accu::unmeta(exact(a), mln_value(I)());
diff --git a/milena/mln/canvas/distance_front.hh b/milena/mln/canvas/distance_front.hh
index caefa91..ac02d2c 100644
--- a/milena/mln/canvas/distance_front.hh
+++ b/milena/mln/canvas/distance_front.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -75,7 +76,7 @@ namespace mln
       const W& w_win = exact(w_win_);
 
       mln_precondition(input.is_valid());
-      // mln_precondition(w_win.is_valid());
+      mln_precondition(w_win.is_valid());
 
       typedef mln_site(I) P;
       typedef std::vector<P> bucket_t;
diff --git a/milena/mln/canvas/distance_geodesic.hh b/milena/mln/canvas/distance_geodesic.hh
index 123bb24..f51e900 100644
--- a/milena/mln/canvas/distance_geodesic.hh
+++ b/milena/mln/canvas/distance_geodesic.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -70,7 +71,7 @@ namespace mln
       const N& nbh   = exact(nbh_);
 
       mln_precondition(input.is_valid());
-      // mln_precondition(nbh.is_valid());
+      mln_precondition(nbh.is_valid());
 
       mln_ch_value(I, D) dmap; // Distance map is aux data.
       initialize(dmap, input);
diff --git a/milena/mln/canvas/labeling.hh b/milena/mln/canvas/labeling.hh
index c8a9e5c..cdd0b10 100644
--- a/milena/mln/canvas/labeling.hh
+++ b/milena/mln/canvas/labeling.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -70,7 +70,7 @@ namespace mln
 	const N& nbh   = exact(nbh_);
 
 	mln_precondition(input.is_valid());
-	// mln_precondition(nbh.is_valid());
+	mln_precondition(nbh.is_valid());
 
 	(void) input;
 	(void) nbh;
diff --git a/milena/mln/convert/to_image.hh b/milena/mln/convert/to_image.hh
index e71aeda..9be01d3 100644
--- a/milena/mln/convert/to_image.hh
+++ b/milena/mln/convert/to_image.hh
@@ -108,7 +108,7 @@ namespace mln
     to_image(const Window<W>& win)
     {
       mln_is_simple_window(W)::check();
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
       mln_image_from_grid(mln_site(W)::grid, bool) tmp;
       convert::from_to(win, tmp);
       return tmp;
@@ -120,7 +120,7 @@ namespace mln
     to_image(const Weighted_Window<W>& w_win)
     {
       mln_is_simple_window(W)::check();
-      // mln_precondition(exact(w_win).is_valid());
+      mln_precondition(exact(w_win).is_valid());
       mln_image_from_grid(mln_site(W)::grid, mln_weight(W)) tmp;
       convert::from_to(exact(w_win), tmp);
       return tmp;
@@ -131,7 +131,7 @@ namespace mln
     mln_image_from_grid(mln_site(N)::grid, bool)
     to_image(const Neighborhood<N>& nbh)
     {
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
       return to_image(exact(nbh).win());
     }
 
diff --git a/milena/mln/core/concept/neighborhood.hh b/milena/mln/core/concept/neighborhood.hh
index f5df84a..5547865 100644
--- a/milena/mln/core/concept/neighborhood.hh
+++ b/milena/mln/core/concept/neighborhood.hh
@@ -152,7 +152,7 @@ namespace mln
     const I& ima = exact(ima_);
     const N& nbh = exact(nbh_);
     mln_precondition(ima.is_valid());
-    // mln_precondition(nbh.is_valid());
+    mln_precondition(nbh.is_valid());
 
     return offsets_wrt(ima, nbh.win());
   }
diff --git a/milena/mln/core/concept/window.hh b/milena/mln/core/concept/window.hh
index 3b4dfe5..64b05fe 100644
--- a/milena/mln/core/concept/window.hh
+++ b/milena/mln/core/concept/window.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -34,8 +34,6 @@
 ///
 /// \todo Operator== should test if the cmp is possible.
 ///
-/// \todo Add an is_valid() method.
-///
 /// \todo The is_centered() method could also exist when the window is
 /// not regular...
 
@@ -327,7 +325,7 @@ namespace mln
     const I& ima = exact(ima_);
     const W& win = exact(win_);
     mln_precondition(ima.is_valid());
-    // mln_precondition(win.is_valid());
+    mln_precondition(win.is_valid());
 
     util::array<int> arr;
     unsigned n = win.size();
@@ -357,7 +355,7 @@ namespace mln
 	const W& win = exact(win_);
 	I& ima = exact(ima_);
 
-	// mln_precondition(win.is_valid());
+	mln_precondition(win.is_valid());
 	mln_precondition(! ima.is_valid());
 
 	// Hack (below) to avoid circular dependency.
diff --git a/milena/mln/core/internal/neighborhood_base.hh b/milena/mln/core/internal/neighborhood_base.hh
index 35349fc..210408e 100644
--- a/milena/mln/core/internal/neighborhood_base.hh
+++ b/milena/mln/core/internal/neighborhood_base.hh
@@ -133,6 +133,9 @@ namespace mln
       /// Site associated type.
       typedef mln_site(W) site;
 
+      /// Return true by default.
+      bool is_valid() const;
+
     protected:
       neighborhood_base();
     };
@@ -151,6 +154,13 @@ namespace mln
     {
     }
 
+    template <typename W, typename E>
+    inline
+    bool
+    neighborhood_base<W,E>::is_valid() const
+    {
+      return true;
+    }
 
     // neighborhood_impl
 
diff --git a/milena/mln/core/internal/window_base.hh b/milena/mln/core/internal/window_base.hh
index 68f9f83..3ab8664 100644
--- a/milena/mln/core/internal/window_base.hh
+++ b/milena/mln/core/internal/window_base.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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
@@ -28,10 +29,9 @@
 #ifndef MLN_CORE_INTERNAL_WINDOW_BASE_HH
 # define MLN_CORE_INTERNAL_WINDOW_BASE_HH
 
-/*! \file mln/core/internal/window_base.hh
- *
- * \brief Definition of a base class for window classes.
- */
+/// \file mln/core/internal/window_base.hh
+///
+/// Definition of a base class for window classes.
 
 # include <mln/core/concept/window.hh>
 
@@ -43,10 +43,10 @@ namespace mln
   {
 
 
-    /*! A base class for window classes.
-     *
-     * \p D is a dpsite type.
-     */
+    /// A base class for window classes.
+    ///
+    /// \p D is a dpsite type.
+    ///
     template <typename D, typename E>
     struct window_base : public Window<E>
     {
@@ -64,6 +64,9 @@ namespace mln
       // This method is used in the neighborhood window-adapter.
       bool is_neighbable_() const;
 
+      /// return true by default.
+      bool is_valid() const;
+
     protected:
       window_base();
     };
@@ -80,6 +83,14 @@ namespace mln
     template <typename D, typename E>
     inline
     bool
+    window_base<D,E>::is_valid() const
+    {
+      return true;
+    }
+
+    template <typename D, typename E>
+    inline
+    bool
     window_base<D,E>::is_neighbable_() const
     {
       return exact(this)->is_symmetric() && ! exact(this)->is_centered();
diff --git a/milena/mln/core/w_window.hh b/milena/mln/core/w_window.hh
index ac55e2a..adacb7e 100644
--- a/milena/mln/core/w_window.hh
+++ b/milena/mln/core/w_window.hh
@@ -348,7 +348,7 @@ namespace mln
 
 	I& ima = exact(ima_);
 	mln_precondition(! ima.is_valid());
-	// mln_precondition(w_win.is_valid());
+	mln_precondition(w_win.is_valid());
 
 	ima.init_(geom::bbox(w_win));
 	{
diff --git a/milena/mln/geom/delta.hh b/milena/mln/geom/delta.hh
index dd7dac4..68afa31 100644
--- a/milena/mln/geom/delta.hh
+++ b/milena/mln/geom/delta.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
 // (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
@@ -98,7 +98,7 @@ namespace mln
     template <typename W>
     unsigned delta(const Window<W>& win)
     {
-      // mln_precondition(exact(win).is_valid());
+      mln_precondition(exact(win).is_valid());
       return internal::delta_dispatch(mln_trait_window_support(W)(),
 				      mln_trait_window_definition(W)(),
 				      exact(win));
@@ -107,14 +107,14 @@ namespace mln
     template <typename W>
     unsigned delta(const Weighted_Window<W>& wwin)
     {
-      // mln_precondition(exact(wwin).is_valid());
+      mln_precondition(exact(wwin).is_valid());
       return delta(exact(wwin).win());
     }
 
     template <typename N>
     unsigned delta(const Neighborhood<N>& nbh)
     {
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
       return delta(exact(nbh).win());
     }
 
diff --git a/milena/mln/labeling/background.hh b/milena/mln/labeling/background.hh
index 30187bd..14e48eb 100644
--- a/milena/mln/labeling/background.hh
+++ b/milena/mln/labeling/background.hh
@@ -77,7 +77,7 @@ namespace mln
       mlc_equal(mln_trait_image_kind(I),
 		mln::trait::image::kind::binary)::check();
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
 
       mln_ch_value(I, L) output = labeling::level(input, false, nbh, nlabels);
 
diff --git a/milena/mln/labeling/foreground.hh b/milena/mln/labeling/foreground.hh
index b5a28e4..b86a718 100644
--- a/milena/mln/labeling/foreground.hh
+++ b/milena/mln/labeling/foreground.hh
@@ -77,7 +77,7 @@ namespace mln
       mlc_equal(mln_trait_image_kind(I),
 		mln::trait::image::kind::binary)::check();
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
 
       mln_ch_value(I, L) output = labeling::level(input, true, nbh, nlabels);
 
diff --git a/milena/mln/labeling/level.hh b/milena/mln/labeling/level.hh
index 17850bc..563e9b9 100644
--- a/milena/mln/labeling/level.hh
+++ b/milena/mln/labeling/level.hh
@@ -79,7 +79,7 @@ namespace mln
 		  L& nlabels)
       {
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	(void) input;
 	(void) val;
diff --git a/milena/mln/level/median.hh b/milena/mln/level/median.hh
index 29eaa99..4a5c3cd 100644
--- a/milena/mln/level/median.hh
+++ b/milena/mln/level/median.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -79,7 +79,7 @@ namespace mln
       median_tests(const Image<I>& input, const Window<W>& win)
       {
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(win).is_valid());
+	mln_precondition(exact(win).is_valid());
 	(void) input;
 	(void) win;
       }
diff --git a/milena/mln/linear/convolve.hh b/milena/mln/linear/convolve.hh
index 1996f76..64779df 100644
--- a/milena/mln/linear/convolve.hh
+++ b/milena/mln/linear/convolve.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -75,7 +75,7 @@ namespace mln
 		     const Weighted_Window<W>& w_win)
       {
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(w_win).is_valid());
+	mln_precondition(exact(w_win).is_valid());
 	(void) input;
 	(void) w_win;
       }
diff --git a/milena/mln/morpho/elementary/closing.hh b/milena/mln/morpho/elementary/closing.hh
index fef94c5..eb1b72f 100644
--- a/milena/mln/morpho/elementary/closing.hh
+++ b/milena/mln/morpho/elementary/closing.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -28,10 +29,9 @@
 #ifndef MLN_MORPHO_ELEMENTARY_CLOSING_HH
 # define MLN_MORPHO_ELEMENTARY_CLOSING_HH
 
-/*! \file mln/morpho/elementary/closing.hh
- *
- * \brief Morphological elementary closing.
- */
+/// \file mln/morpho/elementary/closing.hh
+///
+/// Morphological elementary closing.
 
 # include <mln/morpho/elementary/erosion.hh>
 # include <mln/morpho/elementary/dilation.hh>
@@ -62,7 +62,7 @@ namespace mln
 	trace::entering("morpho::elementary::closing");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = erosion(dilation(input, nbh), nbh);
 
diff --git a/milena/mln/morpho/elementary/dilation.hh b/milena/mln/morpho/elementary/dilation.hh
index 8488100..9b169aa 100644
--- a/milena/mln/morpho/elementary/dilation.hh
+++ b/milena/mln/morpho/elementary/dilation.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 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
@@ -100,10 +101,10 @@ namespace mln
 	trace::entering("morpho::elementary::dilation");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = internal::dilation_dispatch(input, nbh);
-	
+
 	mln_postcondition(output >= input);
 	trace::exiting("morpho::elementary::dilation");
 	return output;
diff --git a/milena/mln/morpho/elementary/erosion.hh b/milena/mln/morpho/elementary/erosion.hh
index 765dabe..b51a552 100644
--- a/milena/mln/morpho/elementary/erosion.hh
+++ b/milena/mln/morpho/elementary/erosion.hh
@@ -100,10 +100,10 @@ namespace mln
 	trace::entering("morpho::elementary::erosion");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
-	
+
 	mln_postcondition(output <= input);
 	trace::exiting("morpho::elementary::erosion");
 	return output;
diff --git a/milena/mln/morpho/elementary/gradient.hh b/milena/mln/morpho/elementary/gradient.hh
index 5c98801..9973afb 100644
--- a/milena/mln/morpho/elementary/gradient.hh
+++ b/milena/mln/morpho/elementary/gradient.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
 // (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
@@ -62,7 +62,7 @@ namespace mln
 	gradient_tests(const Image<I>& input, const Neighborhood<N>& nbh)
 	{
 	  mln_precondition(exact(input).is_valid());
-	  // mln_precondition(exact(nbh).is_valid());
+	  mln_precondition(exact(nbh).is_valid());
 	  (void) input;
 	  (void) nbh;
 	}
diff --git a/milena/mln/morpho/elementary/gradient_external.hh b/milena/mln/morpho/elementary/gradient_external.hh
index 6403845..27056db 100644
--- a/milena/mln/morpho/elementary/gradient_external.hh
+++ b/milena/mln/morpho/elementary/gradient_external.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 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
@@ -111,10 +112,10 @@ namespace mln
 	trace::entering("morpho::elementary::gradient_external");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = internal::gradient_external_dispatch(input, nbh);
-	
+
 	trace::exiting("morpho::elementary::gradient_external");
 	return output;
       }
diff --git a/milena/mln/morpho/elementary/gradient_internal.hh b/milena/mln/morpho/elementary/gradient_internal.hh
index 5bc3f3e..844daac 100644
--- a/milena/mln/morpho/elementary/gradient_internal.hh
+++ b/milena/mln/morpho/elementary/gradient_internal.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 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
@@ -111,10 +112,10 @@ namespace mln
 	trace::entering("morpho::elementary::gradient_internal");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
-	
+
 	mln_postcondition(output <= input);
 	trace::exiting("morpho::elementary::gradient_internal");
 	return output;
diff --git a/milena/mln/morpho/elementary/laplacian.hh b/milena/mln/morpho/elementary/laplacian.hh
index 87b0d92..974504c 100644
--- a/milena/mln/morpho/elementary/laplacian.hh
+++ b/milena/mln/morpho/elementary/laplacian.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -66,7 +67,7 @@ namespace mln
 	trace::entering("morpho::elementary::laplacian");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_trait_op_minus_twice(mln_concrete(I)) output;
 	output = gradient_external(input, nbh) - gradient_internal(input, nbh);
diff --git a/milena/mln/morpho/elementary/opening.hh b/milena/mln/morpho/elementary/opening.hh
index 9b19087..50e8df5 100644
--- a/milena/mln/morpho/elementary/opening.hh
+++ b/milena/mln/morpho/elementary/opening.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -28,10 +29,9 @@
 #ifndef MLN_MORPHO_ELEMENTARY_OPENING_HH
 # define MLN_MORPHO_ELEMENTARY_OPENING_HH
 
-/*! \file mln/morpho/elementary/opening.hh
- *
- * \brief Morphological elementary opening.
- */
+/// \file mln/morpho/elementary/opening.hh
+///
+/// Morphological elementary opening.
 
 # include <mln/morpho/elementary/erosion.hh>
 # include <mln/morpho/elementary/dilation.hh>
@@ -62,7 +62,7 @@ namespace mln
 	trace::entering("morpho::elementary::opening");
 
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = dilation(erosion(input, nbh), nbh);
 
diff --git a/milena/mln/morpho/elementary/top_hat.hh b/milena/mln/morpho/elementary/top_hat.hh
index 4bce465..2f5423d 100644
--- a/milena/mln/morpho/elementary/top_hat.hh
+++ b/milena/mln/morpho/elementary/top_hat.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -28,12 +29,11 @@
 #ifndef MLN_MORPHO_ELEMENTARY_TOP_HAT_HH
 # define MLN_MORPHO_ELEMENTARY_TOP_HAT_HH
 
-/*! \file mln/morpho/elementary/top_hat.hh
- *
- * \brief Morphological elementary top-hats.
- *
- * \todo Save memory.
- */
+/// \file mln/morpho/elementary/top_hat.hh
+///
+/// Morphological elementary top-hats.
+///
+/// \todo Save memory.
 
 # include <mln/morpho/elementary/opening.hh>
 # include <mln/morpho/elementary/closing.hh>
@@ -89,7 +89,7 @@ namespace mln
       {
 	trace::entering("morpho::elementary::top_hat_white");
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = morpho::minus(input,
 					       opening(input, nbh));
@@ -107,7 +107,7 @@ namespace mln
       {
 	trace::entering("morpho::elementary::top_hat_black");
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = morpho::minus(closing(input, nbh),
 					       input);
@@ -125,7 +125,7 @@ namespace mln
       {
 	trace::entering("morpho::elementary::top_hat_self_complementary");
 	mln_precondition(exact(input).is_valid());
-	// mln_precondition(exact(nbh).is_valid());
+	mln_precondition(exact(nbh).is_valid());
 
 	mln_concrete(I) output = morpho::minus(closing(input, nbh),
 					       opening(input, nbh));
diff --git a/milena/mln/morpho/general.hh b/milena/mln/morpho/general.hh
index 5ece056..f4590ea 100644
--- a/milena/mln/morpho/general.hh
+++ b/milena/mln/morpho/general.hh
@@ -82,7 +82,7 @@ namespace mln
 
 	mln_precondition(input.is_valid());
 	mln_precondition(! win.is_empty());
-	// mln_precondition(win.is_valid());
+	mln_precondition(win.is_valid());
 
 	(void) op;
 	(void) input;
diff --git a/milena/mln/morpho/tree/compute_parent.hh b/milena/mln/morpho/tree/compute_parent.hh
index 7cfc1d6..3c33e81 100644
--- a/milena/mln/morpho/tree/compute_parent.hh
+++ b/milena/mln/morpho/tree/compute_parent.hh
@@ -92,7 +92,7 @@ namespace mln
 	  const S& s   = exact(s_);
 
 	  mln_precondition(f.is_valid());
-	  // mln_precondition(nbh.is_valid());
+	  mln_precondition(nbh.is_valid());
 	  mln_precondition(s == f.domain());
 
 	  (void) f;
diff --git a/milena/mln/morpho/tree/max.hh b/milena/mln/morpho/tree/max.hh
index b904fff..24938f5 100644
--- a/milena/mln/morpho/tree/max.hh
+++ b/milena/mln/morpho/tree/max.hh
@@ -69,7 +69,7 @@ namespace mln
 	const N& nbh = exact(nbh_);
 
 	mln_precondition(f.is_valid());
-	// mln_precondition(nbh.is_valid());
+	mln_precondition(nbh.is_valid());
 
 	// For the max-tree, childhood maps "increasing level":
 	p_array<mln_psite(I)> s = level::sort_psites_increasing(f);
diff --git a/milena/mln/transform/distance_front.hh b/milena/mln/transform/distance_front.hh
index 4e9feb9..6054aab 100644
--- a/milena/mln/transform/distance_front.hh
+++ b/milena/mln/transform/distance_front.hh
@@ -61,8 +61,8 @@ namespace mln
       trace::entering("transform::distance_front");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
-      // mln_precondition(exact(w_win).is_valid());
+      mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(w_win).is_valid());
 
       mln_ch_value(I, D) output;
       internal::distance_functor<I> f;
diff --git a/milena/mln/transform/distance_geodesic.hh b/milena/mln/transform/distance_geodesic.hh
index e076309..eb4bfa6 100644
--- a/milena/mln/transform/distance_geodesic.hh
+++ b/milena/mln/transform/distance_geodesic.hh
@@ -59,7 +59,7 @@ namespace mln
       trace::entering("transform::distance_geodesic");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
 
       mln_ch_value(I, D) output;
       internal::distance_functor<I> f;
diff --git a/milena/mln/transform/influence_zone_front.hh b/milena/mln/transform/influence_zone_front.hh
index 014f5d6..55e7138 100644
--- a/milena/mln/transform/influence_zone_front.hh
+++ b/milena/mln/transform/influence_zone_front.hh
@@ -65,8 +65,8 @@ namespace mln
       trace::entering("transform::influence_zone_front");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
-      // mln_precondition(exact(w_win).is_valid());
+      mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(w_win).is_valid());
 
       internal::influence_zone_functor<I> f;
       (void) mln::canvas::distance_front(input, nbh, w_win, max, f);
diff --git a/milena/mln/transform/influence_zone_geodesic.hh b/milena/mln/transform/influence_zone_geodesic.hh
index ca8e56b..7a92cff 100644
--- a/milena/mln/transform/influence_zone_geodesic.hh
+++ b/milena/mln/transform/influence_zone_geodesic.hh
@@ -66,7 +66,7 @@ namespace mln
       trace::entering("transform::influence_zone_geodesic");
 
       mln_precondition(exact(input).is_valid());
-      // mln_precondition(exact(nbh).is_valid());
+      mln_precondition(exact(nbh).is_valid());
 
       internal::influence_zone_functor<I> f;
       (void) mln::canvas::distance_geodesic(input, nbh, max, f);
diff --git a/milena/mln/win/sym.hh b/milena/mln/win/sym.hh
index 208f75a..cc0a680 100644
--- a/milena/mln/win/sym.hh
+++ b/milena/mln/win/sym.hh
@@ -62,7 +62,7 @@ namespace mln
     W sym(const Window<W>& win)
     {
       trace::entering("win::sym");
-      // mln_precondition(win.is_valid());
+      mln_precondition(exact(win).is_valid());
       W tmp = exact(win);
       tmp.sym();
       trace::exiting("win::sym");
@@ -74,7 +74,7 @@ namespace mln
     W sym(const Weighted_Window<W>& w_win)
     {
       trace::entering("win::sym");
-      // mln_precondition(win.is_valid());
+      mln_precondition(exact(w_win).is_valid());
       W tmp = exact(w_win);
       tmp.sym();
       trace::exiting("win::sym");
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/accu/rms.hh: rename attributes and add a hook to the underlying
	values.
---
 milena/ChangeLog       |    7 +++++++
 milena/mln/accu/rms.hh |   26 +++++++++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 205f6d9..5debdb3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,11 @@
 2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+  
+	Cleanup accu::rms.
+
+	* mln/accu/rms.hh: rename attributes and add a hook to the underlying
+	values.
+
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
 
 	Add debug::histo.
 
diff --git a/milena/mln/accu/rms.hh b/milena/mln/accu/rms.hh
index 339eabc..35709eb 100644
--- a/milena/mln/accu/rms.hh
+++ b/milena/mln/accu/rms.hh
@@ -66,13 +66,17 @@ namespace mln
       /// Get the value of the accumulator.
       V to_result() const;
 
+      /// Return the underlying value used to compute the result.
+      /// v = sum(t * t);
+      V hook_value_() const;
+
       /// Check whether this accu is able to return a result.
       /// Always true here.
       bool is_valid() const;
 
     protected:
 
-      V t_;
+      V v_;
       unsigned count_;
     };
 
@@ -107,7 +111,7 @@ namespace mln
     void
     rms<T,V>::init()
     {
-      t_ = literal::zero;
+      v_ = literal::zero;
       count_ = 0;
     }
 
@@ -116,7 +120,7 @@ namespace mln
     void
     rms<T,V>::take_as_init(const T& t)
     {
-      t_ += t * t;
+      v_ += t * t;
       ++count_;
     }
 
@@ -125,7 +129,7 @@ namespace mln
     void
     rms<T,V>::take(const T& t)
     {
-      t_ += t * t;
+      v_ += t * t;
       ++count_;
     }
 
@@ -134,7 +138,7 @@ namespace mln
     void
     rms<T,V>::take(const rms<T,V>& other)
     {
-      t_ += other.t_;
+      v_ += other.v_;
       count_ += other.count_;
     }
 
@@ -144,8 +148,16 @@ namespace mln
     rms<T,V>::to_result() const
     {
       if (count_ == 0)
-	return literal::zero;
-      return math::sqrt<V>(t_ / count_);
+	return V(0);
+      return math::sqrt<V>(v_ / count_);
+    }
+
+    template <typename T, typename V>
+    inline
+    V
+    rms<T,V>::hook_value_() const
+    {
+      return v_;
     }
 
     template <typename T, typename V>
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/debug/histo.hh: new. Print a histogram into a plot data file.
	* mln/debug/all.hh: include this new header.
---
 milena/ChangeLog                      |    8 ++++
 milena/mln/debug/all.hh               |    1 +
 milena/mln/debug/{all.hh => histo.hh} |   63 ++++++++++++++++++++++----------
 3 files changed, 52 insertions(+), 20 deletions(-)
 copy milena/mln/debug/{all.hh => histo.hh} (54%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1599b96..205f6d9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2009-02-05  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
+	Add debug::histo.
+
+	* mln/debug/histo.hh: new. Print a histogram into a plot data file.
+
+	* mln/debug/all.hh: include this new header.
+
 2009-02-04  Roland Levillain  <roland(a)lrde.epita.fr>
 
 	Fix the generation of milena/headers.mk.
diff --git a/milena/mln/debug/all.hh b/milena/mln/debug/all.hh
index c01d416..dd1fda8 100644
--- a/milena/mln/debug/all.hh
+++ b/milena/mln/debug/all.hh
@@ -50,6 +50,7 @@ namespace mln
 # include <mln/debug/colorize.hh>
 # include <mln/debug/format.hh>
 # include <mln/debug/draw_graph.hh>
+# include <mln/debug/histo.hh>
 # include <mln/debug/iota.hh>
 # include <mln/debug/println.hh>
 # include <mln/debug/println_with_border.hh>
diff --git a/milena/mln/debug/all.hh b/milena/mln/debug/histo.hh
similarity index 54%
copy from milena/mln/debug/all.hh
copy to milena/mln/debug/histo.hh
index c01d416..1b0bbeb 100644
--- a/milena/mln/debug/all.hh
+++ b/milena/mln/debug/histo.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory
 // (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
@@ -26,36 +26,59 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef MLN_DEBUG_ALL_HH
-# define MLN_DEBUG_ALL_HH
+#ifndef MLN_DEBUG_HISTO_HH
+# define MLN_DEBUG_HISTO_HH
 
-/// \file mln/debug/all.hh
+/// \file mln/debug/histo.hh
 ///
-/// File that includes all debug-related routines.
+/// save a histogram to a plot data file.
 
+# include <vector>
+# include <mln/core/image/image2d.hh>
+# include <mln/draw/line.hh>
 
 namespace mln
 {
 
-  /// Namespace of routines that help to debug.
   namespace debug
   {
-    /// Implementation namespace of debug namespace.
-    namespace impl {}
-  }
 
-}
 
+    void
+    histo_plot(const histo::array<unsigned>& h, const std::string& filename);
 
-# include <mln/debug/colorize.hh>
-# include <mln/debug/format.hh>
-# include <mln/debug/draw_graph.hh>
-# include <mln/debug/iota.hh>
-# include <mln/debug/println.hh>
-# include <mln/debug/println_with_border.hh>
-# include <mln/debug/put_word.hh>
-# include <mln/debug/quiet.hh>
-# include <mln/debug/slices_2d.hh>
+    void
+    histo_plot(const std::vector<unsigned>& h, const std::string& filename);
 
+# ifndef MLN_INCLUDE_ONLY
 
-#endif // ! MLN_DEBUG_ALL_HH
+    void
+    histo_plot(const histo::array<unsigned>& h, const std::string& filename)
+    {
+      mln_precondition(h.is_valid());
+      histo_plot(h.vect(), filename);
+    }
+
+    void
+    histo_plot(const std::vector<unsigned>& h, const std::string& filename)
+    {
+      std::ofstream file(filename.c_str());
+      if (! file)
+      {
+	std::cerr << "error: cannot open file '" << filename << "'!";
+	abort();
+      }
+
+      for (unsigned i = 0; i < h.size(); ++i)
+	file << i << ' ' << h[i] << std::endl;
+    }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+  } // end of namespace mln::debug
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DEBUG_HISTO_HH
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-05  Fabien Freling  <freling(a)lrde.epita.fr>
	Enable the fastest version of labeling.
	* fabien/labeling.hh: Fastest version enabled.
	* fabien/regional_maxima.cc: Launch 10 times the test.
---
 labeling.hh        |    2 +-
 regional_maxima.cc |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
Index: trunk/milena/sandbox/fabien/regional_maxima.cc
===================================================================
--- trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 3292)
+++ trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 3293)
@@ -46,9 +46,12 @@
   using namespace mln;
   using value::int_u8;
 
-  image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
+  image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
 
   unsigned n;
-  debug::println(labeling::regional_maxima(lena, c4(), n));
+  for (int i = 0; i < 10; ++i)
+  {
+    labeling::regional_maxima(lena, c4(), n);
+  }
   mln_assertion(n == 25);
 }
Index: trunk/milena/sandbox/fabien/labeling.hh
===================================================================
--- trunk/milena/sandbox/fabien/labeling.hh	(revision 3292)
+++ trunk/milena/sandbox/fabien/labeling.hh	(revision 3293)
@@ -530,7 +530,7 @@
 	    &&
 	    mln_is_simple_neighborhood(N)::value
 	};
-	return labeling_sorted_dispatch(metal::false_(),
+	return labeling_sorted_dispatch(metal::bool_<test>(),
 	    input, nbh, nlabels,
 	    functor, increasing);
       }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-05  Fabien Freling  <freling(a)lrde.epita.fr>
	Correct generic implementation labeling.
	* fabien/labeling.hh: Minor fixes, fastest version off.
	* fabien/regional_maxima.cc: Print output.
	* fabien/regional_maxima.hh: Correct generic impl.
---
 labeling.hh        |    6 +++---
 regional_maxima.cc |    3 ++-
 regional_maxima.hh |   16 ++++++++--------
 3 files changed, 13 insertions(+), 12 deletions(-)
Index: trunk/milena/sandbox/fabien/regional_maxima.cc
===================================================================
--- trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 3291)
+++ trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 3292)
@@ -38,6 +38,7 @@
 #include "regional_maxima.hh"
 
 #include <tests/data.hh>
+#include <mln/debug/println.hh>
 
 
 int main()
@@ -48,6 +49,6 @@
   image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
 
   unsigned n;
-  labeling::regional_maxima(lena, c4(), n);
+  debug::println(labeling::regional_maxima(lena, c4(), n));
   mln_assertion(n == 25);
 }
Index: trunk/milena/sandbox/fabien/regional_maxima.hh
===================================================================
--- trunk/milena/sandbox/fabien/regional_maxima.hh	(revision 3291)
+++ trunk/milena/sandbox/fabien/regional_maxima.hh	(revision 3292)
@@ -84,15 +84,15 @@
 
 	void init()                              { data::fill(attr, true); }
 	bool handles(const P&) const             { return true; }
-	bool labels(const P& p) const            { return attr.element(p); }
-	bool equiv(const P& n, const P& p) const { return input.element(n) ==
-	    input.element(p); }
-	void do_no_union(const P& n, const P& p) { mln_invariant(input.element(n) >
-								 input.element(p));
-	  attr.element(p) = false; }
+	bool labels(const P& p) const            { return attr(p); }
+	bool equiv(const P& n, const P& p) const { return input(n) ==
+						   input(p); }
+	void do_no_union(const P& n, const P& p) { mln_invariant(input(n) >
+								 input(p));
+						   attr(p) = false; }
 	void init_attr(const P&)                 {}
-	void merge_attr(const P& r, const P& p)  { attr.element(p) = attr.element(p) &&
-	    attr.element(r); }
+	void merge_attr(const P& r, const P& p)  { attr(p) = attr(p) &&
+	    attr(r); }
 
 	// Fastest implementation
 
Index: trunk/milena/sandbox/fabien/labeling.hh
===================================================================
--- trunk/milena/sandbox/fabien/labeling.hh	(revision 3291)
+++ trunk/milena/sandbox/fabien/labeling.hh	(revision 3292)
@@ -154,7 +154,7 @@
 
 	  // First Pass.
 	  {
-	    mln_fwd_piter(S) p(f.s);
+	    mln_fwd_piter(S) p(s);
 	    mln_niter(N) n(nbh, p);
 	    for_all(p) if (f.handles(p))
 	      {
@@ -184,7 +184,7 @@
 
 	  // Second Pass.
 	  {
-	    mln_bkd_piter(S) p(f.s);
+	    mln_bkd_piter(S) p(s);
 	    for_all(p) if (f.handles(p))
 	      {
 		if (parent(p) == p) // if p is root
@@ -530,7 +530,7 @@
 	    &&
 	    mln_is_simple_neighborhood(N)::value
 	};
-	return labeling_sorted_dispatch(metal::bool_<test>(),
+	return labeling_sorted_dispatch(metal::false_(),
 	    input, nbh, nlabels,
 	    functor, increasing);
       }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-05  Fabien Freling  <freling(a)lrde.epita.fr>
	Compile fastest versions of labeling.
	* fabien/labeling.hh: Compile fastest versions.
	* fabien/regional_maxima.cc: Simple test file.
	* fabien/regional_maxima.hh: Functor in fastest implementation.
---
 labeling.hh        |  293 ++++++++++++++++++++++++++---------------------------
 regional_maxima.cc |   53 +++++++++
 regional_maxima.hh |    8 -
 3 files changed, 204 insertions(+), 150 deletions(-)
Index: trunk/milena/sandbox/fabien/regional_maxima.cc
===================================================================
--- trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 0)
+++ trunk/milena/sandbox/fabien/regional_maxima.cc	(revision 3291)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007, 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.
+
+/*! \file tests/labeling/regional_maxima.cc
+ *
+ * \brief Test on mln::labeling::regional_maxima.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/io/pgm/load.hh>
+
+#include "regional_maxima.hh"
+
+#include <tests/data.hh>
+
+
+int main()
+{
+  using namespace mln;
+  using value::int_u8;
+
+  image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
+
+  unsigned n;
+  labeling::regional_maxima(lena, c4(), n);
+  mln_assertion(n == 25);
+}
Index: trunk/milena/sandbox/fabien/regional_maxima.hh
===================================================================
--- trunk/milena/sandbox/fabien/regional_maxima.hh	(revision 3290)
+++ trunk/milena/sandbox/fabien/regional_maxima.hh	(revision 3291)
@@ -35,7 +35,9 @@
 
 # include <mln/core/concept/image.hh>
 # include <mln/core/concept/neighborhood.hh>
-# include <mln/canvas/labeling.hh>
+
+# include "labeling.hh"
+
 # include <mln/data/fill.hh>
 # include <mln/level/sort_psites.hh>
 
@@ -102,7 +104,7 @@
 	void do_no_union_(unsigned n, unsigned p) { mln_invariant(input.element(n) >
 								  input.element(p));
 	  attr.element(p) = false; }
-	void init_attr_(const P&)                 {}
+	void init_attr_(unsigned)                 {}
 	void merge_attr_(unsigned r, unsigned p)  { attr.element(p) = attr.element(p) &&
 	    attr.element(r); }
 
@@ -110,7 +112,7 @@
 
 	mln_ch_value(I, bool) attr;
 
-	regional_maxima_functor(const I_& input, const N_& nbh)
+	regional_maxima_functor(const I& input)
 	  : input(input)
 	{
 	  initialize(attr, input);
Index: trunk/milena/sandbox/fabien/labeling.hh
===================================================================
--- trunk/milena/sandbox/fabien/labeling.hh	(revision 3290)
+++ trunk/milena/sandbox/fabien/labeling.hh	(revision 3291)
@@ -223,105 +223,104 @@
 	if (parent.element(x) == x)
 	  return x;
 	else
-	  return parent.element(x) = find_root(parent, parent.element(x));
+	  return parent.element(x) = find_root_fastest(parent, parent.element(x));
       }
 
-//       // FIXME: Use the same functer for the generic and the fastest versions 
 
-//       template <typename I, typename N, typename L,
-// 		typename F>
-//       mln_ch_value(I, L)
-// 	labeling_fastest_video(const Image<I>& input_, const Neighborhood<N>& nbh_,
-// 			       F& f, L& nlabels)
-//       {
-// 	trace::entering("canvas::impl::labeling");
-
-// 	// FIXME: Test?!
-
-// 	const I& input = exact(input_);
-// 	const N& nbh   = exact(nbh_);
-
-// 	// Local type.
-// 	typedef mln_psite(I) P;
-
-// 	// Auxiliary data.
-// 	mln_ch_value(I, bool) deja_vu;
-// 	mln_ch_value(I, P)    parent;
-
-// 	// Output.
-// 	mln_ch_value(I, L) output;
-// 	bool status;
-
-// 	// Initialization.
-// 	{
-// 	  initialize(deja_vu, input);
-// 	  mln::data::fill(deja_vu, false);
-
-// 	  initialize(parent, input);
-
-// 	  initialize(output, input);
-// 	  mln::data::fill(output, L(literal::zero));
-// 	  nlabels = 0;
-
-// 	  f.init(); // Client initialization.
-// 	}
-
-// 	// First Pass.
-// 	{
-// 	  mln_pixter(const S) p(f.s);
-// 	  mln_nixter(const S, N) n(p, nbh);
-// 	  for_all(p) if (f.handles(p))
-// 	    {
-// 	      // Make-Set.
-// 	      parent.element(p) = p;
-// 	      f.init_attr(p);
-
-// 	      for_all(n)
-// 		if (input.has(n) && deja_vu(n))
-// 		  {
-// 		    if (f.equiv(n, p))
-// 		      {
-// 			// Do-Union.
-// 			unsigned r = find_root_fastest(parent, n);
-// 			if (r != p)
-// 			  {
-// 			    parent.element(r) = p;
-// 			    f.merge_attr(r, p);
-// 			  }
-// 		      }
-// 		    else
-// 		      f.do_no_union(n, p);
-// 		    (p) = true;
-// 		  }
-// 	    }
-// 	}
-
-// 	// Second Pass.
-// 	{
-// 	  mln_bkd_pixter(S) p(f.s);
-// 	  for_all(p) if (f.handles(p))
-// 	    {
-// 	      if (parent.element(p) == p) // if p is root
-// 		{
-// 		  if (f.labels(p))
-// 		    {
-// 		      if (nlabels == mln_max(L))
-// 			{
-// 			  status = false;
-// 			  return output;
-// 			}
-// 		      output.element(p) = ++nlabels;
-// 		    }
-// 		}
-// 	      else
-// 		output.element(p) = output(parent.element(p));
-// 	    }
-// 	  status = true;
-// 	}
-
-// 	trace::exiting("canvas::impl::labeling");
-// 	return output;
-//       }
+      template <typename I, typename N, typename L,
+	       typename F>
+      mln_ch_value(I, L)
+      labeling_video_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
+	  F& f, L& nlabels)
+      {
+	trace::entering("canvas::impl::labeling");
+
+	// FIXME: Test?!
+
+	const I& input = exact(input_);
+	const N& nbh   = exact(nbh_);
+
+	// Local type.
+	typedef mln_psite(I) P;
+
+	// Auxiliary data.
+	mln_ch_value(I, bool) deja_vu;
+	mln_ch_value(I, P)    parent;
+
+	// Output.
+	mln_ch_value(I, L) output;
+	bool status;
+
+	// Initialization.
+	{
+	  initialize(deja_vu, input);
+	  mln::data::fill(deja_vu, false);
+
+	  initialize(parent, input);
+
+	  initialize(output, input);
+	  mln::data::fill(output, L(literal::zero));
+	  nlabels = 0;
+
+	  f.init_(); // Client initialization.
+	}
+
+	// First Pass.
+	{
+	  mln_pixter(const I) p(input);
+	  mln_nixter(const I, N) n(p, nbh);
+	  for_all(p) if (f.handles_(p))
+	  {
+	    // Make-Set.
+	    parent.element(p) = p;
+	    f.init_attr(p);
+
+	    for_all(n)
+	      if (input.has(n) && deja_vu(n))
+	      {
+		if (f.equiv_(n, p))
+		{
+		  // Do-Union.
+		  unsigned r = find_root_fastest(parent, n);
+		  if (r != p)
+		  {
+		    parent.element(r) = p;
+		    f.merge_attr_(r, p);
+		  }
+		}
+		else
+		  f.do_no_union_(n, p);
+		(p) = true;
+	      }
+	  }
+	}
+
+	// Second Pass.
+	{
+	  mln_bkd_pixter(I) p(input);
+	  for_all(p) if (f.handles_(p))
+	  {
+	    if (parent.element(p) == p) // if p is root
+	    {
+	      if (f.labels_(p))
+	      {
+		if (nlabels == mln_max(L))
+		{
+		  status = false;
+		  return output;
+		}
+		output.element(p) = ++nlabels;
+	      }
+	    }
+	    else
+	      output.element(p) = output(parent.element(p));
+	  }
+	  status = true;
+	}
+
+	trace::exiting("canvas::impl::labeling");
+	return output;
+      }
 
 
 
@@ -345,7 +344,7 @@
 
 	// Auxiliary data.
 	mln_ch_value(I, bool) deja_vu;
-	mln_ch_value(I, P)    parent;
+	mln_ch_value(I, unsigned)    parent;
 
 	// Output.
 	mln_ch_value(I, L) output;
@@ -362,13 +361,13 @@
 	  mln::data::fill(output, L(literal::zero));
 	  nlabels = 0;
 
-	  f.init(); // Client initialization.
+	  f.init_(); // Client initialization.
 	}
 
-	util::array<int> dp = offsers_wrt(input, nbh);
+	util::array<int> dp = offsets_wrt(input, nbh);
 	const unsigned n_nbhs = dp.nelements();
 
-	const unsigned n_points = s.elements();
+	const unsigned n_points = s.nelements();
 
 	// First Pass.
 	{
@@ -376,31 +375,31 @@
 	  for (unsigned i = 0; i < n_points; ++i)
 	    {
 	      unsigned p = s[i];
-	      if (!f.handles(p))
+	      if (!f.handles_(p))
 		continue;
 
 	      // Make-Set.
 	      parent.element(p) = p;
-	      f.init_attr(p);
+	      f.init_attr_(p);
 
 	      for (unsigned j = 0; j < n_nbhs; ++j)
 		{
 		  unsigned n = p + dp[j];
-		  if (!deja_vu[n])
+		  if (!deja_vu.element(n))
 		    continue;
 
-		  if (f.equiv(n, p))
+		  if (f.equiv_(n, p))
 		    {
 		      // Do-Union.
 		      unsigned r = find_root_fastest(parent, n);
 		      if (input.element(r) != input.element(p))
 			{
 			  parent.element(r) = p;
-			  f.merge_attr(r, p);
+			  f.merge_attr_(r, p);
 			}
 		    }
 		  else
-		    f.do_no_union(n, p);
+		    f.do_no_union_(n, p);
 		}
 	      deja_vu.element(p) = true;
 
@@ -412,12 +411,12 @@
 	  for (int i = n_points - 1; i >=0; --i)
 	    {
 	      unsigned p = s[i];
-	      if (!f.handles(p))
+	      if (!f.handles_(p))
 		continue;
 
 	      if (parent.element(p) == p) // if p is root
 		{
-		  if (f.labels(p))
+		  if (f.labels_(p))
 		    {
 		      if (nlabels == mln_max(L))
 			{
@@ -428,7 +427,7 @@
 		    }
 		}
 	      else
-		output.element(p) = output(parent.element(p));
+		output.element(p) = output.element(parent.element(p));
 	    }
 	  status = true;
 	}
@@ -446,45 +445,45 @@
     namespace internal
     {
 
-//       // Video
+      // Video
 
-//       template <typename I, typename N, typename L,
-// 		typename F>
-//       inline
-//       mln_ch_value(I, L)
-// 	labeling_video(metal::false_, const Image<I>& input,
-// 		       const Neighborhood<N>& nbh, L& nlabels, F& functor)
-//       {
-// 	return impl::generic::labeling(input, nbh, input.domain(),
-// 				       nlabels, functor);
-//       }
-
-//       template <typename I, typename N, typename L,
-// 		typename F>
-//       inline
-//       mln_ch_value(I, L)
-// 	labeling_video(metal::true_, const Image<I>& input,
-// 		       const Neighborhood<N>& nbh, L& nlabels, F& functor)
-//       {
-// 	return impl::labeling_fastest_video(input, nbh, nlabels, functor);
-//       }
-
-//       template <typename I, typename N, typename L,
-// 		typename F>
-//       inline
-//       mln_ch_value(I, L)
-// 	labeling_video_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
-// 				L& nlabels, F& functor)
-//       {
-// 	enum {
-// 	  test = mlc_equal(mln_trait_image_speed(I),
-// 			   trait::image::speed::fastest)::value
-// 	  &&
-// 	  mln_is_simple_neighborhood(N)::value
-// 	};
-// 	return impl::generic::labeling_video(metal::bool_<test>(), input,
-// 					     nbh, nlabels, functor);
-//       }
+      template <typename I, typename N, typename L,
+		typename F>
+      inline
+      mln_ch_value(I, L)
+      labeling_video(metal::false_, const Image<I>& input,
+	  const Neighborhood<N>& nbh, L& nlabels, F& functor)
+      {
+	return impl::generic::labeling(input, nbh, input.domain(),
+	    nlabels, functor);
+      }
+
+      template <typename I, typename N, typename L,
+	        typename F>
+      inline
+      mln_ch_value(I, L)
+      labeling_video(metal::true_, const Image<I>& input,
+	  const Neighborhood<N>& nbh, L& nlabels, F& functor)
+      {
+	return impl::labeling_video_fastest(input, nbh, nlabels, functor);
+      }
+
+      template <typename I, typename N, typename L,
+	        typename F>
+      inline
+      mln_ch_value(I, L)
+      labeling_video_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+	  L& nlabels, F& functor)
+      {
+	enum {
+	  test = mlc_equal(mln_trait_image_speed(I),
+	      trait::image::speed::fastest)::value
+	    &&
+	    mln_is_simple_neighborhood(N)::value
+	};
+	return impl::generic::labeling(metal::bool_<test>(), input,
+	    nbh, nlabels, functor);
+      }
 
 
       // Sorted dispatch.
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Augment Laurent's code.
	* theo/esiee/laurent/ismm09/topo_wst.cc (ls): Rename as...
	(l_): ...this.
	* theo/esiee/laurent/ismm09/main.cc: Update.
	* theo/esiee/laurent/ismm09/pseudo_tree.hh: Augment.
	* theo/esiee/laurent/ismm09/lca.hh: Update.
 lca.hh         |    2 
 main.cc        |   19 +++---
 pseudo_tree.hh |  178 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 topo_wst.cc    |    8 +-
 4 files changed, 178 insertions(+), 29 deletions(-)
Index: theo/esiee/laurent/ismm09/topo_wst.cc
--- theo/esiee/laurent/ismm09/topo_wst.cc	(revision 3289)
+++ theo/esiee/laurent/ismm09/topo_wst.cc	(working copy)
@@ -81,12 +81,12 @@
       a[++l] = f(p);
   }
 
-  util::array<L> ls = sort_by_increasing_attributes(a, l_max);
+  util::array<L> l_ = sort_by_increasing_attributes(a, l_max);
 
   {
-    std::cout << "ls:" << std::endl;
+    std::cout << "l_:" << std::endl;
     for (unsigned i = 1; i <= l_max; ++i)
-      std::cout << ls[i] << "(" << a[ls[i]] << ") ";
+      std::cout << l_[i] << "(" << a[l_[i]] << ") ";
     std::cout << std::endl
 	      << std::endl;
   }
@@ -95,5 +95,5 @@
 
   // -> pseudo-tree
 
-   compute_pseudo_tree(w_ext, g, ls, a, e_to_l1_l2);
+   compute_pseudo_tree(w_ext, g, l_, a, e_to_l1_l2);
 }
Index: theo/esiee/laurent/ismm09/main.cc
--- theo/esiee/laurent/ismm09/main.cc	(revision 3289)
+++ theo/esiee/laurent/ismm09/main.cc	(working copy)
@@ -91,19 +91,20 @@
 				       w, // image of labels
 				       l_max);
 
-  util::array<L> ls = sort_by_increasing_attributes(a, l_max);
+  util::array<L> l_ = sort_by_increasing_attributes(a, l_max);
 
-//   {
-//     std::cout << "ls:" << std::endl;
-//     for (unsigned i = 1; i <= l_max; ++i)
-//       std::cout << ls[i] << "(" << a[ls[i]] << ") ";
-//     std::cout << std::endl
-// 	      << std::endl;
-//   }
+  {
+    std::cout << "l_:" << std::endl;
+    for (unsigned i = 1; i <= l_max; ++i)
+      std::cout << l_[i] << "(" << a[l_[i]] << ") ";
+    std::cout << std::endl
+	      << std::endl;
+  }
 
 
 
   // -> pseudo-tree
 
-  compute_pseudo_tree(w, g, ls, a, e_to_l1_l2);
+  compute_pseudo_tree(w_ext, g, l_, a, e_to_l1_l2);
+
 }
Index: theo/esiee/laurent/ismm09/pseudo_tree.hh
--- theo/esiee/laurent/ismm09/pseudo_tree.hh	(revision 3289)
+++ theo/esiee/laurent/ismm09/pseudo_tree.hh	(working copy)
@@ -1,10 +1,25 @@
 
 #include <mln/core/concept/image.hh>
+#include <mln/core/site_set/p_set.hh>
 #include <mln/core/site_set/p_queue.hh>
 #include <mln/core/site_set/p_priority.hh>
+
 #include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
 #include <mln/util/array.hh>
 
+#include "lca.hh"
+
+
+// FIXME: Move elsewhere.
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/level/stretch.hh>
+
+
 
 
 namespace mln
@@ -178,20 +193,24 @@
 	    typename F>
   void
   compute_pseudo_tree(const W& w,
-		      const G& g,
-		      const util::array<L>& ls,
-		      const A& a,
+		      const G& g, // FIXME: Directly input g_line?
+		      const util::array<L>& l_,
+		      const util::array<A>& a,
 		      const F& e_to_l1_l2)
   {
 
     typedef mln_value(G) T;    //  <---  Type of edge values.
     typedef mln_psite(G) E;    //  <---  Type of edges.
 
-    const L l_max = ls.nelements() - 1;
+    const L l_max = l_.nelements() - 1;
 
     mln_VAR( g_line, g | (pw::value(w) == 0) );
 
 
+    // Initialization.
+    // -----------------------------------
+
+
     // Edges -> Priority queue.
 
     typedef p_priority< T, p_queue<E> > Q;
@@ -212,8 +231,12 @@
 
 
 
-    // Initialization.
-    // -----------------------------------
+
+    // 'aa' is the resulting attributes on edges.
+
+    mln_ch_value(g_line_t, A) aa;
+    initialize(aa, g_line);
+    data::fill(aa, 0); // FIXME: Safety iff 0 is an invalidate attribute value!
 
 
 
@@ -274,12 +297,13 @@
 
     for (unsigned i = 1; i < l_max; ++i)
       {
-	L l = ls[i]; // Region label.
+	L l = l_[i]; // Region label.
 	L l1, l2;
 	E e;
 	get_smallest_edge(q, // in-out
 			  l, w, lpar, e_to_l1_l2, // in
 			  e, l1, l2); // out
+	aa(e) = a[l];
 
 	L l1r = find_root_l(lpar, l1),
 	  l2r = find_root_l(lpar, l2);
@@ -288,7 +312,7 @@
 	{
 	  if (i > 1)
 	    {
-	      L former_l = ls[i-1];
+	      L former_l = l_[i-1];
 	      mln_invariant(a[l] >= a[former_l]);
 	    }
 	  mln_invariant(epar(e) == e); // 'e' has not been processed yet.
@@ -302,11 +326,6 @@
 	}
 
 
-
-	// aa(e) = a[l]; // FIXME: Re-activate.
-
-
-
 	/*
 	  std::cout << "l = " << l
 	  << "   e = " << e
@@ -422,7 +441,11 @@
 
 
     {
-      // Display edge tree.
+      // Display 'aa' over all edges.
+
+      debug::println("aa (on 'passing' edges):", aa);
+
+      // Display "edge tree".
 
       mln_ch_value(g_line_t, bool) deja_vu;
       initialize(deja_vu, g_line);
@@ -435,15 +458,140 @@
 	  E e = edge[l];
 	  while (! deja_vu(e))
 	    {
-	      std::cout << e << " -> ";
+	      std::cout << e << " [" << aa(e) << "] -> ";
+	      mln_invariant(aa(e) != 0 && aa(epar(e)) != 0); // aa is valid
+	      mln_invariant(aa(epar(e)) >= aa(e));           // edge parenthood goes with 'aa' increasing
 	      deja_vu(e) = true;
 	      e = epar(e);
 	    }
 	  std::cout << e << std::endl;
 	}
+      std::cout << std::endl;
+
+      // Display "region l -> edge e".
+
+      std::cout << "region:(edge)  =  ";
+      for (L l = 1; l <= l_max; ++l)
+	std::cout << l << ':' << edge[l] << "  ";
+      std::cout << std::endl
+		<< std::endl;
+	
+    } // end of Display.
+
+
+
+    // Testing both that all regions and all "smallest" edges have
+    // merged (assumption: connected domain!).
+
+    {
+      L l_1 = l_[1],
+	l_root = find_root_l(lpar, l_1);
+      mln_invariant(edge[l_1] != null);
+      E e_root = find_root_e(z_epar, edge[l_1]);
+      for (unsigned i = 2; i <= l_max; ++i)
+	{
+	  L l = l_[i];
+	  mln_invariant(find_root_l(lpar, l) == l_root);
+	  mln_invariant(edge[l] != null);
+	  mln_invariant(find_root_e(z_epar, edge[l]) == e_root);
+	}
     }
 
+
+    // Finalization.
+
+    A aa_max = mln_min(A);
+
+    {
+      mln_VAR(aa_ext, aa.unmorph_().unmorph_());
+
+
+      debug::println("aa ext (1):", aa_ext);
+
+
+      std::vector<E> roots;
+      mln_VAR(chl, compute_children(epar, edge, l_max, roots));
+
+      // Connected domain so:
+      mln_invariant(roots.size() == 1);
+      E root = roots[0]; // THE root.
+
+      lca_t<L,chl_t,E> lca(l_max, chl, roots);
+
+      mln_piter(g_line_t) e(g_line.domain());
+      for_all(e)
+      {
+	L l1, l2;
+	e_to_l1_l2(e, l1, l2);
+	mln_invariant(l1 != 0 && l2 > l1);
+	E e_ = lca(edge[l1],edge[l2]);
+
+	mln_invariant(g_line.has(e_)); // e_ is a valid edge.
+	mln_invariant(aa(e_) != 0);    // aa is valid at e_.
+      
+	// The attribute value propagates from the lca to the current edge
+	// of the line:
+	aa(e) = aa(e_);
+	if (aa(e) > aa_max)
+	  aa_max = aa(e);
+      }
+      
+      debug::println("aa:", aa);
+
+      debug::println("aa ext (2):", aa_ext);
+
+      {
+	mln_VAR( aa_line, aa_ext | (pw::value(w) == 0) );
+
+	data::paste(morpho::dilation(extend(aa_line | (pw::value(aa_line) == 0),
+					    aa_line),
+				     c4().win()),
+		    aa_line);
+      }
+
+      debug::println("aa ext (3):", aa_ext);
+
+
+      {
+	using value::int_u8;
+	if (aa_max < 256)
+	  {
+	    image2d<int_u8> output(aa_ext.domain());
+	    data::fill(output, 0);
+	    data::paste(aa_ext, output);
+	    io::pgm::save(output, "aa_line.pgm");
+	  }
+	else
+	  {
+	    std::cerr << "warning: stretching [0," << aa_max << "] to int_u8" << std::endl;
+	  
+	    image2d<int_u8> output(aa_ext.domain());
+	    data::fill(output, 0);
+	    data::paste(aa_ext, output);
+	    io::pgm::save(level::stretch(int_u8(), output),
+			  "aa_line.pgm");
   }
+      }
+
+
+//       mln_VAR(aa_basins, aa_ext | (pw::value(w) != 0));
+//       {
+// 	mln_piter(aa_basins_t) p(aa_basins.domain());
+// 	for_all(p)
+// 	{
+// 	  L l = w(p);
+// 	  aa_basins(p) = aa( edge[l] ); // FIXME: was: a[w(p)];
+// 	}
+//       }
+
+
+//       debug::println("aa ext (4):", aa_ext);
+
+    }
+
+
+  }
+
 
 } // end of namespace mln
 
Index: theo/esiee/laurent/ismm09/lca.hh
--- theo/esiee/laurent/ismm09/lca.hh	(revision 3289)
+++ theo/esiee/laurent/ismm09/lca.hh	(working copy)
@@ -7,7 +7,7 @@
 
   template <typename I, typename E, typename L>
   mln_ch_value(I, std::vector<mln_psite(I)>)
-    compute_children(const I& epar, const std::vector<E>& edge, L l_max, std::vector<E>& roots)
+    compute_children(const I& epar, const util::array<E>& edge, L l_max, std::vector<E>& roots)
   {
     typedef std::vector<mln_psite(I)> C; // Children.
     mln_ch_value(I,C) chl;
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0