* mln/accu/stat/histo1d.hh: New header file.
* mln/accu/stat/histo2d.hh: New header file.
* mln/accu/stat/histo3d_hsl.hh: New header file.
* mln/accu/stat/histo3d_rgb.hh: New header file.
* mln/clustering/k_mean.hh: New header file.
* mln/clustering/kmean1d.hh: New header file.
* mln/clustering/kmean2d.hh: New header file.
* mln/clustering/kmean3d.hh: New header file.
* mln/clustering/kmean_rgb.hh: New header file.
* mln/display/display_histo.hh: New header file.
* mln/display/project_histo.hh: New header file.
* mln/fun/p2b/achromatic.hh: New header file.
* mln/fun/p2b/component_equals.hh: New header file.
* mln/fun/v2v/achromatism.hh: New header file.
* mln/fun/v2v/hue_concentration.hh: New header file.
* mln/fun/v2v/int_u16_to_int_u14.hh: New header file.
* mln/fun/v2v/int_u16_to_int_u14.hh: New header file.
* mln/fun/v2v/log.hh: New header file.
* mln/fun/v2v/rg_to_rgb.hh: New header file.
* mln/fun/v2v/rgb8_to_int_u8: New header file.
* mln/fun/v2v/rgb_to_achromastism_map.hh: New header file.
* mln/fun/v2v/rgb_to_hsv.hh: New header file.
* mln/fun/v2v/rgb_to_hue_map.hh: New header file.
* mln/fun/v2v/rgb_to_saturation_map.hh: New header file.
* mln/fun/v2v/rgb_to_value_map.hh: New header file.
* mln/img_path.hh: New header file.
* mln/io/plot/save_image_sh.hh: New header file.
* mln/math/cell.hh: New header file.
* mln/math/floor.hh: New header file.
* tests/accu/stat/histo1d/Makefile.am: New makefile.
* tests/accu/stat/histo1d/histo1d.cc: New source.
* tests/accu/stat/histo2d/Makefile.am: New makefile.
* tests/accu/stat/histo2d/histo2d.cc: New source.
---
scribo/sandbox/green/ChangeLog | 59 ++
scribo/sandbox/green/README | 223 ++++-
scribo/sandbox/green/mln/accu/stat/histo1d.hh | 340 +++++++
scribo/sandbox/green/mln/accu/stat/histo2d.hh | 358 +++++++
.../sandbox/green/mln/accu/stat/histo3d_hsl.hh | 0
.../sandbox/green/mln/accu/stat/histo3d_rgb.hh | 0
.../sandbox/green/mln/clustering/k_mean.hh | 0
.../sandbox/green/mln/clustering/kmean1d.hh | 0
.../sandbox/green/mln/clustering/kmean2d.hh | 0
.../sandbox/green/mln/clustering/kmean3d.hh | 0
scribo/sandbox/green/mln/clustering/kmean_rgb.hh | 973 ++++++++++++++++++
scribo/sandbox/green/mln/display/display_histo.hh | 180 ++++
scribo/sandbox/green/mln/display/project_histo.hh | 536 ++++++++++
scribo/sandbox/green/mln/fun/p2b/achromatic.hh | 112 ++
.../sandbox/green/mln/fun/p2b/component_equals.hh | 99 ++
scribo/sandbox/green/mln/fun/v2v/achromatism.hh | 64 ++
.../sandbox/green/mln/fun/v2v/hue_concentration.hh | 100 ++
.../green/mln/fun/v2v/int_u16_to_int_u14.hh | 0
.../sandbox/green/mln/fun/v2v/log.hh | 0
.../sandbox/green/mln/fun/v2v/rg_to_rgb.hh | 0
scribo/sandbox/green/mln/fun/v2v/rgb8_to_int_u8.hh | 71 ++
.../sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh | 0
.../green/mln/fun/v2v/rgb_to_achromatism_map.hh | 77 ++
scribo/sandbox/green/mln/fun/v2v/rgb_to_hsv.hh | 149 +++
scribo/sandbox/green/mln/fun/v2v/rgb_to_hue_map.hh | 96 ++
scribo/sandbox/green/mln/fun/v2v/rgb_to_rg.hh | 111 ++
.../green/mln/fun/v2v/rgb_to_saturation_map.hh | 83 ++
.../sandbox/green/mln/fun/v2v/rgb_to_value_map.hh | 75 ++
scribo/sandbox/green/mln/img_path.hh | 239 +++++
scribo/sandbox/green/mln/io/plot/save_image_sh.hh | 1056 ++++++++++++++++++++
scribo/sandbox/green/mln/math/ceil.hh | 64 ++
scribo/sandbox/green/mln/math/floor.hh | 64 ++
scribo/sandbox/green/mln/value/hsv.hh | 424 ++++++++
scribo/sandbox/green/mln/value/rg.hh | 175 ++++
.../green/tests/accu/stat/histo1d/Makefile.am | 153 +++
.../green/tests/accu/stat/histo1d/histo1d.cc | 21 +
.../green/use/accu/stat/histo1d/Makefile.am | 153 +++
.../sandbox/green/use/accu/stat/histo1d/histo1d.cc | 24 +
.../green/use/accu/stat/histo2d/Makefile.am | 153 +++
.../sandbox/green/use/accu/stat/histo2d/histo2d.cc | 33 +
40 files changed, 6247 insertions(+), 18 deletions(-)
create mode 100644 scribo/sandbox/green/mln/accu/stat/histo1d.hh
create mode 100644 scribo/sandbox/green/mln/accu/stat/histo2d.hh
copy {milena => scribo}/sandbox/green/mln/accu/stat/histo3d_hsl.hh (100%)
copy {milena => scribo}/sandbox/green/mln/accu/stat/histo3d_rgb.hh (100%)
copy {milena => scribo}/sandbox/green/mln/clustering/k_mean.hh (100%)
copy {milena => scribo}/sandbox/green/mln/clustering/kmean1d.hh (100%)
copy {milena => scribo}/sandbox/green/mln/clustering/kmean2d.hh (100%)
copy {milena => scribo}/sandbox/green/mln/clustering/kmean3d.hh (100%)
create mode 100644 scribo/sandbox/green/mln/clustering/kmean_rgb.hh
create mode 100644 scribo/sandbox/green/mln/display/display_histo.hh
create mode 100644 scribo/sandbox/green/mln/display/project_histo.hh
create mode 100644 scribo/sandbox/green/mln/fun/p2b/achromatic.hh
create mode 100644 scribo/sandbox/green/mln/fun/p2b/component_equals.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/achromatism.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/hue_concentration.hh
copy {milena => scribo}/sandbox/green/mln/fun/v2v/int_u16_to_int_u14.hh (100%)
copy {milena => scribo}/sandbox/green/mln/fun/v2v/log.hh (100%)
copy {milena => scribo}/sandbox/green/mln/fun/v2v/rg_to_rgb.hh (100%)
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb8_to_int_u8.hh
copy {milena => scribo}/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh (100%)
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_achromatism_map.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_hsv.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_hue_map.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_rg.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_saturation_map.hh
create mode 100644 scribo/sandbox/green/mln/fun/v2v/rgb_to_value_map.hh
create mode 100644 scribo/sandbox/green/mln/img_path.hh
create mode 100644 scribo/sandbox/green/mln/io/plot/save_image_sh.hh
create mode 100644 scribo/sandbox/green/mln/math/ceil.hh
create mode 100644 scribo/sandbox/green/mln/math/floor.hh
create mode 100644 scribo/sandbox/green/mln/value/hsv.hh
create mode 100644 scribo/sandbox/green/mln/value/rg.hh
create mode 100644 scribo/sandbox/green/tests/accu/stat/histo1d/Makefile.am
create mode 100644 scribo/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
create mode 100644 scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am
create mode 100644 scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc
create mode 100644 scribo/sandbox/green/use/accu/stat/histo2d/Makefile.am
create mode 100644 scribo/sandbox/green/use/accu/stat/histo2d/histo2d.cc
diff --git a/scribo/sandbox/green/ChangeLog b/scribo/sandbox/green/ChangeLog
index e69de29..6a3c8fa 100644
--- a/scribo/sandbox/green/ChangeLog
+++ b/scribo/sandbox/green/ChangeLog
@@ -0,0 +1,59 @@
+2010-06-24 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Import files from milena/sandbox/green.
+
+ * mln/accu/stat/histo1d.hh: New header file.
+ * mln/accu/stat/histo2d.hh: New header file.
+ * mln/accu/stat/histo3d_hsl.hh: New header file.
+ * mln/accu/stat/histo3d_rgb.hh: New header file.
+ * mln/clustering/k_mean.hh: New header file.
+ * mln/clustering/kmean1d.hh: New header file.
+ * mln/clustering/kmean2d.hh: New header file.
+ * mln/clustering/kmean3d.hh: New header file.
+ * mln/clustering/kmean_rgb.hh: New header file.
+ * mln/display/display_histo.hh: New header file.
+ * mln/display/project_histo.hh: New header file.
+ * mln/fun/p2b/achromatic.hh: New header file.
+ * mln/fun/p2b/component_equals.hh: New header file.
+ * mln/fun/v2v/achromatism.hh: New header file.
+ * mln/fun/v2v/hue_concentration.hh: New header file.
+ * mln/fun/v2v/int_u16_to_int_u14.hh: New header file.
+ * mln/fun/v2v/int_u16_to_int_u14.hh: New header file.
+ * mln/fun/v2v/log.hh: New header file.
+ * mln/fun/v2v/rg_to_rgb.hh: New header file.
+ * mln/fun/v2v/rgb8_to_int_u8: New header file.
+ * mln/fun/v2v/rgb_to_achromastism_map.hh: New header file.
+ * mln/fun/v2v/rgb_to_hsv.hh: New header file.
+ * mln/fun/v2v/rgb_to_hue_map.hh: New header file.
+ * mln/fun/v2v/rgb_to_saturation_map.hh: New header file.
+ * mln/fun/v2v/rgb_to_value_map.hh: New header file.
+ * mln/img_path.hh: New header file.
+ * mln/io/plot/save_image_sh.hh: New header file.
+ * mln/math/cell.hh: New header file.
+ * mln/math/floor.hh: New header file.
+ * tests/accu/stat/histo1d/Makefile.am: New makefile.
+ * tests/accu/stat/histo1d/histo1d.cc: New source.
+ * tests/accu/stat/histo2d/Makefile.am: New makefile.
+ * tests/accu/stat/histo2d/histo2d.cc: New source.
+
+2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Save histogram library.
+
+ * mln/accu/histo/histo1d.hh: New header file.
+ * mln/accu/histo/histo2d.hh: New header file.
+ * mln/accu/histo/histo3d_rgb.hh: New header file.
+ * mln/accu/histo/histo3d_hsl.hh: New header file.
+
+2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Simple integration test.
+
+ * README: New text file.
+ * ok/mln/img_path.hh: New header file.
+ * ok/mln/accu/histo/histo1d.hh: New header file.
+ * ok/mln/accu/histo/histo2d.hh: New header file.
+ * ok/mln/accu/histo/histo3d.hh: New header file.
+ * ok/test/accu/histo/gaussian.sh: New gnuplot script file.
+ * ok/test/accu/histo/histo1d.cc: New source file.
+
diff --git a/scribo/sandbox/green/README b/scribo/sandbox/green/README
index 4eb71b7..3efe50d 100644
--- a/scribo/sandbox/green/README
+++ b/scribo/sandbox/green/README
@@ -1,32 +1,219 @@
-Le travail est classé dans deux répertoires ok et ko.
-Le répertoire ok correspond aux sources qui ont été reprises et retestées.
-Le répertoire ko correspond aux sources qui ont été juste transférées.
+I ARBORESCENCE
+--------------
-La première brique logicielle importante sur laquelle s'appuie mes travaux est
-la création d'histogrammes sous forme d'image.
+bench ==> Comparaison d'algorithmes d'un point de vue temps d'exécution.
+bug ==> Bug rencontrés dans milena et archivés sous forme de programme.
+build ==> Répertoire d'exécution, non sauvé dans git.
+demo ==> Première version d'un algorithme pour voir son comportement.
+doc ==> Documentation tex ou code minimal pour de petits exemples.
+exp ==> Version avancée des algorithmes pour traitées les bases de données.
+mln ==> Partie mise en librairie milena des différents travaux.
+tests ==> Tests unitaires sur certains algorithmes.
+tools ==> Découpage de certains algorithmes pour mieux les tester séparément.
+use ==> Test de compilation, code minimal pour compiler un élément.
+II COMPILATION
+--------------
-CREATION DES HISTOGRAMMES
--------------------------
+L'unité minimale de code choisie est le répertoire.
+Donc aller dans le répertoire qui nous interesse,
+par exemple, green/demo/annotating/hsv et lancé le make
-ko/mln/accu/stat/histo1d.hh: histogramme image valeur scalaire.
-ko/mln/accu/stat/histo2d.hh: histogramme image valeur vectorielle 2d.
-ko/mln/accu/stat/histo3d_hsl.hh: histogramme image valeur vectorielle 3d (HSL).
-ko/mln/accu/stat/histo3d_rgb.hh: histogramme image valeur vectorielle 3d (RGB).
+#:~/git/olena/scribo/sandbox/green$cd demo/annotating/hsv
+#:~/git/olena/scribo/sandbox/green/demo/annotating/hsv$ make -f Makefile.am
+Cette opération créé dans build le répertoire de compilation
+green/build/demo/annotating/hsv. Dans ce répertoire aura été copié un
+Makefile et tous les fichiers qui ne sont pas des sources. Par
+exemple, des fichiers de calibration comme gaussian.sh (pour vérifier
+la mire du filtre de gaussienne) ou de la documentation à la sauvette
+sous forme de fichiers textes jetés à la va vite dans le répertoire
+pour ne pas perdre l'information recherchée. En l'occurence, ici, il
+n'y a rien à copier. Rendons-nous dans le répertoire de compilation et lançons
+le makefile.
+#:~/git/olena/scribo/sandbox/green/demo/annotating/hsv$
+cd ../../../build/demo/annotating/hsv
+#:~/git/olena/scribo/sandbox/green/build/demo/annotating/hsv$ make clean all
-ok/mln/accu/histo/histo1d.hh: histogramme image valeur scalaire entière.
-ok/mln/accu/histo/histo2d.hh: histogramme image valeur vectorielle 2d entière.
-ok/mln/accu/histo/histo3d.hh: histogramme image valeur vectorielle 3d entière.
+L'exécutable est généré par le makefile, il porte le nom du
+répertoire. Si il y a besoin de mettre à jour le makefile, le faire
+dans le répertoire des sources en éditant Makefile.am, puis en
+régénérant le Makefile dans le répertoire d'exécution par la commande
+make -f Makefile.am depuis le répertoire source.
-SAUVEGARDE DES HISTOGRAMMES
----------------------------
+III MAKEFILE
+------------
+Les makefiles utilisés sont tous les mêmes avec quelques variables
+dont le contenu change dans leur partie en-tête.
+Pour chaque répertoire, le makefile doit savoir si le chemin courant
+est un répertoire de compilation ou un répertoire de source. Pour les
+identifier, il a recours à un pattern qui malheureusemnt fait
+intervenir le nom de la branche de développement (bench,demo,bug,exp ...).
+SOURCE_PATTERN= green/demo
+BUILD__PATTERN= green/build/demo
-VISUALISATION DES HISTOGRAMMES
-------------------------------
\ No newline at end of file
+Si un makefile ne fonctionne pas, il faut vérifier ceci en premier
+lieu. Ici, le makefile doit être situé dans la branche démo.
+
+Autre élément à savoir, la compilation nécessite d'inclure la
+librairie milena, ainsi que les développements propres en vu de leur
+intégration futur dans milena, ceci est fait par un jeu d'INCLUDES1
+et INCLUDES2.
+
+INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
+INCLUDES2= -I$(HOME)/git/olena/milena
+INCLUDES= $(INCLUDES1) $(INCLUDES2)
+
+Suivant l'allure du compte où l'on exécute les makefiles, il faut
+revoir le chemin pour trouver des deux répertoires.
+
+Enfin, les options de compilations ne sont pas toujours les mêmes. Les
+trois lignes possibles sont toutes présentes et seule celle qui est
+utilisée n'est pas commentée. Typiquement, dans la branche de
+développement démo où les perfomances ne sont pas le problème, on
+compilera avec tout le matériel pour utiliser gdb et sans
+optimisation. A l'inverse, dans la branche d'expérimentation, où le
+code a déjà été testé, on cherche à aller vite car on exécute ce code
+sur de nombreuses images. Dans cette optique, pas de débugage, pas de
+traçage, optimisation conséquente.
+
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+
+Une dernière dernière information, dans le cadre des développements
+exp, et tools, on utilise la librairie boost soit pour la
+virtualisation du filesystem, soit pour le formatage des fichiers text
+(réalisation de colonnes, mettre des entiers sur un certain nombre de
+caractères). Une ligne de chargement des librairies peut apparaitre donc.
+
+LOADLIBES= -lboost_filesystem
+
+On retrouvera les includes suivantes dans les sources:
+
+#include <boost/format.hpp>
+#include <boost/filesystem.hpp>
+
+
+IV CHEMINS DES IMAGES
+---------------------
+
+Toutes les images ont toujours été locales sur mon ordinateur. La
+politique a toujours été d'utiliser un fichier img_path pour coder les
+chemins des images. Les chemins étant plutôt long, j'ai toujours eu
+tendance à faire en sorte qu'ils soient compilés en dur (sauf pour la
+partie développement tools qui est vraiment voué à donner des
+exécutables indépendants et génériques). Le fichier mln/img_path.hh
+code la position de toutes les images dans mon arborescence. Il faudra
+donc veiller à changer tous les chemins pour les adapter au compte
+dans lequel on voudra reprendre le code. Dans le code, les références
+aux positions des images sont faites via des macros.
+
+Toutes les images sont située dans git/img. En règle générale, je ne
+traite que des images au format .pgm, .pbm et .ppm. Il m'arrive
+fréquemment de dumper des images au format .sh (gnuplot shell
+image). Pour la branche tools, nous avons utilisé les dumps de milena
+comme format de transfert d'un utilitaire à un autre. Les images sont
+classées suivant leur provenance. Nous avons tout d'abord la base
+OLENA (copie des images de tests milena), la base INIM (très peu
+utilisée voire jamais), la base ICDAR (très utilisée, surtout dans
+exp), la base AFP (très utilisée dans exp) et les bases ANNOTATING1 et
+ANNOTATING2 (pas très utilisées ni l'une, ni l'autre).
+
+La plus part du temps, sauver les résultats dans le répertoire
+d'exécution courant est largement suffisant. Parfois, il est
+nécessaire de sauvegarder de grosses quantités d'informations et de
+les classer comme dans la branche de développement exp. C'est pour
+cela, qu'un certain nombre de macros définissent des endroits pour
+sauvegarder les résultats lors d'expérimentation de grande ampleur sur
+toute la base ICDAR ou AFP.
+
+
+V GNUPLOT SCRIPT SHELL IMAGE FORMAT
+-----------------------------------
+
+J'abrège le nom du format par gnuplot shell format. En fait, c'est un
+format d'image particulier qui a besoin de gnuplot pour être lu. Il
+est donc compatible avec aucun viewer si ce n'est gnuplot, mais a la
+caractéristique d'afficher tous les points de manière visible. Par
+ailleurs, comme il s'agit d'un script gnuplot il permet d'insérer très
+facilement une fonction pour visualiser les données autrement (par
+exemple, changer d'espace: HSL, HSV). Le fichier tire son nom de la
+façon dont il fonctionne. C'est un script shell qui fait un appel à
+gnuplot et lui passe le jeu de données directement à partir de ce même
+fichier, pas besoin de faire appel à un autre fichier. Une fois
+généré, le fichier doit être modifié pour avoir les permissions
+d'exécution (chmod 755 gnuplot_shell_file.sh). Comme je trouve le format
+extrêmement pratique, il se retrouve preque partout dans mes sources.
+
+
+V MLN
+-----
+
+a) La sauvegarde des images au format gnuplot shell
+
+* mln/io/plot/save_image_sh.hh: Librairie sauvegarde format gnuplot shell.
+
+to do ...
+
+
+
+b) Les histogrammes
+
+Un des travaux demandés par théo est la réalisation d'une librairie
+d'histogramme permettant de fournir un résultat sous forme d'image.
+L'intérêt est ensuite de pouvoir filtrer directement ces histogrammes
+par les algorithmes de milena, ou encore d'étudier les valeurs
+caractéristiques par d'autres accumulateurs. Les codes réellement
+utilisés sont histo1d et histo3d RGB. Tous les autres codes sont très
+expérimentaux. Notemment, le code HSL demande de quantifier l'espace
+de comptage puisqu'il est décrit sous la forme de triplets de float
+(les autres sont inférés). Néanmoins, le code est à conserver car il
+contient une séquence d'appels pour les routines permettant de
+considérer la dimension de la teinte comme circulaire.
+
+* mln/accu/stat/histo1d.hh: Accumulateur histogramme image1d.
+* use/accu/stat/histo1d: Code minimal utilisant un histogramme 1d.
+
+* mln/accu/stat/histo2d.hh: Accumulateur histogramme image2d.
+* mln/value/rg.hh: Définition du type vectoriel 2d rouge/vert (RG).
+* mln/fun/v2v/rgb_to_rg.hh: Transformation de l'espace RGB vers l'espace RG.
+* use/accu/stat/histo2d: Code minimal utilisant un histogramme 2d.
+
+
+* mln/accu/stat/histo3d_rgb.hh: Accumulateur histogramme image3d RGB.
+* mln/accu/stat/histo3d_hsl.hh: Accumulateur histogramme image3d HSL.
+
+* use/accu/stat/histo3_rgb: Code minimal utilisant un histogramme 3d RGB.
+* use/accu/stat/histo3_hsl: Code minimal utilisant un histogramme 3d HSL.
+
+
+
+* tests/accu/stat/histo1d
+
+
+
+
+* tests/accu/stat/histo2d
+
+
+
+* use/accu/stat/histo3d_rgb
+* tests/accu/stat/histo3d_rgb
+
+* use/accu/stat/histo3d_hsl
+* tests/accu/stat/histo3d_hsl
+
+
+c) La visualisation des histogrammes 3d
+
+* demo/accu/stat/histo2d
+
+* mln/display/dispay_histo.hh
+* mln/displayproject_histo.hh
diff --git a/scribo/sandbox/green/mln/accu/stat/histo1d.hh
b/scribo/sandbox/green/mln/accu/stat/histo1d.hh
new file mode 100644
index 0000000..d480cf0
--- /dev/null
+++ b/scribo/sandbox/green/mln/accu/stat/histo1d.hh
@@ -0,0 +1,340 @@
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA LRDE
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_ACCU_STAT_HISTO1D_HH
+#define MLN_ACCU_STAT_HISTO1D_HH
+
+/// \file
+///
+/// \brief Define a histogram as accumulator which returns an image1d.
+///
+/// This source implements the discrete histogram version. It was
+/// created for images which the values are derived from integer
+/// type. The number of bins is directly infered from the cardinality
+/// of the image value. So the int_u8 image has got 256 bins, the
+/// int_u<14> image has got 16384 bins. But, this code doesn't work
+/// for that quantification because of the coord limitation (signed
+/// short, as it is defined in mln/core/def/coord.hh). Take care of
+/// the limitation from the result image value. We hard code unsigned,
+/// but it sometimes not enought to count data in one bin. That last
+/// case has not occured since the beginning of the creation of the type.
+///
+/// The following sample is a typical use of the histogram.
+///
+/// #include <mln/accu/stat/histo1d.hh>
+/// #include <mln/data/compute.hh>
+/// #include <mln/core/image/image1d.hh>
+/// #include <mln/core/image/image2d.hh>
+/// #include <mln/img_path.hh>
+/// #include <mln/io/pgm/load.hh>
+/// #include <mln/value/int_u8.hh>
+///
+/// int main()
+/// {
+/// typedef mln::value::int_u8 t_int_u8;
+/// mln::image2d<t_int_u8> img;
+/// mln::image1d<unsigned> histo;
+///
+/// mln::io::pgm::load(img, OLENA_IMG_PATH"/lena.pgm");
+/// histo = mln::data::compute(mln::accu::meta::histo::histo1d(), img);
+///
+/// return 0;
+/// }
+
+
+#include <iostream>
+
+#include <mln/accu/internal/base.hh>
+
+#include <mln/arith/plus.hh>
+
+#include <mln/core/concept/meta_accumulator.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/macros.hh>
+
+#include <mln/literal/zero.hh>
+
+#include <mln/trace/entering.hh>
+#include <mln/trace/exiting.hh>
+
+#include <mln/trait/value/comp.hh>
+
+#include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ // Forward declaration
+ template <typename V>
+ struct histo1d;
+
+ } // end of namespace mln::accu::stat
+
+
+ namespace meta
+ {
+
+ namespace stat
+ {
+
+ struct histo1d : public Meta_Accumulator<histo1d>
+ {
+ template <typename V>
+ struct with
+ {
+ typedef accu::stat::histo1d<V> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta::stat
+
+ } // end of namespace mln::accu::meta
+
+ } // end of namespace mln::accu
+
+ namespace trait
+ {
+
+ template <typename V>
+ struct accumulator_< mln::accu::stat::histo1d<V> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_v when_pix;
+ };
+
+ template <typename V>
+ struct set_precise_binary_<op::eq,
+ accu::stat::histo1d<V>,
+ accu::stat::histo1d<V> >
+ {
+ typedef bool ret;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ /// \brief Define a histogram as accumulator which returns an image1d.
+ ///
+ /// Param V defines the type of the input image value. It is in
+ /// this space that we count the values. For instance, this
+ /// histogram works well for image2d<int_u8> or with
+ /// image2d<int_u<14> >. The number of bins depends directly the
+ /// values V. For 8 bits there is 256 bins, for 14 bits there
+ /// is 16384 bins. Note that over quantification works too (up
+ /// to 14 bits).
+ ///
+ /// \ingroup modaccuvalues
+
+ template <typename V>
+ struct histo1d :
+ public mln::accu::internal::base<image1d<unsigned>, histo1d<V> >
+ {
+ typedef V argument;
+ typedef image1d<unsigned> result;
+ typedef result q_result;
+
+ /// Constructors
+ /// \{
+ /// \brief Infer the size of the resulting image1d domain.
+ ///
+ /// By evaluating the minimum and the maximum of V, we define the domain
+ /// of the resulting image1d.
+ histo1d();
+ /// \}
+
+
+ /// Manipulators.
+ /// \{
+ /// \brief Initialize the histogram with zero value.
+ ///
+ /// This method must be called just before starting the use of the
+ /// histogram. If it's not, resulting values won't converge to the
+ /// density.
+ void init();
+
+
+ /// \brief Update the histogram with the graylevel of the pixel t.
+ /// \param[in] t a graylevel pixel of type V.
+ ///
+ /// The end user shouldn't call this method. In place of it, he can
+ /// go through the data compute interface.
+ void take(const argument& t);
+
+
+ /// \brief Update the histogram with an other histogram.
+ /// \param[in] other the other histogram.
+ ///
+ /// The end user shouldn't call this method. This is part of
+ /// data compute interface mechanism.
+
+ void take(const histo1d<V>& other);
+ /// \}
+
+ /// Accessors.
+ /// \{
+ /// \brief Return the histogram as an image1d.
+ ///
+ /// This is the machinery to communicate with data compute interface.
+ /// The end user should'nt use it.
+ result to_result() const;
+ operator result () const;
+ /// \}
+
+ /// \brief Check whethever this accumulator is able to return a result.
+ ///
+ /// Depends if the resulting image1d is valid. We can assume it is quite
+ /// always the case.
+ bool is_valid() const;
+
+ protected:
+ result count_;
+ };
+
+ /// \brief Check wethever an histogram is equal to an other one.
+ /// \param[in] histo1 the first histogram to compare with.
+ /// \param[in] histo2 the second histogram.
+ ///
+ /// The operator compares all the bins from the two histograms.
+ /// Nobody uses this method unless unitary tests.
+
+ template <typename V>
+ bool operator==(const histo1d<V>& histo1, const histo1d<V>&
histo2);
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ histo1d<V>::histo1d()
+ {
+ trace::entering("mln::accu::stat::histo1d::cstor");
+ typedef mln_trait_value_comp(V,0) comp;
+ typedef point<grid::tick, V> v_point1d;
+ typedef box<v_point1d> v_box1d;
+
+ // comp keep a trace of the dimension of the theorical image.
+ // mln_min(comp) --> 0
+ // mln_max(comp) --> 2^(n-1) [127 for n=7][255 for n=8] ...
+
+ count_.init_(box1d(point1d(mln_min(comp)),
+ point1d(mln_max(comp))));
+
+ // std::cout << "min : " << mln_min(comp) << std::endl;
+ // std::cout << "max : " << mln_max(comp) << std::endl;
+
+ trace::exiting("mln::accu::stat::histo1d::cstor");
+ }
+
+ template <typename V>
+ inline
+ void histo1d<V>::init()
+ {
+ data::fill(count_, literal::zero);
+ }
+
+ template <typename V>
+ inline
+ void histo1d<V>::take(const argument& t)
+ {
+ // Just convert a graylevel value (int_u8 like) to a position for an
+ // iterator on the resulting image.
+ ++count_(point1d(t));
+ }
+
+
+ template <typename V>
+ inline
+ void histo1d<V>::take(const histo1d<V>& other)
+ {
+ count_ += other.count_;
+ }
+
+ template <typename V>
+ inline
+ typename histo1d<V>::result histo1d<V>::to_result() const
+ {
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ histo1d<V>::operator result() const
+ {
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ bool histo1d<V>::is_valid() const
+ {
+ bool result = count_.is_valid();
+
+ return result;
+ }
+
+ template <typename V>
+ bool operator==(const histo1d<V>& histo1, const histo1d<V>&
histo2)
+ {
+ trace::entering("mln::accu::stat::histo1d::operator==");
+
+ bool result = true;
+ const image1d<unsigned>& res1 = histo1.to_result();
+ const image1d<unsigned>& res2 = histo2.to_result();
+
+ mln_precondition(res1.is_valid());
+ mln_precondition(res2.is_valid());
+
+ mln_piter(image1d<unsigned>) p1(res1.domain());
+ mln_piter(image1d<unsigned>) p2(res2.domain());
+
+ for_all_2(p1, p2)
+ result &= (res1(p1) == res2(p2));
+
+ trace::exiting("mln::accu::stat::histo1d::operator==");
+ return result;
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+#endif // ! MLN_ACCU_STAT_HISTO1D_HH
diff --git a/scribo/sandbox/green/mln/accu/stat/histo2d.hh
b/scribo/sandbox/green/mln/accu/stat/histo2d.hh
new file mode 100644
index 0000000..c28723c
--- /dev/null
+++ b/scribo/sandbox/green/mln/accu/stat/histo2d.hh
@@ -0,0 +1,358 @@
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA LRDE
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_ACCU_STAT_HISTO2D_HH
+# define MLN_ACCU_STAT_HISTO2D_HH
+
+/// \file
+///
+/// \brief Define a histogram as accumulator which returns an image2d.
+///
+/// This source implements the discrete histogram version. It was
+/// created for images which the values are derived from integer
+/// type. The number of bins is directly infered from the cardinality
+/// of the image value. It works with vectorial image, typically RGB
+/// space where only RG are preserved. See histo1d.hh for limitations
+/// of such implementation. 8 bits quantification starts to be
+/// expensive, it produces image2d with [0..255,0..255] as domain.
+///
+/// The following sample is a typical use of the histogram.
+///
+/// #include <mln/accu/stat/histo2d.hh>
+/// #include <mln/core/image/image2d.hh>
+/// #include <mln/data/compute.hh>
+/// #include <mln/data/transform.hh>
+/// #include <mln/fun/v2v/rgb_to_rg.hh>
+/// #include <mln/img_path.hh>
+/// #include <mln/io/ppm/load.hh>
+/// #include <mln/value/rg.hh>
+/// #include <mln/value/rgb8.hh>
+///
+/// int main()
+/// {
+/// typedef mln::value::rg<8> t_rg8
+/// typedef mln::value::rgb8 t_rgb8;
+/// typedef mln::fun::v2v::rgb_to_rg<8> t_rgb_to_rg;
+/// typedef mln::image2d<t_rg8> t_image2d_rg8;
+/// typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+/// typedef mln::image2d<unsigned> t_histo;
+/// t_image2d_rgb8 img_rgb8;
+/// t_image2d_rg8 img_rg8;
+/// t_histo histo;
+///
+/// mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+/// img_rg8 = mln::data::transform(img_rgb8, t_rgb_to_rg());
+/// histo = mln::data::compute(mln::accu::meta::stat::histo2d(), img_rg8);
+///
+/// return 0;
+/// }
+
+# include <iostream>
+
+# include <mln/accu/internal/base.hh>
+
+# include <mln/core/macros.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/alias/point2d.hh>
+# include <mln/core/alias/box2d.hh>
+
+# include <mln/trait/value/comp.hh>
+
+# include <mln/arith/plus.hh>
+
+# include <mln/trace/entering.hh>
+# include <mln/trace/exiting.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ // Forward declaration
+ template <typename V>
+ struct histo2d;
+
+ } // end of namespace mln::accu::stat
+
+ namespace meta
+ {
+
+ namespace stat
+ {
+
+ struct histo2d : public Meta_Accumulator<histo2d>
+ {
+ template <typename V>
+ struct with
+ {
+ typedef accu::stat::histo2d<V> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta::stat
+
+ } // end of namespace mln::accu::meta
+
+ } // end of namespace mln::accu
+
+
+ namespace trait
+ {
+
+ template <typename V>
+ struct accumulator_< mln::accu::stat::histo2d<V> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_v when_pix;
+ };
+
+ template <typename V>
+ struct set_precise_binary_<op::eq,
+ accu::stat::histo2d<V>,
+ accu::stat::histo2d<V> >
+ {
+ typedef bool ret;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ /// \brief Define an histogram which returns an image3d .
+ ///
+ /// Param V defines the space in which we count the values.
+ /// For instance, this histogram works image2d<rgb<2>> or
+ /// image2d<rgb<7>>. The histogram count the occurrence of each value.
+ /// The number of bins depends of the grayscale values, for 8 bits there
+ /// is 256x3 bins. Note that over
+ /// quantification works too.
+ ///
+ /// \ingroup modaccuvalues
+
+ template <typename V>
+ struct histo2d :
+ public mln::accu::internal::base<image2d<unsigned>, histo2d<V> >
+ {
+ typedef V argument;
+ typedef image2d<unsigned> result;
+ typedef result q_result;
+
+ /// Constructors
+ /// \{
+ /// \brief Initialize the size of the resulting image1d.
+ ///
+ /// Initialize the size the resulting image from the theorical dynamic
+ /// of the greylevel values (Use V to manage it).
+ histo2d();
+ /// \}
+
+
+ /// Manipulators.
+ /// \{
+ /// \brief Initialize the histogram with zero value.
+ ///
+ /// This method must be called just before starting the use of the
+ /// histogram. If it's not, resulting values won't converge to the
+ /// density.
+ void init();
+
+
+ /// \brief Update the histogram with the RGB pixel t.
+ /// \param[in] t a greylevel pixel of type V.
+ ///
+ /// The end user shouldn't call this method. In place of it, he can
+ /// go through the data compute interface.
+ void take(const argument& t);
+
+
+ /// \brief Update the histogram with an other histogram.
+ /// \param[in] other the other histogram.
+ void take(const histo2d<V>& other);
+ /// \}
+
+ /// Accessors.
+ /// \{
+ /// \brief Return the histogram as an image1d.
+ ///
+ /// This is the machinery to communicate with data compute interface.
+ /// The end user should'nt use it.
+ result to_result() const;
+ operator result () const;
+ /// \}
+
+ /// \brief Check whethever this accumulator is able to return a result.
+ ///
+ /// Depends if the resulting image1d is valid. We can assume it is quite
+ /// always the case.
+ bool is_valid() const;
+
+ protected:
+ result count_;
+ };
+
+ /// \brief Check wethever an histogram is equal to an other one.
+ /// \param[in] histo1 the first histogram to compare with.
+ /// \param[in] histo2 the second histogram.
+ ///
+ /// The operator compare all the bins from the two histogram.
+
+ template <typename V>
+ bool operator==(const histo2d<V>& histo1,
+ const histo2d<V>& histo2);
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ histo2d<V>::histo2d()
+ {
+ trace::entering("mln::accu::stat::histo2d::histo2d");
+ typedef mln_trait_value_comp(V,0) comp0;
+ typedef mln_trait_value_comp(V,1) comp1;
+
+ // comp keep a trace of the dimension of the theorical image.
+ // mln_min(comp) --> 0
+ // mln_max(comp) --> 2^(n-1) [127 for n=7][255 for n=8] ...
+
+ count_.init_(box2d(point2d(mln_min(comp0),
+ mln_min(comp1)),
+ point2d(mln_max(comp0),
+ mln_max(comp1))));
+
+ trace::exiting("mln::accu::stat::histo2d::histo2d");
+ }
+
+ template <typename V>
+ inline
+ void histo2d<V>::init()
+ {
+ trace::entering("mln::accu::stat::histo2d::init");
+
+ data::fill(count_, 0);
+ trace::exiting("mln::accu::stat::histo2d::init");
+ }
+
+ template <typename V>
+ inline
+ void histo2d<V>::take(const argument& t)
+ {
+ trace::entering("mln::accu::stat::histo2d::take");
+
+ // Just convert a greyscale value (int_u8 like) to a position for an
+ // iterator on the resulting image.
+ // Take care to the constructor : Point(slice, row, column)
+ ++count_(point2d(t.red(), t.green()));
+
+ trace::exiting("mln::accu::stat::histo2d::take");
+ }
+
+
+ template <typename V>
+ inline
+ void histo2d<V>::take(const histo2d<V>& other)
+ {
+ trace::entering("mln::accu::stat::histo2d::take");
+
+ count_ += other.count_;
+
+ trace::exiting("mln::accu::stat::histo2d::take");
+ }
+
+ template <typename V>
+ inline
+ typename histo2d<V>::result histo2d<V>::to_result() const
+ {
+ trace::entering("mln::accu::stat::histo2d::to_result");
+
+ trace::exiting("mln::accu::stat::histo2d::to_result");
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ histo2d<V>::operator result() const
+ {
+ trace::entering("mln::accu::stat::histo2d::operator result");
+
+ trace::exiting("mln::accu::stat::histo2d::operator result");
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ bool histo2d<V>::is_valid() const
+ {
+ trace::entering("mln::accu::stat::histo2d::is_valid");
+ bool result = count_.is_valid();
+
+ trace::exiting("mln::accu::stat::histo2d::is_valid");
+ return result;
+ }
+
+ template <typename V>
+ bool operator==(const histo2d<V>& histo1,
+ const histo2d<V>& histo2)
+ {
+ trace::entering("mln::accu::stat::operator==");
+
+ bool result = true;
+ const image2d<unsigned>& res1 = histo1.to_result();
+ const image2d<unsigned>& res2 = histo2.to_result();
+
+ mln_precondition(res1.is_valid());
+ mln_precondition(res2.is_valid());
+
+ mln_piter(image2d<unsigned>) p1(res1.domain());
+ mln_piter(image2d<unsigned>) p2(res2.domain());
+
+ for_all_2(p1, p2)
+ result &= (res1(p1) == res2(p2));
+
+ trace::exiting("mln::accu::stat::operator==");
+ return result;
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+#endif // ! MLN_ACCU_STAT_HISTO2D_HH
diff --git a/milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
b/scribo/sandbox/green/mln/accu/stat/histo3d_hsl.hh
similarity index 100%
copy from milena/sandbox/green/mln/accu/stat/histo3d_hsl.hh
copy to scribo/sandbox/green/mln/accu/stat/histo3d_hsl.hh
diff --git a/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
b/scribo/sandbox/green/mln/accu/stat/histo3d_rgb.hh
similarity index 100%
copy from milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
copy to scribo/sandbox/green/mln/accu/stat/histo3d_rgb.hh
diff --git a/milena/sandbox/green/mln/clustering/k_mean.hh
b/scribo/sandbox/green/mln/clustering/k_mean.hh
similarity index 100%
copy from milena/sandbox/green/mln/clustering/k_mean.hh
copy to scribo/sandbox/green/mln/clustering/k_mean.hh
diff --git a/milena/sandbox/green/mln/clustering/kmean1d.hh
b/scribo/sandbox/green/mln/clustering/kmean1d.hh
similarity index 100%
copy from milena/sandbox/green/mln/clustering/kmean1d.hh
copy to scribo/sandbox/green/mln/clustering/kmean1d.hh
diff --git a/milena/sandbox/green/mln/clustering/kmean2d.hh
b/scribo/sandbox/green/mln/clustering/kmean2d.hh
similarity index 100%
copy from milena/sandbox/green/mln/clustering/kmean2d.hh
copy to scribo/sandbox/green/mln/clustering/kmean2d.hh
diff --git a/milena/sandbox/green/mln/clustering/kmean3d.hh
b/scribo/sandbox/green/mln/clustering/kmean3d.hh
similarity index 100%
copy from milena/sandbox/green/mln/clustering/kmean3d.hh
copy to scribo/sandbox/green/mln/clustering/kmean3d.hh
diff --git a/scribo/sandbox/green/mln/clustering/kmean_rgb.hh
b/scribo/sandbox/green/mln/clustering/kmean_rgb.hh
new file mode 100644
index 0000000..253745b
--- /dev/null
+++ b/scribo/sandbox/green/mln/clustering/kmean_rgb.hh
@@ -0,0 +1,973 @@
+// Copyright (C) 2008,2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_CLUSTERING_KMEAN_RGB_HH
+# define MLN_CLUSTERING_KMEAN_RGB_HH
+
+/// \file
+///
+/// \brief Implements the optimized kmean algorithm.
+///
+/// This algorithm is optimized in the way it proceeds directly with
+/// the rgb values inspite of the pixel attribute. The
+/// algorithm is independant from the image dimension. But, we have to
+/// compute one time the histogram. In fact, we move a recurrent cost
+/// to a fix cost in the complexity. This version is adapted to
+/// image with small quantification.
+
+/// APLATISSEMENT DES KMEAN3D
+
+# include <limits.h>
+# include <iostream>
+
+# include <mln/accu/stat/histo3d_rgb.hh>
+
+# include <mln/algebra/vec.hh>
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/contract.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/macros.hh>
+
+# include <mln/data/compute.hh>
+# include <mln/data/fill.hh>
+# include <mln/data/transform.hh>
+
+# include <mln/debug/println.hh>
+
+# include <mln/io/ppm/save.hh>
+# include <mln/io/pgm/save.hh>
+
+# include <mln/labeling/colorize.hh>
+# include <mln/labeling/mean_values.hh>
+
+# include <mln/literal/zero.hh>
+# include <mln/literal/one.hh>
+
+# include <mln/math/min.hh>
+# include <mln/math/sqr.hh>
+
+# include <mln/norm/l2.hh>
+
+# include <mln/opt/at.hh>
+
+# include <mln/trace/entering.hh>
+# include <mln/trace/exiting.hh>
+
+# include <mln/trait/value_.hh>
+
+# include <mln/util/array.hh>
+
+# include <mln/value/int_u.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/label_8.hh>
+
+
+//--------------------------------------------------------------------------
+// CODE APLATI
+//--------------------------------------------------------------------------
+
+
+namespace mln
+{
+
+ namespace clustering
+ {
+
+ template <typename T, unsigned n, typename I>
+ inline
+ image2d<value::label_8>
+ kmean_rgb(const Image<I>& point,
+ const unsigned k_center,
+ const unsigned watch_dog,
+ const unsigned n_times);
+
+ } // end of namespace mln::clustering
+
+ namespace clustering
+ {
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ //--------------------------------------------------------------------------
+ // Internal.
+ //--------------------------------------------------------------------------
+
+ namespace internal
+ {
+
+ //------------------------------------------------------------------------
+ // Debugging tools
+ //------------------------------------------------------------------------
+
+ /*
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::build_label_dbg()
+ {
+ trace::entering("mln::clustering::kmean3d_a::build_label_dbg");
+
+ mln_piter(t_point_img) pi(_point.domain());
+ mln_piter(t_label_dbg) po(_label_dbg.domain());
+
+ for_all_2(pi, po)
+ {
+ t_value val = _point(pi);
+ t_label grp = _group(point3d(val.blue(), val.red(), val.green()));
+
+ // As label zero has got a particular semantic, the first label is one
+ _label_dbg(po) = ++grp;
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::build_label_dbg");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::build_mean_dbg()
+ {
+ trace::entering("mln::clustering::kmean3d_a::build_mean_dbg");
+
+ mln_piter(t_mean_dbg) p(_mean_dbg.domain());
+
+ for_all(p)
+ {
+ _mean_dbg(p).red() = static_cast<unsigned>(_mean[_label_dbg(p)][0]);
+ _mean_dbg(p).green() = static_cast<unsigned>(_mean[_label_dbg(p)][1]);
+ _mean_dbg(p).blue() = static_cast<unsigned>(_mean[_label_dbg(p)][2]);
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::build_mean_dbg");
+ }
+
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::build_all_dbg()
+ {
+ trace::entering("mln::clustering::kmean3d_a::build_all_dbg");
+ build_label_dbg();
+ //build_mean_dbg();
+ _mean_dbg = labeling::mean_values(_point, _label_dbg, _k_center);
+ _color_dbg = labeling::colorize(value::rgb8(), _label_dbg);
+
+ trace::exiting("mln::clustering::kmean3d_a::build_all_dbg");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::update_cnv()
+ {
+ trace::entering("mln::clustering::kmean3d_a::update_cnv");
+
+ _variance_cnv[_current_launching](point1d(_current_step))
+ = _within_variance;
+
+ mln_eiter(t_mean_img) l(_mean);
+
+ for_all(l)
+ {
+ _mean_cnv[l.index_()][_current_launching](point1d(_current_step))
+ = _mean[l.index_()];
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::update_cnv");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::finalize_cnv()
+ {
+ trace::entering("mln::clustering::kmean3d_a::finalize_cnv");
+
+ // saturate the curv with the within variance
+ for (unsigned i = _current_step; i < _watch_dog; ++i)
+ _variance_cnv[_current_launching](point1d(i)) = _within_variance;
+
+ for (unsigned i = _current_step; i < _watch_dog; ++i)
+ {
+ mln_eiter(t_mean_img) l(_mean);
+
+ for_all(l)
+ {
+ _mean_cnv[l.index_()][_current_launching](point1d(i))
+ = _mean[l.index_()];
+ }
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::finalize_cnv");
+ }
+
+
+
+
+ //--------------------------------------------------------------------------
+ // Printing temporary results
+ //--------------------------------------------------------------------------
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_mean()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_mean");
+
+ mln_eiter(t_mean_img) l(_mean);
+
+ for_all(l)
+ {
+ std::cout << "mean(" << l.index_();
+ std::cout << ") = [r=" << _mean[l.index_()][0];
+ std::cout << ", g=" << _mean[l.index_()][1];
+ std::cout << ", b=" << _mean[l.index_()][2];
+ std::cout << "]" << std::endl;
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_mean");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_number()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_number");
+
+ mln_eiter(t_number_img) l(_number);
+
+ for_all(l)
+ {
+ std::cout << "number(" << l.index_();
+ std::cout << ") = " << _number[l.index_()];
+ std::cout << std::endl;
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_number");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_variance()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_variance");
+
+ mln_eiter(t_variance_img) l(_number);
+
+ for_all(l)
+ {
+ std::cout << "variance(" << l.index_();
+ std::cout << ") = " << _variance[l.index_()];
+ std::cout << std::endl;
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_variance");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_histo()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_histo");
+
+ mln_piter(t_histo_img) rgb(_histo.domain());
+
+ for_all(rgb)
+ {
+ if (0 < _histo(rgb))
+ {
+ std::cout << "histo(r=" << rgb.row();
+ std::cout << ", g=" << rgb.col();
+ std::cout << ", b=" << rgb.sli();
+ std::cout << ")= " << _histo(rgb);
+ std::cout << std::endl;
+ }
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_histo");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_group()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_group");
+
+ mln_piter(t_group_img) rgb(_group.domain());
+
+ for_all(rgb)
+ {
+ if (0 < _histo(rgb))
+ {
+ std::cout << "group(r=" << rgb.row();
+ std::cout << ", g=" << rgb.col();
+ std::cout << ", b=" << rgb.sli();
+ std::cout << ")= " << _group(rgb);
+ std::cout << std::endl;
+ }
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_group");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_distance()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_distance");
+
+ mln_eiter(t_distance_img) l(_distance);
+
+ for_all(l)
+ {
+ mln_piter(t_distance_val) rgb(_distance[l.index_()].domain());
+
+ for_all(rgb)
+ {
+ if (0 < _histo(rgb))
+ {
+ std::cout << "distance(l=" << l.index_();
+ std::cout << ",r=" << rgb.row();
+ std::cout << ", g=" << rgb.col();
+ std::cout << ", b=" << rgb.sli();
+ std::cout << ")= " << _distance[l.index_()](rgb);
+ std::cout << std::endl;
+ }
+ }
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_distance");
+ }
+
+ template <typename T, unsigned n>
+ inline
+ void kmean3d_a<T,n>::print_point()
+ {
+ trace::entering("mln::clustering::kmean3d_a::print_point");
+
+ mln_piter(t_point_img) p(_point.domain());
+
+ for_all(p)
+ {
+ std::cout << "point(r=" << p.row();
+ std::cout << ", c=" << p.col();
+ std::cout << ")= " << _point(p);
+ std::cout << std::endl;
+ }
+
+ trace::exiting("mln::clustering::kmean3d_a::print_point");
+ }
+
+
+
+ template <typename T, unsigned n>
+ inline
+ void rgb_rand_init(t_mean_img mean)
+ {
+ typedef value::rgb<n> t_value;
+ typedef mln_trait_value_comp(t_value,0) t_value_comp0;
+ typedef mln_trait_value_comp(t_value,1) t_value_comp1;
+ typedef mln_trait_value_comp(t_value,2) t_value_comp2;
+ typedef algebra::vec<3,T> t_result3d;
+ typedef util::array<t_result3d> t_mean_img;
+
+ t_value_comp0 min_comp0 = mln_min(t_value_comp0);
+ t_value_comp0 max_comp0 = mln_max(t_value_comp0);
+ t_value_comp1 min_comp1 = mln_min(t_value_comp1);
+ t_value_comp1 max_comp1 = mln_max(t_value_comp1);
+ t_value_comp2 min_comp2 = mln_min(t_value_comp2);
+ t_value_comp2 max_comp2 = mln_max(t_value_comp2);
+ mln_eiter(t_mean_img) l(mean);
+
+ for_all(l)
+ {
+ mean[l.index_()][0] = (rand() % (max_comp0 - min_comp0)) + min_comp0;
+ mean[l.index_()][1] = (rand() % (max_comp1 - min_comp1)) + min_comp1;
+ mean[l.index_()][2] = (rand() % (max_comp2 - min_comp2)) + min_comp2;
+ }
+
+ return mean;
+ }
+
+ */
+
+ } // end of namespace mln::clustering::internal
+
+
+ //--------------------------------------------------------------------------
+ // Impl.
+ //--------------------------------------------------------------------------
+
+ namespace impl
+ {
+
+ //------------------------------------------------------------------------
+ // kmean_image2d_rgb(const t_point_img& point,
+ // const unsigned k_center,
+ // const unsigned watch_dog = 10,
+ // const unsigned n_times = 10)
+ //------------------------------------------------------------------------
+
+ template <unsigned n>
+ struct rgbn_to_lbl8 : Function_v2v< rgbn_to_lbl8<n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef value::label_8 result;
+ typedef value::label_8 t_label;
+ typedef image3d<t_label> t_group_img;
+
+ t_group_img _group;
+
+ rgbn_to_lbl8(t_group_img group) : _group(group) {}
+
+ result operator()(const argument& c) const
+ {
+ value::label_8 tmp = opt::at(_group, c.blue(), c.red(), c.green());
+
+ // FIXME WHY DO WE NOT USE +1
+ return ++tmp;
+ }
+ };
+
+ template <typename T, unsigned n>
+ struct rgb_to_dist : Function_v2v< rgb_to_dist<T,n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef T result;
+ typedef T t_result1d;
+ typedef algebra::vec<3,T> t_result3d;
+ typedef image3d<unsigned> t_histo_img;
+
+ t_result3d _mean;
+ t_histo_img _histo;
+
+ rgb_to_dist(t_result3d mean, t_histo_img histo) : _mean(mean),
+ _histo(histo) {}
+
+ result operator()(const argument& c) const
+ {
+ t_result1d diff2_row = math::sqr(c.row() - _mean[0]);
+ t_result1d diff2_col = math::sqr(c.col() - _mean[1]);
+ t_result1d diff2_sli = math::sqr(c.sli() - _mean[2]);
+ t_result1d tmp = _histo(c)*(diff2_row + diff2_col + diff2_sli);
+
+ return tmp;
+ }
+ };
+
+ template <typename T, unsigned n>
+ inline
+ image2d<value::label_8>
+ kmean_image2d_rgb(const image2d< value::rgb<n> >& point,
+ const unsigned k_center,
+ const unsigned watch_dog = 10,
+ const unsigned n_times = 10)
+ {
+ trace::entering("mln::clustering::impl::kmean_image2d_rgb");
+ trace::quiet = true;
+ // BEGIN TYPEDEF
+ typedef value::rgb<8> t_rgb;
+ typedef value::label<8> t_label;
+ typedef value::rgb<n> t_value;
+ typedef mln_trait_value_comp(t_value,0) t_value_comp0;
+ typedef mln_trait_value_comp(t_value,1) t_value_comp1;
+ typedef mln_trait_value_comp(t_value,2) t_value_comp2;
+ typedef T t_result1d;
+ typedef algebra::vec<3,T> t_result3d;
+
+ typedef image2d<t_value> t_point_img;
+ typedef image3d<unsigned> t_histo_img;
+ typedef util::array<t_result1d> t_number_img;
+ typedef util::array<t_result3d> t_mean_img;
+ typedef util::array<t_result1d> t_variance_img;
+
+ typedef image3d<t_label> t_group_img;
+ typedef image3d<t_result1d> t_distance_val;
+ typedef util::array<t_distance_val> t_distance_img;
+
+ typedef image2d<t_label> t_label_dbg;
+ typedef image2d<t_rgb> t_color_dbg;
+ typedef image2d<t_value> t_mean_dbg;
+
+ typedef image1d<t_result3d> t_mean_val;
+ typedef util::array<t_mean_val> t_mean_set;
+ typedef util::array<t_mean_set> t_mean_cnv;
+ typedef image1d<t_result1d> t_variance_val;
+ typedef util::array<t_variance_val> t_variance_cnv;
+ // END TYPEDEF
+
+ // BEGIN INITIALISATION
+ mln_precondition(point.is_valid());
+
+ static const unsigned _N_TRIES = 3;
+
+ typedef accu::meta::stat::histo3d_rgb t_histo3d_rgb;
+
+ t_result1d _within_variance;
+
+ unsigned _k_center = k_center;
+ unsigned _watch_dog = watch_dog;
+ unsigned _n_times = n_times;
+ t_point_img _point = point;
+
+ // HISTOGRAM INIT
+ t_histo_img _histo = data::compute(t_histo3d_rgb(),
+ _point);
+
+ // CENTER STATS INIT
+ t_number_img _number;
+ t_mean_img _mean;
+ t_variance_img _variance;
+
+ for (unsigned i = 0; i < _k_center; ++i)
+ {
+ _number.append(literal::zero);
+ _mean.append(literal::zero);
+ _variance.append(literal::zero);
+ }
+
+
+ unsigned _current_step = 0;
+ unsigned _current_launching = 0;
+ bool _is_number_valid = false;
+
+ unsigned _launching_min;
+ t_result1d _variance_min;
+ t_mean_img _mean_min;
+
+
+
+ t_group_img _group;
+ t_distance_img _distance;
+
+
+ t_label_dbg _label_dbg;
+ t_color_dbg _color_dbg;
+ t_mean_dbg _mean_dbg;
+
+
+ t_mean_cnv _mean_cnv;
+ t_variance_cnv _variance_cnv;
+
+
+
+
+ _group.init_(box3d(point3d(mln_min(t_value_comp2),
+ mln_min(t_value_comp0),
+ mln_min(t_value_comp1)),
+ point3d(mln_max(t_value_comp2),
+ mln_max(t_value_comp0),
+ mln_max(t_value_comp1))));
+
+ for (unsigned i = 0; i < _k_center; ++i)
+ {
+ t_distance_val img(box3d(point3d(mln_min(t_value_comp2),
+ mln_min(t_value_comp0),
+ mln_min(t_value_comp1)),
+ point3d(mln_max(t_value_comp2),
+ mln_max(t_value_comp0),
+ mln_max(t_value_comp1))));
+
+ _distance.append(img);
+ }
+
+ // Debugging, calibrating and testing
+ initialize(_label_dbg, _point);
+ initialize(_color_dbg, _point);
+ initialize(_mean_dbg, _point);
+
+ // Observing the convergence
+
+ for (unsigned i = 0; i < _n_times; ++i)
+ {
+ t_variance_val img(box1d(point1d(0), point1d(_watch_dog-1)));
+
+ data::fill(img, literal::zero);
+
+ _variance_cnv.append(img);
+ }
+
+ for (unsigned i = 0; i < _k_center; ++i)
+ {
+ t_mean_set mean_set;
+
+ for (unsigned j = 0; j < _n_times; ++j)
+ {
+ t_mean_val img(box1d(point1d(0), point1d(_watch_dog-1)));
+
+ data::fill(img, literal::zero);
+
+ mean_set.append(img);
+ }
+
+ _mean_cnv.append(mean_set);
+ }
+ // END INITIALISATION
+
+ // BEGIN LOOP N TIMES
+ {
+ unsigned tries = 0;
+ _variance_min = mln_max(t_result1d);
+ _current_launching = 0;
+
+ while (_current_launching < _n_times)
+ {
+ // BEGIN LAUNCH ONE TIME
+ trace::quiet = false;
+ trace::entering("Launch one time");
+ trace::quiet = true;
+ {
+ t_result1d old_variance = mln_max(t_result1d);
+ _within_variance = mln_max(t_result1d);
+ _current_step = 0;
+
+ // BEGIN INIT_MEAN
+ trace::quiet = false;
+ trace::entering("init mean");
+ trace::quiet = true;
+ {
+ t_value_comp0 min_comp0 = mln_min(t_value_comp0);
+ t_value_comp0 max_comp0 = mln_max(t_value_comp0);
+ t_value_comp1 min_comp1 = mln_min(t_value_comp1);
+ t_value_comp1 max_comp1 = mln_max(t_value_comp1);
+ t_value_comp2 min_comp2 = mln_min(t_value_comp2);
+ t_value_comp2 max_comp2 = mln_max(t_value_comp2);
+ mln_eiter(t_mean_img) l(_mean);
+
+ for_all(l)
+ {
+ _mean[l.index_()][0]=(rand()%(max_comp0-min_comp0))+min_comp0;
+ _mean[l.index_()][1]=(rand()%(max_comp1-min_comp1))+min_comp1;
+ _mean[l.index_()][2]=(rand()%(max_comp2-min_comp2))+min_comp2;
+ }
+ }
+ trace::quiet = false;
+ trace::exiting("init mean");
+ trace::quiet = true;
+ // END INIT MEAN
+
+
+ // UPDATE DISTANCE
+ trace::quiet = false;
+ trace::entering("update distance");
+ trace::quiet = true;
+
+ for (unsigned i = 0; i < _k_center; ++i)
+ {
+
+ // _distance[i] = data::transform(_histo,
+ // rgb_to_dist<T,n>(_mean[i],
+ // _histo));
+
+ mln_piter(t_distance_val) d(_distance[i].domain());
+
+ for_all(d)
+ {
+ t_result1d diff2_row = math::sqr(d.row() - _mean[i][0]);
+ t_result1d diff2_col = math::sqr(d.col() - _mean[i][1]);
+ t_result1d diff2_sli = math::sqr(d.sli() - _mean[i][2]);
+ _distance[i](d) = _histo(d)*
+ (diff2_row + diff2_col + diff2_sli);
+ }
+ }
+
+ trace::quiet = false;
+ trace::exiting("update distance");
+ trace::quiet = true;
+ // END UPDATE DISTANCE
+
+ do
+ {
+ old_variance = _within_variance;
+
+ // BEGIN UPDATE GROUP
+ trace::quiet = false;
+ trace::entering("update group");
+ trace::quiet = true;
+ {
+ mln_piter(t_group_img) rgb(_group.domain());
+
+ for_all(rgb)
+ {
+ mln_eiter(t_distance_img) l(_distance);
+ t_result1d min = mln_max(t_result1d);
+ t_label label = mln_max(t_label);
+
+ for_all(l)
+ {
+ if (min > _distance[l.index_()](rgb))
+ {
+ min = _distance[l.index_()](rgb);
+ label = l.index_();
+ }
+ }
+
+ _group(rgb) = label;
+ }
+
+ }
+ trace::quiet = false;
+ trace::exiting("update group");
+ trace::quiet = true;
+ // END UPDATE GROUP
+
+ // BEGIN UPDATE MEAN
+ trace::quiet = false;
+ trace::entering("update mean");
+ trace::quiet = true;
+ {
+ mln_eiter(t_number_img) en(_number);
+ mln_eiter(t_mean_img) em(_mean);
+
+ for_all_2(en,em)
+ {
+ _number[en.index_()] = literal::zero;
+ _mean[em.index_()] = literal::zero;
+ }
+
+ mln_piter(t_group_img) rgb(_group.domain());
+
+ for_all(rgb)
+ {
+ _mean[_group(rgb)][0] += rgb.row() * _histo(rgb);
+ _mean[_group(rgb)][1] += rgb.col() * _histo(rgb);
+ _mean[_group(rgb)][2] += rgb.sli() * _histo(rgb);
+ _number(_group(rgb)) += _histo(rgb);
+ }
+
+ mln_eiter(t_mean_img) l(_mean);
+
+ for_all(l)
+ {
+ _is_number_valid = (0 != _number[l.index_()]);
+
+ if (!_is_number_valid)
+ break;
+
+ _mean[l.index_()] /= _number[l.index_()];
+ }
+ }
+ trace::quiet = false;
+ trace::exiting("update mean");
+ trace::quiet = true;
+ // END UPDATE MEAN
+
+
+ // Stopping Nan propagation
+ if (!_is_number_valid)
+ break;
+
+ // UPDATE DISTANCE
+ trace::quiet = false;
+ trace::entering("update distance");
+ trace::quiet = true;
+
+ for (unsigned i = 0; i < _k_center; ++i)
+ {
+ mln_piter(t_distance_val) d(_distance[i].domain());
+
+ for_all(d)
+ {
+ // the square distance
+ t_result1d diff2_row = math::sqr(d.row() - _mean[i][0]);
+ t_result1d diff2_col = math::sqr(d.col() - _mean[i][1]);
+ t_result1d diff2_sli = math::sqr(d.sli() - _mean[i][2]);
+ _distance[i](d) = _histo(d)*
+ (diff2_row + diff2_col + diff2_sli);
+ }
+ }
+ trace::quiet = false;
+ trace::exiting("update distance");
+ trace::quiet = true;
+ // END UPDATE DISTANCE
+
+ // BEGIN UPDATE VARIANCE
+ trace::quiet = false;
+ trace::entering("update variance");
+ trace::quiet = true;
+ {
+ _within_variance = literal::zero;
+ mln_eiter(t_variance_img) l(_variance);
+
+ for_all(l)
+ {
+ _variance[l.index_()] = literal::zero;
+
+ mln_piter(t_group_img) rgb(_group.domain());
+
+ for_all(rgb)
+ {
+ if (l.index_() == _group(rgb))
+ _variance[l.index_()] += _distance[l.index_()](rgb);
+ }
+
+ _within_variance += _variance[l.index_()];
+ }
+
+ }
+ trace::quiet = false;
+ trace::exiting("update variance");
+ trace::quiet = true;
+ // END UPDATE VARIANCE
+
+ //update_cnv();
+
+ ++_current_step;
+ }
+ while (_current_step < _watch_dog &&
+ _within_variance < old_variance);
+
+ //finalize_cnv();
+ //build_all_dbg();
+ }
+ trace::quiet = false;
+ trace::exiting("Launch one time");
+ trace::quiet = true;
+ // END LAUNCH ONE TIME
+
+ if ((_is_number_valid && (_current_step < _watch_dog))||
+ _N_TRIES < tries)
+ {
+ if (_within_variance < _variance_min)
+ {
+ _variance_min = _within_variance;
+ _mean_min = _mean;
+ _launching_min = _current_launching;
+ }
+
+ // Reinitialize the number of echecs possible
+ tries = 0;
+
+ //std::cout << "_current_launching : " <<
_current_launching
+ // << std::endl;
+
+ //std::cout << "within_variance[" << _current_launching
<< "] = "
+ // << _within_variance << std::endl;
+
+ ++_current_launching;
+ }
+ else
+ ++tries;
+ }
+
+ //Debugging code
+ //build_all_dbg();
+
+ }
+ // END LOOP N TIMES
+
+ // BEGIN BUILD LABEL IMAGE
+ _label_dbg = data::transform(_point, rgbn_to_lbl8<n>(_group));
+
+// {
+// mln_piter(t_point_img) pi(_point.domain());
+// mln_piter(t_label_dbg) po(_label_dbg.domain());
+
+// for_all_2(pi, po)
+// {
+// t_value val = _point(pi);
+// t_label grp = _group(point3d(val.blue(),val.red(),val.green()));
+
+// _label_dbg(po) = ++grp;
+// }
+// }
+
+ // END BUILD LABEL IMAGE
+ trace::quiet = false;
+ trace::exiting("mln::clustering::impl::kmean_image2d_rgb");
+
+ return _label_dbg;
+
+ }
+
+ } // end of namespace mln::clustering::impl
+
+
+
+
+
+ //--------------------------------------------------------------------------
+ // Internal.
+ //--------------------------------------------------------------------------
+
+ namespace internal
+ {
+
+ template <typename T, unsigned n>
+ inline
+ image2d<value::label_8>
+ kmean_rgb_dispatch(const image2d< value::rgb<n> >& img,
+ const unsigned k_center,
+ const unsigned watch_dog,
+ const unsigned n_times)
+ {
+ return impl::kmean_image2d_rgb<T,n>(img, k_center, watch_dog, n_times);
+ }
+
+
+ template <typename T, unsigned n, typename I>
+ inline
+ image2d< value::label_8>
+ kmean_rgb_dispatch(const Image<I>& img,
+ const unsigned k_center,
+ const unsigned watch_dog,
+ const unsigned n_times)
+ {
+ return kmean_rgb_dispatch<T,n>(exact(img),k_center,watch_dog,n_times);
+ }
+
+
+ } // end of namespace mln::clustering::internal
+
+
+ //--------------------------------------------------------------------------
+ // Facade.
+ //--------------------------------------------------------------------------
+
+ template <typename T, unsigned n, typename I>
+ inline
+ image2d<value::label_8>
+ kmean_rgb(const Image<I>& point,
+ const unsigned k_center,
+ const unsigned watch_dog,
+ const unsigned n_times)
+ {
+ trace::entering("mln::clustering::kmean_rgb");
+
+ image2d<value::label_8> tmp = internal::kmean_rgb_dispatch<T,n>(point,
+ k_center,
+ watch_dog,
+ n_times);
+ trace::exiting("mln::clustering::kmean_rgb");
+
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::clustering
+
+} // end of namespace mln
+
+#endif // ! MLN_CLUSTERING_KMEAN_RGB_HH
diff --git a/scribo/sandbox/green/mln/display/display_histo.hh
b/scribo/sandbox/green/mln/display/display_histo.hh
new file mode 100644
index 0000000..ef47182
--- /dev/null
+++ b/scribo/sandbox/green/mln/display/display_histo.hh
@@ -0,0 +1,180 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_DISPLAY_DISPLAY_HISTO_HH
+# define MLN_DISPLAY_DISPLAY_HISTO_HH
+
+# include <mln/accu/math/sum.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/data/stretch.hh>
+# include <mln/display/project_histo.hh>
+# include <mln/fun/v2v/log.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/label_8.hh>
+# include <mln/util/array.hh>
+
+
+/// \file
+///
+/// \brief Allow the complete visualization of a 3d histogram by projection.
+///
+/// The 3d histogram is projected in red/green space by accumulating around the
+/// the blue dimension (green and blue composantes are being correlated). In
+/// fact, we sum in along the blue direction. Then, we stretch value to feet
+/// pgm format.
+
+
+namespace mln
+{
+
+ namespace display
+ {
+
+ // Forward declaration.
+ image2d<value::int_u8>
+ display_histo3d_unsigned(const image3d<unsigned>& histo);
+
+ template <unsigned n>
+ image2d< value::int_u<n> >
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::int_u<n> ambiguous_color);
+
+ template <unsigned n>
+ image2d<value::label_8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label);
+
+ template <unsigned n>
+ image2d< value::rgb<n> >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color);
+
+ template <unsigned n>
+ image2d< value::rgb8 >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array< algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color);
+
+#ifndef MLN_INCLUDE_ONLY
+
+ /// \brief Allow the visualization of a 3d histogram by projection.
+ ///
+ /// The 3d histogram is projected in red/green space by
+ /// accumulating around the the blue dimension (green and blue
+ /// composantes are being correlated). In fact, we sum along
+ /// the blue direction. Then, we stretch value to feet pgm
+ /// format.
+ /// Direction r = 1
+ /// Direction g = 2
+ /// Direction b = 0
+ ///
+ /// \parameter[in] histo the histogram in 3d.
+ /// \result return a equivalent 2d image.
+
+ // FIXME : display_shape [in int_u8]
+ image2d<value::int_u8>
+ display_histo3d_unsigned(const image3d<unsigned>& histo)
+ {
+ typedef accu::math::sum<unsigned,unsigned> t_sum;
+ typedef value::int_u8 t_int_u8;
+ typedef fun::v2v::log<float> t_log;
+
+ image2d<unsigned> proj = project_histo<t_sum,0>(histo);
+ image2d<t_int_u8> proj_int = data::stretch(t_int_u8(),
+ data::transform(proj,
+ t_log()));
+ return proj_int;
+ }
+
+ // FIXME : display_color [in int_un]
+ template <unsigned n>
+ image2d< value::int_u<n> >
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::int_u<n> ambiguous_color)
+ {
+ image2d< value::int_u<n> > proj = project2_histo<n,0>(histo,
+ ambiguous_color);
+
+ return proj;
+ }
+
+ // FIXME : display_label [in label]
+ template <unsigned n>
+ image2d<value::label_8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label)
+ {
+ image2d<value::label_8> proj = project2_histo<n,0>(histo,
+ label,
+ ambiguous_label);
+
+ return proj;
+ }
+
+ // FIXME : display_color [in color]
+ template <unsigned n>
+ image2d< value::rgb<n> >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color)
+ {
+ image2d< value::rgb<n> > proj = project3_histo<n,0>(histo,
+ ambiguous_color);
+
+ return proj;
+ }
+
+
+ // FIXME : display_label [in color]
+ template <unsigned n>
+ image2d< value::rgb8 >
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color)
+ {
+ image2d< value::rgb8 > proj = project3_histo<n,0>(histo,
+ label,
+ pal,
+ ambiguous_color);
+
+ return proj;
+ }
+
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DISPLAY_DISPLAY_HISTO_HH
diff --git a/scribo/sandbox/green/mln/display/project_histo.hh
b/scribo/sandbox/green/mln/display/project_histo.hh
new file mode 100644
index 0000000..30bcd6d
--- /dev/null
+++ b/scribo/sandbox/green/mln/display/project_histo.hh
@@ -0,0 +1,536 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_DISPLAY_PROJECT_HISTO_HH
+# define MLN_DISPLAY_PROJECT_HISTO_HH
+
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image3d.hh>
+# include <mln/core/image/dmorph/unproject_image.hh>
+# include <mln/fun/v2v/projection.hh>
+
+# include <mln/accu/image/init.hh>
+# include <mln/accu/image/take.hh>
+# include <mln/accu/image/to_result.hh>
+
+# include <mln/algebra/vec.hh>
+
+# include <mln/opt/at.hh>
+
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/label_8.hh>
+
+# include <mln/util/array.hh>
+
+/// \file
+///
+/// \brief Allow the visualization of 3d histogram.
+/// The 3d histogram is projected in 2d such as the data in that direction
+/// are accumulated to the two others.
+
+namespace mln
+{
+
+ namespace display
+ {
+
+ // Forward declaration.
+ template <typename A, unsigned direction, typename V>
+ image2d<mln_result(A)>
+ project_histo(const image3d<V>& histo);
+
+ template <typename A, unsigned n, unsigned direction, typename V>
+ image2d<mln_result(A)>
+ project2_histo(const image3d<V>& histo,
+ const value::int_u<n>& ambiguous_color);
+
+ template <unsigned n, unsigned direction, typename V>
+ image2d<V>
+ project2_histo(const image3d<unsigned>& histo,
+ const image3d<V>& label);
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb<n> >
+ project3_histo(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color);
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb8 >
+ project3_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3, float> >& pal,
+ const value::rgb8 ambiguous_color);
+ // FIXME ==> palette must be 1d-image not an array !!
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// \brief Allow the visualization of 3d histogram.
+ ///
+ /// The 3d histogram is projected in 2d such as the data in that direction
+ /// are accumulated to the two others.
+ ///
+ /// Parameter A is the type of accumulator, for instance, accu::math::sum.
+ /// Parameter direction is the way of the projection, for instance blue one.
+ /// Parameter V is the value we use to accumulate information.
+ ///
+ /// \prameter[in] the histogram 3d.
+ /// \result the 2d projection of the 3d histogram.
+
+ template <typename A, unsigned direction, typename V>
+ image2d<mln_result(A)>
+ project_histo(const image3d<V>& histo)
+ {
+ typedef fun::v2v::projection<point3d,direction> t_projection;
+
+ image2d<A> histo_accu(histo.nrows(), histo.ncols());
+
+ accu::image::init(histo_accu);
+
+ accu::image::take(unproject(histo_accu,
+ histo.domain(),
+ t_projection()).rw(),
+ histo);
+
+ return accu::image::to_result(histo_accu);
+ }
+
+ // 0 ==> blue
+ // 1 ==> red
+ // 2 ==> green
+
+ // mln::opt::at(histo, blue, red, green)
+
+ template <unsigned n, unsigned direction>
+ image2d< value::int_u<n> >
+ project2_histo(const image3d<unsigned>& histo,
+ const value::int_u<n>& ambiguous_color)
+ {
+ image2d< value::int_u<n> > result;
+
+ if (0 == direction) // blue
+ {
+ image2d< value::int_u<n> > arg_max(histo.nrows(), histo.ncols());
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ opt::at(arg_max,red,green) = pos;
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d< value::int_u<n> > arg_max(histo.ncols(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = red;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,green,blue) = pos;
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d< value::int_u<n> > arg_max(histo.nrows(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = green;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,red,blue) = pos;
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+ template <unsigned n, unsigned direction>
+ image2d<value::label_8>
+ project2_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const value::label_8 ambiguous_label)
+ {
+ image2d<value::label_8> result;
+
+ if (0 == direction) // blue
+ {
+ image2d<value::label_8> arg_max(histo.nrows(), histo.ncols());
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_label;
+ else
+ opt::at(arg_max,red,green) = opt::at(label, pos, red, green);
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d<value::label_8> arg_max(histo.ncols(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = red;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_label;
+ else
+ opt::at(arg_max,green,blue) = opt::at(label, blue, pos, green);
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d<value::label_8> arg_max(histo.nrows(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = green;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_label;
+ else
+ opt::at(arg_max,red,blue) = opt::at(label, blue, red, pos);
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+
+
+
+ // FIXME ... determine the color of each class.
+ // FIXME la palette est supposée en 8 bits
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb8 >
+ project3_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label,
+ const util::array<algebra::vec<3,float> >& pal,
+ const value::rgb8 ambiguous_color)
+ {
+ image2d< value::rgb8 > result;
+
+ if (0 == direction) // blue
+ {
+ image2d< value::rgb8 > arg_max(histo.nrows(), histo.ncols());
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,pos,red,green)][0];
+ value::int_u8 g = pal[opt::at(label,pos,red,green)][1];
+ value::int_u8 b = pal[opt::at(label,pos,red,green)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,red,green) = color;
+ }
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d< value::rgb8 > arg_max(histo.ncols(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = red;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,blue,pos,green)][0];
+ value::int_u8 g = pal[opt::at(label,blue,pos,green)][1];
+ value::int_u8 b = pal[opt::at(label,blue,pos,green)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,green,blue) = color;
+ }
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d< value::rgb8 > arg_max(histo.nrows(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = green;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ {
+ value::int_u8 r = pal[opt::at(label,blue,red,pos)][0];
+ value::int_u8 g = pal[opt::at(label,blue,red,pos)][1];
+ value::int_u8 b = pal[opt::at(label,blue,red,pos)][2];
+ value::rgb8 color(r,g,b);
+
+ opt::at(arg_max,red,blue) = color;
+ }
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+
+ template <unsigned n, unsigned direction>
+ image2d< value::rgb<n> >
+ project3_histo(const image3d<unsigned>& histo,
+ const value::rgb<n> ambiguous_color)
+ {
+ image2d< value::rgb<n> > result;
+
+ if (0 == direction) // blue
+ {
+ image2d< value::rgb<n> > arg_max(histo.nrows(), histo.ncols());
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ def::coord pos = -1;
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = blue;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,green) = ambiguous_color;
+ else
+ opt::at(arg_max,red,green) = value::rgb<n>(red,green,pos);
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d< value::rgb<n> > arg_max(histo.ncols(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = red;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,green,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,green,blue) = value::rgb<n>(pos,green,blue);;
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d< value::rgb<n> > arg_max(histo.nrows(), histo.nslices());
+
+ for (def::coord blue = 0; blue < (signed)histo.nslices(); ++blue)
+ for (def::coord red = 0; red < (signed)histo.nrows(); ++red)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (def::coord green = 0; green < (signed)histo.ncols(); ++green)
+ {
+ if (max < opt::at(histo,blue,red,green))
+ {
+ max = opt::at(histo,blue,red,green);
+ pos = green;
+ }
+ }
+
+ if (-1 == pos)
+ opt::at(arg_max,red,blue) = ambiguous_color;
+ else
+ opt::at(arg_max,red,blue) = value::rgb<n>(red,pos,blue);
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DISPLAY_PROJECT_HISTO_HH
diff --git a/scribo/sandbox/green/mln/fun/p2b/achromatic.hh
b/scribo/sandbox/green/mln/fun/p2b/achromatic.hh
new file mode 100644
index 0000000..1f45b2d
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/p2b/achromatic.hh
@@ -0,0 +1,112 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_P2B_ACHROMATIC_HH
+# define MLN_FUN_P2B_ACHROMATIC_HH
+
+/// \file
+///
+/// In the vectorial image context (as RGB, HSL, HSV), compare one component
+/// to a specific value.
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/trait/value/comp.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+ /// \brief Functor that compare the i-th component of a value.
+ // V is for the type of the value received
+ // i is the ith component to select
+ template <typename T_rgb>
+ struct achromatic : public Function_v2b< achromatic<T_rgb> >
+ {
+ typedef bool result;
+ bool operator()(const point2d& p) const;
+
+ achromatic(const image2d<T_rgb>& img, const float threshold);
+
+ const float threshold_;
+ const image2d<T_rgb>& img_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T_rgb>
+ achromatic<T_rgb>::achromatic(const image2d<T_rgb>& img,
+ const float threshold)
+ : threshold_(threshold), img_(img)
+ {
+ }
+
+ template <typename T_rgb>
+ bool achromatic<T_rgb>::operator()(const point2d& p) const
+ {
+ typedef typename T_rgb::red_t t_red;
+ typedef typename T_rgb::green_t t_green;
+ typedef typename T_rgb::blue_t t_blue;
+
+ const T_rgb rgb = img_(p);
+
+ // To obtain red between 0 and 1
+ const float max_red = mln_max(t_red);
+ const float min_red = mln_min(t_red);
+ const float red = (rgb.red() - min_red)/(max_red - min_red);
+
+ // To obtain green between 0 and 1
+ const float max_green = mln_max(t_green);
+ const float min_green = mln_min(t_green);
+ const float green = (rgb.green()-min_green)/(max_green-min_green);
+
+ // To obtain blue between 0 and 1
+ const float max_blue = mln_max(t_blue);
+ const float min_blue = mln_min(t_blue);
+ const float blue = (rgb.blue()-min_blue)/(max_blue-min_blue);
+
+ bool result = (threshold_ > math::abs(red - green) &&
+ threshold_ > math::abs(red - blue) &&
+ threshold_ > math::abs(green - blue));
+
+ return result;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_ACHROMATIC_HH
diff --git a/scribo/sandbox/green/mln/fun/p2b/component_equals.hh
b/scribo/sandbox/green/mln/fun/p2b/component_equals.hh
new file mode 100644
index 0000000..2a4c62c
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/p2b/component_equals.hh
@@ -0,0 +1,99 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_P2B_COMPONENT_EQUALS_HH
+# define MLN_FUN_P2B_COMPONENT_EQUALS_HH
+
+/// \file
+///
+/// In the vectorial image context (as RGB, HSL, HSV), compare one component
+/// to a specific value.
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/trait/value/comp.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2b
+ {
+
+ /// \brief Functor that compare the i-th component of a value.
+ // V is for the type of the value received
+ // i is the ith component to select
+ template <typename I, unsigned i>
+ struct component_equals : public Function_v2b< component_equals<I,i> >
+ {
+ typedef bool result;
+ bool operator()(const point2d& p) const;
+
+ component_equals(const I& img,
+ const mln_trait_value_comp(mln_value(I),i)& ref);
+
+ const mln_trait_value_comp(mln_value(I),i) _ref;
+ const I& _img;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, unsigned i>
+ inline
+ component_equals<I,i>::
+ component_equals(const I& img,
+ const mln_trait_value_comp(mln_value(I),i)& ref)
+ : _ref(ref), _img(img)
+ {
+ }
+
+ template <typename I, unsigned i>
+ inline
+ bool
+ component_equals<I,i>::operator()(const point2d& p) const
+ {
+ typedef mln_value(I) t_value;
+ typedef mln_trait_value_comp(t_value,i) mln_value_comp;
+
+ t_value v = _img(p);
+ mln_value_comp c = trait::value::internal::comp<t_value,i>::on(v);
+
+ return (c == _ref);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2B_COMPONENT_EQUALS_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/achromatism.hh
b/scribo/sandbox/green/mln/fun/v2v/achromatism.hh
new file mode 100644
index 0000000..72b545c
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/achromatism.hh
@@ -0,0 +1,64 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_ACHROMATISM_HH
+# define MLN_FUN_V2V_ACHROMATISM_HH
+
+# include <mln/value/rgb8.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ struct achromatism : public Function_v2v< achromatism >
+ {
+ typedef float result;
+
+ float operator()(const value::rgb8 rgb) const;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ float achromatism::operator()(const value::rgb8 rgb) const
+ {
+ return (math::abs(rgb.red() - rgb.green())
+ + math::abs(rgb.red() - rgb.blue())
+ + math::abs(rgb.green() - rgb.blue()))/3.0;
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_ACHROMATISM_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/hue_concentration.hh
b/scribo/sandbox/green/mln/fun/v2v/hue_concentration.hh
new file mode 100644
index 0000000..84d26c8
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/hue_concentration.hh
@@ -0,0 +1,100 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_HUE_CONCENTRATION_HH
+# define MLN_FUN_V2V_HUE_CONCENTRATION_HH
+
+# include <mln/core/image/image1d.hh>
+# include <mln/math/abs.hh>
+# include <mln/opt/at.hh>
+# include <mln/value/hsv.hh>
+# include <mln/value/rgb8.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ unsigned peak_histo(const mln::image1d<unsigned>& hue_histo);
+
+ struct hue_concentration : public Function_v2v< hue_concentration >
+ {
+ typedef float result;
+
+ float operator()(const float hue) const;
+
+ hue_concentration(const mln::image1d<unsigned>& hue_histo)
+ {
+ peak = peak_histo(hue_histo);
+ }
+
+ unsigned peak;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ unsigned peak_histo(const mln::image1d<unsigned>& hue_histo)
+ {
+ mln_precondition(hue_histo.is_valid());
+
+ // Find the peak of the histogram
+ unsigned v_max = mln::opt::at(hue_histo, 0);
+ short p_max = 0;
+
+ mln_piter_(mln::image1d<unsigned>) p(hue_histo.domain());
+
+ for_all(p)
+ {
+ if (v_max < hue_histo(p))
+ {
+ v_max = hue_histo(p);
+ p_max = p.ind();
+ }
+ }
+
+ return p_max;
+ }
+
+
+ float hue_concentration::operator()(float hue) const
+ {
+ return mln::math::abs(peak - hue);
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_HUE_CONCENTRATION_HH
diff --git a/milena/sandbox/green/mln/fun/v2v/int_u16_to_int_u14.hh
b/scribo/sandbox/green/mln/fun/v2v/int_u16_to_int_u14.hh
similarity index 100%
copy from milena/sandbox/green/mln/fun/v2v/int_u16_to_int_u14.hh
copy to scribo/sandbox/green/mln/fun/v2v/int_u16_to_int_u14.hh
diff --git a/milena/sandbox/green/mln/fun/v2v/log.hh
b/scribo/sandbox/green/mln/fun/v2v/log.hh
similarity index 100%
copy from milena/sandbox/green/mln/fun/v2v/log.hh
copy to scribo/sandbox/green/mln/fun/v2v/log.hh
diff --git a/milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh
b/scribo/sandbox/green/mln/fun/v2v/rg_to_rgb.hh
similarity index 100%
copy from milena/sandbox/green/mln/fun/v2v/rg_to_rgb.hh
copy to scribo/sandbox/green/mln/fun/v2v/rg_to_rgb.hh
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb8_to_int_u8.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb8_to_int_u8.hh
new file mode 100644
index 0000000..0f63c8c
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb8_to_int_u8.hh
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB8_TO_INT_U8_HH
+# define MLN_FUN_V2V_RGB8_TO_INT_U8_HH
+
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/core/contract.hh>
+
+/// \file
+///
+/// \brief Convert rgb8 color value to int_u8 grey value
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb8 color value to int_u8 grey value
+ ///
+ /// \ingroup modfunv2v
+
+ struct rgb8_to_int_u8 : Function_v2v<rgb8_to_int_u8>
+ {
+ typedef value::rgb8 argument;
+ typedef value::int_u8 result;
+
+ result operator()(const argument& c) const
+ {
+ result res((c.red() + c.green() + c.blue()) / 3);
+
+ return res;
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif // ! MLN_FUN_V2V_RGB8_TO_INT_U8_HH
diff --git a/milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
similarity index 100%
copy from milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
copy to scribo/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_achromatism_map.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_achromatism_map.hh
new file mode 100644
index 0000000..6de63ec
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_achromatism_map.hh
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_ACHROMATISM_MAP_HH
+# define MLN_FUN_V2V_RGB_TO_ACHROMATISM_MAP_HH
+
+# include <mln/math/abs.hh>
+# include <mln/math/max.hh>
+
+# include <mln/value/rgb.hh>
+
+
+/// \file
+///
+/// \brief Convert rgb value to achromatism map.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb value to achromatism map.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb_to_achromatism_map :
+ Function_v2v< rgb_to_achromatism_map<n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef value::int_u<n> result;
+
+ result operator()(const argument& v) const
+ {
+ result max = math::max(math::max(v.red(),v.green()),v.blue());
+ result min = math::min(math::min(v.red(),v.green()),v.blue());
+ result ret = max - min;
+
+ return ret;
+ }
+ };
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_ACHROMATISM_MAP_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_hsv.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_hsv.hh
new file mode 100644
index 0000000..3dd8eb0
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_hsv.hh
@@ -0,0 +1,149 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_HSV_HH
+# define MLN_FUN_V2V_RGB_TO_HSV_HH
+
+#include <mln/math/max.hh>
+#include <mln/math/min.hh>
+
+#include <mln/trait/promote.hh>
+
+#include <mln/value/hsv.hh>
+#include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace value
+ {
+ template <typename H, typename S, typename V> class hsv_;
+ typedef hsv_<float, float, float> hsv_f;
+ typedef hsv_<double, double, double> hsv_d;
+ template <unsigned n> struct rgb;
+ }
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename T_hsv>
+ struct f_rgb_to_hsv_ : public Function_v2v< f_rgb_to_hsv_<T_hsv> >
+ {
+ typedef T_hsv result;
+
+
+ /// HSV implementation from millet.2008.phd.pdf p67
+ template <typename T_rgb>
+ T_hsv operator()(const T_rgb& rgb) const;
+
+ };
+
+ typedef f_rgb_to_hsv_<value::hsv_f> f_rgb_to_hsv_f_t;
+
+ extern f_rgb_to_hsv_f_t f_rgb_to_hsv_f;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// Global variables.
+ /// \{
+ f_rgb_to_hsv_f_t f_rgb_to_hsv_f;
+ /// \}
+
+
+ template <typename T_hsv>
+ template <typename T_rgb>
+ inline
+ T_hsv
+ f_rgb_to_hsv_<T_hsv>::operator()(const T_rgb& rgb) const
+ {
+ typedef typename T_rgb::red_t t_red;
+ typedef typename T_rgb::green_t t_green;
+ typedef typename T_rgb::blue_t t_blue;
+ typedef typename T_hsv::h_type t_hue;
+ typedef typename T_hsv::s_type t_sat;
+ typedef typename T_hsv::v_type t_val;
+ typedef mln_trait_promote(t_hue, t_sat) t_max_hue_sat;
+ typedef mln_trait_promote(t_max_hue_sat, t_val) t_max_hsv;
+
+ // To obtain red between 0 and 1
+ const t_max_hsv max_red = mln_max(t_red);
+ const t_max_hsv min_red = mln_min(t_red);
+ const t_max_hsv red = (rgb.red() - min_red)/(max_red - min_red);
+
+ // To obtain green between 0 and 1
+ const t_max_hsv max_green = mln_max(t_green);
+ const t_max_hsv min_green = mln_min(t_green);
+ const t_max_hsv green =(rgb.green()-min_green)/(max_green-min_green);
+
+ // To obtain blue between 0 and 1
+ const t_max_hsv max_blue = mln_max(t_blue);
+ const t_max_hsv min_blue = mln_min(t_blue);
+ const t_max_hsv blue = (rgb.blue()-min_blue)/(max_blue-min_blue);
+
+ const t_max_hsv max = math::max(red, math::max(green, blue));
+ const t_max_hsv min = math::min(red, math::min(green, blue));
+ const t_max_hsv max_minus_min = max-min;
+ const t_max_hsv s = 0.03;
+
+ // Locals.
+ T_hsv hsv;
+
+ // SPECIFIC CASE WHEN PIXEL IS ACHROMATIC
+ if (s > math::abs(red - blue) &&
+ s > math::abs(blue - red) &&
+ s > math::abs(red - green))
+ {
+ hsv.val() = (red + green + blue)/3.0;
+ hsv.sat() = 0.0;
+ hsv.hue() = -1.0;
+ }
+ else
+ {
+ hsv.val() = max;
+ hsv.sat() = max_minus_min / max;
+ if (max == red)
+ hsv.hue() = 60 * ((green - blue) / max_minus_min);
+ else if (max == green)
+ hsv.hue() = 60 * (2 + (blue - red) / max_minus_min);
+ else // (max == blue)
+ hsv.hue() = 60 * (4 + (red - green) / max_minus_min);
+ }
+ return hsv;
+ }
+
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // end of namespace fun::v2v
+
+ } // end of namespace fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_HSV_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_hue_map.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_hue_map.hh
new file mode 100644
index 0000000..8b228e0
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_hue_map.hh
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_HUE_MAP_HH
+# define MLN_FUN_V2V_RGB_TO_HUE_MAP_HH
+
+# include <mln/math/abs.hh>
+# include <mln/math/max.hh>
+
+# include <mln/value/rgb.hh>
+
+
+/// \file
+///
+/// \brief Convert rgb value to hue map.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb value to hue map.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb_to_hue_map :
+ Function_v2v< rgb_to_hue_map<n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef value::int_u<n> result;
+
+ result operator()(const argument& v) const
+ {
+ const float max = math::max(math::max(v.red(), v.green()), v.blue());
+ const float min = math::min(math::min(v.red(), v.green()), v.blue());
+ const float diff = max - min;
+ float hue = 0;
+
+ if (0 != diff)
+ {
+ if (v.red() == max)
+ {
+ hue = 60 * ((v.green() - v.blue()) / diff);
+
+ if (0 < hue)
+ hue = 360.0 + hue;
+ }
+ else if (v.green() == max)
+ hue = 60 * (2 + (v.blue() - v.red()) / diff);
+ else // (v.blue() == max)
+ hue = 60 * (4 + (v.red() - v.green()) / diff);
+ }
+
+ const result ret = (hue/360.0) * (mln_max(result) - mln_min(result))
+ + mln_min(result);
+
+ return ret;
+ }
+ };
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_HUE_MAP_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_rg.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_rg.hh
new file mode 100644
index 0000000..d4c1e46
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_rg.hh
@@ -0,0 +1,111 @@
+// Copyright (C) 2007,2008,2009,2010 EPITA LRDE
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_RG_HH
+# define MLN_FUN_V2V_RGB_TO_RG_HH
+
+# include <mln/value/rg.hh>
+# include <mln/value/rgb.hh>
+# include <mln/core/contract.hh>
+
+/// \file
+///
+/// \brief Convert a rgb value to a rg value.
+///
+/// This source implements the conversion between rgb space and rg space.
+///
+/// The following sample is a typical use of the rgb/rg conversion function.
+///
+/// #include <mln/accu/stat/histo2d.hh>
+/// #include <mln/core/image/image2d.hh>
+/// #include <mln/data/compute.hh>
+/// #include <mln/data/transform.hh>
+/// #include <mln/fun/v2v/rgb_to_rg.hh>
+/// #include <mln/img_path.hh>
+/// #include <mln/io/ppm/load.hh>
+/// #include <mln/value/rg.hh>
+/// #include <mln/value/rgb8.hh>
+///
+/// int main()
+/// {
+/// typedef mln::value::rg<8> t_rg8
+/// typedef mln::value::rgb8 t_rgb8;
+/// typedef mln::fun::v2v::rgb_to_rg<8> t_rgb_to_rg;
+/// typedef mln::image2d<t_rg8> t_image2d_rg8;
+/// typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+/// typedef mln::image2d<unsigned> t_histo;
+/// t_image2d_rgb8 img_rgb8;
+/// t_image2d_rg8 img_rg8;
+/// t_histo histo;
+///
+/// mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+/// img_rg8 = mln::data::transform(img_rgb8, t_rgb_to_rg());
+/// histo = mln::data::compute(mln::accu::meta::stat::histo2d(), img_rg8);
+///
+/// return 0;
+/// }
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert a rgb value to a rg value.
+ ///
+ /// Param n defines the quantification used for rgb space and rg space.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb_to_rg : Function_v2v< rgb_to_rg<n> >
+ {
+ typedef value::rg<n> result;
+ typedef value::rgb<n> argument;
+
+ /// \brief Convert rgb value to rg value.
+ ///
+ /// \param[in] v the rgb value to convert.
+ ///
+ /// Conversion is done by calling the rg constructor. There is
+ /// no modification of values. The red/green fields from rgb the value
+ /// are preserved. Blue value is dropped.
+
+ result operator()(const argument& v) const
+ {
+ return value::rg<n>(v);
+ }
+ };
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_RG_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_saturation_map.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_saturation_map.hh
new file mode 100644
index 0000000..a8847a0
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_saturation_map.hh
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_SATURATION_MAP_HH
+# define MLN_FUN_V2V_RGB_TO_SATURATION_MAP_HH
+
+# include <mln/math/abs.hh>
+# include <mln/math/max.hh>
+
+# include <mln/value/rgb.hh>
+
+
+/// \file
+///
+/// \brief Convert rgb value to saturation map.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb value to saturation map.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb_to_saturation_map :
+ Function_v2v< rgb_to_saturation_map<n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef value::int_u<n> result;
+
+ result operator()(const argument& v) const
+ {
+ const float max = math::max(math::max(v.red(), v.green()), v.blue());
+ const float min = math::min(math::min(v.red(), v.green()), v.blue());
+ float sat = 0.0;
+
+ if (0 != max)
+ sat = (1 - (float)min/max);
+
+ const result ret = sat * (mln_max(result) - mln_min(result))
+ + mln_min(result);
+
+ return ret;
+ }
+ };
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_SATURATION_MAP_HH
diff --git a/scribo/sandbox/green/mln/fun/v2v/rgb_to_value_map.hh
b/scribo/sandbox/green/mln/fun/v2v/rgb_to_value_map.hh
new file mode 100644
index 0000000..12ac1db
--- /dev/null
+++ b/scribo/sandbox/green/mln/fun/v2v/rgb_to_value_map.hh
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_V2V_RGB_TO_VALUE_MAP_HH
+# define MLN_FUN_V2V_RGB_TO_VALUE_MAP_HH
+
+# include <mln/math/abs.hh>
+# include <mln/math/max.hh>
+
+# include <mln/value/rgb.hh>
+
+
+/// \file
+///
+/// \brief Convert rgb value to value map.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb value to value map.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb_to_value_map :
+ Function_v2v< rgb_to_value_map<n> >
+ {
+ typedef value::rgb<n> argument;
+ typedef value::int_u<n> result;
+
+ result operator()(const argument& v) const
+ {
+ const result ret = math::max(math::max(v.red(), v.green()), v.blue());
+
+ return ret;
+ }
+ };
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_V2V_RGB_TO_VALUE_MAP_HH
diff --git a/scribo/sandbox/green/mln/img_path.hh b/scribo/sandbox/green/mln/img_path.hh
new file mode 100644
index 0000000..d205e1f
--- /dev/null
+++ b/scribo/sandbox/green/mln/img_path.hh
@@ -0,0 +1,239 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_IMG_PATH_HH
+# define MLN_IMG_PATH_HH
+
+# define IMG_PATH "/home/green/git/img"
+# define RET_PATH "/home/green/git/result"
+
+# define INIM_IMG_PATH IMG_PATH"/inim"
+# define INIM_BG_IMG_PATH INIM_IMG_PATH"/bg"
+# define INIM_FG_IMG_PATH INIM_IMG_PATH"/fg"
+# define INIM_IN_IMG_PATH INIM_IMG_PATH"/in"
+
+# define OLENA_IMG_PATH IMG_PATH"/olena"
+
+# define ICDAR_IMG_PATH IMG_PATH"/icdar"
+# define ICDAR_100P_IMG_PATH ICDAR_IMG_PATH"/100p"
+# define ICDAR_100P_PPM_IMG_PATH ICDAR_100P_IMG_PATH"/ppm"
+# define ICDAR_100P_PGM_IMG_PATH ICDAR_100P_IMG_PATH"/pgm"
+# define ICDAR_100P_PBM_IMG_PATH ICDAR_100P_IMG_PATH"/pbm"
+# define ICDAR_100P_THICK_IMG_PATH ICDAR_100P_IMG_PATH"/gradient_thick"
+# define ICDAR_100P_THIN_IMG_PATH ICDAR_100P_IMG_PATH"/gradient_thin"
+
+# define ICDAR_50P_IMG_PATH ICDAR_IMG_PATH"/50p"
+# define ICDAR_50P_PPM_IMG_PATH ICDAR_50P_IMG_PATH"/ppm"
+# define ICDAR_50P_PGM_IMG_PATH ICDAR_50P_IMG_PATH"/pgm"
+# define ICDAR_50P_PBM_IMG_PATH ICDAR_50P_IMG_PATH"/pbm"
+
+# define ICDAR_20P_IMG_PATH ICDAR_IMG_PATH"/20p"
+# define ICDAR_20P_TEXT_ONLY_IMG_PATH ICDAR_20P_IMG_PATH"/text-only"
+# define ICDAR_20P_TEXT_COLOR_IMG_PATH ICDAR_20P_IMG_PATH"/text-color"
+# define ICDAR_20P_TEXT_PHOTO_IMG_PATH ICDAR_20P_IMG_PATH"/text-photo"
+# define ICDAR_20P_GMP30_IMG_PATH ICDAR_20P_IMG_PATH"/gimp-pal-30"
+# define ICDAR_20P_MGK30_IMG_PATH ICDAR_20P_IMG_PATH"/magick-pal-30"
+# define ICDAR_20P_GMP20_IMG_PATH ICDAR_20P_IMG_PATH"/gimp-pal-20"
+# define ICDAR_20P_MGK20_IMG_PATH ICDAR_20P_IMG_PATH"/magick-pal-20"
+# define ICDAR_20P_GMP10_IMG_PATH ICDAR_20P_IMG_PATH"/gimp-pal-10"
+# define ICDAR_20P_MGK10_IMG_PATH ICDAR_20P_IMG_PATH"/magick-pal-10"
+# define ICDAR_20P_INPUT_IMG_PATH ICDAR_20P_IMG_PATH"/ppm"
+# define ICDAR_20P_CROP_IMG_PATH ICDAR_20P_IMG_PATH"/crop"
+# define ICDAR_20P_PGM_IMG_PATH ICDAR_20P_IMG_PATH"/pgm"
+# define ICDAR_20P_PPM_IMG_PATH ICDAR_20P_IMG_PATH"/ppm"
+# define ICDAR_20P_PBM_IMG_PATH ICDAR_20P_IMG_PATH"/pbm"
+
+# define AFP_IMG_PATH IMG_PATH"/afp"
+# define AFP_GMP30_IMG_PATH AFP_IMG_PATH"/gimp-pal-30"
+# define AFP_GMP20_IMG_PATH AFP_IMG_PATH"/gimp-pal-20"
+# define AFP_GMP10_IMG_PATH AFP_IMG_PATH"/gimp-pal-10"
+# define AFP_MGK30_IMG_PATH AFP_IMG_PATH"/magick-pal-30"
+# define AFP_MGK20_IMG_PATH AFP_IMG_PATH"/magick-pal-20"
+# define AFP_MGK10_IMG_PATH AFP_IMG_PATH"/magick-pal-10"
+# define AFP_INPUT_IMG_PATH AFP_IMG_PATH"/ppm"
+# define AFP_PPM_IMG_PATH AFP_IMG_PATH"/ppm"
+# define AFP_JPG_IMG_PATH AFP_IMG_PATH"/jpg"
+
+# define ANNOTATING_1_IMG_PATH IMG_PATH"/annotating-1"
+# define ANNOTATING_1_BILL_IMG_PATH ANNOTATING_1_IMG_PATH"/bill"
+# define ANNOTATING_1_FAX_IMG_PATH ANNOTATING_1_IMG_PATH"/fax"
+# define ANNOTATING_1_HANDWRITTEN_IMG_PATH ANNOTATING_1_IMG_PATH"/handwritten"
+# define ANNOTATING_1_LOGO_IMG_PATH ANNOTATING_1_IMG_PATH"/logo"
+# define ANNOTATING_1_MAP_IMG_PATH ANNOTATING_1_IMG_PATH"/map"
+# define ANNOTATING_1_SCREENSHOT_IMG_PATH ANNOTATING_1_IMG_PATH"/screenshot"
+# define ANNOTATING_1_SLIDE_IMG_PATH ANNOTATING_1_IMG_PATH"/slide"
+# define ANNOTATING_1_TYPED_IMG_PATH ANNOTATING_1_IMG_PATH"/typed"
+# define ANNOTATING_1_PHOTO_IMG_PATH ANNOTATING_1_IMG_PATH"/photo"
+
+# define ANNOTATING_2_IMG_PATH IMG_PATH"/annotating-2"
+# define ANNOTATING_2_BILL_IMG_PATH ANNOTATING_2_IMG_PATH"/bill"
+# define ANNOTATING_2_FAX_IMG_PATH ANNOTATING_2_IMG_PATH"/fax"
+# define ANNOTATING_2_HANDWRITTEN_IMG_PATH ANNOTATING_2_IMG_PATH"/handwritten"
+# define ANNOTATING_2_LOGO_IMG_PATH ANNOTATING_2_IMG_PATH"/logo"
+# define ANNOTATING_2_MAP_IMG_PATH ANNOTATING_2_IMG_PATH"/map"
+# define ANNOTATING_2_SCREENSHOT_IMG_PATH ANNOTATING_2_IMG_PATH"/screenshot"
+# define ANNOTATING_2_SLIDE_IMG_PATH ANNOTATING_2_IMG_PATH"/slide"
+# define ANNOTATING_2_TYPED_IMG_PATH ANNOTATING_2_IMG_PATH"/typed"
+# define ANNOTATING_2_PHOTO_IMG_PATH ANNOTATING_2_IMG_PATH"/photo"
+
+// result directories
+# define ANNOTATING_RET_PATH RET_PATH"/annotating"
+
+# define ANNOTATING_ICDAR_RET_PATH ANNOTATING_RET_PATH"/icdar"
+
+# define ANNOTATING_ICDAR_INPUT_RET_PATH ANNOTATING_ICDAR_RET_PATH"/input"
+# define ANNOTATING_ICDAR_H_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_INPUT_RET_PATH ANNOTATING_ICDAR_INPUT_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_GMP30_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/gimp-pal-30"
+# define ANNOTATING_ICDAR_H_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_GMP30_RET_PATH ANNOTATING_ICDAR_GMP30_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_GMP20_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/gimp-pal-20"
+# define ANNOTATING_ICDAR_H_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_GMP20_RET_PATH ANNOTATING_ICDAR_GMP20_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_GMP10_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/gimp-pal-10"
+# define ANNOTATING_ICDAR_H_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_GMP10_RET_PATH ANNOTATING_ICDAR_GMP10_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_MGK30_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/magick-pal-30"
+# define ANNOTATING_ICDAR_H_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_MGK30_RET_PATH ANNOTATING_ICDAR_MGK30_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_MGK20_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/magick-pal-20"
+# define ANNOTATING_ICDAR_H_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_MGK20_RET_PATH ANNOTATING_ICDAR_MGK20_RET_PATH"/b"
+
+# define ANNOTATING_ICDAR_MGK10_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/magick-pal-10"
+# define ANNOTATING_ICDAR_H_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/h"
+# define ANNOTATING_ICDAR_S_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/s"
+# define ANNOTATING_ICDAR_V_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/v"
+# define ANNOTATING_ICDAR_R_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/r"
+# define ANNOTATING_ICDAR_G_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/g"
+# define ANNOTATING_ICDAR_B_MGK10_RET_PATH ANNOTATING_ICDAR_MGK10_RET_PATH"/b"
+
+
+
+
+# define ANNOTATING_AFP_RET_PATH ANNOTATING_RET_PATH"/afp"
+
+# define ANNOTATING_AFP_INPUT_RET_PATH ANNOTATING_AFP_RET_PATH"/input"
+# define ANNOTATING_AFP_H_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/h"
+# define ANNOTATING_AFP_S_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/s"
+# define ANNOTATING_AFP_V_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/v"
+# define ANNOTATING_AFP_R_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/r"
+# define ANNOTATING_AFP_G_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/g"
+# define ANNOTATING_AFP_B_INPUT_RET_PATH ANNOTATING_AFP_INPUT_RET_PATH"/b"
+
+# define ANNOTATING_AFP_GMP30_RET_PATH ANNOTATING_AFP_RET_PATH"/gimp-pal-30"
+# define ANNOTATING_AFP_H_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/h"
+# define ANNOTATING_AFP_S_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/s"
+# define ANNOTATING_AFP_V_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/v"
+# define ANNOTATING_AFP_R_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/r"
+# define ANNOTATING_AFP_G_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/g"
+# define ANNOTATING_AFP_B_GMP30_RET_PATH ANNOTATING_AFP_GMP30_RET_PATH"/b"
+
+# define ANNOTATING_AFP_GMP20_RET_PATH ANNOTATING_AFP_RET_PATH"/gimp-pal-20"
+# define ANNOTATING_AFP_H_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/h"
+# define ANNOTATING_AFP_S_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/s"
+# define ANNOTATING_AFP_V_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/v"
+# define ANNOTATING_AFP_R_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/r"
+# define ANNOTATING_AFP_G_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/g"
+# define ANNOTATING_AFP_B_GMP20_RET_PATH ANNOTATING_AFP_GMP20_RET_PATH"/b"
+
+# define ANNOTATING_AFP_GMP10_RET_PATH ANNOTATING_AFP_RET_PATH"/gimp-pal-10"
+# define ANNOTATING_AFP_H_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/h"
+# define ANNOTATING_AFP_S_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/s"
+# define ANNOTATING_AFP_V_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/v"
+# define ANNOTATING_AFP_R_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/r"
+# define ANNOTATING_AFP_G_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/g"
+# define ANNOTATING_AFP_B_GMP10_RET_PATH ANNOTATING_AFP_GMP10_RET_PATH"/b"
+
+# define ANNOTATING_AFP_MGK30_RET_PATH
ANNOTATING_AFP_RET_PATH"/magick-pal-30"
+# define ANNOTATING_AFP_H_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/h"
+# define ANNOTATING_AFP_S_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/s"
+# define ANNOTATING_AFP_V_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/v"
+# define ANNOTATING_AFP_R_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/r"
+# define ANNOTATING_AFP_G_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/g"
+# define ANNOTATING_AFP_B_MGK30_RET_PATH ANNOTATING_AFP_MGK30_RET_PATH"/b"
+
+# define ANNOTATING_AFP_MGK20_RET_PATH
ANNOTATING_AFP_RET_PATH"/magick-pal-20"
+# define ANNOTATING_AFP_H_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/h"
+# define ANNOTATING_AFP_S_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/s"
+# define ANNOTATING_AFP_V_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/v"
+# define ANNOTATING_AFP_R_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/r"
+# define ANNOTATING_AFP_G_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/g"
+# define ANNOTATING_AFP_B_MGK20_RET_PATH ANNOTATING_AFP_MGK20_RET_PATH"/b"
+
+# define ANNOTATING_AFP_MGK10_RET_PATH
ANNOTATING_AFP_RET_PATH"/magick-pal-10"
+# define ANNOTATING_AFP_H_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/h"
+# define ANNOTATING_AFP_S_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/s"
+# define ANNOTATING_AFP_V_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/v"
+# define ANNOTATING_AFP_R_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/r"
+# define ANNOTATING_AFP_G_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/g"
+# define ANNOTATING_AFP_B_MGK10_RET_PATH ANNOTATING_AFP_MGK10_RET_PATH"/b"
+
+
+# define ANNOTATING_BILL_RET_PATH ANNOTATING_RET_PATH"/bill"
+# define ANNOTATING_FAX_RET_PATH ANNOTATING_RET_PATH"/fax"
+# define ANNOTATING_HANDWRITTEN_RET_PATH ANNOTATING_RET_PATH"/handwritten"
+# define ANNOTATING_LOGO_RET_PATH ANNOTATING_RET_PATH"/logo"
+# define ANNOTATING_MAP_RET_PATH ANNOTATING_RET_PATH"/map"
+# define ANNOTATING_SCREENSHOT_RET_PATH ANNOTATING_RET_PATH"/screenshot"
+# define ANNOTATING_SLIDE_RET_PATH ANNOTATING_RET_PATH"/slide"
+# define ANNOTATING_TYPED_RET_PATH ANNOTATING_RET_PATH"/typed"
+# define ANNOTATING_PHOTO_RET_PATH ANNOTATING_RET_PATH"/photo"
+
+# define ANNOTATING_ICDAR_ACHROMATISM_RET_PATH
ANNOTATING_ICDAR_RET_PATH"/achromatism"
+
+
+#endif // ! MLN_IMG_PATH_HH
diff --git a/scribo/sandbox/green/mln/io/plot/save_image_sh.hh
b/scribo/sandbox/green/mln/io/plot/save_image_sh.hh
new file mode 100644
index 0000000..137f78d
--- /dev/null
+++ b/scribo/sandbox/green/mln/io/plot/save_image_sh.hh
@@ -0,0 +1,1056 @@
+// Copyright (C) 2007,2008,2009,2010 EPITA LRDE
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_PLOT_SAVE_IMAGE_SH_HH
+# define MLN_IO_PLOT_SAVE_IMAGE_SH_HH
+
+/// \file
+///
+/// \brief Define some functions to export to gnuplot format as a script shell.
+///
+/// Theses routines are dedicated to image visualization. The aim is to display
+/// image whatever the value used as pixel. The behaviour of gnuplot is more
+/// like xv than imageMagick. A Gnuplot script shell file is a text dump file
+/// with a preambule to let gnuplot interpret data. As a script shell, you can
+/// launch it (don't forget the permissions), and every thing is packed in it.
+/// The script file call gnuplot in batch mode, the result window persists and
+/// that's all.
+///
+
+# include <fstream>
+# include <string>
+
+# include <mln/trace/entering.hh>
+# include <mln/trace/exiting.hh>
+
+# include <mln/core/macros.hh>
+# include <mln/core/contract.hh>
+# include <mln/core/image/image1d.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image3d.hh>
+
+# include <mln/geom/min_ind.hh>
+# include <mln/geom/max_ind.hh>
+# include <mln/geom/min_row.hh>
+# include <mln/geom/max_row.hh>
+# include <mln/geom/min_col.hh>
+# include <mln/geom/max_col.hh>
+
+# include <mln/trait/value_.hh>
+
+# include <mln/value/int_u.hh>
+# include <mln/value/int_s.hh>
+# include <mln/value/rgb.hh>
+# include <mln/value/hsl.hh>
+# include <mln/value/hsi.hh>
+
+# include <mln/util/array.hh>
+
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace plot
+ {
+
+ /// \brief Save an image as a gnuplot script shell.
+ ///
+ /// Every thing is save. The image could be 1d, 2d or 3d. The value of
+ /// the pixels could be int_u<n>, int_s<n>, float, double, hsl_f,
hsl_d,
+ /// hsi_f, hsi_d and rgb<n>.
+ ///
+ /// \param[in] img the image which contains the data to save.
+ /// \param[in] filename the name of the unix script shell.
+ /// \return the status of the opening file operation.
+ ///
+ /// The result depends on the permission to save the file with
+ /// filename parameter as unix path. The script shell file must have the
+ /// permission to execute (chmod 755). Launch the script shell to call
+ /// gnuplot in batchmode with fine parameters.
+
+ template <typename I>
+ bool save_image_sh(const Image<I>& img, const std::string&
filename);
+
+ /// \brief Save a stack of image.
+ ///
+ /// This is an experimental support.
+ ///
+ /// \param[in] stack the stack of image to save.
+ /// \param[in] filename the name of the unix script shell.
+ /// \return the status of the opening file operation.
+ ///
+ /// The result depends on the permission to save the file with
+ /// filename parameter as unix path. The script shell file must have the
+ /// permission to execute (chmod 755). Launch the script shell to call
+ /// gnuplot in batchmode with fine parameters.
+ template <typename I>
+ bool save_image_sh(const util::array< image1d<I> >& stack,
+ const std::string& filename);
+
+ template <typename I>
+ bool save_image_sh(const util::array< util::array< image1d<I> >
>& stack,
+ const std::string& filename);
+
+ } // end of namespace mln::io::plot
+
+ } // end of namespace mln::io
+
+
+ namespace io
+ {
+
+ namespace plot
+ {
+
+#ifndef MLN_INCLUDE_ONLY
+
+ //------------------------------------------------------------------------
+ // Impl.
+ //------------------------------------------------------------------------
+
+ namespace impl
+ {
+
+
+ //----------------------------------------------------------------------
+ // save_image_sh_array_array_image1d(const
array<array<image1d<I>>>&,
+ // const string&)
+ //----------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_array_array_image1d(const util::array< util::array<
+ image1d<I> > >& stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d");
+
+ mln_precondition(!stack.is_empty());
+ mln_precondition(!stack[0].is_empty());
+ mln_precondition(stack[0][0].is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_ind = geom::min_ind(stack[0][0]);
+ unsigned max_ind = geom::max_ind(stack[0][0]);
+
+ if (result)
+ {
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set xrange [" <<
min_ind;
+ out << ":" <<
max_ind;
+ out << "]" <<
std::endl;
+ out << "plot '-' with line";
+
+ for (unsigned i = 1; i < stack.size(); ++i)
+ {
+ for (unsigned j = 1; j < stack[i].size(); ++j)
+ {
+
+ out << ",\\" << std::endl;
+ out << " '-' with line";
+ }
+ }
+
+ out << std::endl;
+
+ mln_eiter(util::array< util::array< image1d<I> > >) e0(stack);
+
+ for_all (e0)
+ {
+ mln_eiter(util::array< image1d<I> >) e1(stack[e0.index_()]);
+
+ for_all (e1)
+ {
+ mln_piter(image1d< I >)
+ p(stack[e0.index_()][e1.index_()].domain());
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << stack[e0.index_()][e1.index_()](p) << std::endl;;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ }
+ }
+
+ out << "EOF" <<
std::endl;
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d");
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_array_array_image1d_vec3(
+ // const
array<array<image1d<vec<3,T>>>>&,
+ // const string&)
+ //----------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh_array_array_image1d_vec3(
+ const util::array<util::array<image1d<algebra::vec<3,T> > >
>& stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d_vec3");
+
+ typedef algebra::vec<3,T> t_val;
+ typedef image1d<t_val> t_img;
+ typedef util::array<t_img> t_array;
+ typedef util::array<t_array> t_stack;
+
+ mln_precondition(!stack.is_empty());
+ mln_precondition(!stack[0].is_empty());
+ mln_precondition(stack[0][0].is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_ind = geom::min_ind(stack[0][0]);
+ unsigned max_ind = geom::max_ind(stack[0][0]);
+
+ if (result)
+ {
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set xrange [" <<
min_ind;
+ out << ":" <<
max_ind;
+ out << "]" <<
std::endl;
+ out << "splot '-' with line palette";
+
+ for (unsigned i = 1; i < stack.size(); ++i)
+ {
+ for (unsigned j = 1; j < stack[i].size(); ++j)
+ {
+
+ out << ",\\" << std::endl;
+ out << " '-' with line palette";
+ }
+ }
+
+ out << std::endl;
+
+ mln_eiter(t_stack) e0(stack);
+
+ for_all (e0)
+ {
+ mln_eiter(t_array) e1(stack[e0.index_()]);
+
+ for_all (e1)
+ {
+ mln_piter(t_img) p(stack[e0.index_()][e1.index_()].domain());
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << stack[e0.index_()][e1.index_()](p)[0] << " ";
+ out << stack[e0.index_()][e1.index_()](p)[1] << " ";
+ out << stack[e0.index_()][e1.index_()](p)[2] << std::endl;;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ }
+ }
+
+ out << "EOF" <<
std::endl;
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d_vec3");
+
+ return result;
+ }
+
+
+ //----------------------------------------------------------------------
+ // save_image_sh_array_array_image1d_vec2(
+ // const
array<array<image1d<vec<2,T>>>>&,
+ // const string&)
+ //----------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh_array_array_image1d_vec2(
+ const util::array<util::array<image1d<algebra::vec<2,T> > >
>& stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d_vec2");
+
+ typedef algebra::vec<2,T> t_val;
+ typedef image1d<t_val> t_img;
+ typedef util::array<t_img> t_array;
+ typedef util::array<t_array> t_stack;
+
+ mln_precondition(!stack.is_empty());
+ mln_precondition(!stack[0].is_empty());
+ mln_precondition(stack[0][0].is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_ind = geom::min_ind(stack[0][0]);
+ unsigned max_ind = geom::max_ind(stack[0][0]);
+
+ if (result)
+ {
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set xrange [" <<
min_ind;
+ out << ":" <<
max_ind;
+ out << "]" <<
std::endl;
+ out << "splot '-' with line";
+
+ for (unsigned i = 1; i < stack.size(); ++i)
+ {
+ for (unsigned j = 1; j < stack[i].size(); ++j)
+ {
+
+ out << ",\\" << std::endl;
+ out << " '-' with line";
+ }
+ }
+
+ out << std::endl;
+
+ mln_eiter(t_stack) e0(stack);
+
+ for_all (e0)
+ {
+ mln_eiter(t_array) e1(stack[e0.index_()]);
+
+ for_all (e1)
+ {
+ mln_piter(t_img) p(stack[e0.index_()][e1.index_()].domain());
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << stack[e0.index_()][e1.index_()](p)[0] << " ";
+ out << stack[e0.index_()][e1.index_()](p)[1] << std::endl;;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ }
+ }
+
+ out << "EOF" <<
std::endl;
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::"
+ "save_image_sh_array_array_image1d_vec2");
+
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_array_image1d(const array<image1d<I>>&, const
string&)
+ //----------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_array_image1d(const util::array< image1d<I> >&
stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_array_image1d");
+ mln_precondition(!stack.is_empty());
+ mln_precondition(stack[0].is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_ind = geom::min_ind(stack[0]);
+ unsigned max_ind = geom::max_ind(stack[0]);
+
+ if (result)
+ {
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set xrange [" <<
min_ind;
+ out << ":" <<
max_ind;
+ out << "]" <<
std::endl;
+ out << "plot '-' with line";
+
+ for (unsigned i = 1; i < stack.size(); ++i)
+ {
+
+ out << ",\\" <<
std::endl;
+ out << " '-' with line";
+ }
+
+ out << std::endl;
+
+ mln_eiter(util::array< image1d<I> >) e(stack);
+
+ for_all (e)
+ {
+ mln_piter(image1d< I >) p(stack[e.index_()].domain());
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << stack[e.index_()](p) << std::endl;;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ }
+
+ out << "EOF" <<
std::endl;
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_array_image1d");
+ return result;
+ }
+
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image2d_rgb(const image2d<rgb<n>>&, const string&)
+ //----------------------------------------------------------------------
+
+ template <unsigned n>
+ inline
+ bool save_image_sh_image2d_rgb(const image2d<value::rgb<n> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image2d_rgb");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter(image2d< value::rgb<n> >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, r, g, b) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set xrange [" <<
min_col;
+ out << ":" <<
max_col;
+ out << "]" <<
std::endl;
+ out << "set yrange [-" <<
max_row;
+ out << ":" <<
min_row;
+ out << "]" <<
std::endl;
+ out << "plot '-' using 2:(-\\$1):3:4:5 with rgbimage"
<< std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).red() << " ";
+ out << img(p).green() << " ";
+ out << img(p).blue() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image2d_rgb");
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image2d_hsl(const image2d<hsl_<T,T,T>>&, const
string&)
+ //----------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh_image2d_hsl(const image2d<value::hsl_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image2d_hsl");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ typedef mln::value::hsl_<T,T,T> hsl;
+
+ if (result)
+ {
+ mln_piter(image2d< hsl >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "q(l,s) = (l < 0.5)? (l*(1+s)):(l+s-(l*s))" <<
std::endl;
+ out << "p(l,s) = (2.0 * l - q(l,s))" <<
std::endl;
+ out << "n(x) = (x < 0)?(x+1):(x > 1)?(x-1) :
(x)"<< std::endl;
+ out << std::endl;
+ out << "c(p,q,t) = (t <(1.0/6.0))?(p+(q-p)*6.0*t):\\"<<
std::endl;
+ out << " (t <(1.0/2.0))?(q) :\\" <<
std::endl;
+ out << " (t<(2.0/3.0))?(p+(q-p)*6.0*((2.0/3.0)-t)):\\" <<
std::endl;
+ out << " (p)" << std::endl;
+ out << std::endl;
+ out << "r(h,s,l) = c(p(l,s),q(l,s),n(h/360.0+1.0/3.0))"<<
std::endl;
+ out << "g(h,s,l) = c(p(l,s),q(l,s),n(h/360.0))" <<
std::endl;
+ out << "b(h,s,l) = c(p(l,s),q(l,s),n(h/360.0-1.0/3.0))"<<
std::endl;
+ out << std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set palette gray" <<
std::endl;
+ out << "set xrange [" <<
min_col;
+ out << ":" <<
max_col;
+ out << "]" <<
std::endl;
+ out << "set yrange [-" <<
max_row;
+ out << ":" <<
min_row;
+ out << "]" <<
std::endl;
+ out << "plot '-' using 2:(-\\$1):\\"
<< std::endl;
+ out << " (r(\\$3,\\$4,\\$5)):\\" <<
std::endl;
+ out << " (g(\\$3,\\$4,\\$5)):\\" <<
std::endl;
+ out << " (b(\\$3,\\$4,\\$5)) with rgbimage" <<
std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).hue() << " ";
+ out << img(p).sat() << " ";
+ out << img(p).lum() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image2d_hsl");
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image2d_hsi(const image2d<hsi_<T,T,T>>&, const
string&)
+ //----------------------------------------------------------------------
+
+ template <typename T>
+ inline
+ bool save_image_sh_image2d_hsi(const image2d<value::hsi_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image2d_hsi");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ typedef mln::value::hsi_<T,T,T> hsi;
+
+ if (result)
+ {
+ mln_piter(image2d< hsi >) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF"
<< std::endl;
+ out << "teta(h) = (h/180.0) * pi" <<
std::endl;
+ out << "alpha(s,h) = s*cos(teta(h))" <<
std::endl;
+ out << "beta(s,h) = s*sin(teta(h))" <<
std::endl;
+ out << "n(x) = (x < 0)?(x+1) : (x >
1)?(x-1):(x)"<< std::endl;
+ out << std::endl;
+ out << "c(p,q,t) = (t <(1.0/6.0))?(p+(q-p)*6.0*t):\\"<<
std::endl;
+ out << " (t <(1.0/2.0))?(q) :\\" <<
std::endl;
+ out << " (t <(2.0/3.0))?(p+(q-p)*6.0*((2.0/3.0)-t)):\\"<<
std::endl;
+ out << " (p)" << std::endl;
+ out << std::endl;
+ out << "r(h,s,i) = (sqrt(3.0)/3.0) * i \\" <<
std::endl;
+ out << " + (2.0/(sqrt(6.0))) * beta(s,h)" <<
std::endl;
+ out << "g(h,s,i) = (sqrt(3.0)/3.0) * i \\" <<
std::endl;
+ out << " + (2.0/(sqrt(2.0))) * alpha(s,h)\\" <<
std::endl;
+ out << " - (1.0/(sqrt(6.0))) * beta(s,h)" <<
std::endl;
+ out << "b(h,s,i) = (sqrt(3.0)/3.0) * i \\" <<
std::endl;
+ out << " - (2.0/(sqrt(2.0))) * alpha(s,h) \\"<<
std::endl;
+ out << " - (1.0/(sqrt(6.0))) * beta(s,h)" <<
std::endl;
+ out << std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set palette gray" <<
std::endl;
+ out << "set xrange [" <<
min_col;
+ out << ":" <<
max_col;
+ out << "]" <<
std::endl;
+ out << "set yrange [-" <<
max_row;
+ out << ":" <<
min_row;
+ out << "]" <<
std::endl;
+ out << "plot '-' using 2:(-\\$1):\\"
<< std::endl;
+ out << " (r(\\$3,\\$4,\\$5)):\\" <<
std::endl;
+ out << " (g(\\$3,\\$4,\\$5)):\\" <<
std::endl;
+ out << " (b(\\$3,\\$4,\\$5)) with rgbimage" <<
std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p).hue() << " ";
+ out << img(p).sat() << " ";
+ out << img(p).inty() << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:" <<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image2d_hsi");
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image2d(const image2d<I>&, const string&)
+ //----------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_image2d(const image2d<I>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image2d");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+ unsigned min_row = geom::min_row(img);
+ unsigned max_row = geom::max_row(img);
+ unsigned min_col = geom::min_col(img);
+ unsigned max_col = geom::max_col(img);
+
+ if (result)
+ {
+ mln_piter(image2d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, image).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" <<
std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "set palette gray" <<
std::endl;
+ out << "set xrange [" <<
min_col;
+ out << ":" <<
max_col;
+ out << "]" <<
std::endl;
+ out << "set yrange [-" <<
max_row;
+ out << ":" <<
min_row;
+ out << "]" <<
std::endl;
+ out << "plot '-' using 2:(-\\$1):3 with image"
<<std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image2d");
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image1d(const image1d<I>&, const string&)
+ //----------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh_image1d(const image1d<I>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image1d");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+
+ if (result)
+ {
+ mln_piter(image1d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, impulse).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "##########################" <<
std::endl;
+ out << "# Two columns = (x, val) #" <<
std::endl;
+ out << "##########################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" <<
std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "plot '-' with impulse" <<
std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.ind() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image1d");
+ return result;
+ }
+
+ //----------------------------------------------------------------------
+ // save_image_sh_image3d(const image3d<I>&, const string&)
+ //----------------------------------------------------------------------
+
+
+ template <typename I>
+ inline
+ bool save_image_sh_image3d(const image3d<I>& img,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::impl::save_image_sh_image3d");
+ mln_precondition(img.is_valid());
+
+ std::ofstream out(filename.c_str());
+ bool result = !out.fail();
+
+ if (result)
+ {
+ mln_piter(image3d<I>) p(img.domain());
+
+ // Output data prelude (terminal X11, pointtype 0).
+ out << "#!/bin/sh" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << "# Columns = (x, y, z, val) #" <<
std::endl;
+ out << "####################################" <<
std::endl;
+ out << std::endl;
+ out << "gnuplot <<EOF" <<
std::endl;
+ out << "set terminal x11 persist 1" <<
std::endl;
+ out << "splot '-' with points palette pointtype 7" <<
std::endl;
+
+ // Output data.
+ for_all(p)
+ {
+ out << p.row() << " ";
+ out << p.col() << " ";
+ out << p.sli() << " ";
+ out << img(p) << std::endl;
+ }
+
+ // Close gnuplot data stream.
+ out << "e" <<
std::endl;
+ out << "EOF" <<
std::endl;
+
+ out.close();
+ }
+ else
+ {
+ std::cerr << "ERROR[mln::io::plot::save_image_sh]:"<<
filename;
+ std::cerr << " couldn't be opened !!" <<
std::endl;
+ }
+
+ trace::exiting("mln::io::plot::impl::save_image_sh_image3d");
+ return result;
+ }
+
+ } // end of namespace impl
+
+
+ //------------------------------------------------------------------------
+ // Internal.
+ //------------------------------------------------------------------------
+
+ namespace internal
+ {
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const util::array< image1d<I> >& stack,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_array_image1d(stack, filename);
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const util::array<
+ util::array <image1d<I> > >& stack,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_array_array_image1d(stack, filename);
+ }
+
+ template <typename T>
+ inline
+ bool save_image_sh_dispatch(
+ const util::array<util::array<image1d<algebra::vec<3,T> > >
>& stack,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_array_array_image1d_vec3(stack, filename);
+ }
+
+ template <typename T>
+ inline
+ bool save_image_sh_dispatch(
+ const util::array<util::array<image1d<algebra::vec<2,T> > >
>& stack,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_array_array_image1d_vec2(stack, filename);
+ }
+
+ template <unsigned n>
+ inline
+ bool save_image_sh_dispatch(const image2d<value::rgb<n> >& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image2d_rgb(img, filename);
+ }
+
+ template <typename T>
+ inline
+ bool save_image_sh_dispatch(const image2d<value::hsl_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image2d_hsl(img, filename);
+ }
+
+ template <typename T>
+ inline
+ bool save_image_sh_dispatch(const image2d<value::hsi_<T,T,T> >& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image2d_hsi(img, filename);
+ }
+
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const image2d<I>& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image2d(img, filename);
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const image1d<I>& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image1d(img, filename);
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const image3d<I>& img,
+ const std::string& filename)
+ {
+ return impl::save_image_sh_image3d(img, filename);
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh_dispatch(const Image<I>& img,
+ const std::string& filename)
+ {
+ return save_image_sh_dispatch(exact(img), filename);
+ }
+
+ } // end of namespace mln::io::plot::internal
+
+ //------------------------------------------------------------------------
+ // Facade.
+ //------------------------------------------------------------------------
+
+ template <typename I>
+ inline
+ bool save_image_sh(const Image<I>& img, const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh");
+
+ bool result = internal::save_image_sh_dispatch(img, filename);
+
+ trace::exiting("mln::io::plot::save_image_sh");
+ return result;
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh(const util::array< image1d<I> >& stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh");
+
+ bool result = internal::save_image_sh_dispatch(stack, filename);
+
+ trace::exiting("mln::io::plot::save_image_sh");
+ return result;
+ }
+
+ template <typename I>
+ inline
+ bool save_image_sh(const util::array< util::array< image1d<I> >
>& stack,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::plot::save_image_sh");
+
+ bool result = internal::save_image_sh_dispatch(stack, filename);
+
+ trace::exiting("mln::io::plot::save_image_sh");
+ return result;
+ }
+
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::io::plot
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+#endif // ! MLN_IO_PLOT_SAVE_IMAGE_SH_HH
diff --git a/scribo/sandbox/green/mln/math/ceil.hh
b/scribo/sandbox/green/mln/math/ceil.hh
new file mode 100644
index 0000000..6fc08c8
--- /dev/null
+++ b/scribo/sandbox/green/mln/math/ceil.hh
@@ -0,0 +1,64 @@
+// Copyright (C) 2007, 2008, 2009, 2010
+// EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_MATH_CEIL_HH
+# define MLN_MATH_CEIL_HH
+
+/*! \file
+ *
+ * \brief Define the ceil (ceil) routine.
+ */
+
+# include <cmath>
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename T>
+ T ceil(const T& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T ceil(const T& v)
+ {
+ return std::ceil(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_FLOOR_HH
diff --git a/scribo/sandbox/green/mln/math/floor.hh
b/scribo/sandbox/green/mln/math/floor.hh
new file mode 100644
index 0000000..97e63bd
--- /dev/null
+++ b/scribo/sandbox/green/mln/math/floor.hh
@@ -0,0 +1,64 @@
+// Copyright (C) 2007, 2008, 2009, 2010
+// EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef MLN_MATH_FLOOR_HH
+# define MLN_MATH_FLOOR_HH
+
+/*! \file
+ *
+ * \brief Define the floor (floor) routine.
+ */
+
+# include <cmath>
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename T>
+ T floor(const T& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ T floor(const T& v)
+ {
+ return std::floor(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_FLOOR_HH
diff --git a/scribo/sandbox/green/mln/value/hsv.hh
b/scribo/sandbox/green/mln/value/hsv.hh
new file mode 100644
index 0000000..69948d9
--- /dev/null
+++ b/scribo/sandbox/green/mln/value/hsv.hh
@@ -0,0 +1,424 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_HSV_HH
+# define MLN_VALUE_HSV_HH
+
+#include <mln/value/ops.hh>
+
+#include <mln/value/concept/vectorial.hh>
+#include <mln/value/int_u.hh>
+// #include <mln/algebra/vec.hh>
+
+// Used in from_to
+// #include <mln/fun/v2v/rgb_to_hsv.hh>
+
+
+namespace mln
+{
+
+ // Forward declarations.
+ namespace value
+ {
+
+ template <typename H, typename S, typename V>
+ class hsv_;
+
+ }
+
+
+/*
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ // rgb to hsv_
+ void
+ from_to_(const value::rgb<16>& from,
value::hsv_<float,float,float>& to);
+
+ // rgb to hsv_
+ void
+ from_to_(const value::rgb<8>& from,
value::hsv_<float,float,float>& to);
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+*/
+
+
+ namespace trait
+ {
+
+ template <typename H, typename S, typename V>
+ struct set_precise_binary_< op::plus, mln::value::hsv_<H,S,V>,
+ mln::value::hsv_<H,S,V> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+ template <typename H, typename S, typename V>
+ struct set_precise_binary_< op::minus, mln::value::hsv_<H,S,V>,
+ mln::value::hsv_<H,S,V> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+ template <typename H, typename S, typename V, typename S2>
+ struct set_precise_binary_< op::times, mln::value::hsv_<H,S,V>,
+ mln::value::scalar_<S2> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+ template <typename H, typename S, typename V, typename S2>
+ struct set_precise_binary_< op::div, mln::value::hsv_<H,S,V>,
+ mln::value::scalar_<S2> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+
+ // FIXME : Is there any way more generic? a way to factor
+ // set_precise_binary_< op::div, mln::value::hsv_<H,S,V>,
mln::value::scalar_<S> >
+ // and
+ // set_precise_binary_< op::div, mln::value::hsv_<H,S,V>,
mln::value::int_u<m> >
+ // as for op::times.
+
+ template <typename H, typename S, typename V, unsigned m>
+ struct set_precise_binary_< op::times, mln::value::hsv_<H,S,V>,
+ mln::value::int_u<m> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+ template <typename H, typename S, typename V, unsigned m>
+ struct set_precise_binary_< op::div, mln::value::hsv_<H,S,V>,
+ mln::value::int_u<m> >
+ {
+ typedef mln::value::hsv_<H,S,V> ret;
+ };
+
+ template <typename H, typename S, typename V>
+ struct value_< mln::value::hsv_<H,S,V> >
+ {
+ enum {
+ dim = 3,
+ nbits = (sizeof (H) + sizeof (S) + sizeof (V)) * 8,
+ card = mln_value_card_from_(nbits)
+ };
+
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::color kind;
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef void comp;
+ typedef H comp_0;
+ typedef S comp_1;
+ typedef V comp_2;
+
+ template <typename VAL>
+ static comp_0 get_comp_0(const VAL& v) { return v.hue(); }
+
+ template <typename VAL>
+ static comp_1 get_comp_1(const VAL& v) { return v.sat(); }
+
+ template <typename VAL>
+ static comp_2 get_comp_2(const VAL& v) { return v.val(); }
+
+ typedef mln::value::hsv_<H,S,V> sum;
+ };
+
+ } // end of namespace trait
+
+
+ namespace value
+ {
+
+ template <typename E>
+ struct HSV : Object<E>
+ {
+ };
+
+ template <typename H, typename S, typename V>
+ class hsv_ : public HSV< hsv_<H,S,V> >
+ {
+ public:
+
+ typedef H h_type;
+ typedef S s_type;
+ typedef V v_type;
+
+ /// Constructor without argument.
+ hsv_()
+ {
+ }
+
+ hsv_(const literal::zero_t&)
+ : hue_(0),
+ sat_(0),
+ val_(0)
+ {
+ }
+
+ /// Constructor from component values.
+ hsv_(const H& hue, const S& sat, const V& val)
+ : hue_(hue),
+ sat_(sat),
+ val_(val)
+ {
+ }
+
+ /// Read-only access to the hue component.
+ const H& hue() const;
+ const S& sat() const;
+ const V& val() const;
+
+ /// Read-write access to the hue component.
+ H& hue();
+ S& sat();
+ V& val();
+
+ private:
+ //FIXME: Don't we want to store these values in a vector?
+ H hue_;
+ S sat_;
+ V val_;
+ };
+
+
+ typedef hsv_<float, float, float> hsv_f;
+ typedef hsv_<double, double, double> hsv_d;
+
+
+ /// Print an hsv \p c into the output stream \p ostr.
+ ///
+ /// \param[in,out] ostr An output stream.
+ /// \param[in] c An rgb.
+ ///
+ /// \return The modified output stream \p ostr.
+ template <typename H, typename S, typename V>
+ std::ostream& operator<<(std::ostream& ostr, const
hsv_<H,S,V>& c);
+
+
+ /// Addition.
+ /// {
+ template <typename H, typename S, typename V>
+ hsv_<H,S,V>
+ operator+(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs);
+ /// \}
+
+ /// Subtraction.
+ /// \{
+ template <typename H, typename S, typename V>
+ hsv_<H,S,V>
+ operator-(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs);
+ /// \}
+
+ /// Product.
+ /// \{
+ template <typename H, typename S, typename V, typename S2>
+ hsv_<H,S,V>
+ operator*(const hsv_<H,S,V>& lhs, const mln::value::scalar_<S2>&
s);
+ /// \}
+
+ /// Division.
+ /// \{
+ template <typename H, typename S, typename V, typename S2>
+ hsv_<H,S,V>
+ operator/(const hsv_<H,S,V>& lhs, const mln::value::scalar_<S2>&
s);
+ /// \}
+
+ /// Comparison.
+ /// \{
+ template <typename H, typename S, typename V>
+ bool
+ operator==(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs);
+ /// \}
+
+ } // end of namespace mln::value
+
+
+
+ // More forward declarations
+ namespace fun
+ {
+ namespace v2v
+ {
+
+ template <typename T_hsv>
+ struct f_rgb_to_hsv_;
+
+ typedef f_rgb_to_hsv_<value::hsv_f> f_rgb_to_hsv_f_t;
+
+ extern f_rgb_to_hsv_f_t f_rgb_to_hsv_f;
+
+ }
+
+ }
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace value
+ {
+
+ template <typename H, typename S, typename V>
+ const H&
+ hsv_<H,S,V>::hue() const
+ {
+ return this->hue_;
+ }
+
+ template <typename H, typename S, typename V>
+ const S&
+ hsv_<H,S,V>::sat() const
+ {
+ return this->sat_;
+ }
+
+ template <typename H, typename S, typename V>
+ const V&
+ hsv_<H,S,V>::val() const
+ {
+ return this->val_;
+ }
+
+ template <typename H, typename S, typename V>
+ H&
+ hsv_<H,S,V>::hue()
+ {
+ return this->hue_;
+ }
+
+ template <typename H, typename S, typename V>
+ S&
+ hsv_<H,S,V>::sat()
+ {
+ return this->sat_;
+ }
+
+ template <typename H, typename S, typename V>
+ V&
+ hsv_<H,S,V>::val()
+ {
+ return this->val_;
+ }
+
+
+ template <typename H, typename S, typename V>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const
hsv_<H,S,V>& v)
+ {
+ return ostr << '(' << debug::format(v.hue())
+ << ',' << debug::format(v.sat())
+ << ',' << debug::format(v.val())
+ << ')';
+ }
+
+
+ template <typename H, typename S, typename V>
+ hsv_<H,S,V>
+ operator+(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs)
+ {
+ return hsv_<H,S,V>(lhs.hue() + rhs.hue(),
+ lhs.sat() + rhs.sat(),
+ lhs.val() + rhs.val());
+ }
+
+
+ template <typename H, typename S, typename V>
+ hsv_<H,S,V>
+ operator-(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs)
+ {
+ return hsv_<H,S,V>(lhs.hue() - rhs.hue(),
+ lhs.sat() - rhs.sat(),
+ lhs.val() - rhs.val());
+ }
+
+
+ template <typename H, typename S, typename V, typename S2>
+ hsv_<H,S,V>
+ operator*(const hsv_<H,S,V>& lhs, const mln::value::scalar_<S2>&
s)
+ {
+ return hsv_<H,S,V>(lhs.hue() * s,
+ lhs.sat() * s,
+ lhs.val() * s);
+ }
+
+
+ template <typename H, typename S, typename V, typename S2>
+ hsv_<H,S,V>
+ operator/(const hsv_<H,S,V>& lhs, const mln::value::scalar_<S2>&
s)
+ {
+ return hsv_<H,S,V>(lhs.hue() / s,
+ lhs.sat() / s,
+ lhs.val() / s);
+ }
+
+ template <typename H, typename S, typename V>
+ bool
+ operator==(const hsv_<H,S,V>& lhs, const hsv_<H,S,V>& rhs)
+ {
+ return lhs.hue() == rhs.hue()
+ && lhs.sat() == rhs.sat()
+ && lhs.val() == rhs.val();
+ }
+
+ } // end of namespace mln::value
+
+/*
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ inline
+ void
+ from_to_(const value::rgb<16>& from,
value::hsv_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsv_f(from);
+ }
+
+ inline
+ void
+ from_to_(const value::rgb<8>& from,
value::hsv_<float,float,float>& to)
+ {
+ to = fun::v2v::f_rgb_to_hsv_f(from);
+ }
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+*/
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+#endif // ! MLN_VALUE_HSV_HH
diff --git a/scribo/sandbox/green/mln/value/rg.hh b/scribo/sandbox/green/mln/value/rg.hh
new file mode 100644
index 0000000..d083ffd
--- /dev/null
+++ b/scribo/sandbox/green/mln/value/rg.hh
@@ -0,0 +1,175 @@
+// Copyright (C) 2007, 2008, 2009, 2010 EPITA LRDE
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_RG_HH
+# define MLN_VALUE_RG_HH
+
+/// \file
+///
+/// \brief Define the red/green vectorial image type.
+///
+/// This source implements the red/green (RG) vectorial image type. It
+/// is a partial copy of the rgb type. This type doesn't manage
+/// anykind of interaction. Its purpose is limited to store a couple
+/// of values. Do not use it outside this purpose, i can't garantie
+/// the behaviour.
+///
+/// The following sample is a typical use of the rg type.
+///
+/// #include <mln/accu/stat/histo2d.hh>
+/// #include <mln/core/image/image2d.hh>
+/// #include <mln/data/compute.hh>
+/// #include <mln/data/transform.hh>
+/// #include <mln/fun/v2v/rgb_to_rg.hh>
+/// #include <mln/img_path.hh>
+/// #include <mln/io/ppm/load.hh>
+/// #include <mln/value/rg.hh>
+/// #include <mln/value/rgb8.hh>
+///
+/// int main()
+/// {
+/// typedef mln::value::rg<8> t_rg8
+/// typedef mln::value::rgb8 t_rgb8;
+/// typedef mln::fun::v2v::rgb_to_rg<8> t_rgb_to_rg;
+/// typedef mln::image2d<t_rg8> t_image2d_rg8;
+/// typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+/// typedef mln::image2d<unsigned> t_histo;
+/// t_image2d_rgb8 img_rgb8;
+/// t_image2d_rg8 img_rg8;
+/// t_histo histo;
+///
+/// mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+/// img_rg8 = mln::data::transform(img_rgb8, t_rgb_to_rg());
+/// histo = mln::data::compute(mln::accu::meta::stat::histo2d(), img_rg8);
+///
+/// return 0;
+/// }
+
+
+# include <mln/algebra/vec.hh>
+# include <mln/value/concept/vectorial.hh>
+# include <mln/value/int_u.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/trait/value_.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ // Forward declaration.
+ template <unsigned n> struct rg;
+
+ } // end of namespace mln::value
+
+ namespace trait
+ {
+
+ template <unsigned n>
+ struct value_< mln::value::rg<n> >
+ {
+ enum {
+ dim = 2,
+ nbits = dim * n,
+ card = mln_value_card_from_(nbits)
+ };
+
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::color kind;
+ typedef trait::value::quant::high quant;
+
+ typedef void comp;
+ typedef mln::value::int_u<n> comp_0;
+ typedef mln::value::int_u<n> comp_1;
+
+ static comp_0 get_comp_0(const mln::value::rg<n>& v){return v.red(); }
+ static comp_1 get_comp_1(const mln::value::rg<n>& v){return v.green();}
+
+ typedef algebra::vec<dim, float> sum;
+
+ static const char* name()
+ {
+ static std::string s = std::string("rg").append(1, 8 + '0');
+ return s.c_str();
+ }
+ };
+
+ } // end of namespace mln::trait
+
+ namespace value
+ {
+
+ /// \brief Define the red/green vectorial image type.
+ ///
+ /// Param n defines the quantification used for red/green space.
+
+ template <unsigned n>
+ struct rg :public mln::value::Vectorial< rg<n> >,
+ public internal::value_like_<
+ algebra::vec< 2, int_u<n> >, // Equivalent.
+ algebra::vec< 2, int_u<n> >, // Encoding.
+ algebra::vec< 2, int >, // Interoperation.
+ rg<n> > // Exact.
+ {
+ typedef int_u<n> t_red;
+ typedef int_u<n> t_green;
+
+ int_u<n> red() const {return this->v_[0];}
+ int_u<n>& red() {return this->v_[0];}
+ int_u<n> green() const {return this->v_[1];}
+ int_u<n>& green() {return this->v_[1];}
+
+ /// Constructors
+ /// \{
+ /// \brief Create a rg value.
+ ///
+ /// Two constructors exist, the first one do nothing and the second one
+ /// initializes the red/green components from a rgb value.
+ rg(){}
+ rg(const rgb8& val){this->v_[0] = val.red(); this->v_[1] = val.green();}
+ /// \}
+
+ /// \brief Affect a rg value to this object.
+ /// \param[in] rhs the value to affect to this object.
+ ///
+ /// If the two objects are different, then then copy the
+ /// underline array of values.
+
+ rg operator=(const rg& rhs)
+ {
+ if (&rhs != this)
+ this->v_ = rhs.v_;
+
+ return *this;
+ }
+ };
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ! MLN_VALUE_RG_HH
diff --git a/scribo/sandbox/green/tests/accu/stat/histo1d/Makefile.am
b/scribo/sandbox/green/tests/accu/stat/histo1d/Makefile.am
new file mode 100644
index 0000000..77f9015
--- /dev/null
+++ b/scribo/sandbox/green/tests/accu/stat/histo1d/Makefile.am
@@ -0,0 +1,153 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+#LOADLIBES= -lboost_filesystem
+INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
+INCLUDES2= -I$(HOME)/git/olena/milena
+INCLUDES= $(INCLUDES1) $(INCLUDES2)
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+ECHO= echo
+RM= rm
+MKDIR= mkdir -p
+CP= cp
+
+SOURCE_PATTERN= green/tests
+BUILD__PATTERN= green/build/tests
+
+
+ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
+# Case where make is done from build directory.
+SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
+BUILD__DIR= $(PWD)/
+else
+# Case where make is done from source directory.
+SOURCE_DIR= $(PWD)/
+BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
+endif
+
+SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
+OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
+OBJ= $(patsubst %.cc,%.o,$(SRC))
+SOURCE_MAKEFILE=Makefile.am
+BUILD__MAKEFILE=Makefile
+TARGET_FILE= $(notdir $(PWD))
+SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
+BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
+
+BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
+SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
+
+BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
+SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
+
+TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
+OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
+SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
+OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
+
+#############
+# BOOTSTRAP #
+#############
+
+
+bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
+
+# Create, if nessary, the destination directory
+$(BUILD__DIR):
+ $(MKDIR) $(BUILD__DIR)
+
+# Copy, if nessary, all the files, except the Makefile.am
+$(BUILD__F_PATH): $(SOURCE_F_PATH)
+ $(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
+
+# Copy if nessary, the Makefile.am into Makefile
+$(BUILD__M_PATH): $(SOURCE_M_PATH)
+ $(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
+
+
+#######
+# ALL #
+#######
+
+# We assume that the call is done from the build directory.
+# With the directive vpath, hidden files are found in the source directory.
+
+all: $(TARGET_F_PATH)
+
+
+$(TARGET_F_PATH): $(OBJ_F_PATH)
+ $(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
+
+$(OBJ_F_PATH):$(SRC_F_PATH)
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+
+
+#########
+# CLEAN #
+#########
+
+# Force every time the deletion
+clean: clean_target clean_obj clean_dst clean_old #clean_make
+
+
+clean_target:
+ -@$(RM) $(TARGET_F_PATH) &> /dev/null
+
+clean_obj:
+ -@$(RM) $(OBJ_F_PATH) &> /dev/null
+
+clean_dst:
+ -@$(RM) $(BUILD_F_PATH) &> /dev/null
+
+clean_make:
+ -@$(RM) $(BUILD_M_PATH) &> /dev/null
+
+clean_old:
+ -@$(RM) $(OLD_F_PATH) &> /dev/null
+
+
+#########
+# PRINT #
+#########
+
+print: print_tools print_bootstrap
+
+print_tools:
+ @$(ECHO) "HOME = $(HOME)"
+ @$(ECHO) "INCLUDES = $(INCLUDES)"
+ @$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
+ @$(ECHO) "ECHO = $(ECHO)"
+ @$(ECHO) "RM = $(RM)"
+ @$(ECHO) "MKDIR = $(MKDIR)"
+ @$(ECHO) "CP = $(CP)"
+ @$(ECHO)
+
+print_bootstrap:
+ @$(ECHO) "PWD = $(PWD)"
+ @$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
+ @$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
+ @$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
+ @$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
+ @$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
+ @$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
+ @$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
+ @$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
+ @$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
+ @$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
+ @$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
+ @$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
+ @$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
+ @$(ECHO) "SRC = $(SRC)"
+ @$(ECHO) "OBJ = $(OBJ)"
+ @$(ECHO) "OLD = $(OLD)"
+ @$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
+ @$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
+ @$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
+ @$(ECHO)
diff --git a/scribo/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
b/scribo/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
new file mode 100644
index 0000000..5a5c4c4
--- /dev/null
+++ b/scribo/sandbox/green/tests/accu/stat/histo1d/histo1d.cc
@@ -0,0 +1,21 @@
+/// TEST HISTO1D
+
+#include <mln/accu/stat/histo1d.hh>
+#include <mln/data/compute.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/img_path.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/value/int_u8.hh>
+
+int main()
+{
+ typedef mln::value::int_u8 t_int_u8;
+ mln::image2d<t_int_u8> img;
+ mln::image1d<unsigned> histo;
+
+ mln::io::pgm::load(img, OLENA_IMG_PATH"/lena.pgm");
+ histo = mln::data::compute(mln::accu::meta::stat::histo1d(), img);
+
+ return 0;
+}
diff --git a/scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am
b/scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am
new file mode 100644
index 0000000..a96b2e9
--- /dev/null
+++ b/scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am
@@ -0,0 +1,153 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+#LOADLIBES= -lboost_filesystem
+INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
+INCLUDES2= -I$(HOME)/git/olena/milena
+INCLUDES= $(INCLUDES1) $(INCLUDES2)
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+ECHO= echo
+RM= rm
+MKDIR= mkdir -p
+CP= cp
+
+SOURCE_PATTERN= green/use
+BUILD__PATTERN= green/build/use
+
+
+ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
+# Case where make is done from build directory.
+SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
+BUILD__DIR= $(PWD)/
+else
+# Case where make is done from source directory.
+SOURCE_DIR= $(PWD)/
+BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
+endif
+
+SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
+OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
+OBJ= $(patsubst %.cc,%.o,$(SRC))
+SOURCE_MAKEFILE=Makefile.am
+BUILD__MAKEFILE=Makefile
+TARGET_FILE= $(notdir $(PWD))
+SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
+BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
+
+BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
+SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
+
+BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
+SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
+
+TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
+OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
+SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
+OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
+
+#############
+# BOOTSTRAP #
+#############
+
+
+bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
+
+# Create, if nessary, the destination directory
+$(BUILD__DIR):
+ $(MKDIR) $(BUILD__DIR)
+
+# Copy, if nessary, all the files, except the Makefile.am
+$(BUILD__F_PATH): $(SOURCE_F_PATH)
+ $(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
+
+# Copy if nessary, the Makefile.am into Makefile
+$(BUILD__M_PATH): $(SOURCE_M_PATH)
+ $(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
+
+
+#######
+# ALL #
+#######
+
+# We assume that the call is done from the build directory.
+# With the directive vpath, hidden files are found in the source directory.
+
+all: $(TARGET_F_PATH)
+
+
+$(TARGET_F_PATH): $(OBJ_F_PATH)
+ $(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
+
+$(OBJ_F_PATH):$(SRC_F_PATH)
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+
+
+#########
+# CLEAN #
+#########
+
+# Force every time the deletion
+clean: clean_target clean_obj clean_dst clean_old #clean_make
+
+
+clean_target:
+ -@$(RM) $(TARGET_F_PATH) &> /dev/null
+
+clean_obj:
+ -@$(RM) $(OBJ_F_PATH) &> /dev/null
+
+clean_dst:
+ -@$(RM) $(BUILD_F_PATH) &> /dev/null
+
+clean_make:
+ -@$(RM) $(BUILD_M_PATH) &> /dev/null
+
+clean_old:
+ -@$(RM) $(OLD_F_PATH) &> /dev/null
+
+
+#########
+# PRINT #
+#########
+
+print: print_tools print_bootstrap
+
+print_tools:
+ @$(ECHO) "HOME = $(HOME)"
+ @$(ECHO) "INCLUDES = $(INCLUDES)"
+ @$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
+ @$(ECHO) "ECHO = $(ECHO)"
+ @$(ECHO) "RM = $(RM)"
+ @$(ECHO) "MKDIR = $(MKDIR)"
+ @$(ECHO) "CP = $(CP)"
+ @$(ECHO)
+
+print_bootstrap:
+ @$(ECHO) "PWD = $(PWD)"
+ @$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
+ @$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
+ @$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
+ @$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
+ @$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
+ @$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
+ @$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
+ @$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
+ @$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
+ @$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
+ @$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
+ @$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
+ @$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
+ @$(ECHO) "SRC = $(SRC)"
+ @$(ECHO) "OBJ = $(OBJ)"
+ @$(ECHO) "OLD = $(OLD)"
+ @$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
+ @$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
+ @$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
+ @$(ECHO)
diff --git a/scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc
b/scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc
new file mode 100644
index 0000000..1c6176b
--- /dev/null
+++ b/scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc
@@ -0,0 +1,24 @@
+/// \file
+///
+/// \brief Minimal code for building 1d image histogram version.
+///
+
+#include <mln/accu/stat/histo1d.hh>
+#include <mln/data/compute.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/img_path.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/value/int_u8.hh>
+
+int main()
+{
+ typedef mln::value::int_u8 t_int_u8;
+ mln::image2d<t_int_u8> img;
+ mln::image1d<unsigned> histo;
+
+ mln::io::pgm::load(img, OLENA_IMG_PATH"/lena.pgm");
+ histo = mln::data::compute(mln::accu::meta::stat::histo1d(), img);
+
+ return 0;
+}
diff --git a/scribo/sandbox/green/use/accu/stat/histo2d/Makefile.am
b/scribo/sandbox/green/use/accu/stat/histo2d/Makefile.am
new file mode 100644
index 0000000..a96b2e9
--- /dev/null
+++ b/scribo/sandbox/green/use/accu/stat/histo2d/Makefile.am
@@ -0,0 +1,153 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+#LOADLIBES= -lboost_filesystem
+INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
+INCLUDES2= -I$(HOME)/git/olena/milena
+INCLUDES= $(INCLUDES1) $(INCLUDES2)
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+ECHO= echo
+RM= rm
+MKDIR= mkdir -p
+CP= cp
+
+SOURCE_PATTERN= green/use
+BUILD__PATTERN= green/build/use
+
+
+ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
+# Case where make is done from build directory.
+SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
+BUILD__DIR= $(PWD)/
+else
+# Case where make is done from source directory.
+SOURCE_DIR= $(PWD)/
+BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
+endif
+
+SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
+OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
+OBJ= $(patsubst %.cc,%.o,$(SRC))
+SOURCE_MAKEFILE=Makefile.am
+BUILD__MAKEFILE=Makefile
+TARGET_FILE= $(notdir $(PWD))
+SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
+BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
+
+BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
+SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
+
+BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
+SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
+
+TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
+OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
+SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
+OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
+
+#############
+# BOOTSTRAP #
+#############
+
+
+bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
+
+# Create, if nessary, the destination directory
+$(BUILD__DIR):
+ $(MKDIR) $(BUILD__DIR)
+
+# Copy, if nessary, all the files, except the Makefile.am
+$(BUILD__F_PATH): $(SOURCE_F_PATH)
+ $(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
+
+# Copy if nessary, the Makefile.am into Makefile
+$(BUILD__M_PATH): $(SOURCE_M_PATH)
+ $(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
+
+
+#######
+# ALL #
+#######
+
+# We assume that the call is done from the build directory.
+# With the directive vpath, hidden files are found in the source directory.
+
+all: $(TARGET_F_PATH)
+
+
+$(TARGET_F_PATH): $(OBJ_F_PATH)
+ $(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
+
+$(OBJ_F_PATH):$(SRC_F_PATH)
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+
+
+#########
+# CLEAN #
+#########
+
+# Force every time the deletion
+clean: clean_target clean_obj clean_dst clean_old #clean_make
+
+
+clean_target:
+ -@$(RM) $(TARGET_F_PATH) &> /dev/null
+
+clean_obj:
+ -@$(RM) $(OBJ_F_PATH) &> /dev/null
+
+clean_dst:
+ -@$(RM) $(BUILD_F_PATH) &> /dev/null
+
+clean_make:
+ -@$(RM) $(BUILD_M_PATH) &> /dev/null
+
+clean_old:
+ -@$(RM) $(OLD_F_PATH) &> /dev/null
+
+
+#########
+# PRINT #
+#########
+
+print: print_tools print_bootstrap
+
+print_tools:
+ @$(ECHO) "HOME = $(HOME)"
+ @$(ECHO) "INCLUDES = $(INCLUDES)"
+ @$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
+ @$(ECHO) "ECHO = $(ECHO)"
+ @$(ECHO) "RM = $(RM)"
+ @$(ECHO) "MKDIR = $(MKDIR)"
+ @$(ECHO) "CP = $(CP)"
+ @$(ECHO)
+
+print_bootstrap:
+ @$(ECHO) "PWD = $(PWD)"
+ @$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
+ @$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
+ @$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
+ @$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
+ @$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
+ @$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
+ @$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
+ @$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
+ @$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
+ @$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
+ @$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
+ @$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
+ @$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
+ @$(ECHO) "SRC = $(SRC)"
+ @$(ECHO) "OBJ = $(OBJ)"
+ @$(ECHO) "OLD = $(OLD)"
+ @$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
+ @$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
+ @$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
+ @$(ECHO)
diff --git a/scribo/sandbox/green/use/accu/stat/histo2d/histo2d.cc
b/scribo/sandbox/green/use/accu/stat/histo2d/histo2d.cc
new file mode 100644
index 0000000..6369b5a
--- /dev/null
+++ b/scribo/sandbox/green/use/accu/stat/histo2d/histo2d.cc
@@ -0,0 +1,33 @@
+/// \file
+///
+/// \brief Minimal code for building 2d image histogram version.
+///
+
+#include <mln/accu/stat/histo2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/data/compute.hh>
+#include <mln/data/transform.hh>
+#include <mln/fun/v2v/rgb_to_rg.hh>
+#include <mln/img_path.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/value/rg.hh>
+#include <mln/value/rgb8.hh>
+
+int main()
+{
+ typedef mln::value::rg<8> t_rg8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::fun::v2v::rgb_to_rg<8> t_rgb_to_rg;
+ typedef mln::image2d<t_rg8> t_image2d_rg8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<unsigned> t_histo;
+ t_image2d_rgb8 img_rgb8;
+ t_image2d_rg8 img_rg8;
+ t_histo histo;
+
+ mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm");
+ img_rg8 = mln::data::transform(img_rgb8, t_rgb_to_rg());
+ histo = mln::data::compute(mln::accu::meta::stat::histo2d(), img_rg8);
+
+ return 0;
+}
--
1.5.6.5