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
 
March 2009
- 9 participants
 - 202 discussions
 
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-19  Fabien Freling  <fabien.freling(a)lrde.epita.fr>
	Add a new file translating IGR Matlab code.
	* fabien/bin/dump2pbm.cc: Minor fix.
	* fabien/igr/Makefile: Update.
	* fabien/igr/check.sh: Update.
	* fabien/igr/matlab.cc: New file translating matlab code.
	* fabien/igr/med.cc: Update.
	* fabien/igr/thres.cc: Update.
	* fabien/magick/load.hh: Moved to mln/io/magick.
	* fabien/magick/magick.cc: Update.
---
 TODO             |   12 +++--
 bin/dump2pbm.cc  |   28 +++++++++---
 igr/Makefile     |    3 +
 igr/check.sh     |   10 ++--
 igr/matlab.cc    |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 igr/med.cc       |   47 ++++++++++++++++++++
 igr/thres.cc     |    7 ++-
 magick/magick.cc |    9 +++
 8 files changed, 223 insertions(+), 19 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/matlab.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/matlab.cc	(revision 0)
+++ trunk/milena/sandbox/fabien/igr/matlab.cc	(revision 3545)
@@ -0,0 +1,126 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/dicom/load.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/sum.hh>
+#include <mln/accu/image/all.hh>
+#include <mln/arith/minus.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
+#include <mln/level/compute.hh>
+#include <mln/math/abs.hh>
+#include <mln/pw/all.hh>
+#include <mln/trait/concrete.hh>
+#include <mln/util/array.hh>
+
+#include <cmath>
+
+using namespace mln;
+
+
+inline
+image2d<float> mean_slices(util::array<image2d<float> >& arr_ima, int first, int last)
+{
+  image2d<accu::mean<float> > result;
+
+  mln_precondition(first >=0 && first < arr_ima.nelements());
+  mln_precondition(last >=0 && last < arr_ima.nelements());
+
+  accu::image::init(result);
+  for (int i = first; i < last; ++i)
+    accu::image::take(result, arr_ima[i]);
+
+  return accu::image::to_result(result);
+}
+
+
+int main(int argc, char* argv[])
+{
+  if (argc != 2)
+  {
+    std::cout << "Usage: " << argv[0] << "input" << std::endl;
+    return 1;
+  }
+
+  image3d<value::int_u12> input;
+  io::dicom::load(input, argv[1]);
+  util::array<image2d<float> > arr_ima;
+  for (int i = 0; i < input.nslices(); ++i)
+    arr_ima.append(duplicate(cast_image<float>(slice(input, i))));
+
+  int acqui = 3;  // durée acqui et temps interimages; en secondes
+  int fseuil = 4; // ratio entre signaux trop faibles, éliminés, et bruit de fond mesuré sur l image
+  int ini = 9;    // nombre images ligne de base
+  int ini2 = 20;  // a la fin de la montée vasculaire, à la dixieme image post injection: lissage des images par trois
+
+  // Calcul signal initialmoyen : 8 images de 2 à 9 moyennées=ligne de base
+  image2d<float> imageini = mean_slices(arr_ima, 1, 8);
+
+  int dim1 = imageini.nrows();
+  int dim2 = imageini.ncols();
+  int dim3 = arr_ima.nelements();
+
+  // Calcul auc aire sous la courbe
+  util::array<image2d<float> > arr_sous;
+  for (int k = 0; k < arr_ima.nelements(); ++k)
+    arr_sous.append(arr_ima[k] - imageini);
+
+  // Mesure bruit de fond pour seuiller
+  // calculé sur la première image
+  image2d<bool> roi_noise; // FIXME: init this ROI, should be a domain
+  accu::count<bool> accu_nbrpix1;
+  unsigned nbrpix1 = level::compute(accu_nbrpix1, roi_noise);
+  image2d<float> datasli = arr_ima[0];
+
+  image2d<float> prodsignal1;
+  data::fill(prodsignal1, 0.0);
+  data::paste(datasli | pw::value(roi_noise) == pw::cst(true), prodsignal1);
+
+  // moyenne
+  accu::mean<float> accu_mean;
+  float moysignal1 = level::compute(accu_mean, prodsignal1 | pw::value(roi_noise) == pw::cst(true));
+  // ecart type
+  int som1 = 0;
+  int kk = 0;
+  mln_piter_(image2d<float>) p(datasli.domain());
+  for_all(p)
+  {
+    if (roi_noise(p))
+      som1 += std::pow(math::abs(datasli(p) - moysignal1), 2);
+  }
+  float ectys = std::sqrt(som1 / (nbrpix1 - 1));
+  float seuil = fseuil * ectys;
+
+  // Calcul du masque
+  image2d<bool> masque; // FIXME: init this ROI, should be a domain
+  initialize(masque, datasli);
+  data::fill(masque, false)
+  data::fill(masque | pw::value(datasli) > pw::cst(seuil), true);
+  // si on a choisi une région avec roi2
+  if (nargin>2)
+    masque=masque.*roi2;
+
+  //on applique le masque sur image et imasoustraite
+
+  for k=2:dim3
+    for i=1:dim1
+      for j=1:dim2
+	if(masque(i,j)==0)
+	  image(i,j,k)=0;
+  imasoustraite(i,j,k)=0;
+  end;
+  end;
+  end;
+  end;
+
+  return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/check.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/check.sh	(revision 3544)
+++ trunk/milena/sandbox/fabien/igr/check.sh	(revision 3545)
@@ -15,11 +15,11 @@
     echo "    nbasins = $nbasins"
     ../bin/dumpl32_to_colorize wst.dump $dim $nbasins results/colorize_${3}_${lambda_closing}.ppm
     median=`./med wst.dump $dim $input $nbasins`
-    echo "    median = $median"
+#echo "    median = $median"
     threshold=$(($median / 2))
     ../bin/dumpi12_to_pgm med.dump $dim results/median_${3}_${lambda_closing}.pgm
     ./thres med.dump $dim $threshold
-    mv result.pbm results/result_${3}_${lambda_closing}.pbm
+    ../bin/dump2pbm result.dump $dim results/result_${3}_${lambda_closing}.pbm
 
 #if [ $2 -eq 2 ]; then
 #     if [ ${lambda_closing} -eq 100 ]; then
@@ -39,8 +39,8 @@
 }
 
 process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" 2 "49"
-#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3 "52"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" 3 "52"
 process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" 2 "55"
 process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0058.dcm" 2 "58"
-#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" 3 "61"
-#process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" 3 "64"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" 3 "61"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" 3 "64"
Index: trunk/milena/sandbox/fabien/igr/med.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/med.cc	(revision 3544)
+++ trunk/milena/sandbox/fabien/igr/med.cc	(revision 3545)
@@ -63,6 +63,8 @@
   }
 
   unsigned median = 0;
+  int bg = 0;
+  int fg = 0;
 
   if (dim == 2)
   {
@@ -88,14 +90,57 @@
     accu::median_h<int_u12> accu_med;
     median = level::compute(accu_med, ima_histo | pw::value(ima_histo) != pw::cst(0));
 
+    for (int i = 0; i < histogram.nvalues(); ++i)
+    {
+      if (histogram[i])
+      {
+	if (histogram[i] > median / 2)
+	  ++fg;
+	else ++bg;
+      }
+    }
+
     io::dump::save(wst_mean, "med.dump");
   }
   else
   {
-    // FIXME
+    image3d<L> labels;
+    io::dump::load(labels, argv[1]);
+    image3d<int_u12> dcm;
+    io::dicom::load(dcm, argv[3]);
+
+    mln_VAR(wst_dilate, morpho::elementary::dilation(extend(labels | (pw::value(labels) == 0u), labels), c26()));
+    data::fill((labels | (pw::value(labels) == 0u)).rw(), wst_dilate);
+    mln_VAR(wst_mean, labeling::mean_values(dcm, labels, nbasins));
+
+    histo::array<int_u12> histogram = histo::compute(wst_mean);
+    int j = 0;
+    int k = 0;
+    for (int i = 0; i < histogram.nvalues(); ++i)
+    {
+      if (histogram[i])
+	histogram[i] = i;
+    }
+    image1d<unsigned> ima_histo;
+    convert::from_to(histogram, ima_histo);
+    accu::median_h<int_u12> accu_med;
+    median = level::compute(accu_med, ima_histo | pw::value(ima_histo) != pw::cst(0));
+
+    for (int i = 0; i < histogram.nvalues(); ++i)
+    {
+      if (histogram[i])
+      {
+	if (histogram[i] > median / 2)
+	  ++fg;
+	else ++bg;
+      }
+    }
+
+    io::dump::save(wst_mean, "med.dump");
   }
 
   std::cout << median << std::endl;
+  std::cerr << "    [ " << bg << " <" << median / 2 << "> " << fg << " ]" << std::endl;
 
   return 0;
 }
Index: trunk/milena/sandbox/fabien/igr/thres.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/thres.cc	(revision 3544)
+++ trunk/milena/sandbox/fabien/igr/thres.cc	(revision 3545)
@@ -56,11 +56,14 @@
     image2d<int_u12> input;
     io::dump::load(input, argv[1]);
     image2d<bool> bin_result = binarization::threshold(input, threshold);
-    io::pbm::save(bin_result, "result.pbm");
+    io::dump::save(bin_result, "result.dump");
   }
   else
   {
-    // FIXME
+    image3d<int_u12> input;
+    io::dump::load(input, argv[1]);
+    image3d<bool> bin_result = binarization::threshold(input, threshold);
+    io::dump::save(bin_result, "result.dump");
   }
 
   return 0;
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile	(revision 3544)
+++ trunk/milena/sandbox/fabien/igr/Makefile	(revision 3545)
@@ -48,5 +48,8 @@
 thres: thres.cc
 	g++ -I../../../ ${CXXFLAGS} $^ -o thres
 	
+matlab: matlab.cc
+	g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} -lm $^ -o matlab
+	
 clean:
 	rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO	(revision 3544)
+++ trunk/milena/sandbox/fabien/TODO	(revision 3545)
@@ -30,7 +30,13 @@
 [X] Test 3D workflow on 2D images
 [X] Create colorized colors for graph
 [X] Diff with %
-[ ] Find biggest dark regions (threshold value or median accu - median / 2 - )
-   [ ] Learn regions value
-      [ ] Threshold
+[X] Find biggest dark regions (threshold value or median accu - median / 2 - )
+   [X] Learn regions value
+      [X] Threshold
+         [X] 3D
+         [X] Print nb bg regions // nb fg objets
 [ ] Profile for performance
+[ ] ImageMagick support
+[ ] Integrate external libraries (GDCM, IM)
+[ ] Send result images to lrde account
+[ ] Translate Matlab code
Index: trunk/milena/sandbox/fabien/bin/dump2pbm.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dump2pbm.cc	(revision 3544)
+++ trunk/milena/sandbox/fabien/bin/dump2pbm.cc	(revision 3545)
@@ -1,5 +1,6 @@
-
 #include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/slice_image.hh>
 #include <mln/make/image3d.hh>
 #include <mln/debug/slices_2d.hh>
 
@@ -12,7 +13,7 @@
 
 void usage(char* argv[])
 {
-  std::cerr << "usage: " << argv[0] << " input.dump output.pbm" << std::endl;
+  std::cerr << "usage: " << argv[0] << " input.dump dim output.pbm" << std::endl;
   abort();
 }
 
@@ -23,13 +24,28 @@
   using namespace mln;
   using value::int_u16;
 
-  if (argc != 3)
+  if (argc != 4)
     usage(argv);
 
+  unsigned dim = atoi(argv[2]);
+  if (dim != 2 && dim != 3)
+  {
+    std::cout << "dimensions invalid" << std::endl;
+    return 1;
+  }
+
+  if (dim == 2)
+  {
+    image2d<bool> ima;
+    io::dump::load(ima, argv[1]);
+    io::pbm::save(ima, argv[3]);
+  }
+  else
+  {
   image3d<bool> vol;
   io::dump::load(vol, argv[1]);
 
-  int_u16 bg = 0;
-  image2d<bool> ima = debug::slices_2d(vol, 1.f, bg);
-  io::pbm::save(ima, argv[2]);
+    image2d<bool> ima = debug::slices_2d(vol, 1.f, false);
+    io::pbm::save(ima, argv[3]);
+  }
 }
Index: trunk/milena/sandbox/fabien/magick/load.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/magick/magick.cc
===================================================================
--- trunk/milena/sandbox/fabien/magick/magick.cc	(revision 3544)
+++ trunk/milena/sandbox/fabien/magick/magick.cc	(revision 3545)
@@ -1,11 +1,15 @@
 #include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
 #include <mln/value/rgb8.hh>
 
-#include "load.hh"
+#include <mln/io/magick/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/save.hh>
 
 int main(int argc, char* argv[])
 {
   using namespace mln;
+  using value::int_u8;
   using value::rgb8;
 
   if (argc != 2)
@@ -14,9 +18,10 @@
     return 1;
   }
 
-  image2d<rgb8> lena;
+  image2d<bool> lena;
 
   io::magick::load(lena, argv[1]);
+  io::pbm::save(lena, "result.pbm");
 
   return 0;
 }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    19 Mar '09
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from  Thierry Geraud  <thierry.geraud(a)lrde.epita.fr>
	Add meta-code to access component types of value types.
	* mln/trait/value/internal: New directory.
	* mln/trait/value/internal/all.hh: New.
	* mln/trait/value/internal/comp.hh: New.
	* mln/trait/value/comp.hh: New.
	* mln/trait/value/all.hh: Update.
	* mln/trait/value_.hh,
	* mln/trait/value/nature.hh: Upgrade doc style.
	* mln/value/builtin/symbolics.hh,
	* mln/value/builtin/floatings.hh,
	* mln/value/builtin/integers.hh (trait_): Add dim.
	* mln/value/builtin/carrays.hh: New.
	* mln/value/builtin/all.hh: Update.
	* mln/algebra/vec.hh (trait_): Add dim and comp.
	* tests/trait/value/comp.cc: New.
	* tests/trait/value/Makefile.am: Update.
 mln/algebra/vec.hh               |    7 +
 mln/trait/value/all.hh           |   14 ++-
 mln/trait/value/comp.hh          |   46 ++++++++++++
 mln/trait/value/internal/all.hh  |   39 ++++++++++
 mln/trait/value/internal/comp.hh |  127 ++++++++++++++++++++++++++++++++++
 mln/trait/value/nature.hh        |   10 +-
 mln/trait/value_.hh              |    4 -
 mln/value/builtin/all.hh         |   13 +--
 mln/value/builtin/carrays.hh     |   83 ++++++++++++++++++++++
 mln/value/builtin/floatings.hh   |   12 ++-
 mln/value/builtin/integers.hh    |    5 -
 mln/value/builtin/symbolics.hh   |    5 -
 tests/trait/value/Makefile.am    |    2 
 tests/trait/value/comp.cc        |  142 +++++++++++++++++++++++++++++++++++++++
 14 files changed, 482 insertions(+), 27 deletions(-)
Index: mln/trait/value_.hh
--- mln/trait/value_.hh	(revision 3543)
+++ mln/trait/value_.hh	(working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
Index: mln/trait/value/all.hh
--- mln/trait/value/all.hh	(revision 3543)
+++ mln/trait/value/all.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
 #ifndef MLN_TRAIT_VALUE_ALL_HH
 # define MLN_TRAIT_VALUE_ALL_HH
 
-/*! \file mln/trait/value/all.hh
- *
- * \brief FIXME
- */
+/// \file mln/trait/value/all.hh
+///
+/// Include all value traits.
 
 
 namespace mln
@@ -54,5 +54,9 @@
 # include <mln/trait/value/kind.hh>
 # include <mln/trait/value/quant.hh>
 
+// Sub-directory.
+
+# include <mln/trait/value/internal/all.hh>
+
 
 #endif // ! MLN_TRAIT_VALUE_ALL_HH
Index: mln/trait/value/nature.hh
--- mln/trait/value/nature.hh	(revision 3543)
+++ mln/trait/value/nature.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
 #ifndef MLN_TRAIT_VALUE_NATURE_HH
 # define MLN_TRAIT_VALUE_NATURE_HH
 
-/*! \file mln/trait/value/nature.hh
- *
- * \brief Nature of values (for use in images).
- */
+/// \file mln/trait/value/nature.hh
+///
+/// Nature of values (for use in images).
 
 # include <string>
 
Index: mln/trait/value/internal/all.hh
--- mln/trait/value/internal/all.hh	(revision 0)
+++ mln/trait/value/internal/all.hh	(revision 0)
@@ -0,0 +1,39 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_VALUE_INTERNAL_ALL_HH
+# define MLN_TRAIT_VALUE_INTERNAL_ALL_HH
+
+/// \file mln/trait/value/internal/all.hh
+///
+/// Include all internals for value traits.
+
+
+# include <mln/trait/value/internal/comp.hh>
+
+
+#endif // ! MLN_TRAIT_VALUE_INTERNAL_ALL_HH
Index: mln/trait/value/internal/comp.hh
--- mln/trait/value/internal/comp.hh	(revision 0)
+++ mln/trait/value/internal/comp.hh	(revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_VALUE_INTERNAL_COMP_HH
+# define MLN_TRAIT_VALUE_INTERNAL_COMP_HH
+
+/// \file mln/trait/value/internal/comp.hh
+///
+/// Include all internals for value traits.
+
+# include <mln/metal/bool.hh>
+# include <mln/metal/if.hh>
+
+
+
+# define mln_trait_value_comp(T, i)  typename mln::trait::value::internal::comp< T, i >::ret
+
+
+
+namespace mln
+{
+
+  namespace trait
+  {
+
+
+    // Forward declaration.
+    template <typename V> struct value_;
+
+
+    namespace value
+    {
+
+      namespace internal
+      {
+
+	// bind_comp< T, i >
+
+	template <typename Tr, unsigned i>
+	struct bind_comp;
+
+	template <typename Tr> struct bind_comp< Tr, 0 > { typedef typename Tr::comp_0 ret; };
+	template <typename Tr> struct bind_comp< Tr, 1 > { typedef typename Tr::comp_1 ret; };
+	template <typename Tr> struct bind_comp< Tr, 2 > { typedef typename Tr::comp_2 ret; };
+	template <typename Tr> struct bind_comp< Tr, 3 > { typedef typename Tr::comp_3 ret; };
+	template <typename Tr> struct bind_comp< Tr, 4 > { typedef typename Tr::comp_4 ret; };
+	template <typename Tr> struct bind_comp< Tr, 5 > { typedef typename Tr::comp_5 ret; };
+	template <typename Tr> struct bind_comp< Tr, 6 > { typedef typename Tr::comp_6 ret; };
+	template <typename Tr> struct bind_comp< Tr, 7 > { typedef typename Tr::comp_7 ret; };
+	template <typename Tr> struct bind_comp< Tr, 8 > { typedef typename Tr::comp_8 ret; };
+	template <typename Tr> struct bind_comp< Tr, 9 > { typedef typename Tr::comp_9 ret; };
+
+
+	// get_comp< T, i, dim >
+
+	template <typename C, typename Tr, unsigned i>
+	struct get_comp_helper
+	{
+	  typedef C ret;
+	};
+
+	template <typename Tr, unsigned i>
+	struct get_comp_helper< void, Tr, i >
+	{
+	  typedef typename bind_comp<Tr, i>::ret ret;
+	};
+
+	template <typename T, unsigned i, unsigned dim>
+	struct get_comp
+	{
+	  typedef mln::trait::value_<T> Tr;
+	  typedef typename Tr::comp C;
+	  typedef typename get_comp_helper<C, Tr, i>::ret ret;
+	};
+
+	template <typename T>
+	struct get_comp< T, 0, 1 >
+	{
+	  typedef T ret;
+	};
+	
+
+	// comp< T, i >
+
+	template <typename T, unsigned i>
+	struct comp
+	  : private metal::bool_< (i < mln::trait::value_<T>::dim) >::check_t
+	{
+	  enum { dim = mln::trait::value_<T>::dim };
+	  typedef typename get_comp<T, i, dim>::ret ret;
+	};
+
+      } // end of namespace mln::trait::value::internal
+
+    } // end of namespace mln::trait::value
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_TRAIT_VALUE_INTERNAL_COMP_HH
Index: mln/trait/value/comp.hh
--- mln/trait/value/comp.hh	(revision 0)
+++ mln/trait/value/comp.hh	(revision 0)
@@ -0,0 +1,46 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_VALUE_COMP_HH
+# define MLN_TRAIT_VALUE_COMP_HH
+
+/// \file mln/trait/value/comp.hh
+///
+/// Access to the i-th component type of a given type.
+
+# include <mln/trait/value/internal/comp.hh>
+
+
+
+# define mln_trait_value_comp(T, i)				\
+								\
+   typename mln::trait::value::internal::comp< T, i >::ret
+
+
+
+
+#endif // ! MLN_TRAIT_VALUE_COMP_HH
Index: mln/value/builtin/symbolics.hh
--- mln/value/builtin/symbolics.hh	(revision 3543)
+++ mln/value/builtin/symbolics.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -59,13 +60,13 @@
       typedef value::kind::binary     kind;
 
       enum {
+	dim   = 1,
 	nbits = 1,
 	card  = 2
       };
       typedef value::quant::low       quant;
 
       static const char* name() { return "bool"; }
-
     };
 
   } // end of namespace mln::trait
Index: mln/value/builtin/carrays.hh
--- mln/value/builtin/carrays.hh	(revision 0)
+++ mln/value/builtin/carrays.hh	(revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_VALUE_BUILTIN_CARRAYS_HH
+# define MLN_VALUE_BUILTIN_CARRAYS_HH
+
+/// \file mln/value/builtin/carrays.hh
+///
+/// Traits definition for C arrays.
+
+# include <sstream>
+
+# include <mln/value/concept/built_in.hh>
+# include <mln/value/concept/vectorial.hh>
+# include <mln/trait/value_.hh>
+
+
+namespace mln
+{
+
+
+  template <unsigned n, typename T>
+  struct category< T[n] >
+  {
+    typedef value::Built_In< value::Vectorial<void> > ret;
+  };
+
+
+  namespace trait
+  {
+
+    template <unsigned n, typename T>
+    struct value_< T[n] >
+    {
+      enum {
+	dim   = n,
+	nbits = n * value_<T>::nbits,
+	card  = n * value_<T>::card
+      };
+      typedef T comp;
+
+      typedef value::nature::vectorial nature;
+      typedef mln_trait_value_kind(T)  kind;
+      typedef value::quant::high       quant;
+
+      static const char* name()
+      {
+	std::ostringstream s;
+	s << value_<T>::name() << '[' << n << ']';
+	return s.str();
+      }
+    };
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_BUILTIN_CARRAYS_HH
Index: mln/value/builtin/floatings.hh
--- mln/value/builtin/floatings.hh	(revision 3543)
+++ mln/value/builtin/floatings.hh	(working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -60,10 +60,14 @@
   namespace trait
   {
 
+
+    // float.
+
     template <>
     struct value_< float >
     {
       enum {
+	dim   = 1,
 	nbits = 8 * sizeof(float),
 	card  = 0
       };
@@ -95,10 +99,14 @@
 
     };
 
+
+    // double.
+
     template <>
     struct value_< double >
     {
       enum {
+	dim   = 1,
 	nbits = 8 * sizeof(double),
 	card  = 0
       };
Index: mln/value/builtin/all.hh
--- mln/value/builtin/all.hh	(revision 3543)
+++ mln/value/builtin/all.hh	(working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+// (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -28,15 +29,15 @@
 #ifndef MLN_VALUE_BUILTIN_ALL_HH
 # define MLN_VALUE_BUILTIN_ALL_HH
 
-/*! \file mln/value/builtin/all.hh
- *
- * \brief File that includes all materials related to built-in types.
- */
+/// \file mln/value/builtin/all.hh
+///
+/// File that includes all materials related to built-in types.
 
 
-# include <mln/value/builtin/symbolics.hh>
+# include <mln/value/builtin/carrays.hh>
 # include <mln/value/builtin/integers.hh>
 # include <mln/value/builtin/floatings.hh>
+# include <mln/value/builtin/symbolics.hh>
 
 # include <mln/value/builtin/promotions.hh>
 # include <mln/value/builtin/ops.hh>
Index: mln/value/builtin/integers.hh
--- mln/value/builtin/integers.hh	(revision 3543)
+++ mln/value/builtin/integers.hh	(working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -73,6 +73,7 @@
       public:
 
 	enum {
+	  dim = 1,
 	  nbits = n,
 	  card  = mln_value_card_from_(n)
 	};
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh	(revision 3543)
+++ mln/algebra/vec.hh	(working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2006, 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2006, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -81,11 +81,12 @@
       typedef trait::value::kind::data        kind;
 
       enum {
+	dim   = n,
 	nbits = n * mln_nbits(T),
 	card  = n * mln_card(T)
       };
+      typedef T comp;
       typedef mln_value_quant_from_(card)     quant;
-
       typedef algebra::vec<n, mln_sum(T)> sum;
     };
 
Index: tests/trait/value/comp.cc
--- tests/trait/value/comp.cc	(revision 0)
+++ tests/trait/value/comp.cc	(revision 0)
@@ -0,0 +1,142 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/trait/value/comp.cc
+///
+/// Tests on mln_trait_value_comp.
+///
+/// \todo Add tests on some actual heterogeneous types.
+
+#include <mln/trait/value/comp.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/algebra/vec.hh>
+
+
+
+
+template <typename T, unsigned i, typename C>
+void check_equal()
+{
+  mlc_equal(mln_trait_value_comp(T, i), C)::check();
+}
+
+
+template <typename T>
+void check_scalar()
+{
+  mlc_equal(mln_trait_value_comp(T, 0), T)::check();
+}
+
+
+template <typename T, typename C>
+void check_homogeneous()
+{
+  mlc_equal(mln_trait_value_comp(T, 0), C)::check();
+}
+
+
+namespace mln
+{
+
+  template <typename R, typename G, typename B>
+  struct my_rgb;
+
+  namespace trait
+  {
+
+    template <typename R, typename G, typename B>
+    struct value_< my_rgb<R,G,B> >
+    {
+      enum { dim = 3 };
+      typedef void comp;
+      typedef R comp_0;
+      typedef G comp_1;
+      typedef B comp_2;
+    };
+
+  } // mln::trait
+
+} // mln
+
+
+
+template <typename T,
+	  typename C0, typename C1, typename C2>
+void check_heterogeneous()
+{
+  mlc_equal(mln_trait_value_comp(T, 0), C0)::check();
+  mlc_equal(mln_trait_value_comp(T, 1), C1)::check();
+  mlc_equal(mln_trait_value_comp(T, 2), C2)::check();
+}
+
+
+
+int main()
+{
+  using namespace mln;
+
+
+  // Scalars.
+
+  {
+    typedef mln::value::int_u8 T;
+    check_scalar<T>();
+    check_equal<T, 0, T>();
+  }
+  {
+    typedef int T;
+    check_scalar<T>();
+    check_equal<T, 0, T>();
+  }
+
+
+  // Homogeneous vectors.
+
+  {
+    typedef float C;
+    typedef algebra::vec<2, C> T;
+    check_homogeneous< T, C >();
+    check_equal< T, 0, C >();
+    check_equal< T, 1, C >();
+  }
+  {
+    typedef double C;
+    typedef C T[2];
+    check_homogeneous< T, C >();
+    check_equal< T, 0, C >();
+    check_equal< T, 1, C >();
+  }
+
+
+  // Heterogeneous types.
+
+  {
+    check_heterogeneous< my_rgb< bool, unsigned, float* >,
+                                 bool, unsigned, float* >();
+  }
+}
Index: tests/trait/value/Makefile.am
--- tests/trait/value/Makefile.am	(revision 3543)
+++ tests/trait/value/Makefile.am	(working copy)
@@ -3,8 +3,10 @@
 include $(top_srcdir)/milena/tests/tests.mk
 
 check_PROGRAMS =				\
+  comp						\
   values
 
+comp_SOURCES = comp.cc
 values_SOURCES = values.cc
 
 TESTS = $(check_PROGRAMS)
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        ---
 ChangeLog    |    4 ++++
 configure.ac |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 35f0ba0..58297c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-18  Guillaume Lazzara  <lazzara(a)lrde.epita.fr>
+
+	* configure.ac: configure tests/accu/image.
+
 2009-03-18  Roland Levillain  <roland(a)lrde.epita.fr>
 
 	* configure.ac: Always configure directory external/trimesh/.
diff --git a/configure.ac b/configure.ac
index 0b05502..118ce2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,6 +184,7 @@ AC_CONFIG_FILES([milena/tests/data.hh])
 AC_CONFIG_FILES([
   milena/tests/Makefile
     milena/tests/accu/Makefile
+    milena/tests/accu/image/Makefile
     milena/tests/algebra/Makefile
     milena/tests/arith/Makefile
     milena/tests/binarization/Makefile
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* headers.mk,
	* tests/unit_test/unit-tests.mk: update.
	* mln/morpho/watershed/all.hh: add new include.
	* mln/morpho/watershed/superpose.hh: new routine.
	* tests/morpho/watershed/Makefile.am,
	* tests/morpho/watershed/superpose.cc: add associated test.
---
 milena/ChangeLog                                   |   16 +++-
 milena/headers.mk                                  |   12 ++
 milena/mln/morpho/watershed/all.hh                 |    1 +
 milena/mln/morpho/watershed/superpose.hh           |  127 ++++++++++++++++++++
 milena/tests/morpho/watershed/Makefile.am          |    4 +-
 .../all.hh => tests/morpho/watershed/superpose.cc} |   65 +++++++----
 milena/tests/unit_test/unit-tests.mk               |   22 ++++
 7 files changed, 222 insertions(+), 25 deletions(-)
 create mode 100644 milena/mln/morpho/watershed/superpose.hh
 copy milena/{mln/morpho/watershed/all.hh => tests/morpho/watershed/superpose.cc} (53%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index cda14ac..46e8b76 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,18 @@
-2009-03-16  Guillaume Lazzara  <lazzara(a)lrde.epita.fr>
+2009-03-18  Guillaume Lazzara  <lazzara(a)lrde.epita.fr>
+
+	Add morpho::watershed::superpose.
+
+	* headers.mk,
+	* tests/unit_test/unit-tests.mk: update.
+
+	* mln/morpho/watershed/all.hh: add new include.
+
+	* mln/morpho/watershed/superpose.hh: new routine.
+
+	* tests/morpho/watershed/Makefile.am,
+	* tests/morpho/watershed/superpose.cc: add associated test.
+
+2009-03-18  Guillaume Lazzara  <lazzara(a)lrde.epita.fr>
 
 	Small fixes.
 
diff --git a/milena/headers.mk b/milena/headers.mk
index dfab609..a74f35f 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -234,6 +234,7 @@ mln/fun/v2v/cast.hh \
 mln/fun/v2v/ch_function_value.hh \
 mln/fun/v2v/rgb_to_hsi.hh \
 mln/fun/v2v/enc.hh \
+mln/fun/v2v/projection.hh \
 mln/fun/v2v/convert.hh \
 mln/fun/v2v/essential.hh \
 mln/fun/v2w2v/cos.hh \
@@ -410,6 +411,12 @@ mln/accu/lor_basic.hh \
 mln/accu/transform_diagonal.hh \
 mln/accu/nil.hh \
 mln/accu/bbox.hh \
+mln/accu/image/init.hh \
+mln/accu/image/to_result.hh \
+mln/accu/image/all.hh \
+mln/accu/image/set_value.hh \
+mln/accu/image/take.hh \
+mln/accu/image/take_as_init.hh \
 mln/accu/center.hh \
 mln/accu/line.hh \
 mln/accu/essential.hh \
@@ -652,6 +659,7 @@ mln/morpho/laplacian.hh \
 mln/morpho/all.hh \
 mln/morpho/watershed/flooding.hh \
 mln/morpho/watershed/all.hh \
+mln/morpho/watershed/superpose.hh \
 mln/morpho/opening/approx/all.hh \
 mln/morpho/opening/approx/structural.hh \
 mln/morpho/opening/all.hh \
@@ -812,6 +820,7 @@ mln/core/internal/image_domain_morpher.hh \
 mln/core/internal/image_primary.hh \
 mln/core/internal/set_of.hh \
 mln/core/internal/complex_window_p_base.hh \
+mln/core/internal/piter_identity.hh \
 mln/core/internal/graph_window_base.hh \
 mln/core/internal/piter_adaptor.hh \
 mln/core/internal/weighted_window_base.hh \
@@ -936,6 +945,7 @@ mln/core/clock_neighb2d.hh \
 mln/core/pixter3d.hh \
 mln/core/image/obased_rle_encode.hh \
 mln/core/image/plain.hh \
+mln/core/image/unproject_image.hh \
 mln/core/image/image3d.hh \
 mln/core/image/decorated_image.hh \
 mln/core/image/extension_ima.hh \
@@ -1047,6 +1057,8 @@ mln/io/cloud/load.hh \
 mln/io/cloud/all.hh \
 mln/io/cloud/save.hh \
 mln/io/all.hh \
+mln/io/magick/load.hh \
+mln/io/magick/all.hh \
 mln/io/dump/load.hh \
 mln/io/dump/all.hh \
 mln/io/dump/save.hh \
diff --git a/milena/mln/morpho/watershed/all.hh b/milena/mln/morpho/watershed/all.hh
index 472ff20..cb2238e 100644
--- a/milena/mln/morpho/watershed/all.hh
+++ b/milena/mln/morpho/watershed/all.hh
@@ -60,6 +60,7 @@ namespace mln
 
 
 # include <mln/morpho/watershed/flooding.hh>
+# include <mln/morpho/watershed/superpose.hh>
 
 
 #endif // ! MLN_MORPHO_WATERSHED_ALL_HH
diff --git a/milena/mln/morpho/watershed/superpose.hh b/milena/mln/morpho/watershed/superpose.hh
new file mode 100644
index 0000000..bad2a71
--- /dev/null
+++ b/milena/mln/morpho/watershed/superpose.hh
@@ -0,0 +1,127 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_MORPHO_WATERSHED_SUPERPOSE_HH
+# define MLN_MORPHO_WATERSHED_SUPERPOSE_HH
+
+/// \file mln/morpho/watershed/superpose.hh
+///
+/// Convert an image to a rgb8 image and draw the watershed lines.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/level/convert.hh>
+# include <mln/data/fill.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/literal/colors.hh>
+# include <mln/pw/all.hh>
+
+
+
+namespace mln
+{
+
+  namespace morpho
+  {
+
+    namespace watershed
+    {
+
+      /// Convert an image to a rgb8 image and draw the watershed lines.
+      /*
+      ** \param[in] input_    An image.
+      ** \param[in] ws_ima_   The watershed transform of \p input_.
+      ** \param[in] wsl_color The color used for the watershed line.
+      */
+      template <typename I, typename J>
+      inline
+      mln_ch_value(I,value::rgb8)
+      superpose(const Image<I>& input_,
+		const Image<J>& ws_ima_,
+		const value::rgb8& wsl_color);
+
+
+      /// Convert an image to a rgb8 image and draw the watershed lines.
+      /*
+      ** \param[in] input_    An image.
+      ** \param[in] ws_ima_   The watershed transform of \p input_.
+      **
+      ** The watershed line is drawn in red.
+      */
+      template <typename I, typename J>
+      inline
+      mln_ch_value(I,value::rgb8)
+      superpose(const Image<I>& input,
+		const Image<J>& ws_ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+      template <typename I, typename J>
+      inline
+      mln_ch_value(I,value::rgb8)
+      superpose(const Image<I>& input_,
+		const Image<J>& ws_ima_,
+		const value::rgb8& wsl_color)
+      {
+	trace::entering("morpho::watershed::superpose");
+
+	const I& input = exact(input_);
+	const J& ws_ima = exact(ws_ima_);
+	mln_precondition(input.is_valid());
+	mln_precondition(ws_ima.is_valid());
+
+	mln_ch_value(I,value::rgb8) output = level::convert(value::rgb8(), input);
+
+	data::fill((output | (pw::value(ws_ima) == pw::cst(literal::zero))).rw(),
+		   wsl_color);
+
+	trace::exiting("morpho::watershed::superpose");
+	return output;
+      }
+
+
+      template <typename I, typename J>
+      inline
+      mln_ch_value(I,value::rgb8)
+      superpose(const Image<I>& input,
+		const Image<J>& ws_ima)
+      {
+        return superpose(input, ws_ima, literal::red);
+      }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+    } // end of namespace mln::morpho::watershed
+
+  } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+#endif // ! MLN_MORPHO_WATERSHED_SUPERPOSE_HH
diff --git a/milena/tests/morpho/watershed/Makefile.am b/milena/tests/morpho/watershed/Makefile.am
index 2b022e8..63dc2a7 100644
--- a/milena/tests/morpho/watershed/Makefile.am
+++ b/milena/tests/morpho/watershed/Makefile.am
@@ -3,8 +3,10 @@
 include $(top_srcdir)/milena/tests/tests.mk
 
 check_PROGRAMS =				\
-  flooding
+  flooding 					\
+  superpose
 
 flooding_SOURCES = flooding.cc
+superpose_SOURCES = superpose.cc
 
 TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/morpho/watershed/all.hh b/milena/tests/morpho/watershed/superpose.cc
similarity index 53%
copy from milena/mln/morpho/watershed/all.hh
copy to milena/tests/morpho/watershed/superpose.cc
index 472ff20..edace77 100644
--- a/milena/mln/morpho/watershed/all.hh
+++ b/milena/tests/morpho/watershed/superpose.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -25,41 +25,60 @@
 // reasons why the executable file might be covered by the GNU General
 // Public License.
 
-#ifndef MLN_MORPHO_WATERSHED_ALL_HH
-# define MLN_MORPHO_WATERSHED_ALL_HH
-
-/// \file mln/morpho/watershed/all.hh
+/// \file tests/morpho/watershed/superpose.cc
 ///
-/// File that includes all morphological watershed routines.
+/// Test on mln::morpho::watershed::superpose.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/make/image2d.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/watershed/superpose.hh>
+#include <mln/level/compare.hh>
 
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+#include <mln/debug/iota.hh>
 
 namespace mln
 {
 
-  namespace morpho
+  struct ref_data : Function_p2v<ref_data>
   {
+    typedef value::rgb8 result;
 
-    /// Namespace of morphological watershed routines.
-    namespace watershed
+    value::rgb8 operator()(const point2d& p) const
     {
+      if (p.row() == 2 || p.col() == 2)
+	return literal::red;
+      unsigned val = p.col() + 1 + p.row() * 4;
+      return value::rgb8(val, val, val);
+    }
 
-      /// Namespace of morphological watershed routines
-      /// implementations.
-      namespace watershed
-      {
+  };
 
-	/// Namespace of morphological watershed routines generic
-	/// implementations.
-	namespace generic
-	{}
+} // end of namespace mln
 
-      }
-    }
-  }
-}
+int main()
+{
+  using namespace mln;
 
+  image2d<value::int_u8> ima(4,4);
+  debug::iota(ima);
 
-# include <mln/morpho/watershed/flooding.hh>
+  value::label_8 data_ws[16] = { 1,  1,  0,  2,
+				 1,  1,  0,  2,
+				 0,  0,  0,  0,
+				 5,  5,  0,  4 };
 
+  image2d<value::label_8> ima_ws = make::image2d(data_ws);
 
-#endif // ! MLN_MORPHO_WATERSHED_ALL_HH
+  image2d<value::rgb8> sup = morpho::watershed::superpose(ima, ima_ws);
+  mln_assertion(sup == (ref_data() | sup.domain()));
+}
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index f288f80..1449e41 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -229,6 +229,7 @@ mln_fun_v2v_cast \
 mln_fun_v2v_ch_function_value \
 mln_fun_v2v_rgb_to_hsi \
 mln_fun_v2v_enc \
+mln_fun_v2v_projection \
 mln_fun_v2v_convert \
 mln_fun_v2v_essential \
 mln_fun_v2w2v_cos \
@@ -405,6 +406,12 @@ mln_accu_lor_basic \
 mln_accu_transform_diagonal \
 mln_accu_nil \
 mln_accu_bbox \
+mln_accu_image_init \
+mln_accu_image_to_result \
+mln_accu_image_all \
+mln_accu_image_set_value \
+mln_accu_image_take \
+mln_accu_image_take_as_init \
 mln_accu_center \
 mln_accu_line \
 mln_accu_essential \
@@ -645,6 +652,7 @@ mln_morpho_laplacian \
 mln_morpho_all \
 mln_morpho_watershed_flooding \
 mln_morpho_watershed_all \
+mln_morpho_watershed_superpose \
 mln_morpho_opening_approx_all \
 mln_morpho_opening_approx_structural \
 mln_morpho_opening_all \
@@ -804,6 +812,7 @@ mln_core_internal_image_domain_morpher \
 mln_core_internal_image_primary \
 mln_core_internal_set_of \
 mln_core_internal_complex_window_p_base \
+mln_core_internal_piter_identity \
 mln_core_internal_graph_window_base \
 mln_core_internal_piter_adaptor \
 mln_core_internal_weighted_window_base \
@@ -911,6 +920,7 @@ mln_core_clock_neighb2d \
 mln_core_pixter3d \
 mln_core_image_obased_rle_encode \
 mln_core_image_plain \
+mln_core_image_unproject_image \
 mln_core_image_image3d \
 mln_core_image_decorated_image \
 mln_core_image_extension_ima \
@@ -1018,6 +1028,8 @@ mln_io_cloud_load \
 mln_io_cloud_all \
 mln_io_cloud_save \
 mln_io_all \
+mln_io_magick_load \
+mln_io_magick_all \
 mln_io_dump_load \
 mln_io_dump_all \
 mln_io_dump_save \
@@ -1326,6 +1338,7 @@ mln_fun_v2v_cast_SOURCES = mln_fun_v2v_cast.cc
 mln_fun_v2v_ch_function_value_SOURCES = mln_fun_v2v_ch_function_value.cc
 mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc
 mln_fun_v2v_enc_SOURCES = mln_fun_v2v_enc.cc
+mln_fun_v2v_projection_SOURCES = mln_fun_v2v_projection.cc
 mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc
 mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc
 mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc
@@ -1502,6 +1515,12 @@ mln_accu_lor_basic_SOURCES = mln_accu_lor_basic.cc
 mln_accu_transform_diagonal_SOURCES = mln_accu_transform_diagonal.cc
 mln_accu_nil_SOURCES = mln_accu_nil.cc
 mln_accu_bbox_SOURCES = mln_accu_bbox.cc
+mln_accu_image_init_SOURCES = mln_accu_image_init.cc
+mln_accu_image_to_result_SOURCES = mln_accu_image_to_result.cc
+mln_accu_image_all_SOURCES = mln_accu_image_all.cc
+mln_accu_image_set_value_SOURCES = mln_accu_image_set_value.cc
+mln_accu_image_take_SOURCES = mln_accu_image_take.cc
+mln_accu_image_take_as_init_SOURCES = mln_accu_image_take_as_init.cc
 mln_accu_center_SOURCES = mln_accu_center.cc
 mln_accu_line_SOURCES = mln_accu_line.cc
 mln_accu_essential_SOURCES = mln_accu_essential.cc
@@ -1742,6 +1761,7 @@ mln_morpho_laplacian_SOURCES = mln_morpho_laplacian.cc
 mln_morpho_all_SOURCES = mln_morpho_all.cc
 mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc
 mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc
+mln_morpho_watershed_superpose_SOURCES = mln_morpho_watershed_superpose.cc
 mln_morpho_opening_approx_all_SOURCES = mln_morpho_opening_approx_all.cc
 mln_morpho_opening_approx_structural_SOURCES = mln_morpho_opening_approx_structural.cc
 mln_morpho_opening_all_SOURCES = mln_morpho_opening_all.cc
@@ -1901,6 +1921,7 @@ mln_core_internal_image_domain_morpher_SOURCES = mln_core_internal_image_domain_
 mln_core_internal_image_primary_SOURCES = mln_core_internal_image_primary.cc
 mln_core_internal_set_of_SOURCES = mln_core_internal_set_of.cc
 mln_core_internal_complex_window_p_base_SOURCES = mln_core_internal_complex_window_p_base.cc
+mln_core_internal_piter_identity_SOURCES = mln_core_internal_piter_identity.cc
 mln_core_internal_graph_window_base_SOURCES = mln_core_internal_graph_window_base.cc
 mln_core_internal_piter_adaptor_SOURCES = mln_core_internal_piter_adaptor.cc
 mln_core_internal_weighted_window_base_SOURCES = mln_core_internal_weighted_window_base.cc
@@ -2008,6 +2029,7 @@ mln_core_clock_neighb2d_SOURCES = mln_core_clock_neighb2d.cc
 mln_core_pixter3d_SOURCES = mln_core_pixter3d.cc
 mln_core_image_obased_rle_encode_SOURCES = mln_core_image_obased_rle_encode.cc
 mln_core_image_plain_SOURCES = mln_core_image_plain.cc
+mln_core_image_unproject_image_SOURCES = mln_core_image_unproject_image.cc
 mln_core_image_image3d_SOURCES = mln_core_image_image3d.cc
 mln_core_image_decorated_image_SOURCES = mln_core_image_decorated_image.cc
 mln_core_image_extension_ima_SOURCES = mln_core_image_extension_ima.cc
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        	* Makefile.am,
	* headers.mk,
	* tests/accu/Makefile.am,
	* tests/make/Makefile.am,
	* tests/unit_test/unit-tests.mk: fix build system. 'make dist' now
	works.
	* mln/convert/impl/from_unsigned_to_value.hh: add missing include.
	* mln/core/image/complex_neighborhood_piter.hh,
	* mln/io/magick/load.hh: avoid warnings.
	* mln/core/routine/all.hh
	* mln/labeling/blobs.hh: update doc
	* mln/labeling/compute.hh: add a new postcondition.
	* mln/labeling/relabel.hh: use v2v and v2b functions instead of l2l
	and l2b.
	* mln/make/relabelfun.hh: use v2v and v2b functions instead of l2l
	and l2b and add a new overload.
	* tools/area_flooding.cc: update use of
	morpho::closing::area_on_vertices.
---
 milena/ChangeLog                                   |   30 +++++++++
 milena/Makefile.am                                 |    2 -
 milena/headers.mk                                  |   11 +++
 milena/mln/convert/impl/from_unsigned_to_value.hh  |    1 +
 .../mln/core/image/complex_neighborhood_piter.hh   |    2 +-
 milena/mln/core/routine/all.hh                     |   14 ++--
 milena/mln/io/magick/load.hh                       |   13 ++--
 milena/mln/labeling/blobs.hh                       |    3 +-
 milena/mln/labeling/compute.hh                     |    2 +
 milena/mln/labeling/relabel.hh                     |   59 ++++++++++-------
 milena/mln/make/relabelfun.hh                      |   69 ++++++++++++++++----
 milena/tests/accu/Makefile.am                      |    3 -
 milena/tests/make/Makefile.am                      |    2 +-
 milena/tests/unit_test/unit-tests.mk               |   46 ++++++++++---
 milena/tools/area_flooding.cc                      |   19 ++++--
 15 files changed, 200 insertions(+), 76 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f0c8e0f..cda14ac 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,33 @@
+2009-03-16  Guillaume Lazzara  <lazzara(a)lrde.epita.fr>
+
+	Small fixes.
+
+	* Makefile.am,
+	* headers.mk,
+	* tests/accu/Makefile.am,
+	* tests/make/Makefile.am,
+	* tests/unit_test/unit-tests.mk: fix build system. 'make dist' now
+	works.
+
+	* mln/convert/impl/from_unsigned_to_value.hh: add missing include.
+
+	* mln/core/image/complex_neighborhood_piter.hh,
+	* mln/io/magick/load.hh: avoid warnings.
+
+	* mln/core/routine/all.hh
+	* mln/labeling/blobs.hh: update doc
+
+	* mln/labeling/compute.hh: add a new postcondition.
+
+	* mln/labeling/relabel.hh: use v2v and v2b functions instead of l2l
+	and l2b.
+
+	* mln/make/relabelfun.hh: use v2v and v2b functions instead of l2l
+	and l2b and add a new overload.
+
+	* tools/area_flooding.cc: update use of
+	morpho::closing::area_on_vertices.
+
 2009-03-17  Fabien Freling  <fabien.freling(a)lrde.epita.fr>
 
 	Integrate ImageMagick support in Milena.
diff --git a/milena/Makefile.am b/milena/Makefile.am
index b394cf2..a2b83c6 100644
--- a/milena/Makefile.am
+++ b/milena/Makefile.am
@@ -43,10 +43,8 @@ img/medium.ppm 		\
 img/picasso.pbm 	\
 img/picasso.pgm 	\
 img/quite-small.pgm 	\
-img/small-enlarged.png 	\
 img/small.pbm 		\
 img/small.pgm 		\
-img/small.png 		\
 img/small.ppm 		\
 img/squares-lc.pgm 	\
 img/squares.pgm 	\
diff --git a/milena/headers.mk b/milena/headers.mk
index 9513a84..dfab609 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -262,10 +262,13 @@ mln/fun/meta/hue.hh \
 mln/fun/meta/lum.hh \
 mln/fun/meta/all.hh \
 mln/fun/meta/green.hh \
+mln/fun/meta/second.hh \
 mln/fun/meta/inty.hh \
 mln/fun/meta/blue.hh \
 mln/fun/meta/sat.hh \
+mln/fun/meta/first.hh \
 mln/fun/meta/to_enc.hh \
+mln/fun/meta/essential.hh \
 mln/fun/x2v/trilinear.hh \
 mln/fun/x2v/linear.hh \
 mln/fun/x2v/bilinear.hh \
@@ -285,6 +288,7 @@ mln/convert/to_window.hh \
 mln/convert/from_to.hh \
 mln/convert/impl/from_value_to_value.hh \
 mln/convert/impl/all.hh \
+mln/convert/impl/from_unsigned_to_value.hh \
 mln/convert/impl/from_double_to_value.hh \
 mln/convert/impl/from_site_set_to_image.hh \
 mln/convert/impl/from_image_to_site_set.hh \
@@ -629,6 +633,11 @@ mln/morpho/internal/elementary.hh \
 mln/morpho/contrast.hh \
 mln/morpho/thickening.hh \
 mln/morpho/dilation.hh \
+mln/morpho/approx/dilation.hh \
+mln/morpho/approx/all.hh \
+mln/morpho/approx/erosion.hh \
+mln/morpho/closing/approx/all.hh \
+mln/morpho/closing/approx/structural.hh \
 mln/morpho/closing/all.hh \
 mln/morpho/closing/algebraic.hh \
 mln/morpho/closing/leveling.hh \
@@ -643,6 +652,8 @@ mln/morpho/laplacian.hh \
 mln/morpho/all.hh \
 mln/morpho/watershed/flooding.hh \
 mln/morpho/watershed/all.hh \
+mln/morpho/opening/approx/all.hh \
+mln/morpho/opening/approx/structural.hh \
 mln/morpho/opening/all.hh \
 mln/morpho/opening/algebraic.hh \
 mln/morpho/opening/leveling.hh \
diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh
index 4c6bac7..f5b08ac 100644
--- a/milena/mln/convert/impl/from_unsigned_to_value.hh
+++ b/milena/mln/convert/impl/from_unsigned_to_value.hh
@@ -37,6 +37,7 @@
 # include <utility>
 # include <mln/value/concept/integer.hh>
 # include <mln/core/concept/value.hh>
+# include <mln/value/label.hh>
 # include <mln/math/round.hh>
 
 
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index 32beda6..3eb7b8e 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -339,7 +339,7 @@ namespace mln
   template <typename Pref>
   inline
   void
-  complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref& c)
+  complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref&)
   {
     iter_.center_at(this->center().face());
   }
diff --git a/milena/mln/core/routine/all.hh b/milena/mln/core/routine/all.hh
index 503919b..1c0d3f0 100644
--- a/milena/mln/core/routine/all.hh
+++ b/milena/mln/core/routine/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 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
@@ -28,12 +28,11 @@
 #ifndef MLN_CORE_ROUTINE_ALL_HH
 # define MLN_CORE_ROUTINE_ALL_HH
 
-/*! \file mln/core/routine/all.hh
- *
- * \brief File that includes all core routines.
- *
- * \todo Move files, update, and activate.
- */
+/// \file mln/core/routine/all.hh
+///
+/// File that includes all core routines.
+///
+/// \todo Move files, update, and activate.
 
 
 # include <mln/core/routine/duplicate.hh>
@@ -42,5 +41,4 @@
 # include <mln/core/routine/initialize.hh>
 # include <mln/core/routine/primary.hh>
 
-
 #endif // ! MLN_CORE_ROUTINE_ALL_HH
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index 8636b77..4067395 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -28,13 +28,11 @@
 #ifndef MLN_IO_MAGICK_LOAD_HH
 # define MLN_IO_MAGICK_LOAD_HH
 
-/*!
- * \file   mln/io/magick/load.hh
- *
- * \brief Define a function which loads an image of kind magick with
- * given path.
- *
- */
+///
+/// \file   mln/io/magick/load.hh
+///
+/// Define a function which loads an image of kind magick with
+/// given path.
 
 # include <mln/core/image/image2d.hh>
 # include <mln/value/int_u8.hh>
@@ -99,6 +97,7 @@ namespace mln
       inline
       bool do_it(const value::rgb8& in, value::rgb8& out, const std::string& filename)
       {
+	(void) filename;
 	out = in;
 	return true;
       }
diff --git a/milena/mln/labeling/blobs.hh b/milena/mln/labeling/blobs.hh
index 566d2ba..60040db 100644
--- a/milena/mln/labeling/blobs.hh
+++ b/milena/mln/labeling/blobs.hh
@@ -54,7 +54,8 @@ namespace mln
     ///
     /// \param[in]  input    The input image.
     /// \param[in]  nbh      The connexity of the objects.
-    /// \param[out] nlabels  The number of labels.
+    /// \param[out] nlabels  The Number of labels. Its value is set in the
+    ///			     algorithms.
     /// \return              The label image.
     ///
     /// \pre The input image has to be binary (checked at compile-time).
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
index f6e45f0..e0ad32a 100644
--- a/milena/mln/labeling/compute.hh
+++ b/milena/mln/labeling/compute.hh
@@ -295,6 +295,8 @@ namespace mln
       typedef util::array<mln_result(A)> R;
       R res = internal::compute_dispatch(a, label, nlabels);
 
+      mln_postcondition(res.nelements() == nlabels.next());
+
       trace::exiting("labeling::compute");
       return res;
     }
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index 71e4d05..867a0fb 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
 // (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
@@ -58,12 +58,11 @@ namespace mln
     relabel(const Image<I>&	    label,
 	    const mln_value(I)&	    nlabels,
 	    mln_value(I)&	    new_nlabels,
-	    const Function_l2b<F>&  fl2b);
+	    const Function_v2b<F>&  fv2b);
 
     /// Remove components and relabel a labeled image.
     /// \input[in]  label the labeled image.
     /// \input[in]  nlabels the number of labels in \p label.
-    /// \input[out] new_nlabels the number of labels after relabeling.
     /// \input[in]  f function returning the new component id for each pixel
     /// value.
     ///
@@ -72,8 +71,7 @@ namespace mln
     mln_concrete(I)
     relabel(const Image<I>&	    label,
 	    const mln_value(I)&	    nlabels,
-	    mln_value(I)&	    new_nlabels,
-	    const Function_l2l<F>&  fl2l);
+	    const Function_v2v<F>&  fv2v);
 
     /// Remove components and relabel a labeled image inplace.
     /// \input[in, out] label the labeled image.
@@ -85,7 +83,7 @@ namespace mln
     void
     relabel_inplace(Image<I>&		    label,
 		    mln_value(I)&	    nlabels,
-		    const Function_l2b<F>&  fl2b);
+		    const Function_v2b<F>&  fv2b);
 
     /// Remove components and relabel a labeled image inplace.
     /// \input[in, out] label the labeled image.
@@ -97,7 +95,7 @@ namespace mln
     void
     relabel_inplace(Image<I>&		    label,
 		    mln_value(I)&	    nlabels,
-		    const Function_l2l<F>&  fl2l);
+		    const Function_v2v<F>&  fv2v);
 
 
 # ifndef MLN_INCLUDE_ONLY
@@ -124,6 +122,20 @@ namespace mln
       }
 
       template <typename I, typename F>
+      void
+      relabel_tests(const Image<I>&	    label,
+		    const mln_value(I)&	    nlabels,
+		    const Function<F>&	    f)
+      {
+        // FIXME: we may want to check that it is exactly a label.
+        mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+        mln_precondition(exact(label).is_valid());
+	(void) label;
+	(void) nlabels;
+	(void) f;
+      }
+
+      template <typename I, typename F>
       inline
       void
       relabel_inplace_tests(Image<I>&		    label,
@@ -147,14 +159,13 @@ namespace mln
     mln_concrete(I)
     relabel(const Image<I>&	    label,
 	    const mln_value(I)&	    nlabels,
-	    mln_value(I)&	    new_nlabels,
-	    const Function_l2l<F>&  fl2l)
+	    const Function_v2v<F>&  fv2v)
     {
       trace::entering("labeling::relabel");
 
-      internal::relabel_tests(label, nlabels, new_nlabels, fl2l);
+      internal::relabel_tests(label, nlabels, fv2v);
 
-      mln_concrete(I) output = level::transform(label, fl2l);
+      mln_concrete(I) output = level::transform(label, fv2v);
 
       trace::exiting("labeling::relabel");
       return output;
@@ -168,15 +179,15 @@ namespace mln
     relabel(const Image<I>&	    label,
 	    const mln_value(I)&	    nlabels,
 	    mln_value(I)&	    new_nlabels,
-	    const Function_l2b<F>&  fl2b)
+	    const Function_v2b<F>&  fv2b)
     {
       trace::entering("labeling::relabel");
 
-      internal::relabel_tests(label, nlabels, new_nlabels, fl2b);
+      internal::relabel_tests(label, nlabels, new_nlabels, fv2b);
 
-      typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
-      fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
-      mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l);
+      typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+      fv2v_t fv2v = make::relabelfun(fv2b, nlabels, new_nlabels);
+      mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fv2v);
 
       trace::exiting("labeling::relabel");
       return output;
@@ -189,13 +200,13 @@ namespace mln
     void
     relabel_inplace(Image<I>&		    label,
 		    mln_value(I)&	    nlabels,
-		    const Function_l2l<F>&  fl2l)
+		    const Function_v2v<F>&  fv2v)
     {
       trace::entering("labeling::relabel_inplace");
 
-      internal::relabel_inplace_tests(label, nlabels, fl2l);
+      internal::relabel_inplace_tests(label, nlabels, fv2v);
 
-      level::transform_inplace(label, fl2l);
+      level::transform_inplace(label, fv2v);
 
       trace::exiting("labeling::relabel_inplace");
     }
@@ -207,15 +218,15 @@ namespace mln
     void
     relabel_inplace(Image<I>&		    label,
 		    mln_value(I)&	    nlabels,
-		    const Function_l2b<F>&  fl2b)
+		    const Function_v2b<F>&  fv2b)
     {
       trace::entering("labeling::relabel_inplace");
 
-      internal::relabel_inplace_tests(label, nlabels, fl2b);
+      internal::relabel_inplace_tests(label, nlabels, fv2b);
 
-      typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
-      fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels);
-      labeling::relabel_inplace(label, nlabels, fl2l);
+      typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+      fv2v_t fv2v = make::relabelfun(fv2b, nlabels, nlabels);
+      labeling::relabel_inplace(label, nlabels, fv2v);
 
       trace::exiting("labeling::relabel_inplace");
     }
diff --git a/milena/mln/make/relabelfun.hh b/milena/mln/make/relabelfun.hh
index abbba80..612e3a6 100644
--- a/milena/mln/make/relabelfun.hh
+++ b/milena/mln/make/relabelfun.hh
@@ -42,43 +42,86 @@ namespace mln
   namespace make
   {
 
-    /// Create a l2l function from a l2b function.
+    /// Create a l2l function from a v2b function.
     /// This function can be used to relabel a labeled image.
     ///
-    /// \param[in] f a l2b function.
+    /// \param[in] f a v2b function.
     ///
     /// \return a l2l function.
     ///
     /// \sa mln::labeling::relabel
     template <unsigned n, typename F>
-    mln::fun::l2l::relabel< value::label<n> >
-    relabelfun(const mln::Function_l2b<F>&  fl2b,
-	       const value::label<n>&	    nlabels);
+    fun::l2l::relabel< value::label<n> >
+    relabelfun(const Function_v2b<F>& fv2b,
+	       const value::label<n>& nlabels,
+	       value::label<n>&	      new_nlabels);
+
+    /// Create a l2l function from a v2v function.
+    /// This function can be used to relabel a labeled image.
+    ///
+    /// \param[in] f a v2v function.
+    ///
+    /// \return a l2l function.
+    ///
+    /// \sa mln::labeling::relabel
+    template <unsigned n, typename F>
+    fun::l2l::relabel< value::label<n> >
+    relabelfun(const Function_v2v<F>& fv2v,
+	       const value::label<n>& nlabels,
+	       value::label<n>&	      new_nlabels);
 
 
 # ifndef MLN_INCLUDE_ONLY
 
     template <unsigned n, typename F>
     inline
-    mln::fun::l2l::relabel< value::label<n> >
-    relabelfun(const mln::Function_l2b<F>&  fl2b_,
-	       const value::label<n>&	    nlabels,
-	       value::label<n>&		    new_nlabels)
+    fun::l2l::relabel< value::label<n> >
+    relabelfun(const Function_v2b<F>& fv2b_,
+	       const value::label<n>& nlabels,
+	       value::label<n>&	      new_nlabels)
     {
-      trace::entering("mln::make::relabelfun");
+      trace::entering("make::relabelfun");
 
-      const F& fl2b = exact(fl2b_);
+      const F& fv2b = exact(fv2b_);
 
       value::label<n> tmp_nlabels = literal::zero;
       typedef value::label<n> label_t;
       fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
       for (label_t i = 1; i <= nlabels; ++i)
-	if (fl2b(i))
+	if (fv2b(i))
 	{
 	  fl2l(i) = ++tmp_nlabels;
 	}
       new_nlabels = tmp_nlabels;
-      trace::exiting("mln::make::relabelfun");
+      trace::exiting("make::relabelfun");
+      return fl2l;
+    }
+
+
+    template <unsigned n, typename F>
+    inline
+    fun::l2l::relabel< value::label<n> >
+    relabelfun(const Function_v2v<F>& fv2v_,
+	       const value::label<n>& nlabels,
+	       value::label<n>&	      new_nlabels)
+    {
+      trace::entering("make::relabelfun");
+
+      const F& fv2v = exact(fv2v_);
+
+      value::label<n> tmp_nlabels = literal::zero;
+      typedef value::label<n> label_t;
+      fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
+      for (label_t i = 1; i < nlabels.next(); ++i)
+	if (fl2l(fv2v(i)) == literal::zero)
+	{
+	  fl2l(fv2v(i)) = ++tmp_nlabels;
+	  fl2l(i) = tmp_nlabels;
+	}
+	else
+	  fl2l(i) = fl2l(fv2v(i));
+      new_nlabels = tmp_nlabels;
+      trace::exiting("make::relabelfun");
       return fl2l;
     }
 
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index 3f78d07..fafbec1 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -2,9 +2,6 @@
 
 include $(top_srcdir)/milena/tests/tests.mk
 
-SUBDIRS =					\
-  image
-
 check_PROGRAMS =				\
   all_accus					\
   bbox						\
diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am
index 95eb5ea..bf96093 100644
--- a/milena/tests/make/Makefile.am
+++ b/milena/tests/make/Makefile.am
@@ -13,7 +13,7 @@ check_PROGRAMS =				\
   w_window					\
   w_window_directional
 
-dual_neighb_SOURCES = dual_neighb.c
+dual_neighb_SOURCES = dual_neighb.cc
 graph_SOURCES = graph.cc
 h_mat_SOURCES = h_mat.cc
 image2d_SOURCES = image2d.cc
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index 53cd03f..f288f80 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -93,6 +93,7 @@ mln_util_line_graph \
 mln_util_ord \
 mln_util_tree_fast_to_image \
 mln_util_tree \
+mln_util_couple \
 mln_util_index \
 mln_util_multi_site \
 mln_util_branch_iter \
@@ -256,10 +257,13 @@ mln_fun_meta_hue \
 mln_fun_meta_lum \
 mln_fun_meta_all \
 mln_fun_meta_green \
+mln_fun_meta_second \
 mln_fun_meta_inty \
 mln_fun_meta_blue \
 mln_fun_meta_sat \
+mln_fun_meta_first \
 mln_fun_meta_to_enc \
+mln_fun_meta_essential \
 mln_fun_x2v_trilinear \
 mln_fun_x2v_linear \
 mln_fun_x2v_bilinear \
@@ -279,6 +283,7 @@ mln_convert_to_window \
 mln_convert_from_to \
 mln_convert_impl_from_value_to_value \
 mln_convert_impl_all \
+mln_convert_impl_from_unsigned_to_value \
 mln_convert_impl_from_double_to_value \
 mln_convert_impl_from_site_set_to_image \
 mln_convert_impl_from_image_to_site_set \
@@ -362,6 +367,7 @@ mln_value_label_8 \
 mln_value_essential \
 mln_accu_tuple \
 mln_accu_min_h \
+mln_accu_stat_deviation \
 mln_accu_max \
 mln_accu_lor \
 mln_accu_rank \
@@ -595,7 +601,6 @@ mln_linear_log \
 mln_linear_essential \
 mln_morpho_thinning \
 mln_morpho_meyer_wst \
-mln_morpho_opening \
 mln_morpho_includes \
 mln_morpho_elementary_opening \
 mln_morpho_elementary_gradient_internal \
@@ -621,18 +626,27 @@ mln_morpho_internal_elementary \
 mln_morpho_contrast \
 mln_morpho_thickening \
 mln_morpho_dilation \
+mln_morpho_approx_dilation \
+mln_morpho_approx_all \
+mln_morpho_approx_erosion \
+mln_morpho_closing_approx_all \
+mln_morpho_closing_approx_structural \
 mln_morpho_closing_all \
 mln_morpho_closing_algebraic \
 mln_morpho_closing_leveling \
 mln_morpho_closing_area_on_vertices \
 mln_morpho_closing_area \
 mln_morpho_closing_volume \
+mln_morpho_closing_sum \
 mln_morpho_closing_height \
+mln_morpho_closing_structural \
 mln_morpho_closing_essential \
 mln_morpho_laplacian \
 mln_morpho_all \
 mln_morpho_watershed_flooding \
 mln_morpho_watershed_all \
+mln_morpho_opening_approx_all \
+mln_morpho_opening_approx_structural \
 mln_morpho_opening_all \
 mln_morpho_opening_algebraic \
 mln_morpho_opening_leveling \
@@ -640,6 +654,7 @@ mln_morpho_opening_area_on_vertices \
 mln_morpho_opening_area \
 mln_morpho_opening_volume \
 mln_morpho_opening_height \
+mln_morpho_opening_structural \
 mln_morpho_opening_essential \
 mln_morpho_attribute_all \
 mln_morpho_attribute_volume \
@@ -657,15 +672,12 @@ mln_morpho_tree_utils \
 mln_morpho_tree_data \
 mln_morpho_tree_compute_attribute_image \
 mln_morpho_min \
-mln_morpho_closing \
 mln_morpho_top_hat \
 mln_morpho_erosion \
 mln_morpho_leveling_filter \
-mln_morpho_closing_sum \
 mln_morpho_Rd \
 mln_morpho_thick_miss \
 mln_morpho_algebraic_filter \
-mln_morpho_closing_attribute \
 mln_morpho_rank_filter \
 mln_morpho_essential \
 mln_topo_n_face_iter \
@@ -700,6 +712,7 @@ mln_essential_routine \
 mln_essential_3d \
 mln_essential_2d \
 mln_win_inter \
+mln_win_sphere3d \
 mln_win_backdiag2d \
 mln_win_segment1d \
 mln_win_cuboid3d \
@@ -710,10 +723,10 @@ mln_win_multiple_size \
 mln_win_cube3d \
 mln_win_shift \
 mln_win_sym \
+mln_win_ball \
 mln_win_diff \
 mln_win_multiple \
 mln_win_diag2d \
-mln_win_ball3d \
 mln_win_disk2d \
 mln_win_rectangle2d \
 mln_win_hline2d \
@@ -1177,6 +1190,7 @@ mln_util_line_graph_SOURCES = mln_util_line_graph.cc
 mln_util_ord_SOURCES = mln_util_ord.cc
 mln_util_tree_fast_to_image_SOURCES = mln_util_tree_fast_to_image.cc
 mln_util_tree_SOURCES = mln_util_tree.cc
+mln_util_couple_SOURCES = mln_util_couple.cc
 mln_util_index_SOURCES = mln_util_index.cc
 mln_util_multi_site_SOURCES = mln_util_multi_site.cc
 mln_util_branch_iter_SOURCES = mln_util_branch_iter.cc
@@ -1340,10 +1354,13 @@ mln_fun_meta_hue_SOURCES = mln_fun_meta_hue.cc
 mln_fun_meta_lum_SOURCES = mln_fun_meta_lum.cc
 mln_fun_meta_all_SOURCES = mln_fun_meta_all.cc
 mln_fun_meta_green_SOURCES = mln_fun_meta_green.cc
+mln_fun_meta_second_SOURCES = mln_fun_meta_second.cc
 mln_fun_meta_inty_SOURCES = mln_fun_meta_inty.cc
 mln_fun_meta_blue_SOURCES = mln_fun_meta_blue.cc
 mln_fun_meta_sat_SOURCES = mln_fun_meta_sat.cc
+mln_fun_meta_first_SOURCES = mln_fun_meta_first.cc
 mln_fun_meta_to_enc_SOURCES = mln_fun_meta_to_enc.cc
+mln_fun_meta_essential_SOURCES = mln_fun_meta_essential.cc
 mln_fun_x2v_trilinear_SOURCES = mln_fun_x2v_trilinear.cc
 mln_fun_x2v_linear_SOURCES = mln_fun_x2v_linear.cc
 mln_fun_x2v_bilinear_SOURCES = mln_fun_x2v_bilinear.cc
@@ -1363,6 +1380,7 @@ mln_convert_to_window_SOURCES = mln_convert_to_window.cc
 mln_convert_from_to_SOURCES = mln_convert_from_to.cc
 mln_convert_impl_from_value_to_value_SOURCES = mln_convert_impl_from_value_to_value.cc
 mln_convert_impl_all_SOURCES = mln_convert_impl_all.cc
+mln_convert_impl_from_unsigned_to_value_SOURCES = mln_convert_impl_from_unsigned_to_value.cc
 mln_convert_impl_from_double_to_value_SOURCES = mln_convert_impl_from_double_to_value.cc
 mln_convert_impl_from_site_set_to_image_SOURCES = mln_convert_impl_from_site_set_to_image.cc
 mln_convert_impl_from_image_to_site_set_SOURCES = mln_convert_impl_from_image_to_site_set.cc
@@ -1446,6 +1464,7 @@ mln_value_label_8_SOURCES = mln_value_label_8.cc
 mln_value_essential_SOURCES = mln_value_essential.cc
 mln_accu_tuple_SOURCES = mln_accu_tuple.cc
 mln_accu_min_h_SOURCES = mln_accu_min_h.cc
+mln_accu_stat_deviation_SOURCES = mln_accu_stat_deviation.cc
 mln_accu_max_SOURCES = mln_accu_max.cc
 mln_accu_lor_SOURCES = mln_accu_lor.cc
 mln_accu_rank_SOURCES = mln_accu_rank.cc
@@ -1679,7 +1698,6 @@ mln_linear_log_SOURCES = mln_linear_log.cc
 mln_linear_essential_SOURCES = mln_linear_essential.cc
 mln_morpho_thinning_SOURCES = mln_morpho_thinning.cc
 mln_morpho_meyer_wst_SOURCES = mln_morpho_meyer_wst.cc
-mln_morpho_opening_SOURCES = mln_morpho_opening.cc
 mln_morpho_includes_SOURCES = mln_morpho_includes.cc
 mln_morpho_elementary_opening_SOURCES = mln_morpho_elementary_opening.cc
 mln_morpho_elementary_gradient_internal_SOURCES = mln_morpho_elementary_gradient_internal.cc
@@ -1705,18 +1723,27 @@ mln_morpho_internal_elementary_SOURCES = mln_morpho_internal_elementary.cc
 mln_morpho_contrast_SOURCES = mln_morpho_contrast.cc
 mln_morpho_thickening_SOURCES = mln_morpho_thickening.cc
 mln_morpho_dilation_SOURCES = mln_morpho_dilation.cc
+mln_morpho_approx_dilation_SOURCES = mln_morpho_approx_dilation.cc
+mln_morpho_approx_all_SOURCES = mln_morpho_approx_all.cc
+mln_morpho_approx_erosion_SOURCES = mln_morpho_approx_erosion.cc
+mln_morpho_closing_approx_all_SOURCES = mln_morpho_closing_approx_all.cc
+mln_morpho_closing_approx_structural_SOURCES = mln_morpho_closing_approx_structural.cc
 mln_morpho_closing_all_SOURCES = mln_morpho_closing_all.cc
 mln_morpho_closing_algebraic_SOURCES = mln_morpho_closing_algebraic.cc
 mln_morpho_closing_leveling_SOURCES = mln_morpho_closing_leveling.cc
 mln_morpho_closing_area_on_vertices_SOURCES = mln_morpho_closing_area_on_vertices.cc
 mln_morpho_closing_area_SOURCES = mln_morpho_closing_area.cc
 mln_morpho_closing_volume_SOURCES = mln_morpho_closing_volume.cc
+mln_morpho_closing_sum_SOURCES = mln_morpho_closing_sum.cc
 mln_morpho_closing_height_SOURCES = mln_morpho_closing_height.cc
+mln_morpho_closing_structural_SOURCES = mln_morpho_closing_structural.cc
 mln_morpho_closing_essential_SOURCES = mln_morpho_closing_essential.cc
 mln_morpho_laplacian_SOURCES = mln_morpho_laplacian.cc
 mln_morpho_all_SOURCES = mln_morpho_all.cc
 mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc
 mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc
+mln_morpho_opening_approx_all_SOURCES = mln_morpho_opening_approx_all.cc
+mln_morpho_opening_approx_structural_SOURCES = mln_morpho_opening_approx_structural.cc
 mln_morpho_opening_all_SOURCES = mln_morpho_opening_all.cc
 mln_morpho_opening_algebraic_SOURCES = mln_morpho_opening_algebraic.cc
 mln_morpho_opening_leveling_SOURCES = mln_morpho_opening_leveling.cc
@@ -1724,6 +1751,7 @@ mln_morpho_opening_area_on_vertices_SOURCES = mln_morpho_opening_area_on_vertice
 mln_morpho_opening_area_SOURCES = mln_morpho_opening_area.cc
 mln_morpho_opening_volume_SOURCES = mln_morpho_opening_volume.cc
 mln_morpho_opening_height_SOURCES = mln_morpho_opening_height.cc
+mln_morpho_opening_structural_SOURCES = mln_morpho_opening_structural.cc
 mln_morpho_opening_essential_SOURCES = mln_morpho_opening_essential.cc
 mln_morpho_attribute_all_SOURCES = mln_morpho_attribute_all.cc
 mln_morpho_attribute_volume_SOURCES = mln_morpho_attribute_volume.cc
@@ -1741,15 +1769,12 @@ mln_morpho_tree_utils_SOURCES = mln_morpho_tree_utils.cc
 mln_morpho_tree_data_SOURCES = mln_morpho_tree_data.cc
 mln_morpho_tree_compute_attribute_image_SOURCES = mln_morpho_tree_compute_attribute_image.cc
 mln_morpho_min_SOURCES = mln_morpho_min.cc
-mln_morpho_closing_SOURCES = mln_morpho_closing.cc
 mln_morpho_top_hat_SOURCES = mln_morpho_top_hat.cc
 mln_morpho_erosion_SOURCES = mln_morpho_erosion.cc
 mln_morpho_leveling_filter_SOURCES = mln_morpho_leveling_filter.cc
-mln_morpho_closing_sum_SOURCES = mln_morpho_closing_sum.cc
 mln_morpho_Rd_SOURCES = mln_morpho_Rd.cc
 mln_morpho_thick_miss_SOURCES = mln_morpho_thick_miss.cc
 mln_morpho_algebraic_filter_SOURCES = mln_morpho_algebraic_filter.cc
-mln_morpho_closing_attribute_SOURCES = mln_morpho_closing_attribute.cc
 mln_morpho_rank_filter_SOURCES = mln_morpho_rank_filter.cc
 mln_morpho_essential_SOURCES = mln_morpho_essential.cc
 mln_topo_n_face_iter_SOURCES = mln_topo_n_face_iter.cc
@@ -1784,6 +1809,7 @@ mln_essential_routine_SOURCES = mln_essential_routine.cc
 mln_essential_3d_SOURCES = mln_essential_3d.cc
 mln_essential_2d_SOURCES = mln_essential_2d.cc
 mln_win_inter_SOURCES = mln_win_inter.cc
+mln_win_sphere3d_SOURCES = mln_win_sphere3d.cc
 mln_win_backdiag2d_SOURCES = mln_win_backdiag2d.cc
 mln_win_segment1d_SOURCES = mln_win_segment1d.cc
 mln_win_cuboid3d_SOURCES = mln_win_cuboid3d.cc
@@ -1794,10 +1820,10 @@ mln_win_multiple_size_SOURCES = mln_win_multiple_size.cc
 mln_win_cube3d_SOURCES = mln_win_cube3d.cc
 mln_win_shift_SOURCES = mln_win_shift.cc
 mln_win_sym_SOURCES = mln_win_sym.cc
+mln_win_ball_SOURCES = mln_win_ball.cc
 mln_win_diff_SOURCES = mln_win_diff.cc
 mln_win_multiple_SOURCES = mln_win_multiple.cc
 mln_win_diag2d_SOURCES = mln_win_diag2d.cc
-mln_win_ball3d_SOURCES = mln_win_ball3d.cc
 mln_win_disk2d_SOURCES = mln_win_disk2d.cc
 mln_win_rectangle2d_SOURCES = mln_win_rectangle2d.cc
 mln_win_hline2d_SOURCES = mln_win_hline2d.cc
diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc
index fc5c444..742ec94 100644
--- a/milena/tools/area_flooding.cc
+++ b/milena/tools/area_flooding.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
 //
 // This file is part of the Olena Library.  This library is free
 // software; you can redistribute it and/or modify it under the terms
@@ -44,7 +45,6 @@
         an average grey level of the corresponding region in the input
         image.
 
-  FIXME: do not use mln_VAR.
 */
 
 #include <cstdlib>
@@ -61,7 +61,7 @@
 #include <mln/core/var.hh>
 
 #include <mln/morpho/line_gradient.hh>
-#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/closing/area_on_vertices.hh>
 #include <mln/labeling/regional_minima.hh>
 #include <mln/morpho/meyer_wst.hh>
 
@@ -101,10 +101,14 @@ int main(int argc, char* argv[])
   | Line gradient.  |
   `----------------*/
 
+  // Type of the function mapping graph edges and image sites.
+  typedef fun::i2v::array<util::site_pair<point2d> > fedge_site_t;
+
   // Line graph image.
   typedef fun::i2v::array<val_t> fval_t;
   fval_t values;
-  mln_VAR(lg_ima, morpho::line_gradient(input));
+  typedef pw::image<fval_t, p_edges<util::graph,fedge_site_t> > lg_ima_t;
+  lg_ima_t lg_ima = morpho::line_gradient(input);
 
   /*-----------.
   | Flooding.  |
@@ -129,7 +133,7 @@ int main(int argc, char* argv[])
 		<< "nregions = " << nregions << std::endl;
       lg_ima_t work = duplicate(result);
       // Compute the closing.
-      result = morpho::closing_area_on_vertices(work, nbh, area);
+      result = morpho::closing::area_on_vertices(work, nbh, area);
       // Compute the number of local minima (but get rid of the image,
       // as we don't need it).
       labeling::regional_minima(result, nbh, nregions);
@@ -142,7 +146,10 @@ int main(int argc, char* argv[])
   // Perform a Watershed Transform.
   typedef int_u16 wst_val_t;
   wst_val_t nbasins;
-  mln_VAR(wshed, morpho::meyer_wst(result, nbh, nbasins));
+  typedef pw::image<fun::i2v::array<wst_val_t>,
+		    p_edges<util::graph,fedge_site_t> > wshed_t;
+
+  wshed_t wshed = morpho::meyer_wst(result, nbh, nbasins);
   std::cout << "nbasins = " << nbasins << std::endl;
 
   /*---------.
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    18 Mar '09
                    
                        ---
 ChangeLog    |    4 ++++
 configure.ac |    4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 46326b6..35f0ba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-18  Roland Levillain  <roland(a)lrde.epita.fr>
+
+	* configure.ac: Always configure directory external/trimesh/.
+
 2009-03-13  Frederic Bour  <bour(a)lrde.epita.fr>
 
 	fun update: add unary & binary composition.
diff --git a/configure.ac b/configure.ac
index 52b5b19..0b05502 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,9 +113,7 @@ AM_CONDITIONAL([DARWIN], [echo "$host_os" | grep '^darwin'])
 
 # (Bundled) trimesh2 library.
 OLN_WITH_TRIMESH
-if test x$with_trimesh = xyes; then
-  AC_CONFIG_SUBDIRS([external/trimesh])
-fi
+AC_CONFIG_SUBDIRS([external/trimesh])
 AM_CONDITIONAL([WITH_TRIMESH], [test x$with_trimesh = xyes])
 
 # FreeImage library.
-- 
1.5.6.5
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-17  Fabien Freling  <fabien.freling(a)lrde.epita.fr>
	Integrate ImageMagick support in Milena.
	* mln/io/all.hh: Update.
	* mln/io/magick/all.hh: New file, including load.hh
	* mln/io/magick/load.hh: Implement ImageMagick load support.
---
 all.hh         |    1 
 magick/all.hh  |   50 ++++++++++++++++
 magick/load.hh |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 222 insertions(+)
Index: trunk/milena/mln/io/magick/all.hh
===================================================================
--- trunk/milena/mln/io/magick/all.hh	(revision 0)
+++ trunk/milena/mln/io/magick/all.hh	(revision 3539)
@@ -0,0 +1,50 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_IO_MAGICK_ALL_HH
+# define MLN_IO_MAGICK_ALL_HH
+
+/*! \file mln/io/magick/all.hh
+ *
+ * \brief File that includes all magick io materials.
+ */
+
+
+namespace mln
+{
+
+  namespace io
+  {
+    /// Namespace of magick input/output handling.
+    namespace magick {}
+  }
+
+}
+
+# include <mln/io/magick/load.hh>
+
+#endif // ! MLN_IO_MAGICK_ALL_HH
Index: trunk/milena/mln/io/magick/load.hh
===================================================================
--- trunk/milena/mln/io/magick/load.hh	(revision 0)
+++ trunk/milena/mln/io/magick/load.hh	(revision 3539)
@@ -0,0 +1,171 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_IO_MAGICK_LOAD_HH
+# define MLN_IO_MAGICK_LOAD_HH
+
+/*!
+ * \file   mln/io/magick/load.hh
+ *
+ * \brief Define a function which loads an image of kind magick with
+ * given path.
+ *
+ */
+
+# include <mln/core/image/image2d.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <Magick++.h>
+
+
+namespace mln
+{
+
+  namespace io
+  {
+
+    namespace magick
+    {
+
+      /*! Load a magick image in a Milena image.
+       *
+       * \param[out] ima A reference to the image which will receive
+       * data.
+       * \param[in] filename The source.
+       */
+      template <typename I>
+      void load(Image<I>& ima,
+		const std::string& filename);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+      inline
+      bool do_it(const value::rgb8& in, bool& out, const std::string& filename)
+      {
+	if (in.red() == 255u && in.green() == 255u && in.blue() == 255u)
+	{
+	  out = true;
+	  return true;
+	}
+	if (in.red() == 0u && in.green() == 0u && in.blue() == 0u)
+	{
+	  out = false;
+	  return true;
+	}
+	if (in.red() == in.green() && in.green() == in.blue())
+	  std::cerr << "error: trying to load '" << filename << "' which is a grayscale image into a bool image" << std::endl;
+	else
+	  std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a bool image" << std::endl;
+	return false;
+      }
+
+      inline
+      bool do_it(const value::rgb8& in, value::int_u8& out, const std::string& filename)
+      {
+	if (in.red() == in.green() && in.green() == in.blue())
+	{
+	  out = in.red();
+	  return true;
+	}
+	std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a grayscale image" << std::endl;
+	return false;
+      }
+
+      inline
+      bool do_it(const value::rgb8& in, value::rgb8& out, const std::string& filename)
+      {
+	out = in;
+	return true;
+      }
+
+
+      template <typename I>
+      inline
+      void load(Image<I>& ima_,
+	  const std::string& filename)
+      {
+	trace::entering("mln::io::magick::load");
+
+	I& ima = exact(ima_);
+
+	//std::ifstream file(filename.c_str());
+	//if (! file)
+	//{
+	//  std::cerr << "error: cannot open file '" << filename << "'!";
+	//  abort();
+	//}
+
+	Magick::Image im_file(filename);
+	im_file.modifyImage();
+	im_file.type(Magick::TrueColorType);
+	int columns = im_file.columns();
+	int rows = im_file.rows();
+	/*std::cout << "width: " <<columns << std::endl;
+	  std::cout << "height: " <<rows << std::endl;
+	  std::cout << "depth: " <<im_file.depth() << std::endl;
+	  std::cout << "format: " <<im_file.format() << std::endl;
+	  std::cout << "magick: " <<im_file.magick() << std::endl;*/
+
+	const Magick::PixelPacket *pixel_cache = im_file.getConstPixels(0, 0, columns, rows);
+
+	algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
+	algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
+	vmin[0] = 0;
+	vmin[1] = 0;
+	vmax[0] = rows - 1;
+	vmax[1] = columns - 1;
+	mln_site(I) pmin(vmin);
+	mln_site(I) pmax(vmax);
+	mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
+	initialize(ima, result);
+	mln_piter(I) p(ima.domain());
+	for_all(p)
+	{
+	  const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+					     + (int) p.to_site().to_vec()[1];
+	  value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // WARNING: Quantum = 16bits but rgb is 8bits
+	  mln_value(I) res;
+	  if (!do_it(pix, res, filename))
+	    abort();
+	  ima(p) = res;
+	}
+
+	trace::exiting("mln::io::magick::load");
+      }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+    } // end of namespace mln::io::magick
+
+  } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_MAGICK_LOAD_HH
Index: trunk/milena/mln/io/all.hh
===================================================================
--- trunk/milena/mln/io/all.hh	(revision 3538)
+++ trunk/milena/mln/io/all.hh	(revision 3539)
@@ -49,6 +49,7 @@
 # include <mln/io/cloud/all.hh>
 # include <mln/io/dump/all.hh>
 # include <mln/io/dicom/load.hh>
+# include <mln/io/magick/all.hh>
 # include <mln/io/pbm/all.hh>
 # include <mln/io/pfm/all.hh>
 # include <mln/io/pgm/all.hh>
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-16  Frederic Bour  <bour(a)lrde.epita.fr>
	Clean of new function implementation.
	* sandbox/fred/mln/core/concept/meta_function.hh,
	* sandbox/fred/mln/core/concept,
	* sandbox/fred/mln/core/image/thru_morpher.hh,
	* sandbox/fred/mln/core/image,
	* sandbox/fred/mln/core,
	* sandbox/fred/mln/fun/binary.hh,
	* sandbox/fred/mln/fun/compose.hh,
	* sandbox/fred/mln/fun/composition.hh,
	* sandbox/fred/mln/fun/math/abs.hh,
	* sandbox/fred/mln/fun/math/cos.hh,
	* sandbox/fred/mln/fun/math/inf.hh,
	* sandbox/fred/mln/fun/math/norm.hh,
	* sandbox/fred/mln/fun/math/sup.hh,
	* sandbox/fred/mln/fun/math,
	* sandbox/fred/mln/fun/spe/binary.hh,
	* sandbox/fred/mln/fun/spe/unary.hh,
	* sandbox/fred/mln/fun/spe,
	* sandbox/fred/mln/fun/unary.hh,
	* sandbox/fred/mln/fun,
	* sandbox/fred/mln/trait/fun.hh,
	* sandbox/fred/mln/trait/next/solve.hh,
	* sandbox/fred/mln/trait/next/solve_binary.hh,
	* sandbox/fred/mln/trait/next/solve_unary.hh,
	* sandbox/fred/mln/trait/next,
	* sandbox/fred/mln/trait,
	* sandbox/fred/mln: New. Clean files,
	  respecting milena file hierarchy.
	* sandbox/fred/Makefile,
	* sandbox/fred/overload.cc,
	* sandbox/fred/old/site_wrapper.hh,
	* sandbox/fred/old/value.cc,
	* sandbox/fred/old/overload.cc: Old files management.
	* sandbox/fred/tests/Makefile,
	* sandbox/fred/tests/cos.cc,
	* sandbox/fred/tests/fun.cc,
	* sandbox/fred/tests/thru.cc,
	* sandbox/fred/tests: New. Small test for functions.
---
 mln/core/concept/meta_function.hh |  203 +++++++++++++++++++++++++
 mln/core/image/thru_morpher.hh    |  307 ++++++++++++++++++++++++++++++++++++++
 mln/fun/binary.hh                 |  103 ++++++++++++
 mln/fun/compose.hh                |  100 ++++++++++++
 mln/fun/composition.hh            |  237 +++++++++++++++++++++++++++++
 mln/fun/math/abs.hh               |   69 ++++++++
 mln/fun/math/cos.hh               |   76 +++++++++
 mln/fun/math/inf.hh               |   69 ++++++++
 mln/fun/math/norm.hh              |  119 ++++++++++++++
 mln/fun/math/sup.hh               |   69 ++++++++
 mln/fun/spe/binary.hh             |  108 +++++++++++++
 mln/fun/spe/unary.hh              |  201 ++++++++++++++++++++++++
 mln/fun/unary.hh                  |  247 ++++++++++++++++++++++++++++++
 mln/trait/fun.hh                  |  131 ++++++++++++++++
 mln/trait/next/solve.hh           |  152 ++++++++++++++++++
 mln/trait/next/solve_binary.hh    |  302 +++++++++++++++++++++++++++++++++++++
 mln/trait/next/solve_unary.hh     |  171 +++++++++++++++++++++
 old/overload.cc                   |  296 ++++++++++++++++++++++++++++++++++++
 old/site_wrapper.hh               |  188 +++++++++++++++++++++++
 old/value.cc                      |   24 ++
 tests/Makefile                    |   25 +++
 tests/cos.cc                      |   34 ++++
 tests/fun.cc                      |  108 +++++++++++++
 tests/thru.cc                     |   37 ++++
 24 files changed, 3376 insertions(+)
Index: trunk/milena/sandbox/fred/overload.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/tests/thru.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/thru.cc	(revision 0)
+++ trunk/milena/sandbox/fred/tests/thru.cc	(revision 3538)
@@ -0,0 +1,37 @@
+// Meta functions test
+#include <mln/fun/essential.hh>
+#include <mln/fun/math/cos.hh>
+#include <mln/core/image/thru_morpher.hh>
+#include <mln/fun/compose.hh>
+
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/all.hh>
+#include <iostream>
+#include <typeinfo>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+
+int main()
+{
+  using namespace mln;
+
+  fun::cos cos;
+  typedef image2d<float> I;
+  I ima(5, 5);
+
+  image2d<value::int_u8> tmp(5, 5);
+  debug::iota(tmp);
+  data::fill_with_image(ima, tmp);
+
+  debug::println(ima);
+  debug::println(thru(cos, ima));
+
+  thru_image<I, fun::cos::with<fun::cos>::ret::result::with<float>::ret > ima2;
+  ima2 = thru(cos(cos), ima);
+
+  data::fill_with_image(ima2, (pw::value(tmp) - pw::cst(13.0f)) / pw::cst(12.0f) | tmp.domain());
+
+  debug::println(ima);
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/cos.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/cos.cc	(revision 0)
+++ trunk/milena/sandbox/fred/tests/cos.cc	(revision 3538)
@@ -0,0 +1,34 @@
+// Meta functions test
+#include <mln/fun/math/cos.hh>
+#include <mln/fun/compose.hh>
+
+#include <iostream>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+int main()
+{
+  mln::fun::cos cos;
+  mln::fun::compose compose;
+
+  double x;
+  dbg_print(cos(compose)(cos,cos)(x) = 0.857553);
+  dbg_print(x);
+  dbg_print(cos(compose)(cos,cos)(0.));
+
+  // COS
+  {
+    mln_invariant(cos(0.) == 1.);
+    dbg_print(cos(0.));
+    dbg_print(cos(mln::math::acos(0.5)));
+  }
+
+  // COS
+  {
+    double x;
+    dbg_print(cos(x) = 1.);
+    mln_invariant(cos(x) == 1.);
+    dbg_print(x);
+  }
+
+  std::cout << "Ok." << std::endl;
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc	(revision 0)
+++ trunk/milena/sandbox/fred/tests/fun.cc	(revision 3538)
@@ -0,0 +1,108 @@
+// Meta functions test
+#include <mln/fun/math/abs.hh>
+#include <mln/fun/math/cos.hh>
+#include <mln/fun/math/norm.hh>
+// #include <mln/fun/math/inc.hh>
+// #include <mln/fun/math/red.hh>
+
+#include <iostream>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+int main()
+{
+  mln::fun::abs abs;
+  mln::fun::cos cos;
+//   mln::fun::inc inc;
+//   mln::fun::red red;
+
+  mln::fun::norm::l1 l1;
+  mln::fun::norm::l2 l2;
+  mln::fun::norm::linfty linfty;
+
+  std::cout << "Read only tests." << std::endl;
+  std::cout << "----------------" << std::endl;
+
+  // ABS
+  mln_invariant(abs(-1) == 1);
+  dbg_print(abs(-1));
+  dbg_print(abs(-3.1415926535));
+
+  int x = 1;
+//   abs(x) = 2;
+//   abs.set(x, 2);
+
+//   // INC
+//   mln_invariant(inc(-1) == 0);
+//   dbg_print(inc(-1));
+//   dbg_print(inc(-3.1415926535));
+
+  // COS
+  mln_invariant(cos(0.) == 1.);
+  dbg_print(cos(0.));
+  dbg_print(cos(mln::math::acos(0.5)));
+
+//   // RED
+//   mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
+//   dbg_print(red(mln::value::rgb8(8,13,21)));
+
+  // NORM
+  mln::algebra::vec<3, double> v;
+  v[0] = 1;
+  v[1] = -1;
+  v[2] = 0;
+  dbg_print(v);
+  dbg_print(l1(v));
+//   dbg_print(cos(l1)(v));
+  dbg_print(l2(v));
+  dbg_print(linfty(v));
+
+  std::cout << "Read/Write tests." << std::endl;
+  std::cout << "-----------------" << std::endl;
+
+  // INC
+//   {
+//     int x;
+//     dbg_print(inc(x) = 1);
+//     mln_invariant(inc(x) == 1);
+//     dbg_print(inc(x));
+//     dbg_print(x);
+//   }
+
+  // COS
+  {
+    double x;
+    dbg_print(cos(x) = 1.);
+    mln_invariant(cos(x) == 1.);
+    dbg_print(x);
+  }
+
+  // RED
+//   {
+//     mln::value::rgb8 rgb(8,13,21);
+//     dbg_print(rgb);
+//     dbg_print(red(rgb) = 0);
+// // FIXME: Doesn't compile! mln_invariant(red(rgb) == 0);
+//     dbg_print(rgb);
+//   }
+
+  // NORM
+  {
+    dbg_print(v);
+    dbg_print(l1(v) = 1.0);
+    dbg_print(l1(v));
+    dbg_print(v);
+//     mln_invariant(l1(v) == 1.0); FIXME: check with epsilon
+
+    dbg_print(l2(v) = 1.0);
+    dbg_print(l2(v));
+    dbg_print(v);
+//     mln_invariant(l2(v) == 1.0);
+
+    dbg_print(linfty(v) = 1.0);
+    dbg_print(linfty(v));
+    dbg_print(v);
+//     mln_invariant(linfty(v) == 1.0);
+  }
+
+  std::cout << "All invariants passed." << std::endl;
+}
Index: trunk/milena/sandbox/fred/tests/Makefile
===================================================================
--- trunk/milena/sandbox/fred/tests/Makefile	(revision 0)
+++ trunk/milena/sandbox/fred/tests/Makefile	(revision 3538)
@@ -0,0 +1,25 @@
+TARGET=fun
+OBJS=$(TARGET).o
+
+OLENADIR=../../../..
+MILENADIR=$(OLENADIR)/milena
+
+CXXFLAGS=-I$(MILENADIR) -I../ -DNDEBUG -O1 -ffast-math
+CXX=g++
+LD=g++
+LDFLAGS=
+RM=rm
+
+$(TARGET): $(OBJS)
+	$(LD) $(LDFLAGS) -o $@ $(OBJS)
+
+%.o: %.cc
+	$(CXX) $(CXXFLAGS) -c $<
+
+%.o: %.hh
+	$(CXX) $(CXXFLAGS) -c $<
+
+all: $(TARGET)
+
+clean:
+	$(RM) -f $(TARGET) *.o *~
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/fun.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/fun.hh	(revision 3538)
@@ -0,0 +1,131 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_FUN_HH
+# define MLN_TRAIT_FUN_HH
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/if.hh>
+
+#define mln_trait_fun_is_assignable(Fun) typename mln::trait::fun::is_assignable< Fun >::ret
+#define mln_trait_fun_is_assignable_(Fun) mln::trait::fun::is_assignable< Fun >::ret
+#define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::fun::is_assignable< A, B >::ret
+#define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::fun::is_assignable< A, B >::ret
+
+#define mln_trait_fun_is_parametrable(Fun) typename mln::trait::fun::is_parametrable< Fun >::ret
+#define mln_trait_fun_is_parametrable_(Fun) mln::trait::fun::is_parametrable< Fun >::ret
+
+#define mln_trait_fun_lvalue(Fun) typename mln::trait::fun::get_lvalue< Fun >::ret
+#define mln_trait_fun_param(Fun) typename mln::trait::fun::get_param< Fun >::ret
+
+namespace mln
+{
+
+  namespace trait
+  {
+
+    namespace fun
+    {
+
+      namespace internal
+      {
+
+	namespace introspect
+	{
+
+	  template <typename T>
+	  struct except_void_t
+	  {
+	    typedef void ret;
+	  };
+
+	  template <>
+	  struct except_void_t<void>;
+
+	  template <typename T, typename V>
+	  struct has_lvalue_t
+	  {
+	    typedef metal::false_ ret;
+	    typedef void type;
+	  };
+
+	  template <typename T>
+	  struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
+	  {
+	    typedef metal::true_ ret;
+	    typedef typename T::lvalue type;
+	  };
+
+	  template <typename T, typename V>
+	  struct has_param_t
+	  {
+	    typedef metal::false_ ret;
+	    typedef void type;
+	  };
+
+	  template <typename T>
+	  struct has_param_t<T, typename except_void_t<typename T::param>::ret>
+	  {
+	    typedef metal::true_ ret;
+	    typedef typename T::param type;
+	  };
+
+	} // end of namespace mln::trait::fun::internal::introspect
+
+      } // end of namespace mln::trait::fun::internal
+
+      template <typename F>
+      struct is_assignable
+      {
+	typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret;
+      };
+
+      template <typename F>
+      struct is_parametrable
+      {
+	typedef typename internal::introspect::has_param_t<F, void>::ret ret;
+      };
+
+      template <typename F>
+      struct get_lvalue
+      {
+	typedef typename internal::introspect::has_lvalue_t<F, void>::type ret;
+      };
+
+      template <typename F>
+      struct get_param
+      {
+	typedef typename internal::introspect::has_param_t<F, void>::type ret;
+      };
+
+    } // end of namespace mln::trait::fun
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_FUN_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh	(revision 3538)
@@ -0,0 +1,171 @@
+// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+#ifndef MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+
+/*!
+ * \file   mln/trait/next/solve_unary.hh
+ *
+ * \brief  FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+#  ifndef MLN_DEBUG_TRAITS
+#  endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      namespace internal
+      {
+
+
+	template < typename Name,
+		   typename Category,
+		   typename T >
+	struct trait_set_unary_;
+
+	template < typename Name,
+		   template <class> class Category, typename _,
+		   typename T >
+	struct trait_set_unary_< Name, Category<_>, T >
+	{
+	  typedef typename mln::trait::next::set_unary_<Name, Category, T>::ret ret;
+	};
+
+
+	// Fwd decls.
+	template < typename Name,
+		   typename Category, typename T >
+	struct get_unary_;
+
+
+	template < typename user_ret, /* != not_found and != undefined */
+		   typename Name,
+		   typename Category, typename T >
+	struct helper_get_unary_
+	{
+	  typedef user_ret ret;  // The user has defined 'ret' so we return it.
+	};
+
+
+	template < typename Name,
+		   typename Category, typename T >
+	struct helper_get_unary_< /* user_ret == */ not_found,
+				  Name, Category, T >
+	{
+	  typedef not_found ret;  // End of search due to a blocker; 'ret' is not found.
+	};
+
+
+	template < typename Name,
+		   typename Category, typename T >
+	struct helper_get_unary_< /* user_ret == */ undefined,
+				  Name, Category, T >
+	{
+	  typedef typename mln::internal::super_category_< Category, T >::ret Super_Category;
+	  typedef typename get_unary_<Name, Super_Category, T>::ret ret;   // No user ret definition => Recursion.
+	};
+
+
+	template < typename Name,
+		   typename Category, typename T >
+	struct get_unary_
+	{
+	  typedef typename trait_set_unary_<Name, Category, T>::ret user_ret;  // First get 'user_ret'
+	  typedef helper_get_unary_<user_ret, Name, Category, T> helper;       // Set the helper to make a decision.
+	  typedef mlc_ret(helper) ret;                                         // Return.
+	};
+
+
+	template < typename precise_ret,
+		   typename Name,
+		   typename Category, typename T >
+	struct helper_choose_unary_wrt_ /* precise_ret != undefined */
+	{
+	  typedef precise_ret ret;                                 // -> A precise ret has been defined so it is it.
+	};
+
+	template < typename Name,
+		   typename Category, typename T >
+	struct helper_choose_unary_wrt_< /* precise_ret == */ undefined,
+					Name, Category, T >
+	{
+	  typedef typename get_unary_<Name, Category, T>::ret ret; // -> Go up into the category inheritance
+								  //    to fetch a ret from 'set_unary_'s.
+	};
+
+	template < typename Name,
+		   typename Category, typename T >
+	struct helper_solve_unary_
+	{
+	  typedef typename set_precise_unary_<Name, T>::ret precise_ret;
+	  typedef helper_choose_unary_wrt_< precise_ret, /* undefined or not (?) */
+					    Name, Category, T> helper;
+	  typedef mlc_ret(helper) ret;
+	};
+
+      } // end of namespace mln::trait::next::internal
+
+
+      template < typename Name,
+		typename T_ >
+      struct solve_unary
+      {
+	typedef mln_exact(T_) T;
+	typedef typename mln::category<T>::ret Category;
+	typedef internal::helper_solve_unary_< Name, Category, T > meta_code;
+	typedef typename meta_code::ret ret;
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_UNARY_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve.hh	(revision 3538)
@@ -0,0 +1,152 @@
+// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_NEXT_SOLVE_HH
+# define MLN_TRAIT_NEXT_SOLVE_HH
+
+/*!
+ * \file   mln/trait/next/solve.hh
+ *
+ * \brief  FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+#  ifndef MLN_DEBUG_TRAITS
+#  endif // ! MLN_DEBUG_TRAITS
+
+
+# define mln_trait_nunary(Name, T)  typename mln::trait::next::solve_unary< Name, T >::ret
+# define mln_trait_nunary_(Name, T)          mln::trait::next::solve_unary< Name, T >::ret
+
+# define mln_trait_nbinary(Name, T1, T2)  typename mln::trait::next::solve_binary< Name, T1, T2 >::ret
+# define mln_trait_nbinary_(Name, T1, T2)          mln::trait::next::solve_binary< Name, T1, T2 >::ret
+
+
+
+namespace mln
+{
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      // Unary case.
+
+
+      template < typename Name,
+		 typename T >
+      struct set_precise_unary_
+      {
+	typedef undefined ret;
+      };
+
+
+      template < typename Name,
+		 template <class> class Category_T, typename T >
+      struct set_unary_
+      {
+	typedef undefined ret;
+      };
+
+      template < typename Name,
+		 typename T >
+      struct set_unary_< Name, Unknown, T > // Blocker; top of inheritance.
+      {
+	typedef not_found ret;
+      };
+
+
+
+
+      // Binary case.
+
+
+      template < typename Name,
+		 typename L,
+		 typename R >
+      struct set_precise_binary_
+      {
+	typedef undefined ret;
+      };
+
+
+      template < typename Name,
+		 template <class> class Category_L, typename L,
+		 template <class> class Category_R, typename R >
+      struct set_binary_
+      {
+	typedef undefined ret;
+      };
+
+      template < typename Name,
+		 typename L,
+		 template <class> class Category_R, typename R >
+      struct set_binary_< Name, Unknown, L, Category_R, R > // Left blocker.
+      {
+	typedef not_found ret;
+      };
+
+      template < typename Name,
+		 template <class> class Category_L, typename L,
+		 typename R >
+      struct set_binary_< Name, Category_L, L, Unknown, R > // Right blocker.
+      {
+	typedef not_found ret;
+      };
+
+      template < typename Name,
+		 typename L,
+		 typename R >
+      struct set_binary_< Name, Unknown, L, Unknown, R > // Blocker.
+      {
+	typedef not_found ret;
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+# include <mln/trait/next/solve_unary.hh>
+# include <mln/trait/next/solve_binary.hh>
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh	(revision 3538)
@@ -0,0 +1,302 @@
+// Copyright (C) 2006, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+#ifndef MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+
+/// \file   mln/trait/next/solve_binary.hh
+///
+///  FIXME
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+#  ifndef MLN_DEBUG_TRAITS
+#  endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      namespace internal
+      {
+
+
+	template < typename Name,
+		  typename Category_L, typename L,
+		  typename Category_R, typename R >
+	struct trait_set_binary_;
+
+	template < typename Name,
+		  template <class> class Category_L, typename _l, typename L,
+		  template <class> class Category_R, typename _r, typename R >
+	struct trait_set_binary_< Name,
+				Category_L<_l>, L,
+				Category_R<_r>, R >
+	{
+	  typedef typename mln::trait::next::set_binary_<Name,
+							 Category_L, L,
+							 Category_R, R>::ret ret;
+	};
+
+
+	// triplet_ret_
+
+	template < unsigned i_L_, unsigned i_R_, typename ret_ >
+	struct triplet_
+	{
+	  typedef ret_ ret;
+	};
+
+
+	// merge_triplets_
+
+	template < typename L_trp, typename R_trp >
+	struct merge_triplets_;
+
+	template < unsigned L_i_L, unsigned L_i_R, typename L_ret,
+		  unsigned R_i_L, unsigned R_i_R, typename R_ret >
+	struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+				triplet_<R_i_L, R_i_R, R_ret> >
+	{
+	  typedef metal::bool_<(L_i_L <= R_i_L && L_i_R <= R_i_R)> take_L;
+	  typedef metal::bool_<(R_i_L <= L_i_L && R_i_R <= L_i_R)> take_R;
+	  typedef metal::or_<take_L, take_R> ok;
+	  typedef typename metal::if_< metal::and_<ok, take_L>,
+				      triplet_<L_i_L, L_i_R, L_ret>,
+				      typename metal::if_< metal::and_<ok, take_R>,
+							    triplet_<R_i_L, R_i_R, R_ret>,
+							    triplet_<0,0, not_found> >::ret >::ret ret;
+	};
+
+	template < unsigned i_L, unsigned i_R, typename LR_ret >
+	struct merge_triplets_< triplet_<i_L, i_R, LR_ret>,
+				triplet_<i_L, i_R, LR_ret> >
+	{
+	  typedef triplet_<i_L, i_R, LR_ret> ret;
+	};
+
+
+	template < unsigned L_i_L, unsigned L_i_R, unsigned L_i_max,
+		  unsigned R_i_L, unsigned R_i_R, unsigned R_i_max >
+	// L_i_max and R_i_max differ
+	struct helper_merge_triplets_same_ret_
+	{
+	  // The winning couple between L_* and R_* is the one which
+	  // maximum index is the smallest; for instance, with:
+	  //   left  branch giving L_i_L = 5 and L_i_R = 1 so L_i_max = 5
+	  //   right branch giving L_i_L = 3 and L_i_R = 4 so R_i_max = 4
+	  // the right branch wins.
+	  enum { i_L = (L_i_max < R_i_max ? L_i_L : R_i_L),
+		i_R = (L_i_max < R_i_max ? L_i_R : R_i_R) };
+	};
+
+	template < unsigned L_i_L, unsigned L_i_R, unsigned i_max,
+		  unsigned R_i_L, unsigned R_i_R >
+	// L_i_max is equal to R_i_max
+	struct helper_merge_triplets_same_ret_< L_i_L, L_i_R, i_max,
+						R_i_L, R_i_R, i_max >
+	{
+	  // The winning couple is the one with the minimum index.
+	  enum { L_i_min = (L_i_L < L_i_R ? L_i_L : L_i_R),
+		R_i_min = (R_i_L < R_i_R ? R_i_L : R_i_R),
+		i_L = (L_i_min < R_i_min ? L_i_L : R_i_L),
+		i_R = (L_i_min < R_i_min ? L_i_R : R_i_R) };
+	};
+
+
+	template < unsigned L_i_L, unsigned L_i_R, typename LR_ret,
+		  unsigned R_i_L, unsigned R_i_R >
+	struct merge_triplets_< triplet_<L_i_L, L_i_R, LR_ret>,
+				triplet_<R_i_L, R_i_R, LR_ret> >
+	{
+	  typedef helper_merge_triplets_same_ret_< L_i_L, L_i_R, (L_i_L > L_i_R ? L_i_L : L_i_R),
+						  R_i_L, R_i_R, (R_i_L > R_i_R ? R_i_L : R_i_R) > helper;
+	  typedef triplet_<helper::i_L, helper::i_R, LR_ret> ret;
+	};
+
+	template < unsigned L_i_L, unsigned L_i_R, typename L_ret >
+	struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+				triplet_<  0,     0,   not_found> >
+	{
+	  typedef triplet_<L_i_L, L_i_R, L_ret> ret;
+	};
+
+	template < unsigned R_i_L, unsigned R_i_R, typename R_ret >
+	struct merge_triplets_< triplet_<  0,     0,   not_found>,
+				triplet_<R_i_L, R_i_R, R_ret> >
+	{
+	  typedef triplet_<R_i_L, R_i_R, R_ret> ret;
+	};
+
+	template <> // To disambiguate.
+	struct merge_triplets_< triplet_<0, 0, not_found>,
+				triplet_<0, 0, not_found> >
+	{
+	  typedef triplet_<0u,0u, not_found> ret;
+	};
+
+
+
+	// Fwd decl.
+	template < typename Name,
+		  unsigned i_L, typename Category_L, typename L,
+		  unsigned i_R, typename Category_R, typename R >
+	struct get_binary_;
+
+
+	template < typename user_ret, /* != not_found and != undefined */
+		  typename Name,
+		  unsigned i_L, typename Category_L, typename L,
+		  unsigned i_R, typename Category_R, typename R >
+	struct helper_get_binary_
+	{
+	  typedef triplet_< i_L, i_R, user_ret > ret; // The user has defined 'ret' so we return it.
+	};
+
+	template < typename Name,
+		  unsigned i_L, typename Category_L, typename L,
+		  unsigned i_R, typename Category_R, typename R >
+	struct helper_get_binary_< /* user_ret == */ not_found,
+				  Name,  i_L, Category_L, L,  i_R, Category_R, R >
+	{
+	  typedef triplet_< 0, 0, not_found > ret; // End of search due to a blocker; 'ret' is not found.
+	};
+
+
+	template < typename Name,
+		  unsigned i_L, typename Category_L, typename L,
+		  unsigned i_R, typename Category_R, typename R >
+	struct helper_get_binary_< /* user_ret == */ undefined,
+				  Name, i_L,Category_L, L, i_R,Category_R, R >
+	{
+	  // No user definition for 'ret' so treillis construction in a static recursive way.
+
+	  // FIXME: We *do* need to handle this search with a priority!
+	  // FIXME: for a result can be found in both branches...
+
+	  typedef typename mln::internal::super_category_< Category_L, L >::ret Super_Category_L;
+	  typedef typename mln::internal::super_category_< Category_R, R >::ret Super_Category_R;
+
+	  typedef get_binary_< Name,
+			      i_L + 1, Super_Category_L, L,
+			      i_R,     Category_R,       R > L_branch;
+	  typedef mlc_ret(L_branch) L_trp;
+
+	  typedef get_binary_< Name,
+			      i_L,     Category_L,       L,
+			      i_R + 1, Super_Category_R, R > R_branch;
+	  typedef mlc_ret(R_branch) R_trp;
+
+	  typedef typename merge_triplets_< L_trp, R_trp >::ret ret;
+	};
+
+
+	template < typename Name,
+		  unsigned i_L, typename Category_L, typename L,
+		  unsigned i_R, typename Category_R, typename R >
+	struct get_binary_
+	{
+	  typedef typename trait_set_binary_<Name, Category_L,L,
+					    Category_R,R>::ret user_ret;  // First get 'user_ret'
+	  typedef helper_get_binary_<user_ret, Name, i_L,Category_L,L,
+						    i_R,Category_R,R> helper;        // Set the helper to make a decision.
+	  typedef mlc_ret(helper) ret;                                                // Return a triplet.
+	};
+
+
+	template < typename precise_ret,
+		  typename Name,
+		  typename Category_L, typename L,
+		  typename Category_R, typename R >
+	struct helper_choose_binary_wrt_ /* precise_ret != undefined */
+	{
+	  typedef precise_ret ret;                                                 // -> A precise ret has been defined so it is it.
+	};
+
+	template < typename Name,
+		  typename Category_L, typename L,
+		  typename Category_R, typename R >
+	struct helper_choose_binary_wrt_< /* precise_ret == */ undefined,
+					  Name, Category_L, L, Category_R, R >
+	{
+	  typedef typename get_binary_< Name,
+					0, Category_L, L,
+					0, Category_R, R >::ret triplet;           // Browse upwards the category inheritance
+	  typedef mlc_ret(triplet) ret;                                            // to fetch ret from 'get_binary_'s.
+	};
+
+
+	template < typename Name,
+		  typename Category_L, typename L,
+		  typename Category_R, typename R >
+	struct helper_solve_binary_
+	{
+	  typedef typename set_precise_binary_<Name, L, R>::ret precise_ret; /* undefined or not (?) */
+	  typedef helper_choose_binary_wrt_<precise_ret, Name, Category_L,L, Category_R,R> helper;
+	  typedef mlc_ret(helper) ret;
+	};
+
+      } // end of namespace mln::trait::internal
+
+
+      // FIXME: Postfix solve_binary with a '-'(?)
+      template < typename Name,
+		typename L_,
+		typename R_ >
+      struct solve_binary
+      {
+	typedef mln_exact(L_) L;
+	typedef mln_exact(R_) R;
+	typedef typename mln::category<L>::ret Category_L;
+	typedef typename mln::category<R>::ret Category_R;
+	typedef internal::helper_solve_binary_< Name, Category_L, L, Category_R, R > meta_code;
+	typedef typename meta_code::ret ret;
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_BINARY_HH
Index: trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh	(revision 3538)
@@ -0,0 +1,307 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE_THRU_MORPHER_HH
+# define MLN_CORE_IMAGE_THRU_MORPHER_HH
+
+# include <mln/core/internal/image_value_morpher.hh>
+# include <mln/core/concept/meta_function.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/trait/fun.hh>
+
+///
+/// \file mln/core/image/thru_morpher.hh
+///
+/// \brief Definition of a morpher that morph image values through a function.
+///
+/// \todo Debug constness of thru_image
+
+namespace mln
+{
+
+  // Forward declaration.
+  template <typename I, typename F> struct thru_image;
+
+  namespace internal
+  {
+    template <typename I, typename F> struct thru_image_write;
+    template <typename I, typename F> struct thru_image_read;
+
+    /// Find correct implementation
+    template <typename I, typename F>
+    struct thru_find_impl
+    {
+      typedef thru_image_write<I, F> write;
+      typedef thru_image_read<I, F> read;
+      typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret,
+		     mlc_and(mlc_not(mlc_is_const(I)),
+			     mlc_equal(mln_trait_image_pw_io(I),
+				       trait::image::pw_io::read_write))),
+		     write, read) ret;
+    };
+
+    /// Data structure for \c mln::thru_image<I>.
+    template <typename I, typename F>
+    struct data< thru_image<I, F> >
+    {
+      data(I& ima, const F& f);
+
+      I ima_;
+      // FIXME: value or pointer or whatever ?
+      F f_;
+    };
+
+  } // end of namespace mln::internal
+
+
+  namespace trait
+  {
+
+    template <typename I, typename F>
+    struct image_< thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret > // Same as I except...
+    {
+      // ...these changes.
+      typedef trait::image::category::value_morpher category;
+      typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+      typedef trait::image::value_access::computed value_access;
+    };
+
+    template <typename I, typename F>
+    struct image_< mln::internal::thru_image_write<I, F> > : image_< I > // Same as I except...
+    {
+      typedef trait::image::vw_io::read_write vw_io;
+    };
+
+    template <typename I, typename F>
+    struct image_< mln::internal::thru_image_read<I, F> > : image_< I > // Same as I except...
+    {
+      typedef trait::image::vw_io::read vw_io;
+    };
+
+  } // end of namespace mln::trait
+
+
+
+  // FIXME: Doc!
+
+  namespace internal
+  {
+
+    template <typename I, typename F>
+    class thru_image_read : public internal::image_value_morpher< I, typename F::result, thru_image<I,F> >
+    {
+    public:
+
+      /// Skeleton.
+      typedef thru_image<tag::image_<I>, F> skeleton;
+
+      /// Point_Site associated type.
+      typedef mln_psite(I) psite;
+
+      /// Value associated type.
+      typedef typename F::result value;
+
+      /// Return type of read-only access.
+      typedef typename F::result rvalue;
+
+      rvalue operator()(const mln_psite(I)& p) const;
+
+    };
+
+    // Inheritance from read ?!
+    template <typename I, typename F>
+    class thru_image_write : public thru_image_read<I,F>
+    {
+      public:
+
+	/// Type returned by the read-write pixel value operator.
+// 	typedef typename F::template lresult<typename F::argument>::ret lvalue;
+	typedef typename F::lresult lvalue;
+
+	using thru_image_read<I,F>::operator();
+	lvalue operator()(const mln_psite(I)& p);
+
+    };
+  }
+
+  template <typename I, typename F>
+  class thru_image : public internal::thru_find_impl<I, F>::ret
+  {
+  public:
+
+    thru_image();
+    thru_image(I& ima);
+    thru_image(I& ima, const F& f);
+
+    void init_(I& ima, const F& f);
+
+    /// Const promotion via conversion.
+    operator thru_image<const I, F>() const;
+  };
+
+  template <typename I, typename F>
+  thru_image<I, F> thru(const mln::Function<F>& f,
+			Image<I>& ima);
+
+  template <typename I, typename F>
+  const thru_image<const I, F> thru(const mln::Function<F>& f,
+				    const Image<I>& ima);
+
+  template <typename I, typename M>
+  thru_image<I, mln_fun_with(M, mln_value(I))>
+  thru(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+  template <typename I, typename M>
+  const thru_image<const I, mln_fun_with(M, mln_value(I))>
+  thru(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+  // internal::data< thru_image<I,S> >
+
+  namespace internal
+  {
+
+    template <typename I, typename F>
+    inline
+    data< thru_image<I, F> >::data(I& ima, const F& f)
+      : ima_(ima),
+	f_(f)
+    {
+    }
+
+  } // end of namespace mln::internal
+
+  // thru_image<I>
+
+  template <typename I, typename F>
+  inline
+  thru_image<I, F>::thru_image()
+  {
+  }
+
+  template <typename I, typename F>
+  inline
+  thru_image<I, F>::thru_image(I& ima, const F& f)
+  {
+    mln_precondition(ima.is_valid());
+    init_(ima, f);
+  }
+
+  template <typename I, typename F>
+  inline
+  thru_image<I, F>::thru_image(I& ima)
+  {
+    mln_precondition(ima.is_valid());
+    init_(ima, mln_value(I)());
+  }
+
+  template <typename I, typename F>
+  inline
+  void
+  thru_image<I, F>::init_(I& ima, const F& f)
+  {
+    mln_precondition(! this->is_valid());
+    mln_precondition(ima.is_valid());
+    this->data_ = new internal::data< thru_image<I, F> >(ima, f);
+  }
+
+  template <typename I, typename F>
+  inline
+  thru_image<I, F>::operator thru_image<const I, F>() const
+  {
+    thru_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+    return tmp;
+  }
+
+  namespace internal
+  {
+
+    template <typename I, typename F>
+    inline
+    typename thru_image_read<I, F>::rvalue
+    thru_image_read<I, F>::operator()(const mln_psite(I)& p) const
+    {
+      mln_precondition(this->is_valid());
+      return this->data_->f_(this->data_->ima_(p));
+    }
+
+    template <typename I, typename F>
+    inline
+    typename thru_image_write<I, F>::lvalue
+    thru_image_write<I, F>::operator()(const mln_psite(I)& p)
+    {
+      mln_precondition(this->is_valid());
+      return this->data_->f_(this->data_->ima_(p));
+    }
+
+  }
+
+  // thru
+  template <typename I, typename F>
+  thru_image<I, F> thru(const mln::Function<F>& f,
+			Image<I>& ima)
+  {
+    thru_image<I, F> tmp(exact(ima), exact(f));
+    return tmp;
+  }
+
+  template <typename I, typename F>
+  thru_image<const I, F> thru(const mln::Function<F>& f,
+			      const Image<I>& ima)
+  {
+    thru_image<const I, F> tmp(exact(ima), exact(f));
+    return tmp;
+  }
+
+  template <typename I, typename M>
+  thru_image<I, mln_fun_with(M, mln_value(I))>
+  thru(const mln::Meta_Function<M>& f, Image<I>& ima)
+  {
+    typedef mln_fun_with(M, mln_value(I)) F;
+    thru_image<I, F> tmp(exact(ima), F());
+
+    return tmp;
+  }
+
+  template <typename I, typename M>
+  thru_image<const I, mln_fun_with(M, mln_value(I))>
+  thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
+  {
+    typedef mln_fun_with(M, mln_value(I)) F;
+    thru_image<const I, F> tmp(exact(ima), F());
+
+    return tmp;
+  }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRU_MORPHER_HH
Index: trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh	(revision 3538)
@@ -0,0 +1,203 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_META_FUNCTION_HH
+# define MLN_CORE_CONCEPT_META_FUNCTION_HH
+
+/// \file mln/core/concept/meta_function.hh
+///
+/// Definition of the concept of mln::Meta_Function.
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
+
+
+# define mln_fun_with(F, T) \
+typename F::template with< T >::ret
+
+# define mln_fun_with_(F, T) \
+F::with< T >::ret
+
+
+# define mln_fun_result(F, T) \
+typename F::template with< T >::ret::result
+
+
+# define mln_fun_result_(F, T) \
+F::with< T >::ret::result
+
+
+
+namespace mln
+{
+
+  // Fwd decl.
+  template <typename E> struct Meta_Function;
+  template <typename E> struct Meta_Function_v2v;
+  template <typename E> struct Meta_Function_vv2v;
+
+  // Meta_Function category flag type.
+  template <>
+  struct Meta_Function<void>
+  {
+    typedef Object<void> super;
+  };
+
+
+  /*! \brief Base class for implementation of meta functions.
+   *
+   * The parameter \a E is the exact type.
+   *
+   * \see mln::doc::Meta_Function for a complete documentation of
+   * this class contents.
+   */
+  template <typename E>
+  struct Meta_Function : public Object<E>
+  {
+    typedef Meta_Function<void> category;
+  protected:
+    Meta_Function();
+  };
+
+  /*----------------------.
+  | Unary meta function.  |
+  `----------------------*/
+
+  template <>
+  struct Meta_Function_v2v<void> { typedef Meta_Function<void> super; };
+
+  /// Base class for implementation of function-objects from
+  /// value to value.
+  ///
+  /// The parameter \a E is the exact type.
+  ///
+  template <typename E>
+  struct Meta_Function_v2v : public Meta_Function<E>
+  {
+    typedef Meta_Function_v2v<void> category;
+
+    protected:
+      Meta_Function_v2v();
+      Meta_Function_v2v(const Meta_Function_v2v&);
+  };
+
+  /*-----------------------.
+  | Binary meta function.  |
+  `-----------------------*/
+
+  template <>
+  struct Meta_Function_vv2v<void> { typedef Meta_Function<void> super; };
+
+  /// Base class for implementation of function-objects from
+  /// value to value.
+  ///
+  /// The parameter \a E is the exact type.
+  ///
+  template <typename E>
+  struct Meta_Function_vv2v : public Meta_Function<E>
+  {
+    typedef Meta_Function_vv2v<void> category;
+
+    protected:
+      Meta_Function_vv2v();
+      Meta_Function_vv2v(const Meta_Function_vv2v&);
+  };
+
+  namespace fun
+  {
+
+    // To be specialized when some state (attributes) have to be transfered
+    // from the meta-function to the function.
+    // Warning: the first argument has to be an object with the exact type.
+    template <typename M, typename T>
+    mln_fun_with(M, T)
+    unmeta(const M&, T);
+
+    template <typename M, typename T>
+    void
+    unmeta(const Meta_Function<M>&, T); // Safety.
+
+  } // end of namespace mln::fun
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+  template <typename E>
+  inline
+  Meta_Function<E>::Meta_Function()
+  {
+    // FIXME: Check "with" on E.
+  }
+
+  template <typename E>
+  inline
+  Meta_Function_v2v<E>::Meta_Function_v2v()
+  {
+  }
+
+  template <typename E>
+  inline
+  Meta_Function_v2v<E>::Meta_Function_v2v(const Meta_Function_v2v<E>& rhs)
+  : Meta_Function<E>(rhs)
+  {
+  }
+
+  template <typename E>
+  inline
+  Meta_Function_vv2v<E>::Meta_Function_vv2v()
+  {
+  }
+
+  template <typename E>
+  inline
+  Meta_Function_vv2v<E>::Meta_Function_vv2v(const Meta_Function_vv2v<E>& rhs)
+  : Meta_Function<E>(rhs)
+  {
+  }
+
+  namespace fun
+  {
+
+    template <typename M, typename T>
+    inline
+    mln_fun_with(M, T)
+    unmeta(const M&, T)
+    {
+      mlc_is_a(M, Meta_Function)::check();
+      mln_fun_with(M, T) a;
+      return a;
+    }
+
+  } // end of namespace mln::fun
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_META_FUNCTION_HH
Index: trunk/milena/sandbox/fred/mln/fun/composition.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/composition.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/composition.hh	(revision 3538)
@@ -0,0 +1,237 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPOSITION_HH
+# define MLN_FUN_COMPOSITION_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+
+namespace mln
+{
+  // Composition
+  namespace fun
+  {
+
+    namespace internal
+    {
+
+      // Compositions may take this has initialization parameter
+      template <typename F, typename G>
+      struct composition_param
+      {
+	composition_param(const F& f, const G& g) : f_(f), g_(g) {}
+	composition_param() {}
+
+	F f_;
+	G g_;
+      };
+
+      // Composition types...
+      template <template <class> class CatF,  typename F,
+		template <class> class CatG, typename G>
+      struct composition;
+
+      // Meta
+      template <typename F, typename G>
+      struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+      : mln::fun::unary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, composition_param<F, G> >
+      {
+	typedef mln::fun::unary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, composition_param<F, G> > super;
+
+	composition() {};
+	composition(const typename super::param& p) : super(p) {};
+
+	typedef composition exact_type;
+      };
+
+      template <typename F, typename G>
+      struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+      : mln::fun::binary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, composition_param<F, G> >
+      {
+	typedef mln::fun::binary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, composition_param<F, G> > super;
+
+	composition() {};
+	composition(const typename super::param& p) : super(p) {};
+
+	typedef composition exact_type;
+      };
+
+      // Concrete
+      template <typename F, typename G>
+      struct composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+      {
+	typedef mln::fun::spe::unary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>, typename G::argument> exact_type;
+      };
+
+      template <typename F, typename G>
+      struct composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+      {
+	typedef mln::fun::spe::binary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>,
+				       typename G::argument1, typename G::argument2> exact_type;
+      };
+
+      // Unary compositions implementation inherit from composition_unary_impl...
+      template <bool has_lvalue, typename F, typename F_spe, typename G, typename G_spe>
+      struct composition_unary_impl_helper;
+
+      template <typename F, typename F_spe, typename G, typename G_spe>
+      struct composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+      {
+	typedef typename G_spe::argument argument;
+	typedef typename F_spe::result   result;
+	typedef composition_param<F, G> param;
+
+	composition_unary_impl_helper() {}
+	composition_unary_impl_helper(const param& p) : f_(p.f_), g_(p.g_) {}
+
+	void init(const param& p)
+	{
+	  f_ = p.f_;
+	  g_ = p.g_;
+	}
+
+	result read(const argument& x) const
+	{
+	  return this->f_(this->g_(x));
+	}
+
+      protected:
+	F f_;
+	G g_;
+      };
+
+      template <typename F, typename F_spe, typename G, typename G_spe>
+      struct composition_unary_impl_helper<true, F, F_spe, G, G_spe>
+      : composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+      {
+	typedef composition_unary_impl_helper<false, F, F_spe, G, G_spe> super;
+	typedef typename G_spe::lvalue   lvalue;
+
+	composition_unary_impl_helper() {}
+	composition_unary_impl_helper(const typename super::param& p) : super(p) {}
+
+	void write(lvalue l, const typename super::result& x) const
+	{
+	  typename G_spe::result r(this->g_(l));
+
+	  this->f_.set(r, x);
+	  this->g_.set(l, r);
+	}
+      };
+
+      template <typename F, typename F_spe, typename G, typename G_spe>
+      struct composition_unary_impl
+      : composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe>
+      {
+	typedef composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe> super;
+
+	composition_unary_impl() {}
+	composition_unary_impl(const typename super::param& p) : super(p) {}
+      };
+
+      // Binary compositions implementation inherit from composition_binary_inherit...
+      template <typename F, typename F_spe, typename G, typename G_spe>
+      struct composition_binary_impl
+      {
+	typedef typename G_spe::argument1 argument1;
+	typedef typename G_spe::argument2 argument2;
+	typedef typename F_spe::result   result;
+	typedef composition_param<F, G> param;
+
+	composition_binary_impl() {}
+	composition_binary_impl(const param& p) : f_(p.f_), g_(p.g_) {}
+
+	void init(const param& p)
+	{
+	  f_ = p.f_;
+	  g_ = p.g_;
+	}
+
+	result read(const argument1& a, const argument2& b) const
+	{
+	  return this->f_(this->g_(a, b));
+	}
+
+      protected:
+	F f_;
+	G g_;
+      };
+
+    } // end of namespace mln::fun::internal
+
+  } // end of namespace mln::fun
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <typename F, typename G, typename T>
+      struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, T>
+      {
+	typedef typename G::template with<T>::ret G_fun;
+	typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+	typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G_fun> ret;
+      };
+
+      template <typename F, typename G, typename T1, typename T2>
+      struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, T1, T2>
+      {
+	typedef typename G::template with<T1, T2>::ret G_fun;
+	typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+	typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G_fun> ret;
+      };
+
+      template <typename F, typename G>
+      struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>,
+				typename G::argument>
+      {
+	typedef typename F::template with<typename G::result>::ret F_fun;
+
+	typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G> ret;
+      };
+
+      template <typename F, typename G>
+      struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>,
+				 typename G::argument1, typename G::argument2>
+      {
+	typedef typename F::template with<typename G::result>::ret F_fun;
+
+	typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G> ret;
+      };
+
+    }  // end of namespace mln::trait::next
+
+  }  // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSITION_HH */
Index: trunk/milena/sandbox/fred/mln/fun/binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/binary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/binary.hh	(revision 3538)
@@ -0,0 +1,103 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_BINARY_HH
+# define MLN_FUN_BINARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/binary.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+  namespace fun
+  {
+
+    template <typename F>
+    struct binary : mln::Meta_Function_vv2v< binary<F> >
+    {
+
+      template <typename T1, typename T2>
+      struct with
+      {
+	typedef spe::binary<F, T1, T2> ret;
+      };
+
+      template <typename T1, typename T2>
+      typename with<T1, T2>::ret::result operator()(const T1& a, const T2& b) const
+      {
+	typename with<T1, T2>::ret tmp;
+	return tmp(a, b);
+      }
+
+    };
+
+    template <typename F, typename P>
+    struct binary_param: binary<F>
+    {
+      typedef P param;
+
+      binary_param() {};
+      binary_param(const param& p) : p_(p) {};
+
+      void init(const param& p)
+      {
+	p_ = p;
+      }
+
+      param& parameter()
+      {
+	return p_;
+      }
+
+      protected:
+	param p_;
+    };
+
+    template <typename F>
+    struct binary_param<F, F>: binary<F>
+    {
+      typedef F param;
+
+      void init(const param& p)
+      {
+	exact(*this) = p;
+      }
+
+      param& parameter()
+      {
+	return exact(*this);
+      }
+    };
+
+  } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_BINARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/compose.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/compose.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/compose.hh	(revision 3538)
@@ -0,0 +1,100 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPOSE_HH
+# define MLN_FUN_COMPOSE_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/composition.hh>
+
+namespace mln
+{
+  // Composition
+  namespace fun
+  {
+    struct compose : binary<compose> {};
+
+    namespace internal
+    {
+
+      template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+      struct compose_helper
+      {
+	typedef F argument1;
+	typedef G argument2;
+
+	typedef typename composition<CatF, F, CatG, G>::exact_type result;
+	typedef typename result::param param;
+
+	static result read(const F& f, const G& g)
+	{
+	  return result(param(f, g));
+	}
+      };
+
+    } // end of namespace mln::fun::internal
+
+  } // end of namespace mln::fun
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      // All kinds of supported compositions (meta : unary) with (meta or not : unary or binary)
+      template <typename F, typename G>
+      struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+      {
+	typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> ret;
+      };
+
+      template <typename F, typename G>
+      struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+      {
+	typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> ret;
+      };
+
+      template <typename F, typename G>
+      struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+      {
+	typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_v2v, G> ret;
+      };
+
+      template <typename F, typename G>
+      struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+      {
+	typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_vv2v, G> ret;
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+}  // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSE_HH */
Index: trunk/milena/sandbox/fred/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/binary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/spe/binary.hh	(revision 3538)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_SPE_BINARY_HH
+# define MLN_FUN_SPE_BINARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+/// \todo Implements parameter support
+
+namespace mln
+{
+
+  namespace fun
+  {
+
+    namespace spe
+    {
+
+      // Forward declaration
+      template <typename Fun, typename T1, typename T2>
+      struct binary;
+
+      namespace impl
+      {
+
+	template <typename Fun, typename T1, typename T2>
+	struct binary_impl : mln::Function_v2v< binary<Fun, T1, T2> >
+	{
+	  typedef mln_trait_nbinary(Fun, T1, T2) impl;
+
+	  typedef typename impl::argument1 argument1;
+	  typedef typename impl::argument2 argument2;
+	  typedef typename impl::result    result;
+
+	  binary_impl()
+	  : impl_()
+	  {
+	  }
+
+	  binary_impl(const impl& f)
+	  : impl_(f)
+	  {
+	  }
+
+	  result operator () (const argument1& a, const argument2& b) const
+	  {
+	    return this->impl_.read(a, b);
+	  }
+
+	protected:
+	  impl impl_;
+	};
+
+      } // end of namespace mln::fun::spe::impl
+
+      template <typename Fun, typename T1, typename T2>
+      struct binary
+      : impl::binary_impl<Fun, T1, T2>
+      {
+	typedef impl::binary_impl<Fun, T1, T2> super;
+
+	binary()
+	: super()
+	{
+	}
+
+	binary(const typename super::impl& f)
+	: super(f)
+	{
+	}
+
+	using super::operator();
+      };
+
+    } // end of namespace mln::fun::spe
+
+  } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_SPE_BINARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/unary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/spe/unary.hh	(revision 3538)
@@ -0,0 +1,201 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_SPE_UNARY_HH
+# define MLN_FUN_SPE_UNARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+  namespace fun
+  {
+
+    namespace spe
+    {
+
+      namespace internal
+      {
+
+	template <typename Impl>
+	struct unary_modifier
+	{
+	  typedef typename Impl::result   result;
+	  typedef typename Impl::argument argument;
+	  typedef typename Impl::lvalue   lvalue;
+	  typedef unary_modifier          lresult;
+
+	  // FIXME: "argument& x" or "lvalue x" directly? ~~~
+	  unary_modifier(const Impl& impl, argument& x)
+	  : x_(&x), impl_(&impl)
+	  {
+	  }
+
+	  result to_result() const
+	  {
+	    return impl_->read(*x_);
+	  };
+
+	  operator result() const
+	  {
+	    return to_result();
+	  };
+
+	  const result& operator = (const result& r) const
+	  {
+	    impl_->write(*x_, r);
+	    return r;
+	  }
+
+	private:
+	  argument *x_;
+	  const Impl *impl_;
+	};
+
+      } // end of namespace mln::fun::internal
+
+      // Forward declaration (defined in mln/fun/unary.hh)
+      template <typename Fun, typename T>
+      struct unary;
+
+      namespace impl
+      {
+
+	template <bool set, typename Fun, typename T>
+	struct unary_impl_set;
+
+	template <typename Fun, typename T>
+	struct unary_impl_set<false, Fun, T> : mln::Function_v2v< unary<Fun, T> >
+	{
+	  typedef mln_trait_nunary(Fun, T) impl;
+
+	  typedef typename impl::argument argument;
+	  typedef typename impl::result   result;
+	  typedef mln_trait_fun_param(impl) param_;
+	  typedef mlc_if(mlc_equal(param_, void), impl, param_) init_param;
+
+	  unary_impl_set() {}
+
+	  unary_impl_set(const init_param& p) : impl_(p) {}
+
+	  result operator () (const argument& value) const
+	  {
+	    return this->impl_.read(value);
+	  }
+
+	protected:
+	  impl impl_;
+	};
+
+	template <typename Fun, typename T>
+	struct unary_impl_set<true, Fun, T> : unary_impl_set<false, Fun, T>
+	{
+	  typedef unary_impl_set<false, Fun, T> super;
+	  typedef typename super::impl      impl;
+
+	  typedef typename impl::argument        argument;
+	  typedef typename impl::result          result;
+	  typedef typename impl::lvalue          lvalue;
+	  typedef mln::fun::spe::internal::unary_modifier<impl> lresult;
+
+	  unary_impl_set() {}
+	  unary_impl_set(const typename super::init_param& p) : super(p) {}
+
+	  void set(lvalue l, const result& r) const
+	  {
+	    this->impl_.write(l, r);
+	  }
+
+	  lresult operator () (argument& value) const
+	  {
+	    return lresult(this->impl_, value);
+	  }
+
+	  using super::operator();
+	};
+
+	template <bool set, typename Fun, typename T>
+	struct unary_impl_param;
+
+	template <typename Fun, typename T>
+	struct unary_impl_param<false, Fun, T>
+	: impl::unary_impl_set<mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+	{
+	  typedef impl::unary_impl_set<mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T> super;
+
+	  unary_impl_param() {}
+	  unary_impl_param(const typename super::init_param& p) : super(p) {}
+	};
+
+	template <typename Fun, typename T>
+	struct unary_impl_param<true, Fun, T>
+	: unary_impl_param<false, Fun, T>
+	{
+	  typedef unary_impl_param<false, Fun, T> super;
+
+	  unary_impl_param() {}
+	  unary_impl_param(const typename super::init_param& p) : super(p) {}
+
+	  typedef typename super::param_ param;
+
+	  void init(const param& p)
+	  {
+	    this->impl_.init(p);
+	  }
+	};
+
+      } // end of namespace mln::fun::spe::impl
+
+      template <typename Fun, typename T>
+      struct unary
+      : impl::unary_impl_param<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+      {
+	typedef impl::unary_impl_param<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+		super;
+
+	unary() {}
+	unary(const typename super::init_param& p) : super(p) {}
+
+	using super::operator();
+      };
+
+    } // end of namespace mln::fun::spe
+
+  } // end of namespace mln::fun
+
+  template <typename Impl>
+  std::ostream& operator << (std::ostream& o, const mln::fun::spe::internal::unary_modifier<Impl>& m)
+  {
+    return o << m.to_result();
+  }
+
+} // end of namespace mln
+
+#endif /* ! UNARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/cos.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/cos.hh	(revision 3538)
@@ -0,0 +1,76 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_MATH_COS_HH
+# define MLN_FUN_MATH_COS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+  // Cosinus, bijective
+  namespace fun
+  {
+    struct cos : unary<cos> {};
+  }
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <typename T>
+      struct set_unary_<mln::fun::cos, mln::value::Floating, T>
+      {
+	typedef set_unary_ ret;
+	typedef T result;
+	typedef T argument;
+	typedef T& lvalue;
+
+	static result read(const argument& x)
+	{
+	  return math::cos(x);
+	}
+
+	static void write(lvalue l, const result& x)
+	{
+	  l = math::acos(x);
+	}
+      };
+
+    }
+
+  }
+
+}
+
+#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/abs.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/abs.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/abs.hh	(revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_MATH_ABS_HH
+# define MLN_FUN_MATH_ABS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/concept/scalar.hh>
+# include <mln/math/abs.hh>
+
+namespace mln
+{
+
+  // Absolute value, pure
+  namespace fun
+  {
+    struct abs : unary<abs> {};
+  }
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <typename T>
+      struct set_unary_<mln::fun::abs, mln::value::Scalar, T>
+      {
+	typedef set_unary_ ret;
+	typedef T result;
+	typedef T argument;
+
+	static result read(const argument& x)
+	{
+	  return math::abs(x);
+	}
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+}  // end of namespace mln
+
+#endif /* ! MLN_FUN_MATH_ABS_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/sup.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/sup.hh	(revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_MATH_SUP_HH
+# define MLN_FUN_MATH_SUP_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/max.hh>
+
+namespace mln
+{
+
+  // Cosinus, bijective
+  namespace fun
+  {
+    struct sup : binary<sup> {};
+  }
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <typename T, typename T>
+      struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+      {
+	typedef set_binary_ ret;
+	typedef T result;
+	typedef T argument1;
+	typedef T argument2;
+
+	static result read(const argument1& a, const argument1& b)
+	{
+	  return math::max(a, b);
+	}
+      };
+
+    }
+
+  }
+
+}
+
+#endif /* ! MLN_FUN_MATH_SUP_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/norm.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/norm.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/norm.hh	(revision 3538)
@@ -0,0 +1,119 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_MATH_NORM_HH
+# define MLN_FUN_MATH_NORM_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/norm/all.hh>
+
+namespace mln
+{
+
+  // Common norm functions, reversible
+  namespace fun
+  {
+    namespace norm
+    {
+      struct l1 : unary<l1> {};
+
+      struct l2 : unary<l2> {};
+
+      struct linfty : unary<linfty> {};
+    }
+  }
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <unsigned n, typename T>
+      struct set_precise_unary_<mln::fun::norm::l1, mln::algebra::vec<n, T> >
+      {
+	typedef set_precise_unary_ ret;
+	typedef mln::algebra::vec<n, T> argument;
+	typedef argument& lvalue;
+	typedef mln_sum_product(argument,argument) result;
+	
+	static result read(const argument& x)
+	{
+	  return mln::norm::l1(x);
+	}
+	
+	static void write(lvalue l, const result& x)
+	{
+	  l = l / read(l) * x;
+	}
+      };
+
+      template <unsigned n, typename T>
+      struct set_precise_unary_<mln::fun::norm::l2, mln::algebra::vec<n, T> >
+      {
+	typedef set_precise_unary_ ret;
+	typedef mln::algebra::vec<n, T> argument;
+	typedef argument& lvalue;
+	typedef mln_sum_product(argument,argument) result;
+	
+	static result read(const argument& x)
+	{
+	  return mln::norm::l2(x);
+	}
+	
+	static void write(lvalue l, const result& x)
+	{
+	  l = l / read(l) * x;
+	}
+      };
+
+      template <unsigned n, typename T>
+      struct set_precise_unary_<mln::fun::norm::linfty, mln::algebra::vec<n, T> >
+      {
+	typedef set_precise_unary_ ret;
+	typedef mln::algebra::vec<n, T> argument;
+	typedef argument& lvalue;
+	typedef mln_sum_product(argument,argument) result;
+	
+	static result read(const argument& x)
+	{
+	  return mln::norm::linfty(x);
+	}
+	
+	static void write(lvalue l, const result& x)
+	{
+	  l = l / read(l) * x;
+	}
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+  
+} // end of namespace mln
+
+#endif /* ! NORM_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/inf.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/inf.hh	(revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_MATH_INF_HH
+# define MLN_FUN_MATH_INF_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/min.hh>
+
+namespace mln
+{
+
+  // Cosinus, bijective
+  namespace fun
+  {
+    struct inf : binary<inf> {};
+  }
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      template <typename T, typename T>
+      struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+      {
+	typedef set_binary_ ret;
+	typedef T result;
+	typedef T argument1;
+	typedef T argument2;
+
+	static result read(const argument1& a, const argument1& b)
+	{
+	  return math::min(a, b);
+	}
+      };
+
+    }
+
+  }
+
+}
+
+#endif /* ! MLN_FUN_MATH_INF_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/unary.hh	(revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/unary.hh	(revision 3538)
@@ -0,0 +1,247 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_UNARY_HH
+# define MLN_FUN_UNARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/unary.hh>
+# include <mln/trait/next/solve.hh>
+
+namespace mln
+{
+
+  namespace fun
+  {
+
+    // Forward declarations, for composition with unary::operator()(Fun)
+    struct compose;
+
+    template <typename F>
+    struct unary;
+
+    namespace internal
+    {
+
+      template <typename T>
+      struct unary_with {};
+
+      template <bool has_param, typename M, typename T>
+      struct unary_with_param_helper;
+
+      template <typename M, typename T>
+      struct unary_with_param_helper<false, M, T>
+      {
+	typedef mln::fun::spe::unary<M, T> function;
+
+	static function inst(const M&)
+	{
+	  return function();
+	};
+
+      };
+
+      template <typename M, typename T>
+      struct unary_with_param_helper<true, M, T>
+      {
+	typedef mln::fun::spe::unary<M, T> function;
+
+	static function inst(const M& m)
+	{
+	  return function(m.parameter());
+	};
+
+      };
+
+      template <bool has_lvalue, typename M, typename T>
+      struct unary_with_lvalue_helper;
+
+      template <typename M, typename T>
+      struct unary_with_lvalue_helper<false, M, T>
+      : unary_with_param_helper<mln_trait_fun_is_parametrable_(M)::value, M, T>
+      {
+	typedef unary_with_param_helper<mln_trait_fun_is_parametrable_(M)::value, M, T> super;
+	typedef typename super::function function;
+
+	static typename function::result call(const M& m, const T& x)
+	{
+	  function f(super::inst(m));
+	  return f(x);
+	}
+      };
+
+      template <typename M, typename T>
+      struct unary_with_lvalue_helper<true, M, T>
+      : unary_with_lvalue_helper<false, M, T>
+      {
+	typedef unary_with_lvalue_helper<false, M, T> super;
+	typedef typename super::function function;
+
+	static typename function::lresult lcall(const M& m, T& x)
+	{
+	  function f(super::inst(m));
+	  return f(x);
+	}
+
+	static void set(const M& m, typename function::lvalue v, const T& x)
+	{
+	  function f(super::inst(m));
+	  f.set(v, x);
+	}
+      };
+
+      template <typename M, typename T>
+      struct unary_with_helper
+      : unary_with_lvalue_helper<mln_trait_fun_is_assignable__1comma_(mln::fun::spe::unary<M, T>)::value, M, T>
+      {
+      };
+
+    } // end of namespace mln::fun::internal
+
+    template <typename F>
+    struct unary: mln::Meta_Function_v2v< F >
+    {
+
+      template <typename T>
+      struct with {
+	typedef mln_trait_nunary(internal::unary_with<F>, T) impl;
+	typedef typename impl::function ret;
+      };
+
+      template <typename T>
+      typename with<T>::ret::result operator()(const T& v) const
+      {
+	return with<T>::impl::call(exact(*this), v);
+      }
+
+      template <typename T>
+      typename with<T>::ret::lresult operator()(T& v) const
+      {
+	return with<T>::impl::lcall(exact(*this), v);
+      }
+
+      template <typename T, typename R>
+      void set(T& v, const R& r) const
+      {
+	with<T>::impl::set(exact(*this), v, r);
+      }
+
+    };
+
+    template <typename F, typename P>
+    struct unary_param: unary<F>
+    {
+      typedef P param;
+
+      unary_param() {};
+      unary_param(const param& p) : p_(p) {};
+
+      void init(const param& p)
+      {
+	p_ = p;
+      }
+
+      param& parameter()
+      {
+	return p_;
+      }
+
+      const param& parameter() const
+      {
+	return p_;
+      }
+
+    protected:
+      param p_;
+
+    };
+
+    template <typename F>
+    struct unary_param<F, F>: unary<F>
+    {
+      typedef F param;
+
+      void init(const param& p)
+      {
+	exact(*this) = p;
+      }
+
+      param& parameter()
+      {
+	return exact(*this);
+      }
+
+      const param& parameter() const
+      {
+	return exact(*this);
+      }
+
+    };
+
+  } // end of namespace mln::fun
+
+  namespace trait
+  {
+
+    namespace next
+    {
+
+      // Any type
+      template <typename F, typename T>
+      struct set_unary_< mln::fun::internal::unary_with<F>, mln::Object, T>
+      {
+	typedef mln::fun::internal::unary_with_helper<F, T> ret;
+      };
+
+      // Meta Function
+      template <typename F, typename G>
+      struct set_unary_< mln::fun::internal::unary_with<F>, mln::Meta_Function, G>
+      {
+	// FIXME: Workaround for cyclic references (unary -> unary_with -> compose -> unary)
+	template <typename T>
+	struct identity
+	{
+	  typedef T ret;
+	};
+
+	typedef set_unary_ ret;
+	typedef typename identity<mln::fun::compose>::ret::template with<F, G>::ret function;
+
+	static typename function::result call(const F& f, const G& g)
+	{
+	  function tmp;
+	  return tmp(f, g);
+	}
+      };
+
+    } // end of namespace mln::trait::next
+
+  } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_UNARY_HH */
Index: trunk/milena/sandbox/fred/old/overload.cc
===================================================================
--- trunk/milena/sandbox/fred/old/overload.cc	(revision 0)
+++ trunk/milena/sandbox/fred/old/overload.cc	(revision 3538)
@@ -0,0 +1,296 @@
+#include <mln/core/concept/function.hh>
+#include <mln/core/concept/value.hh>
+#include <mln/fun/internal/resolve.hh>
+#include <mln/trait/op/plus.hh>
+
+
+#define mln_result__1comma(Tleft, Tright)  \
+  typename Tleft, Tright ::result
+
+
+// Avantage de cette methode:
+//  - la surcharge est rendue effectivement possible pour des familles de types
+//    et permet de passer en argument une fonction meme s'il existe de multiple definitions
+//    (^^ sic pour la qualite de l'explication ^^)
+//  - de maniere souple (set_previse_binary & set_binary).
+//
+// Inconvenients:
+//  - beaucoup de code/verbeux
+//    - necessite de reecrire la resolution a la main
+//    - l'implementation des differentes surcharge n'est pas aussi intuitive qu'en C++
+//      naturel
+//  - passage par les categories. Impossible de tirer parti de la hierarchie
+//    "naturelle" des types en C++.
+//
+
+// INF
+namespace mln
+{
+
+  // Forward declaration.
+  namespace fun {
+    namespace vv2v {
+      template <typename T> struct inf;
+    }
+  }
+
+
+  namespace trait
+  {
+
+    // Default (whatever the category):
+    // "inf" performs a "min"!
+    template <template <class> class Category, typename T>
+    struct set_unary_< fun::vv2v::inf, Category, T >
+    {
+      typedef set_unary_< fun::vv2v::inf, Category, T > ret;
+
+      static T exec(const T& t1, const T& t2)
+      {
+	return t1 < t2 ? t1 : t2;
+      }
+
+      // In the case of a binary function with two different argument
+      // types, we shall instrument this definition with the result
+      // type...
+    };
+
+  } // mln::trait
+
+
+
+  namespace fun
+  {
+
+    namespace vv2v
+    {
+
+      // fun::vv2v::inf<T>
+
+      template <typename T>
+      struct inf : Function_vv2v< inf<T> >
+      {
+	typedef T result;
+
+	typedef mln_fun_internal_resolve(inf) impl;
+
+	T operator()(const T& t1, const T& t2) const
+	{
+	  return impl::exec(t1, t2);
+	}
+      };
+
+
+      // fun::vv2v::meta::inf
+
+      namespace meta
+      {
+
+	struct inf
+	{
+
+	  // A meta-fun can act as a function :-)
+
+	  template <typename T>
+	  T operator()(const T& t1, const T& t2) const
+	  // Here, we know the result type of vv2v::inf<T> so
+	  // we explictly write it.
+	  {
+	    fun::vv2v::inf<T> f;
+	    return f(t1, t2);
+	  }
+
+	  // The "meta-fun -> fun" code is similar to the one in
+	  // mln/accu/min.hh
+	  template <typename T>
+	  struct with
+	  {
+	    typedef fun::vv2v::inf<T> ret;
+	  };
+	};
+
+      } // mln::fun::vv2v::meta
+
+    } // mln::fun::vv2v
+
+  } // mln::fun
+
+  // Yay! A special type equipped with a particular 'inf'.
+
+  struct rgb : Value<rgb>
+  {
+    typedef rgb enc;
+    typedef rgb equiv; // Those couple of typedefs are required by the concept.
+    rgb() {}
+    rgb(int r, int g, int b) : r(r), g(g), b(b) {}
+    int r, g, b;
+  };
+
+  std::ostream& operator<<(std::ostream& ostr, const rgb& c)
+  {
+    ostr << c.r << ' ' << c.g << ' ' << c.b;
+  }
+
+  namespace trait
+  {
+
+    template <>
+    struct set_precise_unary_< fun::vv2v::inf, rgb >
+    {
+      typedef set_precise_unary_< fun::vv2v::inf, rgb > ret;
+
+      static rgb exec(const rgb& c1, const rgb& c2)
+      {
+	// "Inf" is component-wise "min".
+	return rgb(c1.r < c2.r ? c1.r : c2.r,
+		   c1.g < c2.g ? c1.g : c2.g,
+		   c1.b < c2.b ? c1.b : c2.b);
+      }
+    };
+
+  } // mln::trait
+
+} // mln
+
+// PLUS
+namespace mln
+{
+
+  // Forward declaration.
+  namespace fun {
+    namespace vv2v {
+      template <typename L, typename R> struct plus;
+    }
+  }
+
+
+  namespace trait
+  {
+
+    // Default (whatever the category):
+    // "plus(l, r)" performs "l + r"!
+    template <template <class> class Category_L, typename L,
+	      template <class> class Category_R, typename R>
+    struct set_binary_< fun::vv2v::plus,
+			Category_L, L,
+			Category_R, R>
+    {
+      typedef set_binary_< fun::vv2v::plus, Category_L, L, Category_R, R> ret;
+
+      typedef mln_trait_op_plus(L,R) result;
+
+      static result exec(const L& t1, const R& t2)
+      {
+	return t1 + t2;
+      }
+
+      // In the case of a binary function with two different argument
+      // types, we shall instrument this definition with the result
+      // type...
+    };
+
+  } // mln::trait
+
+
+
+  namespace fun
+  {
+
+    namespace vv2v
+    {
+
+      // fun::vv2v::plus<L,R>
+
+      template <typename L, typename R>
+      struct plus : Function_vv2v< plus<L,R> >
+      {
+	typedef mln_fun_internal_resolve(plus) impl;
+	typedef mln_result(impl) result;
+
+	result operator()(const L& t1, const R& t2) const
+	{
+	  return impl::exec(t1, t2);
+	}
+      };
+
+
+      // fun::vv2v::meta::plus
+
+      namespace meta
+      {
+
+	struct plus
+	{
+
+	  // A meta-fun can act as a function :-)
+
+	  template <typename L, typename R>
+	  mln_result__1comma(fun::vv2v::plus<L,R>)
+	  operator()(const L& t1, const R& t2) const
+	  // Here, we do NOT know the result type of vv2v::plus<L,R> so
+	  // we cannot explictly write it.
+	  {
+	    fun::vv2v::plus<L,R> f;
+	    return f(t1, t2);
+	  }
+
+	  // The "meta-fun -> fun" code is similar to the one in
+	  // mln/accu/min.hh
+	  template <typename L, typename R>
+	  struct with
+	  {
+	    typedef fun::vv2v::plus<L,R> ret;
+	  };
+	};
+
+      } // mln::fun::vv2v::meta
+
+    } // mln::fun::vv2v
+
+  } // mln::fun
+
+
+  namespace trait
+  {
+
+    template <>
+    struct set_precise_binary_< fun::vv2v::plus, rgb, rgb >
+    {
+      typedef set_precise_binary_< fun::vv2v::plus, rgb, rgb > ret;
+      typedef rgb result;
+
+      static rgb exec(const rgb& c1, const rgb& c2)
+      {
+	// "plus" is component-wise "plus".
+	return rgb(c1.r + c2.r,
+		   c1.g + c2.g,
+		   c1.b + c2.b);
+      }
+    };
+
+    template <>
+    struct set_precise_binary_< mln::trait::op::plus, rgb, rgb >
+    {
+      typedef rgb ret;
+    };
+
+  } // mln::trait
+
+} // mln
+
+
+using namespace mln;
+
+int main()
+{
+  fun::vv2v::meta::inf inf;
+  std::cout << inf(3, 5) << std::endl;
+
+  rgb c1(1, 2, 3), c2(2, 1, 2);
+  std::cout << inf(c1, c2) << std::endl;
+
+  fun::vv2v::meta::plus plus;
+  std::cout << plus(plus(3.1f, 5), 3.1415926535) << std::endl;
+
+  std::cout << plus(c1, c2) << std::endl;
+}
Index: trunk/milena/sandbox/fred/old/value.cc
===================================================================
--- trunk/milena/sandbox/fred/old/value.cc	(revision 0)
+++ trunk/milena/sandbox/fred/old/value.cc	(revision 3538)
@@ -0,0 +1,24 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/opt/at.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/accu/bbox.hh>
+#include <mln/canvas/morpho/connected_filter.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include "value_wrapper.hh"
+#include "site_wrapper.hh"
+
+using namespace mln;
+
+int main()
+{
+  typedef mln::image2d<mln::point2d> I;
+
+  I a(8, 8);
+  for (int i = 0; i < 8; i++)
+    for (int j = 0; j < 8; j++)
+      for (int k = 0; k < 2; k++)
+	opt::at(a, i, j)[k] = 20 + (k ? i : j);
+
+  debug::println(canvas::morpho::connected_filter(a, c4(), morpho::attribute::site_wrapper< accu::bbox<mln::point2d> >(), make::box2d(8, 8), true));
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/old/site_wrapper.hh
===================================================================
--- trunk/milena/sandbox/fred/old/site_wrapper.hh	(revision 0)
+++ trunk/milena/sandbox/fred/old/site_wrapper.hh	(revision 3538)
@@ -0,0 +1,188 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library.  This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction.  Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.  This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
+# define MLN_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
+
+/// \file mln/morpho/attribute/volume.hh
+///
+/// Transform an accumulator to a site (when_pix::use_p) accumulator.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/util/pix.hh>
+
+# define mln_morpho_attribute_use_p_(T) mln::morpho::attribute::site_wrapper< T >
+# define mln_morpho_attribute_use_p(T) mln::morpho::attribute::site_wrapper< T >
+
+namespace mln
+{
+
+  // Forward declaration.
+  namespace morpho {
+    namespace attribute {
+      template <typename T> class site_wrapper;
+    }
+  }
+
+
+  // Traits.
+
+  namespace trait
+  {
+
+    template <typename A>
+    struct accumulator_< morpho::attribute::site_wrapper<A> >
+    {
+      typedef accumulator::has_untake::no    has_untake;
+      typedef accumulator::has_set_value::no has_set_site;
+      typedef accumulator::has_stop::no      has_stop;
+      typedef accumulator::when_pix::use_p   when_pix;
+    };
+
+  } // end of namespace mln::trait
+
+  namespace morpho
+  {
+
+    namespace attribute
+    {
+
+      /// Value wrapper accumulator meta-class.
+      ///
+      /// The parameter \p A is the base accumulator to wrap.
+      template <typename A>
+      struct site_wrapper
+	: public mln::accu::internal::base< typename A::result , site_wrapper<A> >
+      {
+	typedef typename A::argument argument;
+	typedef typename A::result result;
+
+	site_wrapper();
+
+	/// Manipulators.
+	/// \{
+	void init();
+
+	void take(const argument& v);
+	template <typename I>
+	void take(const util::pix<I>& px);
+	void take(const site_wrapper<A>& other);
+
+	void take_as_init(const argument& v);
+	template <typename I>
+	void take_as_init(const util::pix<I>& px);
+	/// \}
+
+	/// Get the site of the accumulator.
+	result to_result() const;
+
+	/// Check whether this accu is able to return a result.
+	bool is_valid() const;
+
+      protected:
+	/// Delegatee accumulator.
+	A accu_;
+      };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+      template <typename A>
+      site_wrapper<A>::site_wrapper()
+        : accu_()
+      {
+      }
+
+      template <typename A>
+      void
+      site_wrapper<A>::init()
+      {
+	accu_.init();
+      }
+
+      template <typename A>
+      void
+      site_wrapper<A>::take(const argument& v)
+      {
+	accu_.take(v);
+      }
+
+      template <typename A>
+      template <typename I>
+      void
+      site_wrapper<A>::take(const util::pix<I>& px)
+      {
+	take(px.v());
+      }
+
+      template <typename A>
+      void
+      site_wrapper<A>::take(const site_wrapper<A>& other)
+      {
+	accu_.take(other.accu_);
+      }
+
+      template <typename A>
+      void
+      site_wrapper<A>::take_as_init(const argument& v)
+      {
+	accu_.take_as_init(v);
+      }
+
+      template <typename A>
+      template <typename I>
+      void
+      site_wrapper<A>::take_as_init(const util::pix<I>& px)
+      {
+	accu_.take_as_init(px);
+      }
+
+      template <typename A>
+      typename site_wrapper<A>::result
+      site_wrapper<A>::to_result() const
+      {
+	return accu_.to_result();
+      }
+
+      template <typename A>
+      bool
+      site_wrapper<A>::is_valid() const
+      {
+	return accu_.is_valid();
+      }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+    } // end of namespace mln::morpho::attribute
+
+  } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    16 Mar '09
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-16  Edwin Carlinet  <carlinet(a)lrde.epita.fr>
	Fix component tree test to work with new iterators.
	* mln/morpho/tree/compute_attribute_image.hh: Modify code to
	make it work with new tree implementation.
	* mln/morpho/tree/data.hh: Fix bug in preorder iterator (last
	element was ignored).
	* sandbox/edwin/tree/propagate_node.hh,
	* sandbox/edwin/tree/propagation.cc:  Optimize propagation for
	new component tree implementation.
	* tests/morpho/tree/data.cc: Add some tests.
---
 mln/morpho/tree/compute_attribute_image.hh |    3 -
 mln/morpho/tree/data.hh                    |   61 +++++++++++++++------
 sandbox/edwin/tree/propagate_node.hh       |   84 +++--------------------------
 sandbox/edwin/tree/propagation.cc          |   44 +++++++--------
 tests/morpho/tree/data.cc                  |   41 ++++++++++----
 5 files changed, 110 insertions(+), 123 deletions(-)
Index: trunk/milena/tests/morpho/tree/data.cc
===================================================================
--- trunk/milena/tests/morpho/tree/data.cc	(revision 3536)
+++ trunk/milena/tests/morpho/tree/data.cc	(revision 3537)
@@ -62,18 +62,39 @@
   debug::println( "on node = ", t.parent_image() | t.nodes()  );
 
   {
-    std::cout << "nodes = ";
-    tree_t::nodes_t::fwd_piter p(t.nodes());
-    for_all(p)
-      std::cout << p << ' ';
-    std::cout << std::endl;
+    /* Check site and node up order */
+    tree_t::up_node_piter n(t);
+    tree_t::up_site_piter s(t);
+    n.start();
+    for_all(s)
+      if (t.is_a_node(s))
+	{
+	  mln_assertion(s == n);
+	  n.next();
+	}
+    mln_assertion(!n.is_valid());
+  }
+
+  {
+    /* Check site and node up order */
+    tree_t::dn_node_piter n(t);
+    tree_t::dn_site_piter s(t);
+    n.start();
+    for_all(s)
+      if (t.is_a_node(s))
+	{
+	  mln_assertion(s == n);
+	  n.next();
+	}
+    mln_assertion(!n.is_valid());
   }
+
+
   {
     std::cout << "nodes = ";
-    tree_t::fwd_piter p(t.domain());
-    for_all(p)
-      if (t.is_a_node(p))
-	std::cout << p << ' ';
+    tree_t::up_node_piter n(t);
+    for_all(n)
+      std::cout << n << ' ';
     std::cout << std::endl
 	      << std::endl;
   }
@@ -82,7 +103,7 @@
   {
     image2d<unsigned> area(ima.domain());
     data::fill(area, 1);
-    tree_t::fwd_piter p(t.domain());
+    tree_t::up_site_piter p(t);
     for_all(p)
       if (! t.is_root(p))
 	area(t.parent(p)) += area(p);
Index: trunk/milena/mln/morpho/tree/compute_attribute_image.hh
===================================================================
--- trunk/milena/mln/morpho/tree/compute_attribute_image.hh	(revision 3536)
+++ trunk/milena/mln/morpho/tree/compute_attribute_image.hh	(revision 3537)
@@ -36,6 +36,7 @@
 /// \todo Specialize for low quant (and try fastest).
 
 # include <mln/core/concept/image.hh>
+# include <mln/morpho/tree/data.hh>
 # include <mln/trait/accumulators.hh>
 # include <mln/util/pix.hh>
 # include <mln/data/fill.hh>
@@ -143,7 +144,7 @@
 	    take_as_init(acc(p), t.f(), p);
 	}
 	{
-	  mln_fwd_piter(T) p(t.domain());
+	  mln_up_site_piter(T) p(t);
 	  // Propagate attribute from a site to its parent.
 	  for_all(p)
 	    if (! t.is_root(p))
Index: trunk/milena/mln/morpho/tree/data.hh
===================================================================
--- trunk/milena/mln/morpho/tree/data.hh	(revision 3536)
+++ trunk/milena/mln/morpho/tree/data.hh	(revision 3537)
@@ -38,7 +38,6 @@
 /// learn why we want the 1st pass to be in forward scan of s).
 
 # include <mln/morpho/tree/compute_parent.hh>
-//# include <mln/core/image/sub_image.hh>
 # include <mln/core/site_set/p_array.hh>
 # include <mln/core/internal/site_set_iterator_base.hh>
 # include <mln/core/internal/piter_identity.hh>
@@ -56,10 +55,6 @@
 # define mln_dn_node_piter_(T)  T::dn_node_piter
 # define mln_preorder_piter_(T) T::preorder_piter
 
-// FIXME: rename these iterators.
-//# define mln_up_leaf_piter(T) typename T::up_leaf_piter;
-//# define mln_dn_leaf_piter(T) typename T::dn_leaf_piter;
-
 namespace mln
 {
 
@@ -139,15 +134,8 @@
 
 	/// \}
 
-	const p_array<mln_psite(I)>& children(const mln_psite(I)& p) const
-	{
-	  return children_(p);
-	}
-
-	const mln_ch_value(I, nodes_t)& children_image() const
-	{
-	  return children_;
-	}
+	const p_array<mln_psite(I)>& children(const mln_psite(I)& p) const;
+	const mln_ch_value(I, nodes_t)& children_image() const;
 
 	/// \{ Tests.
 
@@ -290,6 +278,10 @@
 	/// Constructor.
 	preorder_piter(const T& t);
 
+
+	preorder_piter(const T& t,
+		       const mln_psite(T::function)& p);
+
 	/// Test if the iterator is valid.
 	bool is_valid_() const;
 
@@ -305,7 +297,8 @@
       protected:
 	using super_::p_;
 	using super_::s_;
-	std::deque<mln_psite(T)> stack_; // FIXME: implement p_stack.
+	std::deque<mln_psite(T::function)> stack_; // FIXME: implement p_stack.
+	const mln_psite(T::function)* root_;
   };
 
 
@@ -455,6 +448,22 @@
 	return f_(p);
       }
 
+      template <typename I, typename S>
+      inline
+      const p_array<mln_psite(I)>&
+      data<I,S>::children(const mln_psite(I)& p) const
+      {
+	return children_(p);
+      }
+
+      template <typename I, typename S>
+      inline
+      const mln_ch_value(I, p_array<mln_psite(I)>)&
+      data<I,S>::children_image() const
+      {
+	return children_;
+      }
+
 
 
       // Iterators.
@@ -463,12 +472,23 @@
       template <typename T>
       inline
       preorder_piter<T>::preorder_piter()
+	: root_ (0)
       {
       }
 
       template <typename T>
       inline
       preorder_piter<T>::preorder_piter(const T& t)
+	: root_ (0)
+      {
+	this->change_target(t);
+      }
+
+      template <typename T>
+      inline
+      preorder_piter<T>::preorder_piter(const T& t,
+					const mln_psite(T::function)& p)
+	: root_ (&p)
       {
 	this->change_target(t);
       }
@@ -495,7 +515,13 @@
       preorder_piter<T>::start_()
       {
 	this->invalidate();
-	mln_dn_node_piter(T) n(s_->nodes());
+	stack_.push_back(mln_psite(T::function)()); // needed for last element.
+
+	if (root_)
+	  stack_.push_back(*root_);
+	else
+	  {
+	    mln_dn_node_piter(T) n(*s_);
 	int roots = 0;
 	for (n.start(); n.is_valid() && roots < s_->nroots(); n.next())
 	  if (s_->is_root(n))
@@ -503,6 +529,7 @@
 	    stack_.push_back(n);
 	    roots++;
 	  }
+	  }
 
 	this->next();
       }
@@ -514,6 +541,8 @@
       {
 	p_ = stack_.back();
 	stack_.pop_back();
+	if (!exact(this)->is_valid())
+	  return;
 	mln_fwd_piter(T::nodes_t) child(s_->children(p_));
 	for_all(child)
 	  stack_.push_back(child);
Index: trunk/milena/sandbox/edwin/tree/propagate_node.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate_node.hh	(revision 3536)
+++ trunk/milena/sandbox/edwin/tree/propagate_node.hh	(revision 3537)
@@ -31,6 +31,7 @@
 
 #include <mln/morpho/tree/data.hh>
 #include <mln/core/site_set/p_array.hh>
+#include <stack>
 
 /// \file mln/morpho/tree/propagate_node.hh
 ///
@@ -44,35 +45,6 @@
       /**
       ** Propagate a value to a node and its descendants.
       **
-      ** @param n Forward iterator related to the node.
-      ** @param t Reference to components tree.
-      ** @param a_ Reference to image.
-      ** @param v Value to propagate. Default is a_(n).
-      */
-      template <typename T, typename A>
-      void
-      propagate_node_to_descendants(mln_dn_node_piter(T)& n,
-				    const T& t,
-				    Image<A>& a_,
-				    mln_value(A) v);
-
-      /**
-      ** Propagate the value of a node to its descendants.
-      **
-      ** @param n Forward iterator related to the node.
-      ** @param t Reference to components tree.
-      ** @param a_ Reference to image.
-      */
-      template <typename T, typename A>
-      void
-      propagate_node_to_descendants(mln_dn_node_piter(T)& n,
-				    const T& t,
-				    Image<A>& a_);
-
-
-      /**
-      ** Propagate a value to a node and its descendants.
-      **
       ** @param n The root of subtree which value propagates in.
       ** @param t The reference to components tree.
       ** @param a_ The reference to image.
@@ -127,51 +99,10 @@
 				  Image<A>& a_);
 
 
-
-
-
+# ifndef MLN_INCLUDE_ONLY
 
       /* Descendants propagation */
 
-      template <typename T, typename A>
-      void
-      propagate_node_to_descendants(mln_dn_node_piter(T)& n,
-				    const T& t,
-				    Image<A>& a_,
-				    mln_value(A) v)
-      {
-	A& a = exact(a_);
-	mln_precondition(a.is_valid());
-	mln_precondition(a.domain() == t.f().domain());
-	mln_precondition(n.is_valid());
-	mln_precondition(t.is_a_node(n));
-
-	mln_ch_value(A, bool) ancestors;
-	initialize(ancestors, a);
-	data::fill(ancestors, false);
-	ancestors(n) = true;
-
-	mln_dn_node_piter(T) it(n);
-	for (it.next(); it.is_valid(); it.next())
-	  {
-	    if (ancestors(t.parent(it)))
-	      {
-		ancestors(it) = true;
-		a(it) = v;
-	      }
-	  }
-      }
-
-      template <typename T, typename A>
-      inline
-      void
-      propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
-				    const T& t,
-				    Image<A>& a_)
-      {
-	A& a = exact(a_);
-	propagate_node_to_descendants(n, t, a, a(n));
-      }
 
       template <typename T, typename A>
       void
@@ -188,9 +119,13 @@
 
 	if (!t.is_a_node(n)) // Get the representant.
 	  n = t.parent(n);
+	mln_assertion(t.is_a_node(n));
+
+	typename T::preorder_piter pp(t, n);
 
-	mln_dn_node_piter(T) it(find_bkd(t.nodes(), n));
-	propagate_node_to_descendants(it, t, a, v);
+	pp.start(); // We don't set n to v.
+	for (pp.next(); pp.is_valid(); pp.next())
+	  a(pp) = v;
       }
 
       template <typename T, typename A>
@@ -220,7 +155,7 @@
 	mln_precondition(a.domain() == t.f().domain());
 	mln_precondition(a.domain().has(n));
 
-	if (!t.is_a_node(n))
+	if (!t.is_a_node(n)) // Get the representant.
 	  n = t.parent(n);
 	mln_assertion(t.is_a_node(n));
 
@@ -245,6 +180,7 @@
 	propagate_node_to_ancestors(n, t, a, a(n));
       }
 
+# endif // ! MLN_INCLUDE_ONLY
 
     } // end of namespace mln::morpho::tree
   } // end of namespace mln::morpho
Index: trunk/milena/sandbox/edwin/tree/propagation.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagation.cc	(revision 3536)
+++ trunk/milena/sandbox/edwin/tree/propagation.cc	(revision 3537)
@@ -90,25 +90,25 @@
   dsp("Propagate node to descendants  : (point2d(0, 2), tree, dup)");
   display_tree_attributes(tree, dup);
 
-  dup = duplicate(input);
-  morpho::tree::propagate_value_to_ancestors(117, tree, dup, 0);
-  dsp("Propagate value to ancestors  : (117, tree, dup, 0)");
-  display_tree_attributes(tree, dup);
-
-  dup = duplicate(input);
-  morpho::tree::propagate_value_to_ancestors(117, tree, dup);
-  dsp("Propagate value to ancestors  : (117, tree, dup)");
-  display_tree_attributes(tree, dup);
-
-  dup = duplicate(input);
-  morpho::tree::propagate_value_to_descendants(117, tree, dup, 0);
-  dsp("Propagate value to descendants  : (117, tree, dup, 0)");
-  display_tree_attributes(tree, dup);
-
-  dup = duplicate(input);
-  morpho::tree::propagate_value_to_descendants(117, tree, dup);
-  dsp("Propagate value to descendants  : (117, tree, dup)");
-  display_tree_attributes(tree, dup);
+ //  dup = duplicate(input);
+//   morpho::tree::propagate_value_to_ancestors(117, tree, dup, 0);
+//   dsp("Propagate value to ancestors  : (117, tree, dup, 0)");
+//   display_tree_attributes(tree, dup);
+
+//   dup = duplicate(input);
+//   morpho::tree::propagate_value_to_ancestors(117, tree, dup);
+//   dsp("Propagate value to ancestors  : (117, tree, dup)");
+//   display_tree_attributes(tree, dup);
+
+//   dup = duplicate(input);
+//   morpho::tree::propagate_value_to_descendants(117, tree, dup, 0);
+//   dsp("Propagate value to descendants  : (117, tree, dup, 0)");
+//   display_tree_attributes(tree, dup);
+
+//   dup = duplicate(input);
+//   morpho::tree::propagate_value_to_descendants(117, tree, dup);
+//   dsp("Propagate value to descendants  : (117, tree, dup)");
+//   display_tree_attributes(tree, dup);
 
 
 
@@ -123,9 +123,9 @@
   dsp("Propagate value to descendants  : (it_max, tree, dup, 69)");
   display_tree_attributes(tree, dup);
 
-  mln_dn_node_piter_(tree_t) n(tree);
-  n.start();
-  print(tree.children_image(), n);
+//    mln_dn_node_piter_(tree_t) n(tree);
+//    n.start();
+//    print(tree.children_image(), n);
 
   std::cout << "\n";
   mln_preorder_piter_(tree_t) pit(tree);
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    16 Mar '09
                    
                          URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-16  Fabien Freling  <fabien.freling(a)lrde.epita.fr>
	Fix median threshold and add ImageMagick load support..
	* fabien/igr/Makefile: Update.
	* fabien/igr/check.sh: Update.
	* fabien/igr/med.cc: Fix median value.
	* fabien/magick/Makefile: Update.
	* fabien/magick/load.hh: Implement Magick support.
	* fabien/magick/magick.cc: Test file for Magick support.
---
 igr/Makefile     |    2 -
 igr/check.sh     |    7 ++--
 igr/med.cc       |   26 +++++++++++----
 magick/load.hh   |   95 ++++++++++++++++++++-----------------------------------
 magick/magick.cc |   19 +++++++----
 5 files changed, 74 insertions(+), 75 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/check.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/check.sh	(revision 3535)
+++ trunk/milena/sandbox/fabien/igr/check.sh	(revision 3536)
@@ -12,11 +12,14 @@
     echo "  for lambda_closing = ${lambda_closing}";
     ./clo_vol grad.dump $dim ${lambda_closing}
     nbasins=`./wst clo_vol.dump $dim`
+    echo "    nbasins = $nbasins"
     ../bin/dumpl32_to_colorize wst.dump $dim $nbasins results/colorize_${3}_${lambda_closing}.ppm
     median=`./med wst.dump $dim $input $nbasins`
+    echo "    median = $median"
+    threshold=$(($median / 2))
     ../bin/dumpi12_to_pgm med.dump $dim results/median_${3}_${lambda_closing}.pgm
-    ./thres med.dump $dim $median
-    mv bin_result.pbm results/result_${3}_${lambda_closing}.pbm
+    ./thres med.dump $dim $threshold
+    mv result.pbm results/result_${3}_${lambda_closing}.pbm
 
 #if [ $2 -eq 2 ]; then
 #     if [ ${lambda_closing} -eq 100 ]; then
Index: trunk/milena/sandbox/fabien/igr/med.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/med.cc	(revision 3535)
+++ trunk/milena/sandbox/fabien/igr/med.cc	(revision 3536)
@@ -20,9 +20,12 @@
 #include <mln/core/routine/extend.hh>
 #include <mln/accu/mean.hh>
 #include <mln/accu/median_h.hh>
-#include <mln/morpho/elementary/dilation.hh>
+#include <mln/histo/array.hh>
+#include <mln/histo/compute.hh>
+#include <mln/labeling/compute.hh>
 #include <mln/labeling/mean_values.hh>
 #include <mln/level/compute.hh>
+#include <mln/morpho/elementary/dilation.hh>
 #include <mln/pw/all.hh>
 #include <mln/util/array.hh>
 
@@ -59,6 +62,8 @@
     return 1;
   }
 
+  unsigned median = 0;
+
   if (dim == 2)
   {
     image2d<L> labels;
@@ -70,18 +75,27 @@
     data::fill((labels | (pw::value(labels) == 0u)).rw(), wst_dilate);
     mln_VAR(wst_mean, labeling::mean_values(dcm, labels, nbasins));
 
-    accu::mean<float> accu_mean;
-    util::array<float> means = level::compute(accu_mean, wst_mean);
-
-    // FIXME: Take median value of means
+    histo::array<int_u12> histogram = histo::compute(wst_mean);
+    int j = 0;
+    int k = 0;
+    for (int i = 0; i < histogram.nvalues(); ++i)
+    {
+      if (histogram[i])
+	histogram[i] = i;
+    }
+    image1d<unsigned> ima_histo;
+    convert::from_to(histogram, ima_histo);
+    accu::median_h<int_u12> accu_med;
+    median = level::compute(accu_med, ima_histo | pw::value(ima_histo) != pw::cst(0));
 
     io::dump::save(wst_mean, "med.dump");
-    std::cout << median << std::endl;
   }
   else
   {
     // FIXME
   }
 
+  std::cout << median << std::endl;
+
   return 0;
 }
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile	(revision 3535)
+++ trunk/milena/sandbox/fabien/igr/Makefile	(revision 3536)
@@ -49,4 +49,4 @@
 	g++ -I../../../ ${CXXFLAGS} $^ -o thres
 	
 clean:
-	rm -rf *.dump *.p?m *.plot *.log *.csv
+	rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
Index: trunk/milena/sandbox/fabien/magick/magick.cc
===================================================================
--- trunk/milena/sandbox/fabien/magick/magick.cc	(revision 3535)
+++ trunk/milena/sandbox/fabien/magick/magick.cc	(revision 3536)
@@ -1,15 +1,22 @@
 #include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
 
 #include "load.hh"
 
-int main()
+int main(int argc, char* argv[])
 {
   using namespace mln;
-  using value::int_u8;
+  using value::rgb8;
 
-  image2d<int_u8> lena;
+  if (argc != 2)
+  {
+    std::cout << "Usage: " << argv[0] << " filename.ext" << std::endl;
+    return 1;
+  }
+
+  image2d<rgb8> lena;
+
+  io::magick::load(lena, argv[1]);
 
-  //io::magick::load(lena, "/Users/HiSoKa/Work/LRDE/Olena/resources/CardiacCT/178562160.dcm");
-  io::magick::load(lena, "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm");
+  return 0;
 }
Index: trunk/milena/sandbox/fabien/magick/Makefile
===================================================================
Index: trunk/milena/sandbox/fabien/magick/load.hh
===================================================================
--- trunk/milena/sandbox/fabien/magick/load.hh	(revision 3535)
+++ trunk/milena/sandbox/fabien/magick/load.hh	(revision 3536)
@@ -37,6 +37,7 @@
  */
 
 # include <mln/core/image/image2d.hh>
+# include <mln/value/rgb8.hh>
 # include <Magick++.h>
 
 
@@ -59,58 +60,19 @@
       void load(Image<I>& ima,
 		const std::string& filename);
 
-      /*! Load a magick image in a Milena image. To use this routine, you
-       *  should specialize the template whith the value type of the
-       *  image loaded. (ex : load<value::int_u8>("...") )
-       *
-       * \param[in] filename The image source.
-       *
-       * \return An image2d which contains loaded data.
-       */
-      template <typename V>
-      image2d<V> load(const std::string& filename);
-
-      /*! Load a magick image in a Milena image. To use this routine, you
-       *  should specialize the template whith the value type of the
-       *  image loaded. (ex : load<value::int_u8>("...") )
-       *
-       * \param[in] filename The image source.
-       *
-       * \return An image2d which contains loaded data.
-       */
-      template <typename V>
-      image3d<V> load(const std::string& filename);
 
 # ifndef MLN_INCLUDE_ONLY
 
-      template <typename V>
-      inline
-      image2d<V> load(const std::string& filename)
-      {
-	trace::entering("mln::io::magick::load");
-	image2d<V> ima;// = io::pnm::load<V>(MAGICK, filename);
-	trace::exiting("mln::io::magick::load");
-	return ima;
-      }
-
-      template <typename V>
-      inline
-      image3d<V> load(const std::string& filename)
-      {
-	trace::entering("mln::io::magick::load");
-	image2d<V> ima;// = io::pnm::load<V>(MAGICK, filename);
-	trace::exiting("mln::io::magick::load");
-	return ima;
-      }
-
 
       template <typename I>
       inline
-      void load(Image<I>& ima,
+      void load(Image<I>& ima_,
 		const std::string& filename)
       {
 	trace::entering("mln::io::magick::load");
 
+	I& ima = exact(ima_);
+
 	//std::ifstream file(filename.c_str());
 	//if (! file)
 	//{
@@ -118,24 +80,37 @@
 	//  abort();
 	//}
 
-	Magick::Image file(filename);
-	//std::cout << "file attribute: " << file.attribute() << std::endl;
-	std::cout << "width: " << file.columns() << std::endl;
-	std::cout << "height: " << file.rows() << std::endl;
-	std::cout << "x resolution: " << file.xResolution() << std::endl;
-	std::cout << "y resolution: " << file.yResolution() << std::endl;
-	std::cout << "depth: " << file.depth() << std::endl;
-	//std::cout << "packets: " << file.packets() << std::endl;
-	//std::cout << "packet size: " << file.packetSize() << std::endl;
-	std::cout << "comment: " << file.comment() << std::endl;
-	std::cout << "format: " << file.format() << std::endl;
-	std::cout << "number of scenes: " << file.imageInfo()->number_scenes << std::endl;
-	std::cout << "scene: " << file.imageInfo()->scene << std::endl;
-	std::cout << "filename: " << file.imageInfo()->filename << std::endl;
-
-	//Magick::Pixels::Pixels pixels(file);
-	//std::cout << "sizeof PixelPacket: " << sizeof (pixel_cache) << std::endl;
-	//std::cout << "sizeof *PixelPacket: " << sizeof (*pixel_cache) << std::endl;
+	Magick::Image im_file(filename);
+	im_file.modifyImage();
+	im_file.type(Magick::TrueColorType);
+	int columns = im_file.columns();
+	int rows = im_file.rows();
+	/*std::cout << "width: " <<columns << std::endl;
+	std::cout << "height: " <<rows << std::endl;
+	std::cout << "depth: " <<im_file.depth() << std::endl;
+	std::cout << "comment: " <<im_file.comment() << std::endl;
+	std::cout << "format: " <<im_file.format() << std::endl;
+	std::cout << "filename: " <<im_file.imageInfo()->filename << std::endl;*/
+
+	const Magick::PixelPacket *pixel_cache = im_file.getConstPixels(0, 0, columns, rows);
+
+	algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
+        algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
+	vmin[0] = 0;
+	vmin[1] = 0;
+	vmax[0] = rows - 1;
+	vmax[1] = columns - 1;
+	mln_site(I) pmin(vmin);
+        mln_site(I) pmax(vmax);
+        mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
+        initialize(ima, result);
+        mln_piter(I) p(ima.domain());
+	for_all(p)
+	{
+	  const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+							 + (int) p.to_site().to_vec()[1];
+	  ima(p) = value::rgb8(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // WARNING: Quantum = 16bits but rgb is 8bits
+	}
 
 	trace::exiting("mln::io::magick::load");
       }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0