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
 
- 9625 discussions
 
                    
                        	* mln/util/internal/graph_edge.hh,
	* mln/util/internal/graph_base.hh,
	* mln/core/site_set/p_edges.hh,
	* mln/core/site_set/p_vertices.hh: fix compilation issues.
	* mln/fun/i2v/array.hh,
	* mln/pw/image.hh,
	* mln/core/site_set/p_graph_piter.hh: cleanup.
	* mln/util/internal/graph_vertex_psite.hh,
	* mln/util/graph.hh: fix wrong include.
	* tests/core/site_set/pset_if.cc: use geom::nsites() instead of
	estim::nsites().
---
 milena/ChangeLog                               |   19 +++
 milena/mln/core/site_set/p_edges.hh            |    2 +-
 milena/mln/core/site_set/p_graph_piter.hh      |  140 +-----------------------
 milena/mln/core/site_set/p_vertices.hh         |    6 +-
 milena/mln/fun/i2v/array.hh                    |    2 +-
 milena/mln/pw/image.hh                         |    2 +-
 milena/mln/util/graph.hh                       |    3 +-
 milena/mln/util/internal/graph_base.hh         |   23 +++-
 milena/mln/util/internal/graph_edge.hh         |    2 +-
 milena/mln/util/internal/graph_vertex_psite.hh |    1 +
 milena/tests/core/site_set/pset_if.cc          |    4 +-
 11 files changed, 49 insertions(+), 155 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b0a73d6..4535ac6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -14,6 +14,25 @@
 
 2008-10-26  Guillaume Lazzara  <z(a)lrde.epita.fr>
 
+	Various small Fixes and cleanup.
+
+	* mln/util/internal/graph_edge.hh,
+	* mln/util/internal/graph_base.hh,
+	* mln/core/site_set/p_edges.hh,
+	* mln/core/site_set/p_vertices.hh: fix compilation issues.
+
+	* mln/fun/i2v/array.hh,
+	* mln/pw/image.hh,
+	* mln/core/site_set/p_graph_piter.hh: cleanup.
+
+	* mln/util/internal/graph_vertex_psite.hh,
+	* mln/util/graph.hh: fix wrong include.
+
+	* tests/core/site_set/pset_if.cc: use geom::nsites() instead of
+	estim::nsites().
+
+2008-10-26  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
 	Change return type of Site_set::nsites() from unsigned to std:size_t.
 
 	* mln/core/concept/box.hh,
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index 3c94998..16d7c45 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -207,7 +207,7 @@ namespace mln
   p_edges<G, F>::has(const util::edge<G2>& e) const
   {
     mln_precondition(is_valid());
-    return e.g()->is_subgraph_of(*g_) && g_->has(e) && e.is_valid();
+    return e.g().is_subgraph_of(*g_) && g_->has(e) && e.is_valid();
   }
 
   template <typename G, typename F>
diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh
index 2a235c5..da5ae3d 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -35,10 +35,6 @@
 //# include <mln/core/site_set/p_graph.hh>
 //# include <mln/core/image/graph_psite.hh>
 
-/* FIXME: Iterators on p_graph and p_line_graph share common code.
-   Factor as much as possible.  */
-
-
 namespace mln
 {
   // Fwd decls.
@@ -49,7 +45,7 @@ namespace mln
   | p_graph_piter<S,I>.  |
   `------------------------*/
 
-  /// \brief Forward iterator on point sites of a mln::S.
+  /// \brief Generic iterator on point sites of a mln::S.
   template <typename S, typename I>
   class p_graph_piter
     : public internal::site_set_iterator_base< S,
@@ -99,66 +95,11 @@ namespace mln
   operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p);
 
 
-  /*------------------------.
-  | p_graph_bkd_piter_<S,I>.  |
-  `------------------------*/
-
-  /// \brief Backward iterator on point sites of a mln::S.
-/*  template <typename S, typename I>
-  class p_graph_bkd_piter_
-    : public internal::site_set_iterator_base< S,
-					       p_graph_bkd_piter_<S,I> >
-  {
-    typedef p_graph_bkd_piter_<S,I> self_;
-    typedef internal::site_set_iterator_base< S, self_ > super_;
-    typedef I iter;
-
-  public:
-    /// Construction and assignment.
-    /// \{
-    p_graph_bkd_piter_();
-    p_graph_bkd_piter_(const S& pv);
-    /// \}
-
-    /// Manipulation.
-    /// \{
-    /// Test if the iterator is valid.
-    bool is_valid_() const;
-    /// Invalidate the iterator.
-    void invalidate_();
-
-    /// Start an iteration.
-    void start_();
-    /// Go to the next point.
-    void next_();
-    /// \}
-
-  private:
-    /// Update the psite corresponding to this iterator.
-    void update_();
-
-  private:
-    /// The psite corresponding to this iterator.
-    using super_::p_;
-
-    /// The underlying vertex iterator.
-    iter iter_;
-  };
-
-
-  /// Print an mln::p_graph_bkd_piter_<S,I>.
-  template <typename S, typename I>
-  inline
-  std::ostream&
-  operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p);
-*/
-
-
 # ifndef MLN_INCLUDE_ONLY
 
-  /*------------------------.
+  /*---------------------.
   | p_graph_piter<S,I>.  |
-  `------------------------*/
+  `---------------------*/
 
   template <typename S, typename I>
   inline
@@ -232,81 +173,6 @@ namespace mln
     return ostr << p.unproxy_();
   }
 
-
-  /*------------------------.
-  | p_graph_bkd_piter_<S,I>.  |
-  `------------------------*/
-
-/*  template <typename S, typename I>
-  inline
-  p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_()
-  {
-    mln_postcondition(!this->is_valid());
-  }
-
-  template <typename S, typename I>
-  inline
-  p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_(const S& pv)
-    : iter_(pv.g())
-  {
-    this->change_target(pv);
-    mln_postcondition(!this->is_valid());
-  }
-
-  template <typename S, typename I>
-  inline
-  bool
-  p_graph_bkd_piter_<S,I>::is_valid_() const
-  {
-    return p_.is_valid();
-  }
-
-  template <typename S, typename I>
-  inline
-  void
-  p_graph_bkd_piter_<S,I>::invalidate_()
-  {
-    p_.invalidate();
-  }
-
-  template <typename S, typename I>
-  inline
-  void
-  p_graph_bkd_piter_<S,I>::start_()
-  {
-    iter_.start();
-      if (this->is_valid())
-	update_();
-  }
-
-  template <typename S, typename I>
-  inline
-  void
-  p_graph_bkd_piter_<S,I>::next_()
-  {
-    iter_.next();
-      if (this->is_valid())
-	update_();
-  }
-
-  template <typename S, typename I>
-  inline
-  void
-  p_graph_bkd_piter_<S,I>::update_()
-  {
-    mln_precondition(this->is_valid());
-    // Update psite_.
-    p_.update_id(iter_.id());
-  }
-
-  template <typename S, typename I>
-  inline
-  std::ostream&
-  operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p)
-  {
-    return ostr << p.unproxy_();
-  }
-*/
 # endif // ! MLN_INCLUDE_ONLY
 
 } // end of mln
diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh
index 461bd51..371c581 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -222,7 +222,7 @@ namespace mln
     mln_precondition(is_valid());
     return
       // Check whether P is compatible with this psite set.
-      (p.g() == g_) &&
+      (p.g() == *g_) &&
       // Check that the vertex id of P belongs to the range of valid
       // vertex ids.
       (p.is_valid());
@@ -259,10 +259,6 @@ namespace mln
   bool
   operator==(const p_vertices<G, F>& lhs, const p_vertices<G, F>& rhs)
   {
-    /* FIXME: We should not rely on pointer equality here, as graph
-       will soon become shells using (shared) tracked pointers to
-       actual data.  So, delegate the equality test to the graphs
-       themselves.  */
     return (*lhs.g_) == (*rhs.g_);
   }
 
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 3fb026c..219be8a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -62,7 +62,7 @@ namespace mln
 
 	T operator()(unsigned i) const;
 	T& operator()(unsigned i);
-	
+
       private:
 	std::vector<T> v_;
       };
diff --git a/milena/mln/pw/image.hh b/milena/mln/pw/image.hh
index 624fc11..ba07d40 100644
--- a/milena/mln/pw/image.hh
+++ b/milena/mln/pw/image.hh
@@ -259,7 +259,7 @@ namespace mln
     template <typename F, typename S>
     inline
     mln_result(F)
-      image<F,S>::operator()(const mln_psite(S)& p) const
+    image<F,S>::operator()(const mln_psite(S)& p) const
     {
       mln_precondition(this->data_->pset_.has(p));
       return this->data_->f_(p);
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index aecb8e9..1cafb19 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -33,7 +33,7 @@
 
 # include <mln/util/internal/graph_base.hh>
 # include <mln/util/internal/graph_iter.hh>
-# include <mln/util/internal/graph_nbh_iter_base.hh>
+# include <mln/util/internal/graph_nbh_iter.hh>
 # include <mln/util/ord_pair.hh>
 
 namespace mln
@@ -210,7 +210,6 @@ namespace mln
 
 } // end of namespace mln
 
-
 # ifndef MLN_INCLUDE_ONLY
 
 namespace mln
diff --git a/milena/mln/util/internal/graph_base.hh b/milena/mln/util/internal/graph_base.hh
index d98c6ff..2937258 100644
--- a/milena/mln/util/internal/graph_base.hh
+++ b/milena/mln/util/internal/graph_base.hh
@@ -125,8 +125,14 @@ namespace mln
       };
 
     } // end of namespace mln::util::internal
+
   } // End of namespace mln::util
 
+  template <typename E>
+  bool
+  operator==(const util::internal::graph_base<E>& lhs,
+	     const util::internal::graph_base<E>& rhs);
+
 # ifndef MLN_INCLUDE_ONLY
 
   namespace util
@@ -186,7 +192,7 @@ namespace mln
       bool
       graph_base<E>::has(const util::vertex<E>& v) const
       {
-	return has_v(v.id());
+	return exact(this)->has_v(v.id());
       }
 
       /*--------------.
@@ -198,7 +204,7 @@ namespace mln
       bool
       graph_base<E>::has(const util::edge<E>& e) const
       {
-	return has_e(e.id());
+	return exact(this)->has_e(e.id());
       }
 
       /*--------.
@@ -216,15 +222,14 @@ namespace mln
 	for (unsigned v = 0; v < g->v_nmax(); ++v)
 	  {
 	    ostr << "vertex: " << v << std::endl << " -- adjacent vertices: ";
-	    for (int n = 0; n < g->v_nmax_nbh_vertices(v); ++n)
+	    for (unsigned n = 0; n < g->v_nmax_nbh_vertices(v); ++n)
 	      ostr << g->v_ith_nbh_vertex(v, n) << " ";
 	    ostr << std::endl;
 	  }
 	ostr << std::endl;
 
 	ostr << "edges:" << std::endl;
-	unsigned ei = 0;
-	for (int i = 0; i < g->e_nmax(); ++i)
+	for (unsigned i = 0; i < g->e_nmax(); ++i)
 	  ostr << "edge " << i << ": ("
 	       << g->v1(i) << ", "
 	       << g->v2(i) << " )"
@@ -237,6 +242,14 @@ namespace mln
 
 # endif // ! MLN_INCLUDE_ONLY
 
+  template <typename E>
+  inline
+  bool
+  operator==(const util::internal::graph_base<E>& lhs,
+	     const util::internal::graph_base<E>& rhs)
+  {
+    return lhs.graph_id() == rhs.graph_id();
+  }
 
 } // end of namespace mln
 
diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh
index 42d0e62..510bfd9 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -170,7 +170,7 @@ namespace mln
     template <typename G>
     inline
     edge<G>::edge()
-      : g_(0), id_(0)
+      : id_(0)
     {
     }
 
diff --git a/milena/mln/util/internal/graph_vertex_psite.hh b/milena/mln/util/internal/graph_vertex_psite.hh
index b0b57cd..3db903c 100644
--- a/milena/mln/util/internal/graph_vertex_psite.hh
+++ b/milena/mln/util/internal/graph_vertex_psite.hh
@@ -30,6 +30,7 @@
 
 # include <mln/core/concept/pseudo_site.hh>
 # include <mln/util/internal/graph_psite_base.hh>
+# include <mln/util/internal/graph_vertex.hh>
 
 namespace mln
 {
diff --git a/milena/tests/core/site_set/pset_if.cc b/milena/tests/core/site_set/pset_if.cc
index b4a9469..9918f56 100644
--- a/milena/tests/core/site_set/pset_if.cc
+++ b/milena/tests/core/site_set/pset_if.cc
@@ -36,7 +36,7 @@
 #include <mln/fun/p2b/chess.hh>
 #include <mln/convert/to_image.hh>
 #include <mln/convert/to_p_set.hh>
-#include <mln/estim/nsites.hh>
+#include <mln/geom/nsites.hh>
 
 
 int main()
@@ -44,7 +44,7 @@ int main()
   using namespace mln;
 
   box2d box_8x8 = make::box2d(8, 8);
-  mln_assertion(estim::nsites((box_8x8 | fun::p2b::chess)) == 32);
+  mln_assertion(geom::nsites((box_8x8 | fun::p2b::chess)) == 32);
 
   {
     p_set<point2d> s = convert::to_p_set(box_8x8 | fun::p2b::chess);
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                        
                            
                                
                            
                            2691: Change return type of Site_set::nsites() from	unsigned to std:size_t.
                        
                        
by Guillaume Lazzara 27 Oct '08
                    by Guillaume Lazzara 27 Oct '08
27 Oct '08
                    
                        	* mln/core/concept/box.hh,
	* mln/core/concept/site_set.hh,
	* mln/core/site_set/p_array.hh,
	* mln/core/site_set/p_complex.hh,
	* mln/core/site_set/p_faces.hh,
	* mln/core/site_set/p_graph.hh,
	* mln/core/site_set/p_image.hh,
	* mln/core/site_set/p_key.hh,
	* mln/core/site_set/p_line2d.hh,
	* mln/core/site_set/p_line_graph.hh,
	* mln/core/site_set/p_priority.hh,
	* mln/core/site_set/p_queue.hh,
	* mln/core/site_set/p_queue_fast.hh,
	* mln/core/site_set/p_run.hh,
	* mln/core/site_set/p_set.hh:
	Update declarations.
---
 milena/ChangeLog                         |   21 +++++++++++++++++++++
 milena/mln/core/concept/box.hh           |    6 +++---
 milena/mln/core/concept/site_set.hh      |    3 +--
 milena/mln/core/site_set/p_array.hh      |    4 ++--
 milena/mln/core/site_set/p_complex.hh    |    4 ++--
 milena/mln/core/site_set/p_faces.hh      |    4 ++--
 milena/mln/core/site_set/p_graph.hh      |    4 ++--
 milena/mln/core/site_set/p_image.hh      |    6 +++---
 milena/mln/core/site_set/p_key.hh        |    6 +++---
 milena/mln/core/site_set/p_line2d.hh     |    4 ++--
 milena/mln/core/site_set/p_line_graph.hh |    4 ++--
 milena/mln/core/site_set/p_priority.hh   |    6 +++---
 milena/mln/core/site_set/p_queue.hh      |    4 ++--
 milena/mln/core/site_set/p_queue_fast.hh |    4 ++--
 milena/mln/core/site_set/p_run.hh        |    6 +++---
 milena/mln/core/site_set/p_set.hh        |    4 ++--
 16 files changed, 55 insertions(+), 35 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2c1de6a..b0a73d6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -12,6 +12,27 @@
 	* mln/level/transform.hh,
 	* mln/level/paste.hh: Rename routines.
 
+2008-10-26  Guillaume Lazzara  <z(a)lrde.epita.fr>
+
+	Change return type of Site_set::nsites() from unsigned to std:size_t.
+
+	* mln/core/concept/box.hh,
+	* mln/core/concept/site_set.hh,
+	* mln/core/site_set/p_array.hh,
+	* mln/core/site_set/p_complex.hh,
+	* mln/core/site_set/p_faces.hh,
+	* mln/core/site_set/p_graph.hh,
+	* mln/core/site_set/p_image.hh,
+	* mln/core/site_set/p_key.hh,
+	* mln/core/site_set/p_line2d.hh,
+	* mln/core/site_set/p_line_graph.hh,
+	* mln/core/site_set/p_priority.hh,
+	* mln/core/site_set/p_queue.hh,
+	* mln/core/site_set/p_queue_fast.hh,
+	* mln/core/site_set/p_run.hh,
+	* mln/core/site_set/p_set.hh:
+	Update declarations.
+
 2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
 
 	Fix mln::level::stretch w.r.t. the initialization.
diff --git a/milena/mln/core/concept/box.hh b/milena/mln/core/concept/box.hh
index 607372e..aabb8a7 100644
--- a/milena/mln/core/concept/box.hh
+++ b/milena/mln/core/concept/box.hh
@@ -82,7 +82,7 @@ namespace mln
      *
      * \warning This method is final for all box classes.
      */
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
   protected:
     Box();
@@ -157,12 +157,12 @@ namespace mln
 
   template <typename E>
   inline
-  unsigned
+  std::size_t
   Box<E>::nsites() const
   {
     if (! exact(this)->is_valid())
       return 0;
-    unsigned count = 1;
+    std::size_t count = 1;
     typedef mln_site(E) P; // Helps g++-3.3.5.
     for (unsigned i = 0; i < P::dim; ++i)
       count *= exact(this)->len(i);
diff --git a/milena/mln/core/concept/site_set.hh b/milena/mln/core/concept/site_set.hh
index 40b288e..dff5a11 100644
--- a/milena/mln/core/concept/site_set.hh
+++ b/milena/mln/core/concept/site_set.hh
@@ -186,8 +186,7 @@ namespace mln
     {
       static void run()
       {
-	// FIXME: Return type should be std::size_t.
-	unsigned (E::*m)() const = & E::nsites;
+	std::size_t (E::*m)() const = & E::nsites;
 	m = 0;
       }
     };
diff --git a/milena/mln/core/site_set/p_array.hh b/milena/mln/core/site_set/p_array.hh
index 7e0a95b..31fa521 100644
--- a/milena/mln/core/site_set/p_array.hh
+++ b/milena/mln/core/site_set/p_array.hh
@@ -125,7 +125,7 @@ namespace mln
     void change(const psite& p, const P& new_p);
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Append a point \p p.
@@ -383,7 +383,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_array<P>::nsites() const
   {
     return vect_.size();
diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh
index 7b5e815..5f5c656 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -149,7 +149,7 @@ namespace mln
     /// `known'.)
     /* FIXME: Return type should be std::size_t (see
        mln/core/concept/site_set.hh). */
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Return The number of faces in the complex.
     std::size_t nfaces() const;
@@ -236,7 +236,7 @@ namespace mln
 
   template <unsigned D, typename G>
   inline
-  unsigned
+  std::size_t
   p_complex<D, G>::nsites() const
   {
     return nfaces();
diff --git a/milena/mln/core/site_set/p_faces.hh b/milena/mln/core/site_set/p_faces.hh
index 0d79798..5827ad4 100644
--- a/milena/mln/core/site_set/p_faces.hh
+++ b/milena/mln/core/site_set/p_faces.hh
@@ -120,7 +120,7 @@ namespace mln
     /// `known'.)
     /* FIXME: Return type should be std::size_t (see
        mln/core/concept/site_set.hh). */
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Return The number of faces in the complex.
     std::size_t nfaces() const;
@@ -212,7 +212,7 @@ namespace mln
 
   template <unsigned N, unsigned D, typename P>
   inline
-  unsigned
+  std::size_t
   p_faces<N, D, P>::nsites() const
   {
     return nfaces();
diff --git a/milena/mln/core/site_set/p_graph.hh b/milena/mln/core/site_set/p_graph.hh
index b530152..6146d6f 100644
--- a/milena/mln/core/site_set/p_graph.hh
+++ b/milena/mln/core/site_set/p_graph.hh
@@ -104,7 +104,7 @@ namespace mln
     /// Required by the mln::Point_Set concept.
     /* FIXME: Return type should be std::size_t (see
        mln/core/concept/site_set.hh). */
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Return The number of vertices in the graph.
     std::size_t nvertices() const;
@@ -208,7 +208,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_graph<P>::nsites() const
   {
     return nvertices();
diff --git a/milena/mln/core/site_set/p_image.hh b/milena/mln/core/site_set/p_image.hh
index 930de2e..b3d9511 100644
--- a/milena/mln/core/site_set/p_image.hh
+++ b/milena/mln/core/site_set/p_image.hh
@@ -115,7 +115,7 @@ namespace mln
     bool is_valid() const;
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Insertion element associated type. 
@@ -149,7 +149,7 @@ namespace mln
   private:
 
     I ima_;
-    unsigned nsites_;
+    std::size_t nsites_;
   };
 
 
@@ -198,7 +198,7 @@ namespace mln
 
   template <typename I>
   inline
-  unsigned
+  std::size_t
   p_image<I>::nsites() const
   {
     return nsites_;
diff --git a/milena/mln/core/site_set/p_key.hh b/milena/mln/core/site_set/p_key.hh
index 4b416be..7b294b9 100644
--- a/milena/mln/core/site_set/p_key.hh
+++ b/milena/mln/core/site_set/p_key.hh
@@ -115,7 +115,7 @@ namespace mln
     bool is_valid() const;
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Insertion element associated type. 
@@ -192,7 +192,7 @@ namespace mln
     k_t k_;
 
     // Number of sites.
-    unsigned n_;
+    std::size_t n_;
 
     // Run invariance tests and return the result.
     bool run_() const;
@@ -245,7 +245,7 @@ namespace mln
   
   template <typename K, typename P>
   inline
-  unsigned
+  std::size_t
   p_key<K,P>::nsites() const
   {
     mln_invariant(run_());
diff --git a/milena/mln/core/site_set/p_line2d.hh b/milena/mln/core/site_set/p_line2d.hh
index 9ad9549..262c2f0 100644
--- a/milena/mln/core/site_set/p_line2d.hh
+++ b/milena/mln/core/site_set/p_line2d.hh
@@ -112,7 +112,7 @@ namespace mln
 
 
     /// Give the number of points.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Give the point that begins the line.
     const point2d& begin() const;
@@ -252,7 +252,7 @@ namespace mln
   }
 
   inline
-  unsigned
+  std::size_t
   p_line2d::nsites() const
   {
     return arr_.nsites();
diff --git a/milena/mln/core/site_set/p_line_graph.hh b/milena/mln/core/site_set/p_line_graph.hh
index b9a3ed0..0cd6680 100644
--- a/milena/mln/core/site_set/p_line_graph.hh
+++ b/milena/mln/core/site_set/p_line_graph.hh
@@ -109,7 +109,7 @@ namespace mln
     /// `known'.)
     /* FIXME: Return type should be std::size_t (see
        mln/core/concept/site_set.hh). */
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Return The number of vertices in the graph.
     std::size_t nvertices() const;
@@ -196,7 +196,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_line_graph<P>::nsites() const
   {
     return nedges();
diff --git a/milena/mln/core/site_set/p_priority.hh b/milena/mln/core/site_set/p_priority.hh
index 147dece..3a630cf 100644
--- a/milena/mln/core/site_set/p_priority.hh
+++ b/milena/mln/core/site_set/p_priority.hh
@@ -114,7 +114,7 @@ namespace mln
     bool is_valid() const;
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Push in the queue with \p priority the element \p e.
@@ -181,7 +181,7 @@ namespace mln
 
     util::set<P> p_;
     q_type_      q_;
-    unsigned     n_;
+    std::size_t  n_;
 
     // Run invariance tests and return the result.
     bool run_() const;
@@ -225,7 +225,7 @@ namespace mln
   
   template <typename P, typename Q>
   inline
-  unsigned
+  std::size_t
   p_priority<P,Q>::nsites() const
   {
     mln_invariant(run_());
diff --git a/milena/mln/core/site_set/p_queue.hh b/milena/mln/core/site_set/p_queue.hh
index babc994..8692f57 100644
--- a/milena/mln/core/site_set/p_queue.hh
+++ b/milena/mln/core/site_set/p_queue.hh
@@ -108,7 +108,7 @@ namespace mln
 
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Push a site \p p in the queue.
@@ -195,7 +195,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_queue<P>::nsites() const
   {
     return q_.size();
diff --git a/milena/mln/core/site_set/p_queue_fast.hh b/milena/mln/core/site_set/p_queue_fast.hh
index 199edc4..54f8146 100644
--- a/milena/mln/core/site_set/p_queue_fast.hh
+++ b/milena/mln/core/site_set/p_queue_fast.hh
@@ -110,7 +110,7 @@ namespace mln
     bool compute_has(const P& p) const;
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Push a site \p p in the queue.
@@ -236,7 +236,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_queue_fast<P>::nsites() const
   {
     mln_invariant(end_ >= begin_);
diff --git a/milena/mln/core/site_set/p_run.hh b/milena/mln/core/site_set/p_run.hh
index 21644eb..f618d89 100644
--- a/milena/mln/core/site_set/p_run.hh
+++ b/milena/mln/core/site_set/p_run.hh
@@ -128,7 +128,7 @@ namespace mln
     bool has_index(unsigned short i) const;
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
     /// Give the length of the run.
     unsigned short length() const;
@@ -162,7 +162,7 @@ namespace mln
     P start_;
 
     /// The length of the run.
-    unsigned short len_;
+    std::size_t len_;
   };
 
 
@@ -307,7 +307,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_run<P>::nsites() const
   {
     mln_precondition(is_valid());
diff --git a/milena/mln/core/site_set/p_set.hh b/milena/mln/core/site_set/p_set.hh
index 817d56b..041b4a2 100644
--- a/milena/mln/core/site_set/p_set.hh
+++ b/milena/mln/core/site_set/p_set.hh
@@ -107,7 +107,7 @@ namespace mln
 
 
     /// Give the number of sites.
-    unsigned nsites() const;
+    std::size_t nsites() const;
 
 
     /// Insertion element associated type. 
@@ -192,7 +192,7 @@ namespace mln
 
   template <typename P>
   inline
-  unsigned
+  std::size_t
   p_set<P>::nsites() const
   {
     return s_.nelements();
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from  Ugo Jardonnet  <ugo.jardonnet(a)lrde.epita.fr>
	INIM: Clean up classification.
	* classif/iccvg04.cc: Clean it up.
 iccvg04.cc |   82 ++++++++-----------------------------------------------------
 1 file changed, 11 insertions(+), 71 deletions(-)
Index: classif/iccvg04.cc
--- classif/iccvg04.cc	(revision 2688)
+++ classif/iccvg04.cc	(working copy)
@@ -14,7 +14,6 @@
 #include <mln/util/array.hh>
 #include <mln/labeling/compute.hh>
 
-// FIXME: !?
 #include <mln/geom/all.hh>
 
 #include <mln/io/ppm/load.hh>
@@ -99,86 +98,45 @@
 void
 classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
 {
-
   unsigned count[nbasins + 1];
   memset(count, 0, (nbasins + 1) * sizeof(unsigned));
-  algebra::vec<3, unsigned> sum[nbasins + 1];
 
+  algebra::vec<3, unsigned> sum[nbasins + 1];
   for (int i = 1; i < nbasins + 1; ++i)
     sum[i] = literal::zero;
 
+  // Compute representatives of every class
   mln_piter(I) p(ima.domain());
   for_all(p)
   {
     point3d p3(ima(p).red() / f, ima(p).green() / f, ima(p).blue() / f);
     int w = ws(p3);
 
-    // Check if we are not on a border of the WS
+    //check if we are not on a border of the WS
     if (w != 0)
     {
       count[w] += histo(p3);
       sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3);
     }
-#if DEBUG
-    std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl;
-#endif // DEBUG
   }
-
   for (int i = 1; i < nbasins + 1; ++i)
-  {
-    sum[i] *= f;
-    sum[i] /= count[i];
-    //std::cout << "count[" << i << "] = " << count[i] << std::endl;
-#if DEBUG
-    std::cout << "sum[" << i << "] = " << sum[i] << std::endl;
-#endif // DEBUG
-  }
-
+    sum[i] = (sum[i] * f) / count[i];
 
+  // Make an output image where colors are replaced by their representatives.
   mln_piter(I) pi(ima.domain());
   I out(ima.domain());
-  I ws_out(ima.domain());
-
   for_all(pi)
   {
-    value::rgb8 coul = ima(pi);
 
+    //retrieve color class
+    value::rgb8 coul = ima(pi);
     int w = ws(point3d(coul.red() / f, coul.green() / f, coul.blue() / f));
 
-    if (w != 0) // If w == 0 it means that the current point is part of a border of the watershed
-    {
-#if DEBUG
-      std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << std::endl;
-#endif
+    //if w == 0, out(pi) = 0 ie is part of a border of the watershed
       out(pi) = convert::to<value::rgb8>(sum[w]);
-      //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]);
-      ws_out(pi) = value::rgb8(0, 0, 0);
     }
-    else
-    {
-#if DEBUG
-      std::cerr << "Border : " << pi << std::endl;
-#endif
-      ws_out(pi) = value::rgb8(255, 255, 255);
-
-      // FIXME
-      // ima(pi) is a border in the histogram and therefore lacks of a mean color.
-      // Choosing a good value for out(pi) is not so easy. One idea could be to randomly
-      // choose a color from one of the surrounding classes, but it's not the best idea
-      // because of large « border » zones.
-      out(pi) = value::rgb8(255, 255, 255);
-    }
-
-    //std::cerr << "(" << coul << ") -> (" << out(pi) << "); sum[" << w << "] = " << sum[w] << " -> " << convert::to<value::rgb8>(sum[w]) << std::endl;
-  }
-
-  // 1- La valeur contenue dans sum n'est pas correctement écrite dans out.ppm. À vérifier !
-  // 2- Le cast de sum[w] en rgb8 se passe très bizarrement. À vérifier !
-  // 3- Rajoute le std::cout de count change le comportement du programme. À vérifier !
-  // 4- Le WS semble faire des pâtés (beaucoup de points de classe 0)
 
   io::ppm::save(out, "out.ppm");
-  io::ppm::save(ws_out, "out-ws.ppm");
 }
 
 bool usage(int argc, char ** argv)
@@ -196,7 +154,6 @@
 {
   if (not usage(argc, argv))
     return 1;
-
   const int div_factor = atoi(argv[2]);
   const int lambda = atoi(argv[3]);
 
@@ -205,36 +162,19 @@
 
   //make histo
   image3d<unsigned> histo = fill_histo(ima,div_factor);
-  {
-    unsigned m, M;
-    estim::min_max(histo, m, M);
-    std::cout << "histo : " << m << ' ' << M << std::endl;
-  }
 
   //revert histo
   image3d<unsigned> rhisto = arith::revert(histo);
-  {
-    unsigned m, M;
-    estim::min_max(rhisto, m, M);
-    std::cout << "rhisto : " << m << ' ' << M << std::endl;
-  }
 
-  //compute closing_area of histo
+  //compute closing_volume of histo
   image3d<unsigned> histo_closure(histo.domain());
-  morpho::closing_area(rhisto, c6(), lambda, histo_closure);
-  {
-    unsigned m, M;
-    estim::min_max(histo_closure, m, M);
-    std::cout << "histo_closure : " << m << ' ' << M << std::endl;
-  }
+  morpho::closing_volume(rhisto, c6(), lambda, histo_closure);
 
   //watershed over histo_closure
   unsigned nbasins = 0;
   image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins);
-
   std::cout << "nbassins : " << nbasins << std::endl;
 
-  // Classify image !
-  //classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
+  //classify image
   classify_image(ima, histo, ws, nbasins, div_factor);
 }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from  Nicolas Ballas  <ballas(a)lrde.epita.fr>
	Fix bugs in low level routines.
	* tests/level/fill_with_image.cc,
	* tests/level/transform.cc,
	* tests/level/paste.cc: Add tests.
	* mln/core/image/cast_image.hh: Update properties.
	* mln/level/transform.spe.hh,
	* mln/level/paste.spe.hh,
	* mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs.
	* mln/level/transform.hh,
	* mln/level/paste.hh: Rename routines.
 mln/core/image/cast_image.hh     |   12 +++
 mln/level/fill_with_image.spe.hh |  111 +++++++++++++++++++++++--------
 mln/level/paste.hh               |    2 
 mln/level/paste.spe.hh           |  117 ++++++++++++++++++++++++--------
 mln/level/transform.hh           |    2 
 mln/level/transform.spe.hh       |  135 ++++++++++++++++++++++++++-----------
 tests/level/fill_with_image.cc   |  139 +++++++++++++++++++++++++++++++++++++--
 tests/level/paste.cc             |  122 +++++++++++++++++++++++++++++++++-
 tests/level/transform.cc         |   62 +++++++++++++++++
 9 files changed, 592 insertions(+), 110 deletions(-)
Index: tests/level/fill_with_image.cc
--- tests/level/fill_with_image.cc	(revision 2687)
+++ tests/level/fill_with_image.cc	(working copy)
@@ -32,17 +32,24 @@
 
 #include <mln/level/fill_with_value.hh>
 #include <mln/level/fill_with_image.hh>
+#include <mln/level/compare.hh>
 
+#include <mln/core/image/image1d.hh>
 #include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
 #include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
 #include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
 
-#include <mln/core/image/image_if.hh>
-#include <mln/level/compare.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
 
 #include <mln/debug/iota.hh>
 #include <mln/debug/println.hh>
-#include <mln/fun/p2b/chess.hh>
+#include <mln/trace/all.hh>
 
 
 int main()
@@ -50,6 +57,7 @@
   using namespace mln;
   const unsigned size = 100;
 
+  // 2d tests
   {
     image2d<unsigned int> ima(size, size);
     image2d<unsigned int> ima2(size, size);
@@ -68,7 +76,7 @@
     debug::iota(ima2);
 
     level::fill_with_image(ima, ima2);
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
   }
 
   {
@@ -88,4 +96,127 @@
       mln_assertion(ima_if(p) == 42);
 
   }
+
+  // tests in three dimension
+  {
+    box3d b(point3d(1,2,1), point3d(2,4,3));
+    image3d<int> ima(b, 2);
+    debug::iota(ima);
+
+    box3d b2(point3d(-1,-2,-1), point3d(3,6,3));
+    image3d<int> ima2(b2, 2);
+    debug::iota(ima2);
+
+    image3d<int> ima3(b, 2);
+
+    level::fill_with_image(ima, ima2); // Not so fast version...
+    mln_assertion(ima == (ima2 | b));
+
+    level::fill_with_image(ima3, ima); // Fast version...
+    mln_assertion(ima == ima3);
+  }
+
+  // image 1d test
+  {
+    image1d<unsigned short> ima(size);
+    image1d<unsigned short> out(size);
+
+    debug::iota(ima);
+    level::fill_with_image(out, ima);
+
+    mln_assertion(ima == out);
+  }
+
+
+  // pw image test
+  {
+    const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+                                                 make::box2d(-2,-2, 15,15));
+    image2d<short unsigned int> out(8, 8);
+
+    level::fill(out, 0);
+    level::fill_with_image(out, ima);
+  }
+
+  // flat image test
+  {
+    flat_image<short, box2d> ima(5, make::box2d(size, size));
+    image2d<unsigned short> out(size, size);
+
+    level::fill_with_value(ima, 51);
+    level::fill_with_image(out, ima);
+
+    mln_assertion(ima == out);
+  }
+
+  // image if test
+  {
+    typedef image2d<unsigned short> I;
+    typedef image_if<I, fun::p2b::chess_t> II;
+
+    I ima(size, size);
+    I out(size, size);
+    II ima_if = ima | fun::p2b::chess;
+
+    level::fill_with_value(ima, 42);
+    level::fill_with_value(out, 0);
+    level::fill_with_image(ima_if, ima);
+
+    mln_piter_(II) p(ima_if.domain());
+    for_all(p)
+      mln_assertion(ima_if(p) == ima(p));
+  }
+
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+
+    I in(size, size);
+    II cast(in);
+    I out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    level::fill_with_image(out, cast);
+
+    mln_assertion(cast == out);
+  }
+
+  // sub_image test
+   {
+     typedef image2d<int> I;
+     typedef sub_image< image2d<int>, box2d > II;
+
+     I ima(size, size);
+     I out(size, size);
+     II sub_ima(ima, make::box2d(4,4, 10,10));
+
+
+     level::fill(ima, 51);
+     level::fill(out, 0);
+     level::fill_with_image(sub_ima, ima);
+
+     II::piter p(sub_ima.domain());
+     for_all(p)
+       mln_assertion(sub_ima(p) == ima(p));
+   }
+
+   // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    level::fill_with_image(out, extend_ima);
+
+    mln_assertion(out == extend_ima);
+  }
+
 }
Index: tests/level/transform.cc
--- tests/level/transform.cc	(revision 2687)
+++ tests/level/transform.cc	(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -37,7 +37,11 @@
 #include <mln/core/image/image3d.hh>
 #include <mln/pw/image.hh>
 #include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
 #include <mln/core/image/image_if.hh>
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
+
 
 #include <mln/level/fill.hh>
 #include <mln/level/transform.hh>
@@ -140,6 +144,7 @@
       mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
   }
 
+  // image if test
   {
     typedef image2d<unsigned short> I;
     typedef image_if<I, fun::p2b::chess_t> II;
@@ -157,4 +162,59 @@
       mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p));
   }
 
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+    typedef image2d<unsigned short> III;
+
+    I in(size, size);
+    II cast(in);
+    III out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    out = level::transform(cast, mysqrt());
+
+    II::piter p(cast.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(cast(p)) == out(p));
+  }
+
+  // sub_image test
+  {
+    typedef image2d<int> I;
+    typedef sub_image< image2d<int>, box2d > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II sub_ima(ima, make::box2d(4,4, 10,10));
+    III out(size, size);
+
+    level::fill(ima, 51);
+    out = level::transform(sub_ima, mysqrt());
+
+    II::piter p(sub_ima.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(sub_ima(p)) == out(p));
+  }
+
+  // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    out = level::transform(extend_ima, mysqrt());
+
+    II::piter p(extend_ima.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(extend_ima(p)) == out(p));
+  }
 }
Index: tests/level/paste.cc
--- tests/level/paste.cc	(revision 2687)
+++ tests/level/paste.cc	(working copy)
@@ -30,21 +30,32 @@
  * \brief Tests on mln::level::paste.
  */
 
+#include <mln/core/image/image1d.hh>
 #include <mln/core/image/image2d.hh>
 #include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
 #include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
 
 #include <mln/level/fill.hh>
 #include <mln/level/paste.hh>
 #include <mln/level/compare.hh>
 
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
+
 #include <mln/debug/iota.hh>
 #include <mln/debug/println.hh>
+#include <mln/trace/all.hh>
 
 
 int main()
 {
   using namespace mln;
+  const unsigned size = 50;
 
   // tests in two dimension
   {
@@ -59,10 +70,10 @@
     image2d<int> ima3(b, 2);
 
     level::paste(ima, ima2); // Not so fast version...
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
 
     level::paste(ima, ima3); // Fast version...
-    assert(ima == ima3);
+    mln_assertion(ima == ima3);
   }
 
   // tests in three dimension
@@ -78,9 +89,112 @@
     image3d<int> ima3(b, 2);
 
     level::paste(ima, ima2); // Not so fast version...
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
 
     level::paste(ima, ima3); // Fast version...
-    assert(ima == ima3);
+    mln_assertion(ima == ima3);
+  }
+
+    /// image 1d test
+  {
+    image1d<unsigned short> ima(size);
+    image1d<unsigned short> out(size);
+
+    debug::iota(ima);
+    level::paste(ima, out);
+
+    mln_assertion(ima == out);
+  }
+
+
+  /// pw image test
+  {
+    const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+                                                 make::box2d(2,2, 5,5));
+    image2d<short unsigned int> out(8, 8);
+
+    level::fill(out, 0);
+    level::paste(ima, out);
+  }
+
+  // flat image test
+  {
+    flat_image<short, box2d> ima(5, make::box2d(size, size));
+    image2d<unsigned short> out(size, size);
+
+    level::fill_with_value(ima, 51);
+    level::paste(ima, out);
+
+    mln_assertion(ima == out);
+  }
+
+  // image if test
+  {
+    typedef image2d<unsigned short> I;
+    typedef image_if<I, fun::p2b::chess_t> II;
+
+    I ima(size, size);
+    I out(size, size);
+    II ima_if = ima | fun::p2b::chess;
+
+    level::fill_with_value(ima, 0);
+    debug::iota(ima);
+    level::paste(ima_if, out);
+
+    mln_assertion(ima_if == out);
+  }
+
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+    typedef image2d<unsigned short> III;
+
+    I in(size, size);
+    II cast(in);
+    III out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    level::paste(cast, out);
+
+    mln_assertion(cast == out);
+  }
+
+  // sub_image test
+   {
+     typedef image2d<int> I;
+     typedef sub_image< image2d<int>, box2d > II;
+     typedef image2d<unsigned short> III;
+
+     I ima(size, size);
+     II sub_ima(ima, make::box2d(4,4, 10,10));
+     III out(size, size);
+
+     level::fill(ima, 51);
+     level::paste(sub_ima, out);
+
+     II::piter p(sub_ima.domain());
+     for_all(p)
+       mln_assertion(sub_ima(p) == out(p));
+   }
+
+   // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    level::paste(extend_ima, out);
+
+    II::piter p(extend_ima.domain());
+    for_all(p)
+      mln_assertion(extend_ima(p) == out(p));
   }
 }
Index: mln/core/image/cast_image.hh
--- mln/core/image/cast_image.hh	(revision 2687)
+++ mln/core/image/cast_image.hh	(working copy)
@@ -91,8 +91,20 @@
     struct image_< cast_image_<T,I> > :
       cast_image_trait_selector<T, I, mln_trait_image_vw_io(I)>
     {
+    private:
+      typedef mlc_equal(mln_trait_value_quant(T),
+			trait::value::quant::high) is_high_quant_;
+    public:
+      typedef mlc_if(is_high_quant_,
+		     trait::image::quant::high,
+		     trait::image::quant::low) quant;
+
       typedef trait::image::value_io::read_only value_io;
       typedef trait::image::pw_io::read pw_io;
+      typedef trait::image::value_access::indirect value_access;
+
+      /// FIXME is the following property correct?
+      typedef trait::image::ext_domain::none ext_domain;
     };
 
   } // end of namespace mln::trait
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh	(revision 2687)
+++ mln/level/transform.spe.hh	(working copy)
@@ -175,6 +175,7 @@
         for_all(pi)
         {
           po.val() = f(pi.val());
+          po.next();
         }
 
 	trace::exiting("level::impl::transform_fast");
@@ -204,8 +205,8 @@
         po.start();
         for_all(pi)
         {
-          //po.val() = lut(pi.val);
-          po.val() = f(pi.val());
+          po.val() = lut(pi.val());
+          po.next();
         }
 
 	trace::exiting("level::impl::transform_fast_lowq");
@@ -221,7 +222,7 @@
         /// Deal with image not updated
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::undef,
+        void transform_dispatch_(mln::trait::undef,
                                 mln::trait::image::quant::any,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
@@ -232,7 +233,7 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::any,
+        void transform_dispatch_(mln::trait::image::vw_set::any,
                                 mln::trait::image::quant::any,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
@@ -243,7 +244,7 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::uni,
+        void transform_dispatch_(mln::trait::image::vw_set::uni,
                                 mln::trait::image::quant::any,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
@@ -255,7 +256,7 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::none,
+        void transform_dispatch_(mln::trait::image::vw_set::none,
                                 mln::trait::image::quant::low,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
@@ -266,7 +267,34 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch_oneblock(mln::trait::image::quant::any,
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::some,
+                                 mln::trait::image::ext_domain::some,
+                                 const Image<I>& input_,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output_)
+        {
+          const I& input  = exact(input_);
+          O& output       = exact(output_);
+
+
+          if (input.domain() == output.domain())
+            transform_fast(input, f, output);
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
+                                mln_trait_image_quant(I)(),
+                                input, f, output);
+        }
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::none,
+                                 mln::trait::image::ext_domain::none,
                                          const Image<I>& input,
                                          const Function_v2v<F>& f,
                                          Image<O>& output)
@@ -276,7 +304,33 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch_oneblock(mln::trait::image::quant::low,
+        void transform_dispatch_(mln::trait::image::quant::low,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::some,
+                                 mln::trait::image::ext_domain::some,
+                                 const Image<I>& input_,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output_)
+        {
+          const I& input  = exact(input_);
+          O& output       = exact(output_);
+
+          if (input.domain() == output.domain())
+            transform_fast_lowq(input, f, output);
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
+                                mln_trait_image_quant(I)(),
+                                input, f, output);
+        }
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::quant::low,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::none,
+                                 mln::trait::image::ext_domain::none,
                                          const Image<I>& input,
                                          const Function_v2v<F>& f,
                                          Image<O>& output)
@@ -287,20 +341,37 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::any,
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::any,
+                                 mln::trait::image::value_access::any,
+                                 mln::trait::image::ext_domain::any,
+                                 mln::trait::image::ext_domain::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
+        {
+          transform_dispatch_(mln_trait_image_vw_set(I)(),
+                              mln_trait_image_quant(I)(),
+                              input, f, output);
+        }
+
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::value_storage::any,
                                 mln::trait::image::value_storage::any,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
                                 Image<O>& output)
         {
-          transform_dispatch(mln_trait_image_vw_set(I)(),
+          transform_dispatch_(mln_trait_image_vw_set(I)(),
                              mln_trait_image_quant(I)(),
                              input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::singleton,
+        void transform_dispatch_(mln::trait::image::value_storage::singleton,
                                 mln::trait::image::value_storage::any,
                                 const Image<I>& input,
                                 const Function_v2v<F>& f,
@@ -311,7 +382,7 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::one_block,
+        void transform_dispatch_(mln::trait::image::value_storage::one_block,
                                 mln::trait::image::value_storage::one_block,
                                 const Image<I>& input_,
                                 const Function_v2v<F>& f_,
@@ -320,40 +391,22 @@
           const I& input  = exact(input_);
           O& output       = exact(output_);
 
+
           /// Check basic properties
-          if (mlc_is(mln_trait_image_value_access(O),
-                     trait::image::value_access::direct)::value &&
-              mlc_is(mln_trait_image_value_access(I),
-                     trait::image::value_access::direct)::value &&
-              mlc_is(mln_trait_image_value_alignement(I),
+          if (mlc_is(mln_trait_image_value_alignement(I),
                      trait::image::value_alignement::with_grid)::value &&
               mlc_is(mln_trait_image_value_alignement(O),
                      trait::image::value_alignement::with_grid)::value)
             {
-              /// Check ext_domain
-              if (
-                  ((mlc_is(mln_trait_image_ext_domain(I),
-                           trait::image::ext_domain::fixed)::value ||
-                    mlc_is(mln_trait_image_ext_domain(I),
-                          trait::image::ext_domain::extendable)::value) &&
-                   (mlc_is(mln_trait_image_ext_domain(O),
-                           trait::image::ext_domain::fixed)::value ||
-                    mlc_is(mln_trait_image_ext_domain(O),
-                           trait::image::ext_domain::extendable)::value) &&
-                   input.border() == output.border()) ||
-                  (mlc_is(mln_trait_image_ext_domain(I),
-                          trait::image::ext_domain::none)::value &&
-                   mlc_is(mln_trait_image_ext_domain(O),
-                          trait::image::ext_domain::none)::value))
-                {
-
-                  /// Check domain
-                  if (input.domain() == output.domain())
-                    transform_dispatch_oneblock(mln_trait_image_quant(I)(),
+              transform_dispatch_(mln_trait_image_quant(I)(),
+                                  mln_trait_image_value_access(I)(),
+                                  mln_trait_image_value_access(O)(),
+                                  mln_trait_image_ext_domain(I)(),
+                                  mln_trait_image_ext_domain(O)(),
                                                 input, f_, output);
                 }
-            }
-          transform_dispatch(mln_trait_image_vw_set(I)(),
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
                              mln_trait_image_quant(I)(),
                              input, f_, output);
         }
@@ -362,11 +415,11 @@
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(const Image<I>& input,
+        void transform_dispatch_(const Image<I>& input,
                                 const Function_v2v<F>& f,
                                 Image<O>& output)
         {
-          transform_dispatch(mln_trait_image_value_storage(I)(),
+          transform_dispatch_(mln_trait_image_value_storage(I)(),
                              mln_trait_image_value_storage(O)(),
                              input, f, output);
         }
Index: mln/level/paste.spe.hh
--- mln/level/paste.spe.hh	(revision 2687)
+++ mln/level/paste.spe.hh	(working copy)
@@ -66,11 +66,9 @@
       namespace generic
       {
 	template <typename I, typename J>
-	void paste_(const Image<I>& input, Image<J>& output);
+	void paste(const Image<I>& input, Image<J>& output);
       }
 
-
-
 //       template <typename I, typename J>
 //       inline
 //       void paste_lines_(const I& data, J& destination)
@@ -111,10 +109,30 @@
         for_all(pi)
         {
           po.val() = pi.val();
+          po.next();
         }
         trace::entering("level::impl::paste_fast");
       }
 
+
+      template <typename I, typename J>
+      void paste_fast_singleton(const Image<I>& input_, Image<J>& output_)
+      {
+        trace::entering("level::impl::paste_fast_singleton");
+
+        const I& input = exact(input_);
+        J& output      = exact(output_);
+
+        level::internal::paste_tests(input, output);
+
+        mln_pixter(J) po(output);
+
+        for_all(po)
+          po.val() = input.val();
+
+        trace::entering("level::impl::paste_fast_singleton");
+      }
+
     } // end of namespace impl.
 
 
@@ -122,6 +140,48 @@
     namespace internal
     {
 
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::direct,
+                  mln::trait::image::value_access::direct,
+                  mln::trait::image::ext_domain::some,
+                  mln::trait::image::ext_domain::some,
+                  const Image<I>& input_,
+                  Image<J>& output_)
+      {
+        const I& input  = exact(input_);
+        J& output       = exact(output_);
+
+        if (input.domain() == output.domain())
+          impl::paste_fast(input, output);
+        else
+          impl::generic::paste(input, output);
+      }
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::direct,
+                  mln::trait::image::value_access::direct,
+                  mln::trait::image::ext_domain::none,
+                  mln::trait::image::ext_domain::none,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::paste_fast(input, output);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::any,
+                  mln::trait::image::value_access::any,
+                  mln::trait::image::ext_domain::any,
+                  mln::trait::image::ext_domain::any,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::generic::paste(input, output);
+      }
 
       template <typename I, typename J>
       inline
@@ -130,51 +190,45 @@
                   const Image<I>& input,
                   Image<J>& output)
       {
-        impl::generic::paste_(input, output);
+        impl::generic::paste(input, output);
       }
 
       template <typename I, typename J>
       inline
-      void paste_(trait::image::value_storage::one_block,
+      void paste_(trait::image::value_storage::singleton,
                   trait::image::value_storage::one_block,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::paste_fast_singleton(input, output);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_storage::one_block,
+                  mln::trait::image::value_storage::one_block,
                   const Image<I>& input_,
                   Image<J>& output_)
       {
         const I& input  = exact(input_);
         J& output       = exact(output_);
 
+
         /// Check basic properties
-        if (mlc_is(mln_trait_image_value_access(J),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_access(I),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_alignement(I),
+        if (mlc_is(mln_trait_image_value_alignement(I),
                    trait::image::value_alignement::with_grid)::value &&
             mlc_is(mln_trait_image_value_alignement(J),
                    trait::image::value_alignement::with_grid)::value)
           {
-            /// Check ext_domain
-            if (
-                ((mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::extendable)::value) &&
-                 (mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::extendable)::value) &&
-                 input.border() == output.border()) ||
-                (mlc_is(mln_trait_image_ext_domain(I),
-                        trait::image::ext_domain::none)::value &&
-                 mlc_is(mln_trait_image_ext_domain(J),
-                        trait::image::ext_domain::none)::value))
-              {
-                /// Check domain
-                if (input.domain() == output.domain())
-                  impl::paste_fast(input, output);
-              }
+            paste_(mln_trait_image_value_access(I)(),
+                   mln_trait_image_value_access(J)(),
+                   mln_trait_image_ext_domain(I)(),
+                   mln_trait_image_ext_domain(J)(),
+                   input, output);
           }
-        impl::generic::paste_(input, output);
+        else
+          impl::generic::paste(input, output);
       }
 
 
@@ -182,6 +236,7 @@
       inline
       void paste_(const Image<I>& input, Image<J>& output)
       {
+
         paste_(mln_trait_image_value_storage(I)(),
                mln_trait_image_value_storage(J)(),
                input, output);
Index: mln/level/fill_with_image.spe.hh
--- mln/level/fill_with_image.spe.hh	(revision 2687)
+++ mln/level/fill_with_image.spe.hh	(working copy)
@@ -86,9 +86,31 @@
         for_all(pi)
         {
           pi.val() = d.val();
+          d.next();
         }
         trace::entering("level::impl::fill_with_image_fast");
       }
+
+
+      template <typename I, typename J>
+      void fill_with_image_fast_singleton(Image<I>& ima_,
+                                          const Image<J>& data_)
+      {
+        trace::entering("level::impl::fill_with_image_fast_singleton");
+
+        I& ima               = exact(ima_);
+        const J& data        = exact(data_);
+
+        level::internal::fill_with_image_tests(ima, data);
+
+        mln_pixter(I) pi(ima);
+
+        for_all(pi)
+          pi.val() = data.val();
+
+        trace::entering("level::impl::fill_with_image_fast_singleton");
+      }
+
     } // end of namespace mln::level::impl
 
 
@@ -99,6 +121,49 @@
 
       template <typename I, typename J>
       inline
+      void fill_with_image_(mln::trait::image::value_access::direct,
+                            mln::trait::image::value_access::direct,
+                            mln::trait::image::ext_domain::some,
+                            mln::trait::image::ext_domain::some,
+                            Image<I>& ima_,
+                            const Image<J>& data_)
+      {
+        I& ima        = exact(ima_);
+        const J& data = exact(data_);
+
+        if (ima.domain() == data.domain())
+          impl::fill_with_image_fast(ima, data);
+        else
+          impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_access::direct,
+                            mln::trait::image::value_access::direct,
+                            mln::trait::image::ext_domain::none,
+                            mln::trait::image::ext_domain::none,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::fill_with_image_fast(ima, data);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_access::any,
+                            mln::trait::image::value_access::any,
+                            mln::trait::image::ext_domain::any,
+                            mln::trait::image::ext_domain::any,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
       void fill_with_image_(trait::image::value_storage::any,
                             trait::image::value_storage::any,
                             Image<I>& ima,
@@ -110,49 +175,41 @@
       template <typename I, typename J>
       inline
       void fill_with_image_(trait::image::value_storage::one_block,
-                            trait::image::value_storage::one_block,
+                            trait::image::value_storage::singleton,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_storage::one_block,
+                            mln::trait::image::value_storage::one_block,
                             Image<I>& ima_,
                             const Image<J>& data_)
       {
         I& ima        = exact(ima_);
         const J& data = exact(data_);
 
+
         /// Check basic properties
-        if (mlc_is(mln_trait_image_value_access(J),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_access(I),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_alignement(I),
+        if (mlc_is(mln_trait_image_value_alignement(I),
                    trait::image::value_alignement::with_grid)::value &&
             mlc_is(mln_trait_image_value_alignement(J),
                    trait::image::value_alignement::with_grid)::value)
           {
-            /// Check ext_domain
-            if (
-                ((mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::extendable)::value) &&
-                 (mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::extendable)::value) &&
-                 data.border() == data.border()) ||
-                (mlc_is(mln_trait_image_ext_domain(I),
-                        trait::image::ext_domain::none)::value &&
-                 mlc_is(mln_trait_image_ext_domain(J),
-                        trait::image::ext_domain::none)::value))
-              {
-                /// Check domain
-                if (data.domain() == data.domain())
-                  impl::fill_with_image_fast(ima, data);
-              }
+            fill_with_image_(mln_trait_image_value_access(I)(),
+                             mln_trait_image_value_access(J)(),
+                             mln_trait_image_ext_domain(I)(),
+                             mln_trait_image_ext_domain(J)(),
+                             ima, data);
           }
+        else
         impl::generic::fill_with_image(ima, data);
       }
 
 
-
       template <typename I, typename J>
       inline
       void fill_with_image_(Image<I>& ima, const Image<J>& data)
Index: mln/level/transform.hh
--- mln/level/transform.hh	(revision 2687)
+++ mln/level/transform.hh	(working copy)
@@ -159,7 +159,7 @@
         trace::entering("level::transform");
 
         mln_precondition(exact(output).domain() >= exact(input).domain());
-        transform_dispatch(exact(input), exact(f), exact(output));
+        transform_dispatch_(exact(input), exact(f), exact(output));
 
         trace::exiting("level::transform");
       }
Index: mln/level/paste.hh
--- mln/level/paste.hh	(revision 2687)
+++ mln/level/paste.hh	(working copy)
@@ -102,7 +102,7 @@
 
 	template <typename I, typename J>
 	inline
-	void paste_(const Image<I>& input_, Image<J>& output_)
+	void paste(const Image<I>& input_, Image<J>& output_)
 	{
 	  trace::entering("level::impl::generic::paste");
 
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* tests/level/fill_with_image.cc,
	* tests/level/transform.cc,
	* tests/level/paste.cc: Add tests.
	* mln/core/image/cast_image.hh: Update properties.
	* mln/level/transform.spe.hh,
	* mln/level/paste.spe.hh,
	* mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs.
	* mln/level/transform.hh,
	* mln/level/paste.hh: Rename routines.
---
 milena/ChangeLog                        |   14 ++
 milena/mln/core/image/cast_image.hh     |   12 ++
 milena/mln/level/fill_with_image.spe.hh |  113 ++++++++++++----
 milena/mln/level/paste.hh               |    2 +-
 milena/mln/level/paste.spe.hh           |  117 ++++++++++++-----
 milena/mln/level/transform.hh           |    2 +-
 milena/mln/level/transform.spe.hh       |  225 +++++++++++++++++++------------
 milena/tests/level/fill_with_image.cc   |  139 ++++++++++++++++++-
 milena/tests/level/paste.cc             |  122 ++++++++++++++++-
 milena/tests/level/transform.cc         |   62 +++++++++-
 10 files changed, 652 insertions(+), 156 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 35f360b..2c1de6a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-27  Nicolas Ballas  <ballas(a)lrde.epita.fr>
+
+	Fix bugs in low level routines.
+
+	* tests/level/fill_with_image.cc,
+	* tests/level/transform.cc,
+	* tests/level/paste.cc: Add tests.
+	* mln/core/image/cast_image.hh: Update properties.
+	* mln/level/transform.spe.hh,
+	* mln/level/paste.spe.hh,
+	* mln/level/fill_with_image.spe.hh: Update dispatch, fix bugs.
+	* mln/level/transform.hh,
+	* mln/level/paste.hh: Rename routines.
+
 2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
 
 	Fix mln::level::stretch w.r.t. the initialization.
diff --git a/milena/mln/core/image/cast_image.hh b/milena/mln/core/image/cast_image.hh
index 6de5892..d5baa8d 100644
--- a/milena/mln/core/image/cast_image.hh
+++ b/milena/mln/core/image/cast_image.hh
@@ -91,8 +91,20 @@ namespace mln
     struct image_< cast_image_<T,I> > :
       cast_image_trait_selector<T, I, mln_trait_image_vw_io(I)>
     {
+    private:
+      typedef mlc_equal(mln_trait_value_quant(T),
+			trait::value::quant::high) is_high_quant_;
+    public:
+      typedef mlc_if(is_high_quant_,
+		     trait::image::quant::high,
+		     trait::image::quant::low) quant;
+
       typedef trait::image::value_io::read_only value_io;
       typedef trait::image::pw_io::read pw_io;
+      typedef trait::image::value_access::indirect value_access;
+
+      /// FIXME is the following property correct?
+      typedef trait::image::ext_domain::none ext_domain;
     };
 
   } // end of namespace mln::trait
diff --git a/milena/mln/level/fill_with_image.spe.hh b/milena/mln/level/fill_with_image.spe.hh
index 846da96..6084e72 100644
--- a/milena/mln/level/fill_with_image.spe.hh
+++ b/milena/mln/level/fill_with_image.spe.hh
@@ -86,9 +86,31 @@ namespace mln
         for_all(pi)
         {
           pi.val() = d.val();
+          d.next();
         }
         trace::entering("level::impl::fill_with_image_fast");
       }
+
+
+      template <typename I, typename J>
+      void fill_with_image_fast_singleton(Image<I>& ima_,
+                                          const Image<J>& data_)
+      {
+        trace::entering("level::impl::fill_with_image_fast_singleton");
+
+        I& ima               = exact(ima_);
+        const J& data        = exact(data_);
+
+        level::internal::fill_with_image_tests(ima, data);
+
+        mln_pixter(I) pi(ima);
+
+        for_all(pi)
+          pi.val() = data.val();
+
+        trace::entering("level::impl::fill_with_image_fast_singleton");
+      }
+
     } // end of namespace mln::level::impl
 
 
@@ -99,6 +121,49 @@ namespace mln
 
       template <typename I, typename J>
       inline
+      void fill_with_image_(mln::trait::image::value_access::direct,
+                            mln::trait::image::value_access::direct,
+                            mln::trait::image::ext_domain::some,
+                            mln::trait::image::ext_domain::some,
+                            Image<I>& ima_,
+                            const Image<J>& data_)
+      {
+        I& ima        = exact(ima_);
+        const J& data = exact(data_);
+
+        if (ima.domain() == data.domain())
+          impl::fill_with_image_fast(ima, data);
+        else
+          impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_access::direct,
+                            mln::trait::image::value_access::direct,
+                            mln::trait::image::ext_domain::none,
+                            mln::trait::image::ext_domain::none,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::fill_with_image_fast(ima, data);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_access::any,
+                            mln::trait::image::value_access::any,
+                            mln::trait::image::ext_domain::any,
+                            mln::trait::image::ext_domain::any,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
       void fill_with_image_(trait::image::value_storage::any,
                             trait::image::value_storage::any,
                             Image<I>& ima,
@@ -110,49 +175,41 @@ namespace mln
       template <typename I, typename J>
       inline
       void fill_with_image_(trait::image::value_storage::one_block,
-                            trait::image::value_storage::one_block,
+                            trait::image::value_storage::singleton,
+                            Image<I>& ima,
+                            const Image<J>& data)
+      {
+        impl::generic::fill_with_image(ima, data);
+      }
+
+      template <typename I, typename J>
+      inline
+      void fill_with_image_(mln::trait::image::value_storage::one_block,
+                            mln::trait::image::value_storage::one_block,
                             Image<I>& ima_,
                             const Image<J>& data_)
       {
         I& ima        = exact(ima_);
         const J& data = exact(data_);
 
+
         /// Check basic properties
-        if (mlc_is(mln_trait_image_value_access(J),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_access(I),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_alignement(I),
+        if (mlc_is(mln_trait_image_value_alignement(I),
                    trait::image::value_alignement::with_grid)::value &&
             mlc_is(mln_trait_image_value_alignement(J),
                    trait::image::value_alignement::with_grid)::value)
           {
-            /// Check ext_domain
-            if (
-                ((mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::extendable)::value) &&
-                 (mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::extendable)::value) &&
-                 data.border() == data.border()) ||
-                (mlc_is(mln_trait_image_ext_domain(I),
-                        trait::image::ext_domain::none)::value &&
-                 mlc_is(mln_trait_image_ext_domain(J),
-                        trait::image::ext_domain::none)::value))
-              {
-                /// Check domain
-                if (data.domain() == data.domain())
-                  impl::fill_with_image_fast(ima, data);
-              }
+            fill_with_image_(mln_trait_image_value_access(I)(),
+                             mln_trait_image_value_access(J)(),
+                             mln_trait_image_ext_domain(I)(),
+                             mln_trait_image_ext_domain(J)(),
+                             ima, data);
           }
-        impl::generic::fill_with_image(ima, data);
+        else
+          impl::generic::fill_with_image(ima, data);
       }
 
 
-
       template <typename I, typename J>
       inline
       void fill_with_image_(Image<I>& ima, const Image<J>& data)
diff --git a/milena/mln/level/paste.hh b/milena/mln/level/paste.hh
index c3b8fcc..6bbac4a 100644
--- a/milena/mln/level/paste.hh
+++ b/milena/mln/level/paste.hh
@@ -102,7 +102,7 @@ namespace mln
 
 	template <typename I, typename J>
 	inline
-	void paste_(const Image<I>& input_, Image<J>& output_)
+	void paste(const Image<I>& input_, Image<J>& output_)
 	{
 	  trace::entering("level::impl::generic::paste");
 
diff --git a/milena/mln/level/paste.spe.hh b/milena/mln/level/paste.spe.hh
index 028ced8..e7c7390 100644
--- a/milena/mln/level/paste.spe.hh
+++ b/milena/mln/level/paste.spe.hh
@@ -66,11 +66,9 @@ namespace mln
       namespace generic
       {
 	template <typename I, typename J>
-	void paste_(const Image<I>& input, Image<J>& output);
+	void paste(const Image<I>& input, Image<J>& output);
       }
 
-
-
 //       template <typename I, typename J>
 //       inline
 //       void paste_lines_(const I& data, J& destination)
@@ -111,10 +109,30 @@ namespace mln
         for_all(pi)
         {
           po.val() = pi.val();
+          po.next();
         }
         trace::entering("level::impl::paste_fast");
       }
 
+
+      template <typename I, typename J>
+      void paste_fast_singleton(const Image<I>& input_, Image<J>& output_)
+      {
+        trace::entering("level::impl::paste_fast_singleton");
+
+        const I& input = exact(input_);
+        J& output      = exact(output_);
+
+        level::internal::paste_tests(input, output);
+
+        mln_pixter(J) po(output);
+
+        for_all(po)
+          po.val() = input.val();
+
+        trace::entering("level::impl::paste_fast_singleton");
+      }
+
     } // end of namespace impl.
 
 
@@ -122,6 +140,48 @@ namespace mln
     namespace internal
     {
 
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::direct,
+                  mln::trait::image::value_access::direct,
+                  mln::trait::image::ext_domain::some,
+                  mln::trait::image::ext_domain::some,
+                  const Image<I>& input_,
+                  Image<J>& output_)
+      {
+        const I& input  = exact(input_);
+        J& output       = exact(output_);
+
+        if (input.domain() == output.domain())
+          impl::paste_fast(input, output);
+        else
+          impl::generic::paste(input, output);
+      }
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::direct,
+                  mln::trait::image::value_access::direct,
+                  mln::trait::image::ext_domain::none,
+                  mln::trait::image::ext_domain::none,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::paste_fast(input, output);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_access::any,
+                  mln::trait::image::value_access::any,
+                  mln::trait::image::ext_domain::any,
+                  mln::trait::image::ext_domain::any,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::generic::paste(input, output);
+      }
 
       template <typename I, typename J>
       inline
@@ -130,51 +190,45 @@ namespace mln
                   const Image<I>& input,
                   Image<J>& output)
       {
-        impl::generic::paste_(input, output);
+        impl::generic::paste(input, output);
       }
 
       template <typename I, typename J>
       inline
-      void paste_(trait::image::value_storage::one_block,
+      void paste_(trait::image::value_storage::singleton,
                   trait::image::value_storage::one_block,
+                  const Image<I>& input,
+                  Image<J>& output)
+      {
+        impl::paste_fast_singleton(input, output);
+      }
+
+
+      template <typename I, typename J>
+      inline
+      void paste_(mln::trait::image::value_storage::one_block,
+                  mln::trait::image::value_storage::one_block,
                   const Image<I>& input_,
                   Image<J>& output_)
       {
         const I& input  = exact(input_);
         J& output       = exact(output_);
 
+
         /// Check basic properties
-        if (mlc_is(mln_trait_image_value_access(J),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_access(I),
-                   trait::image::value_access::direct)::value &&
-            mlc_is(mln_trait_image_value_alignement(I),
+        if (mlc_is(mln_trait_image_value_alignement(I),
                    trait::image::value_alignement::with_grid)::value &&
             mlc_is(mln_trait_image_value_alignement(J),
                    trait::image::value_alignement::with_grid)::value)
           {
-            /// Check ext_domain
-            if (
-                ((mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(I),
-                         trait::image::ext_domain::extendable)::value) &&
-                 (mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::fixed)::value ||
-                  mlc_is(mln_trait_image_ext_domain(J),
-                         trait::image::ext_domain::extendable)::value) &&
-                 input.border() == output.border()) ||
-                (mlc_is(mln_trait_image_ext_domain(I),
-                        trait::image::ext_domain::none)::value &&
-                 mlc_is(mln_trait_image_ext_domain(J),
-                        trait::image::ext_domain::none)::value))
-              {
-                /// Check domain
-                if (input.domain() == output.domain())
-                  impl::paste_fast(input, output);
-              }
+            paste_(mln_trait_image_value_access(I)(),
+                   mln_trait_image_value_access(J)(),
+                   mln_trait_image_ext_domain(I)(),
+                   mln_trait_image_ext_domain(J)(),
+                   input, output);
           }
-        impl::generic::paste_(input, output);
+        else
+          impl::generic::paste(input, output);
       }
 
 
@@ -182,6 +236,7 @@ namespace mln
       inline
       void paste_(const Image<I>& input, Image<J>& output)
       {
+
         paste_(mln_trait_image_value_storage(I)(),
                mln_trait_image_value_storage(J)(),
                input, output);
diff --git a/milena/mln/level/transform.hh b/milena/mln/level/transform.hh
index adece40..255751e 100644
--- a/milena/mln/level/transform.hh
+++ b/milena/mln/level/transform.hh
@@ -159,7 +159,7 @@ namespace mln
         trace::entering("level::transform");
 
         mln_precondition(exact(output).domain() >= exact(input).domain());
-        transform_dispatch(exact(input), exact(f), exact(output));
+        transform_dispatch_(exact(input), exact(f), exact(output));
 
         trace::exiting("level::transform");
       }
diff --git a/milena/mln/level/transform.spe.hh b/milena/mln/level/transform.spe.hh
index 0f044d2..e498997 100644
--- a/milena/mln/level/transform.spe.hh
+++ b/milena/mln/level/transform.spe.hh
@@ -175,6 +175,7 @@ namespace mln
         for_all(pi)
         {
           po.val() = f(pi.val());
+          po.next();
         }
 
 	trace::exiting("level::impl::transform_fast");
@@ -195,8 +196,8 @@ namespace mln
 
         level::internal::transform_tests(input, f, output);
 
-         value::lut_vec<mln_vset(I), mln_result(F)>
-           lut(input.values_eligible(), f);
+        value::lut_vec<mln_vset(I), mln_result(F)>
+          lut(input.values_eligible(), f);
 
         mln_pixter(const I) pi(input);
         mln_pixter(O) po(output);
@@ -204,8 +205,8 @@ namespace mln
         po.start();
         for_all(pi)
         {
-          //po.val() = lut(pi.val);
-          po.val() = f(pi.val());
+          po.val() = lut(pi.val());
+          po.next();
         }
 
 	trace::exiting("level::impl::transform_fast_lowq");
@@ -221,33 +222,33 @@ namespace mln
         /// Deal with image not updated
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::undef,
-                                mln::trait::image::quant::any,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::undef,
+                                 mln::trait::image::quant::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           impl::generic::transform(input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::any,
-                                mln::trait::image::quant::any,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::image::vw_set::any,
+                                 mln::trait::image::quant::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           impl::generic::transform(input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::uni,
-                                mln::trait::image::quant::any,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::image::vw_set::uni,
+                                 mln::trait::image::quant::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           impl::transform_taken(input, f, output);
         }
@@ -255,31 +256,84 @@ namespace mln
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::vw_set::none,
-                                mln::trait::image::quant::low,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::image::vw_set::none,
+                                 mln::trait::image::quant::low,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           impl::transform_lowq(input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch_oneblock(mln::trait::image::quant::any,
-                                         const Image<I>& input,
-                                         const Function_v2v<F>& f,
-                                         Image<O>& output)
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::some,
+                                 mln::trait::image::ext_domain::some,
+                                 const Image<I>& input_,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output_)
+        {
+          const I& input  = exact(input_);
+          O& output       = exact(output_);
+
+
+          if (input.domain() == output.domain())
+            transform_fast(input, f, output);
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
+                                mln_trait_image_quant(I)(),
+                                input, f, output);
+        }
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::none,
+                                 mln::trait::image::ext_domain::none,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           transform_fast(input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch_oneblock(mln::trait::image::quant::low,
-                                         const Image<I>& input,
-                                         const Function_v2v<F>& f,
-                                         Image<O>& output)
+        void transform_dispatch_(mln::trait::image::quant::low,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::some,
+                                 mln::trait::image::ext_domain::some,
+                                 const Image<I>& input_,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output_)
+        {
+          const I& input  = exact(input_);
+          O& output       = exact(output_);
+
+          if (input.domain() == output.domain())
+            transform_fast_lowq(input, f, output);
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
+                                mln_trait_image_quant(I)(),
+                                input, f, output);
+        }
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::quant::low,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::value_access::direct,
+                                 mln::trait::image::ext_domain::none,
+                                 mln::trait::image::ext_domain::none,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           transform_fast_lowq(input, f, output);
         }
@@ -287,88 +341,87 @@ namespace mln
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::any,
-                                mln::trait::image::value_storage::any,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::image::quant::any,
+                                 mln::trait::image::value_access::any,
+                                 mln::trait::image::value_access::any,
+                                 mln::trait::image::ext_domain::any,
+                                 mln::trait::image::ext_domain::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
-          transform_dispatch(mln_trait_image_vw_set(I)(),
-                             mln_trait_image_quant(I)(),
-                             input, f, output);
+          transform_dispatch_(mln_trait_image_vw_set(I)(),
+                              mln_trait_image_quant(I)(),
+                              input, f, output);
         }
 
+
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::singleton,
-                                mln::trait::image::value_storage::any,
-                                const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(mln::trait::image::value_storage::any,
+                                 mln::trait::image::value_storage::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
+        {
+          transform_dispatch_(mln_trait_image_vw_set(I)(),
+                              mln_trait_image_quant(I)(),
+                              input, f, output);
+        }
+
+        template <typename I, typename F, typename O>
+        inline
+        void transform_dispatch_(mln::trait::image::value_storage::singleton,
+                                 mln::trait::image::value_storage::any,
+                                 const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
           transform_singleton(input, f, output);
         }
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(mln::trait::image::value_storage::one_block,
-                                mln::trait::image::value_storage::one_block,
-                                const Image<I>& input_,
-                                const Function_v2v<F>& f_,
-                                Image<O>& output_)
+        void transform_dispatch_(mln::trait::image::value_storage::one_block,
+                                 mln::trait::image::value_storage::one_block,
+                                 const Image<I>& input_,
+                                 const Function_v2v<F>& f_,
+                                 Image<O>& output_)
         {
           const I& input  = exact(input_);
           O& output       = exact(output_);
 
+
           /// Check basic properties
-          if (mlc_is(mln_trait_image_value_access(O),
-                     trait::image::value_access::direct)::value &&
-              mlc_is(mln_trait_image_value_access(I),
-                     trait::image::value_access::direct)::value &&
-              mlc_is(mln_trait_image_value_alignement(I),
+          if (mlc_is(mln_trait_image_value_alignement(I),
                      trait::image::value_alignement::with_grid)::value &&
               mlc_is(mln_trait_image_value_alignement(O),
                      trait::image::value_alignement::with_grid)::value)
             {
-              /// Check ext_domain
-              if (
-                  ((mlc_is(mln_trait_image_ext_domain(I),
-                           trait::image::ext_domain::fixed)::value ||
-                    mlc_is(mln_trait_image_ext_domain(I),
-                          trait::image::ext_domain::extendable)::value) &&
-                   (mlc_is(mln_trait_image_ext_domain(O),
-                           trait::image::ext_domain::fixed)::value ||
-                    mlc_is(mln_trait_image_ext_domain(O),
-                           trait::image::ext_domain::extendable)::value) &&
-                   input.border() == output.border()) ||
-                  (mlc_is(mln_trait_image_ext_domain(I),
-                          trait::image::ext_domain::none)::value &&
-                   mlc_is(mln_trait_image_ext_domain(O),
-                          trait::image::ext_domain::none)::value))
-                {
-
-                  /// Check domain
-                  if (input.domain() == output.domain())
-                    transform_dispatch_oneblock(mln_trait_image_quant(I)(),
-                                                input, f_, output);
-                }
+              transform_dispatch_(mln_trait_image_quant(I)(),
+                                  mln_trait_image_value_access(I)(),
+                                  mln_trait_image_value_access(O)(),
+                                  mln_trait_image_ext_domain(I)(),
+                                  mln_trait_image_ext_domain(O)(),
+                                  input, f_, output);
             }
-          transform_dispatch(mln_trait_image_vw_set(I)(),
-                             mln_trait_image_quant(I)(),
-                             input, f_, output);
+          else
+            transform_dispatch_(mln_trait_image_vw_set(I)(),
+                                mln_trait_image_quant(I)(),
+                                input, f_, output);
         }
 
 
 
         template <typename I, typename F, typename O>
         inline
-        void transform_dispatch(const Image<I>& input,
-                                const Function_v2v<F>& f,
-                                Image<O>& output)
+        void transform_dispatch_(const Image<I>& input,
+                                 const Function_v2v<F>& f,
+                                 Image<O>& output)
         {
-          transform_dispatch(mln_trait_image_value_storage(I)(),
-                             mln_trait_image_value_storage(O)(),
-                             input, f, output);
+          transform_dispatch_(mln_trait_image_value_storage(I)(),
+                              mln_trait_image_value_storage(O)(),
+                              input, f, output);
         }
 
       }
diff --git a/milena/tests/level/fill_with_image.cc b/milena/tests/level/fill_with_image.cc
index a9bd8cf..303dad8 100644
--- a/milena/tests/level/fill_with_image.cc
+++ b/milena/tests/level/fill_with_image.cc
@@ -32,17 +32,24 @@
 
 #include <mln/level/fill_with_value.hh>
 #include <mln/level/fill_with_image.hh>
+#include <mln/level/compare.hh>
 
+#include <mln/core/image/image1d.hh>
 #include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
 #include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
 #include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
 
-#include <mln/core/image/image_if.hh>
-#include <mln/level/compare.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
 
 #include <mln/debug/iota.hh>
 #include <mln/debug/println.hh>
-#include <mln/fun/p2b/chess.hh>
+#include <mln/trace/all.hh>
 
 
 int main()
@@ -50,6 +57,7 @@ int main()
   using namespace mln;
   const unsigned size = 100;
 
+  // 2d tests
   {
     image2d<unsigned int> ima(size, size);
     image2d<unsigned int> ima2(size, size);
@@ -68,7 +76,7 @@ int main()
     debug::iota(ima2);
 
     level::fill_with_image(ima, ima2);
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
   }
 
   {
@@ -88,4 +96,127 @@ int main()
       mln_assertion(ima_if(p) == 42);
 
   }
+
+  // tests in three dimension
+  {
+    box3d b(point3d(1,2,1), point3d(2,4,3));
+    image3d<int> ima(b, 2);
+    debug::iota(ima);
+
+    box3d b2(point3d(-1,-2,-1), point3d(3,6,3));
+    image3d<int> ima2(b2, 2);
+    debug::iota(ima2);
+
+    image3d<int> ima3(b, 2);
+
+    level::fill_with_image(ima, ima2); // Not so fast version...
+    mln_assertion(ima == (ima2 | b));
+
+    level::fill_with_image(ima3, ima); // Fast version...
+    mln_assertion(ima == ima3);
+  }
+
+  // image 1d test
+  {
+    image1d<unsigned short> ima(size);
+    image1d<unsigned short> out(size);
+
+    debug::iota(ima);
+    level::fill_with_image(out, ima);
+
+    mln_assertion(ima == out);
+  }
+
+
+  // pw image test
+  {
+    const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+                                                 make::box2d(-2,-2, 15,15));
+    image2d<short unsigned int> out(8, 8);
+
+    level::fill(out, 0);
+    level::fill_with_image(out, ima);
+  }
+
+  // flat image test
+  {
+    flat_image<short, box2d> ima(5, make::box2d(size, size));
+    image2d<unsigned short> out(size, size);
+
+    level::fill_with_value(ima, 51);
+    level::fill_with_image(out, ima);
+
+    mln_assertion(ima == out);
+  }
+
+  // image if test
+  {
+    typedef image2d<unsigned short> I;
+    typedef image_if<I, fun::p2b::chess_t> II;
+
+    I ima(size, size);
+    I out(size, size);
+    II ima_if = ima | fun::p2b::chess;
+
+    level::fill_with_value(ima, 42);
+    level::fill_with_value(out, 0);
+    level::fill_with_image(ima_if, ima);
+
+    mln_piter_(II) p(ima_if.domain());
+    for_all(p)
+      mln_assertion(ima_if(p) == ima(p));
+  }
+
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+
+    I in(size, size);
+    II cast(in);
+    I out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    level::fill_with_image(out, cast);
+
+    mln_assertion(cast == out);
+  }
+
+  // sub_image test
+   {
+     typedef image2d<int> I;
+     typedef sub_image< image2d<int>, box2d > II;
+
+     I ima(size, size);
+     I out(size, size);
+     II sub_ima(ima, make::box2d(4,4, 10,10));
+
+
+     level::fill(ima, 51);
+     level::fill(out, 0);
+     level::fill_with_image(sub_ima, ima);
+
+     II::piter p(sub_ima.domain());
+     for_all(p)
+       mln_assertion(sub_ima(p) == ima(p));
+   }
+
+   // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    level::fill_with_image(out, extend_ima);
+
+    mln_assertion(out == extend_ima);
+  }
+
 }
diff --git a/milena/tests/level/paste.cc b/milena/tests/level/paste.cc
index cd97898..e748602 100644
--- a/milena/tests/level/paste.cc
+++ b/milena/tests/level/paste.cc
@@ -30,21 +30,32 @@
  * \brief Tests on mln::level::paste.
  */
 
+#include <mln/core/image/image1d.hh>
 #include <mln/core/image/image2d.hh>
 #include <mln/core/image/image3d.hh>
+#include <mln/pw/image.hh>
+#include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/image_if.hh>
 #include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
 
 #include <mln/level/fill.hh>
 #include <mln/level/paste.hh>
 #include <mln/level/compare.hh>
 
+#include <mln/fun/p2b/chess.hh>
+#include <mln/fun/p2v/iota.hh>
+
 #include <mln/debug/iota.hh>
 #include <mln/debug/println.hh>
+#include <mln/trace/all.hh>
 
 
 int main()
 {
   using namespace mln;
+  const unsigned size = 50;
 
   // tests in two dimension
   {
@@ -59,10 +70,10 @@ int main()
     image2d<int> ima3(b, 2);
 
     level::paste(ima, ima2); // Not so fast version...
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
 
     level::paste(ima, ima3); // Fast version...
-    assert(ima == ima3);
+    mln_assertion(ima == ima3);
   }
 
   // tests in three dimension
@@ -78,9 +89,112 @@ int main()
     image3d<int> ima3(b, 2);
 
     level::paste(ima, ima2); // Not so fast version...
-    assert(ima == (ima2 | b));
+    mln_assertion(ima == (ima2 | b));
 
     level::paste(ima, ima3); // Fast version...
-    assert(ima == ima3);
+    mln_assertion(ima == ima3);
+  }
+
+    /// image 1d test
+  {
+    image1d<unsigned short> ima(size);
+    image1d<unsigned short> out(size);
+
+    debug::iota(ima);
+    level::paste(ima, out);
+
+    mln_assertion(ima == out);
+  }
+
+
+  /// pw image test
+  {
+    const pw::image<fun::p2v::iota_t, box2d> ima(fun::p2v::iota,
+                                                 make::box2d(2,2, 5,5));
+    image2d<short unsigned int> out(8, 8);
+
+    level::fill(out, 0);
+    level::paste(ima, out);
+  }
+
+  // flat image test
+  {
+    flat_image<short, box2d> ima(5, make::box2d(size, size));
+    image2d<unsigned short> out(size, size);
+
+    level::fill_with_value(ima, 51);
+    level::paste(ima, out);
+
+    mln_assertion(ima == out);
+  }
+
+  // image if test
+  {
+    typedef image2d<unsigned short> I;
+    typedef image_if<I, fun::p2b::chess_t> II;
+
+    I ima(size, size);
+    I out(size, size);
+    II ima_if = ima | fun::p2b::chess;
+
+    level::fill_with_value(ima, 0);
+    debug::iota(ima);
+    level::paste(ima_if, out);
+
+    mln_assertion(ima_if == out);
+  }
+
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+    typedef image2d<unsigned short> III;
+
+    I in(size, size);
+    II cast(in);
+    III out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    level::paste(cast, out);
+
+    mln_assertion(cast == out);
+  }
+
+  // sub_image test
+   {
+     typedef image2d<int> I;
+     typedef sub_image< image2d<int>, box2d > II;
+     typedef image2d<unsigned short> III;
+
+     I ima(size, size);
+     II sub_ima(ima, make::box2d(4,4, 10,10));
+     III out(size, size);
+
+     level::fill(ima, 51);
+     level::paste(sub_ima, out);
+
+     II::piter p(sub_ima.domain());
+     for_all(p)
+       mln_assertion(sub_ima(p) == out(p));
+   }
+
+   // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    level::paste(extend_ima, out);
+
+    II::piter p(extend_ima.domain());
+    for_all(p)
+      mln_assertion(extend_ima(p) == out(p));
   }
 }
diff --git a/milena/tests/level/transform.cc b/milena/tests/level/transform.cc
index f177446..e0b8ec9 100644
--- a/milena/tests/level/transform.cc
+++ b/milena/tests/level/transform.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -37,7 +37,11 @@
 #include <mln/core/image/image3d.hh>
 #include <mln/pw/image.hh>
 #include <mln/core/image/flat_image.hh>
+#include <mln/core/image/cast_image.hh>
 #include <mln/core/image/image_if.hh>
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/image/extension_val.hh>
+
 
 #include <mln/level/fill.hh>
 #include <mln/level/transform.hh>
@@ -140,6 +144,7 @@ int main()
       mln_assertion((unsigned short)std::sqrt(ima(p)) == out(p));
   }
 
+  // image if test
   {
     typedef image2d<unsigned short> I;
     typedef image_if<I, fun::p2b::chess_t> II;
@@ -157,4 +162,59 @@ int main()
       mln_assertion((unsigned short)std::sqrt(ima_if(p)) == out(p));
   }
 
+  // cast image test
+  {
+    typedef image2d<unsigned short> I;
+    typedef cast_image_<int, I> II;
+    typedef image2d<unsigned short> III;
+
+    I in(size, size);
+    II cast(in);
+    III out(size, size);
+
+    level::fill(in, 51);
+    level::fill(out, 42);
+
+    out = level::transform(cast, mysqrt());
+
+    II::piter p(cast.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(cast(p)) == out(p));
+  }
+
+  // sub_image test
+  {
+    typedef image2d<int> I;
+    typedef sub_image< image2d<int>, box2d > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II sub_ima(ima, make::box2d(4,4, 10,10));
+    III out(size, size);
+
+    level::fill(ima, 51);
+    out = level::transform(sub_ima, mysqrt());
+
+    II::piter p(sub_ima.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(sub_ima(p)) == out(p));
+  }
+
+  // extended image test
+  {
+    typedef image2d<int> I;
+    typedef extension_val< image2d<int> > II;
+    typedef image2d<unsigned short> III;
+
+    I ima(size, size);
+    II extend_ima(ima, 5);
+    III out(size, size);
+
+    level::fill(ima, 51);
+    out = level::transform(extend_ima, mysqrt());
+
+    II::piter p(extend_ima.domain());
+    for_all(p)
+      mln_assertion((unsigned short)std::sqrt(extend_ima(p)) == out(p));
+  }
 }
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* classif/iccvg04.cc: Cleanup. Fix wrong initialization.
---
 milena/sandbox/ChangeLog          |    6 ++++
 milena/sandbox/classif/iccvg04.cc |   54 +++++++++++++++---------------------
 2 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 074d329..686d969 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-25  Ugo Jardonnet  <jardonnet(a)lrde.epita.fr>
+
+	INIM: classif: Fix iccvg04.
+
+	* classif/iccvg04.cc: Cleanup. Fix wrong initialization.
+
 2008-10-24  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
 
 	Update morpho classif for LN.
diff --git a/milena/sandbox/classif/iccvg04.cc b/milena/sandbox/classif/iccvg04.cc
index b0525ef..1902e90 100644
--- a/milena/sandbox/classif/iccvg04.cc
+++ b/milena/sandbox/classif/iccvg04.cc
@@ -101,20 +101,11 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
 {
 
   unsigned count[nbasins + 1];
-  memset(count, 0, nbasins + 1);
+  memset(count, 0, (nbasins + 1) * sizeof(unsigned));
   algebra::vec<3, unsigned> sum[nbasins + 1];
 
   for (int i = 1; i < nbasins + 1; ++i)
-  {
     sum[i] = literal::zero;
-  }
-
-  /*mln_piter(K) p(ws.domain());
-  for_all(p)
-  {
-    count[ws(p)] += histo(p);
-    sum[ws(p)] += histo(p) * convert::to<algebra::vec<3, value::int_u8> >(p) * f;
-  }*/
 
   mln_piter(I) p(ima.domain());
   for_all(p)
@@ -128,7 +119,9 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
       count[w] += histo(p3);
       sum[w] += histo(p3) * convert::to< algebra::vec<3, value::int_u8> >(p3);
     }
+#if DEBUG
     std::cerr << "p3 : " << p3 << " == " << convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl;
+#endif // DEBUG
   }
 
   for (int i = 1; i < nbasins + 1; ++i)
@@ -136,7 +129,9 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
     sum[i] *= f;
     sum[i] /= count[i];
     //std::cout << "count[" << i << "] = " << count[i] << std::endl;
+#if DEBUG
     std::cout << "sum[" << i << "] = " << sum[i] << std::endl;
+#endif // DEBUG
   }
 
 
@@ -152,14 +147,18 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
 
     if (w != 0) // If w == 0 it means that the current point is part of a border of the watershed
     {
+#if DEBUG
       std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << sum[w] << std::endl;
+#endif
       out(pi) = convert::to<value::rgb8>(sum[w]);
       //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]);
       ws_out(pi) = value::rgb8(0, 0, 0);
     }
     else
     {
+#if DEBUG
       std::cerr << "Border : " << pi << std::endl;
+#endif
       ws_out(pi) = value::rgb8(255, 255, 255);
 
       // FIXME
@@ -182,8 +181,22 @@ classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
   io::ppm::save(ws_out, "out-ws.ppm");
 }
 
+bool usage(int argc, char ** argv)
+{
+  if (argc != 4)
+  {
+    std::cout << "usage: " << argv[0] << " image div_factor lambda" << std::endl;
+    return false;
+  }
+  return true;
+}
+
+
 int main(int argc, char **argv)
 {
+  if (not usage(argc, argv))
+    return 1;
+
   const int div_factor = atoi(argv[2]);
   const int lambda = atoi(argv[3]);
 
@@ -198,20 +211,6 @@ int main(int argc, char **argv)
     std::cout << "histo : " << m << ' ' << M << std::endl;
   }
 
-// Normalize histogram frequences
-#if 0
-  image3d<value::int_u8> nhisto(histo.domain());
-  level::stretch(histo, nhisto);
-  //image3d<value::int_u8> nhisto = normalizeu8(histo);
-  {
-    value::int_u8 m, M;
-    estim::min_max(nhisto, m, M);
-    std::cout << "nhisto : " << m << ' ' << M << std::endl;
-   }
-#endif
-
-  //display(nhisto, "histo");
-
   //revert histo
   image3d<unsigned> rhisto = arith::revert(histo);
   {
@@ -219,7 +218,6 @@ int main(int argc, char **argv)
     estim::min_max(rhisto, m, M);
     std::cout << "rhisto : " << m << ' ' << M << std::endl;
   }
-  //display(rhisto, "rhisto");
 
   //compute closing_area of histo
   image3d<unsigned> histo_closure(histo.domain());
@@ -230,18 +228,12 @@ int main(int argc, char **argv)
     std::cout << "histo_closure : " << m << ' ' << M << std::endl;
   }
 
-  //display_proj_revert(histo_closure, "chisto.ppm");
-
   //watershed over histo_closure
   unsigned nbasins = 0;
   image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins);
 
   std::cout << "nbassins : " << nbasins << std::endl;
 
-  //display(ws, "ws");
-  //display_proj_revert(ws, "whisto.ppm");
-  //gplot(ws);
-
   // Classify image !
   //classify_image(const I& ima, const J& histo, const K& ws, int nbasins, int f)
   classify_image(ima, histo, ws, nbasins, div_factor);
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from  Ugo Jardonnet  <jardonnet(a)lrde.epita.fr>
	INIM: classif: Fix iccvg04.
	* classif/iccvg04.cc: Cleanup. Fix wrong initialization.
  iccvg04.cc |   54 +++++++++++++++++++++++-------------------------------
  1 file changed, 23 insertions(+), 31 deletions(-)
Index: classif/iccvg04.cc
--- classif/iccvg04.cc	(revision 2686)
+++ classif/iccvg04.cc	(working copy)
@@ -101,20 +101,11 @@
  {
    unsigned count[nbasins + 1];
-  memset(count, 0, nbasins + 1);
+  memset(count, 0, (nbasins + 1) * sizeof(unsigned));
    algebra::vec<3, unsigned> sum[nbasins + 1];
    for (int i = 1; i < nbasins + 1; ++i)
-  {
      sum[i] = literal::zero;
-  }
-
-  /*mln_piter(K) p(ws.domain());
-  for_all(p)
-  {
-    count[ws(p)] += histo(p);
-    sum[ws(p)] += histo(p) * convert::to<algebra::vec<3, value::int_u8> 
 >(p) * f;
-  }*/
    mln_piter(I) p(ima.domain());
    for_all(p)
@@ -128,7 +119,9 @@
        count[w] += histo(p3);
        sum[w] += histo(p3) * convert::to< algebra::vec<3, 
value::int_u8> >(p3);
      }
+#if DEBUG
      std::cerr << "p3 : " << p3 << " == " << 
convert::to<algebra::vec<3, value::int_u8> >(p3) << std::endl;
+#endif // DEBUG
    }
    for (int i = 1; i < nbasins + 1; ++i)
@@ -136,7 +129,9 @@
      sum[i] *= f;
      sum[i] /= count[i];
      //std::cout << "count[" << i << "] = " << count[i] << std::endl;
+#if DEBUG
      std::cout << "sum[" << i << "] = " << sum[i] << std::endl;
+#endif // DEBUG
    }
@@ -152,14 +147,18 @@
      if (w != 0) // If w == 0 it means that the current point is part 
of a border of the watershed
      {
+#if DEBUG
        std::cerr << "out(" << pi << ") = sum[" << w << "]; //" << 
sum[w] << std::endl;
+#endif
        out(pi) = convert::to<value::rgb8>(sum[w]);
        //out(pi) = value::rgb8(sum[w][0], sum[w][1], sum[w][2]);
        ws_out(pi) = value::rgb8(0, 0, 0);
      }
      else
      {
+#if DEBUG
        std::cerr << "Border : " << pi << std::endl;
+#endif
        ws_out(pi) = value::rgb8(255, 255, 255);
        // FIXME
@@ -182,8 +181,22 @@
    io::ppm::save(ws_out, "out-ws.ppm");
  }
+bool usage(int argc, char ** argv)
+{
+  if (argc != 4)
+  {
+    std::cout << "usage: " << argv[0] << " image div_factor lambda" << 
std::endl;
+    return false;
+  }
+  return true;
+}
+
+
  int main(int argc, char **argv)
  {
+  if (not usage(argc, argv))
+    return 1;
+
    const int div_factor = atoi(argv[2]);
    const int lambda = atoi(argv[3]);
@@ -198,20 +211,6 @@
      std::cout << "histo : " << m << ' ' << M << std::endl;
    }
-// Normalize histogram frequences
-#if 0
-  image3d<value::int_u8> nhisto(histo.domain());
-  level::stretch(histo, nhisto);
-  //image3d<value::int_u8> nhisto = normalizeu8(histo);
-  {
-    value::int_u8 m, M;
-    estim::min_max(nhisto, m, M);
-    std::cout << "nhisto : " << m << ' ' << M << std::endl;
-   }
-#endif
-
-  //display(nhisto, "histo");
-
    //revert histo
    image3d<unsigned> rhisto = arith::revert(histo);
    {
@@ -219,7 +218,6 @@
      estim::min_max(rhisto, m, M);
      std::cout << "rhisto : " << m << ' ' << M << std::endl;
    }
-  //display(rhisto, "rhisto");
    //compute closing_area of histo
    image3d<unsigned> histo_closure(histo.domain());
@@ -230,18 +228,12 @@
      std::cout << "histo_closure : " << m << ' ' << M << std::endl;
    }
-  //display_proj_revert(histo_closure, "chisto.ppm");
-
    //watershed over histo_closure
    unsigned nbasins = 0;
    image3d<unsigned> ws = morpho::meyer_wst(histo_closure, c6(), nbasins);
    std::cout << "nbassins : " << nbasins << std::endl;
-  //display(ws, "ws");
-  //display_proj_revert(ws, "whisto.ppm");
-  //gplot(ws);
-
    // Classify image !
    //classify_image(const I& ima, const J& histo, const K& ws, int 
nbasins, int f)
    classify_image(ima, histo, ws, nbasins, div_factor);
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/level/stretch.hh
	(mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)):
	Initialize the output image from the input.
---
 milena/ChangeLog            |    8 ++++++++
 milena/mln/level/stretch.hh |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 47a4f3a..35f360b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
 2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
 
+	Fix mln::level::stretch w.r.t. the initialization.
+
+	* mln/level/stretch.hh
+	(mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)):
+	Initialize the output image from the input.
+
+2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
+
 	First attempt at generating a GraphViz' neato output.
 
 	* tests/morpho/complex_image_wst.cc: Generate a neato graph.
diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh
index 81c516f..4b70e66 100644
--- a/milena/mln/level/stretch.hh
+++ b/milena/mln/level/stretch.hh
@@ -70,6 +70,8 @@ namespace mln
       {
 	trace::entering("level::impl::stretch");
 
+	initialize(output, input);
+
 	mln_value(I) min_, max_;
 	estim::min_max(input, min_, max_);
 	if (max_ != min_)
-- 
1.6.0.1
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* mln/level/stretch.hh
	(mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)):
	Initialize the output image from the input.
---
 milena/ChangeLog            |    8 ++++++++
 milena/mln/level/stretch.hh |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 47a4f3a..35f360b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
 2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
 
+	Fix mln::level::stretch w.r.t. the initialization.
+
+	* mln/level/stretch.hh
+	(mln::level::impl::stretch(int_u<n>, const Image<I>&, Image<O>&)):
+	Initialize the output image from the input.
+
+2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
+
 	First attempt at generating a GraphViz' neato output.
 
 	* tests/morpho/complex_image_wst.cc: Generate a neato graph.
diff --git a/milena/mln/level/stretch.hh b/milena/mln/level/stretch.hh
index 81c516f..4b70e66 100644
--- a/milena/mln/level/stretch.hh
+++ b/milena/mln/level/stretch.hh
@@ -70,6 +70,8 @@ namespace mln
       {
 	trace::entering("level::impl::stretch");
 
+	initialize(output, input);
+
 	mln_value(I) min_, max_;
 	estim::min_max(input, min_, max_);
 	if (max_ != min_)
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    24 Oct '08
                    
                        	* tests/morpho/complex_image_wst.cc: Generate a neato graph.
---
 milena/ChangeLog                         |    6 ++
 milena/tests/morpho/complex_image_wst.cc |  111 +++++++++++++++++++++++++++++-
 2 files changed, 116 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9994d8b..47a4f3a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2008-10-24  Roland Levillain  <roland(a)lrde.epita.fr>
+
+	First attempt at generating a GraphViz' neato output.
+
+	* tests/morpho/complex_image_wst.cc: Generate a neato graph.
+
 2008-10-24  Nicolas Ballas  <ballas(a)lrde.epita.fr>
 
 	Update transform routine interface.
diff --git a/milena/tests/morpho/complex_image_wst.cc b/milena/tests/morpho/complex_image_wst.cc
index 88e5bc9..8060cee 100644
--- a/milena/tests/morpho/complex_image_wst.cc
+++ b/milena/tests/morpho/complex_image_wst.cc
@@ -29,8 +29,15 @@
 /// \brief Testing Meyer's Watershed Transform on mln::complex_image.
 
 #include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iomanip>
 
 #include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/black.hh>
+#include <mln/literal/white.hh>
+
 #include <mln/core/alias/point2d.hh>
 
 #include <mln/core/site_set/p_faces.hh>
@@ -47,6 +54,29 @@
 #include <mln/morpho/closing_area.hh>
 #include <mln/morpho/meyer_wst.hh>
 
+#include <mln/core/concept/function.hh>
+
+// FIXME: To be put elsewhere (from milena/sandbox/geraud/wst_edge.cc).
+struct colorize : mln::Function_v2v< colorize >
+{
+  typedef mln::value::rgb8 result;
+  colorize(unsigned max)
+    : lut(max + 1)
+  {
+    lut[0] = mln::literal::black;
+    for (unsigned i = 1; i <= max; ++i)
+      lut[i] = result(100 + std::rand() % 150,
+		      100 + std::rand() % 150,
+		      100 + std::rand() % 150);
+  }
+  result operator()(unsigned i) const
+  {
+    return lut[i];
+  }
+  std::vector<result> lut;
+};
+
+
 
 int main()
 {
@@ -203,5 +233,84 @@ int main()
 
      We definitely need a complex_image that can accept a subset of a
      complex as domain (or at least a p_face<N, D, P>.  */
-  std::cout << "nbasins = " << nbasins << std::endl;
+  wst_val_t actual_nbasins = nbasins - c.nfaces<0>();
+  std::cout << "nbasins = " << actual_nbasins << std::endl;
+
+
+  colorize color(nbasins);
+
+  std::ofstream g("wst.neato");
+  g << "graph wst"  << std::endl
+    << "{" << std::endl
+    << "  graph [bgcolor = \"#000000\"]" << std::endl
+    << "  edge [color = \"#FFFFFF\"]" << std::endl
+    << "  node [color = \"#FFFFFF\", fontcolor = \"#FFFFFF\" ]" << std::endl;
+
+  // Vertices.
+  typedef complex_higher_neighborhood<D, G> e_nbh_t;
+  e_nbh_t e_nbh;
+  mln_niter_(e_nbh_t) v_e(e_nbh, v_);   
+  for_all(v_)
+  {
+    // Find the adjacent basin (color).
+    value::rgb8 basin_color = literal::white;
+    for_all(v_e)
+      if (wshed(v_e) != 0)
+	{
+	  basin_color = color(wshed(v_e));
+	  break;
+	}
+    std::ostringstream basin_color_str;
+    basin_color_str << '#'
+		    << std::hex
+		    << std::setfill('0')
+		    << std::setw(2) << basin_color.red()
+		    << std::setw(2) << basin_color.green()
+		    << std::setw(2) << basin_color.blue()
+		    << std::dec;
+
+    g << "  v" << v_.unproxy_().face_id()
+      << " [pos = \""
+      << std::fixed << std::setprecision(1)
+      << (float)v_.to_site().front()[1] << ", "
+      << -(float)v_.to_site().front()[0]
+      << "\", color = \"" << basin_color_str.str()
+      << "\", fillcolor = \"" << basin_color_str.str()
+      << "\", pin = \"true\", style=\"filled,setlinewidth(3)\"];"
+      << std::endl;
+  }
+
+  for_all(e)
+  {
+    value::rgb8 basin_color = color(wshed(e));
+    std::ostringstream basin_color_str;
+    basin_color_str << '#'
+	      << std::hex
+	      << std::setfill('0')
+	      << std::setw(2) << basin_color.red()
+	      << std::setw(2) << basin_color.green()
+	      << std::setw(2) << basin_color.blue()
+	      << std::dec;
+
+    // Adjacent vertices.
+    v.start();
+    topo::face<1> v1 = v.unproxy_().face();
+    point2d p1 = v.to_site().front();
+    v.next();
+    topo::face<1> v2 = v.unproxy_().face();
+    point2d p2 = v.to_site().front();
+    v.next();
+    mln_invariant(!v.is_valid());
+
+    // Edges.
+    g << "  v" << v1.face_id() << " -- v" << v2.face_id() << " ";
+    if (wshed(e) == 0)
+      g << "[color = \"#FFFFFF\"];" << std::endl;
+    else
+      g << "[color = \"" << basin_color_str.str()
+	<< "\", style=\"setlinewidth(3)\"];" << std::endl;
+  }
+
+  g << "}" << std::endl;
+  g.close();
 }
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0