Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
February 2010
- 6 participants
- 91 discussions
24 Feb '10
Work around the regional labeling chain and experiment it on the
annoting database.
* green/exp/labeling/regional_maxima/Makefile.am: Add boost library.
* green/exp/labeling/regional_maxima/regional_maxima.cc: Count colors.
---
.../green/exp/labeling/regional_maxima/Makefile.am | 1 +
.../labeling/regional_maxima/regional_maxima.cc | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
index ab76e18..8e204c6 100644
--- a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
+++ b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
@@ -6,6 +6,7 @@
# TOOLS #
#########
+LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
index 28b6b88..a66c1b7 100644
--- a/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
+++ b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
@@ -98,10 +98,10 @@ unsigned count_image_color(const std::string& image)
input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
// FIXME UTILISER UN PREDICAT COMME FUN::CHESS
- histo = mln::data::compute(t_histo3d_fun(), input_rgbn | mln::pw::value(0));
-// return mln::data::compute(t_count_fun(), input_rgbn);
+ histo = mln::data::compute(t_histo3d_fun(), input_rgbn);
+ return mln::data::compute(t_count_fun(), histo);
// FIXME REALISER UN COUNT AVEC UN PREDICA SUR L'IMAGE
- return nb_pixel;
+ //return nb_pixel;
// opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
// label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
--
1.5.6.5
1
0
last-svn-commit-9-g4e56a00 Test clipart operators described by Millet on annoting database.
by green 24 Feb '10
by green 24 Feb '10
24 Feb '10
* green/exp/annoting/nb_color: New experimentation directory.
* green/exp/annoting/nb_color/Makefile.am: New Makefile.
* green/exp/annoting/nb_color/nb_color.cc: New experementation.
* green/exp/annoting/stddev_color: New experimentation directory.
* green/exp/annoting/stddev_color/Makefile.am: New Makefile.
* green/exp/annoting/stddev_color/stddev_color.cc: New experimentation.
---
.../nb_color}/Makefile.am | 1 +
.../green/exp/annoting/nb_color/nb_color.cc | 131 ++++++++++++++++++++
.../stddev_color}/Makefile.am | 1 +
.../annoting/stddev_color/stddev_color.cc | 73 ++++++++----
4 files changed, 184 insertions(+), 22 deletions(-)
copy milena/sandbox/green/exp/{labeling/regional_maxima => annoting/nb_color}/Makefile.am (99%)
create mode 100644 milena/sandbox/green/exp/annoting/nb_color/nb_color.cc
copy milena/sandbox/green/exp/{labeling/regional_maxima => annoting/stddev_color}/Makefile.am (99%)
copy milena/sandbox/green/{demo => exp}/annoting/stddev_color/stddev_color.cc (63%)
diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am b/milena/sandbox/green/exp/annoting/nb_color/Makefile.am
similarity index 99%
copy from milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
copy to milena/sandbox/green/exp/annoting/nb_color/Makefile.am
index ab76e18..8e204c6 100644
--- a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
+++ b/milena/sandbox/green/exp/annoting/nb_color/Makefile.am
@@ -6,6 +6,7 @@
# TOOLS #
#########
+LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
diff --git a/milena/sandbox/green/exp/annoting/nb_color/nb_color.cc b/milena/sandbox/green/exp/annoting/nb_color/nb_color.cc
new file mode 100644
index 0000000..6dd9c26
--- /dev/null
+++ b/milena/sandbox/green/exp/annoting/nb_color/nb_color.cc
@@ -0,0 +1,131 @@
+// COUNTING THE IMAGE COLORS
+
+#include <iostream>
+#include <sstream>
+#include <boost/filesystem.hpp>
+
+#include <mln/img_path.hh>
+
+#include <mln/accu/math/count.hh>
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/binarization/threshold.hh>
+
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+// #include <mln/morpho/opening/volume.hh>
+
+#include <mln/io/ppm/load.hh>
+
+#include <mln/pw/value.hh>
+#include <mln/pw/cst.hh>
+
+#include <mln/util/timer.hh>
+
+#include <mln/value/rgb8.hh>
+//#include <mln/value/rgb.hh>
+
+// FIXME
+// Pour la classification des images, pour gagner du temps,
+// peut être peut-on réduire toutes les images à 100x100 avec 2^5 couleurs ?
+
+// n < 8, n is the degree of quantification
+template <unsigned n>
+unsigned count_image_color(const std::string& image)
+{
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image3d<bool> t_histo3d_bool;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::meta::math::count t_count_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgbn input_rgbn;
+ t_image2d_rgbn output_rgbn;
+ t_histo3d histo;
+// t_histo3d opened;
+ t_histo3d_bool filtered;
+
+ mln::io::ppm::load(input_rgb8, image.c_str());
+
+ unsigned nb_pixel = input_rgb8.ncols() * input_rgb8.nrows();
+ unsigned min_volume = (unsigned)(nb_pixel * 0.0001);
+ unsigned nb_color = 0;
+
+// input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
+ histo = mln::data::compute(t_histo3d_fun(), input_rgb8);
+// opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
+ filtered = mln::binarization::threshold(histo, min_volume);
+ nb_color = mln::data::compute(t_count_fun(),
+ (filtered|(mln::pw::value(filtered)!=0)).rw());
+
+ return nb_color;
+}
+
+int main()
+{
+ typedef boost::filesystem::path t_path;
+ //typedef boost::filesystem::initial_path<t_path()> t_init_path;
+ typedef boost::filesystem::directory_iterator t_iter_path;
+
+ t_path full_path[] = {t_path(ANNOTING_BILL_IMG_PATH),
+ t_path(ANNOTING_FAX_IMG_PATH),
+ t_path(ANNOTING_HANDWRITTEN_IMG_PATH),
+ t_path(ANNOTING_LOGO_IMG_PATH),
+ t_path(ANNOTING_MAP_IMG_PATH),
+ t_path(ANNOTING_PHOTO_IMG_PATH),
+ t_path(ANNOTING_SCREENSHOT_IMG_PATH),
+ t_path(ANNOTING_SLIDE_IMG_PATH),
+ t_path(ANNOTING_TYPED_IMG_PATH)};
+
+ for (int i = 0; i < 9; ++i)
+ {
+ std::cerr << "entering " << full_path[i] << std::endl;
+ std::cout << "entering " << full_path[i] << std::endl;
+
+ if (boost::filesystem::exists(full_path[i]) &&
+ boost::filesystem::is_directory(full_path[i]))
+ {
+ boost::filesystem::system_complete(full_path[i]);
+ const t_iter_path end_iter;
+ unsigned count = 0;
+ unsigned sum1 = 0;
+ unsigned sum2 = 0;
+
+ for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter)
+ {
+ unsigned val = count_image_color<8>(dir_iter->path().string());
+
+ ++count;
+ sum1 += val;
+ sum2 += val*val;
+
+ std::cout << dir_iter->path().string() << " => " << val << std::endl;
+ // FIXME NB COULEURS BRUTES
+ // FIXME NB DE COULEURS
+ // FIXME LISTE DES COULEURS
+ // IMPORTANCES
+ }
+
+ float mean = sum1 / count;
+ float var = ((float)sum2 / count) - (mean * mean);
+
+ std::cout << "mean : " << mean << std::endl;
+ std::cout << "var : " << var << std::endl;
+ }
+ }
+
+ return 0;
+}
diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am b/milena/sandbox/green/exp/annoting/stddev_color/Makefile.am
similarity index 99%
copy from milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
copy to milena/sandbox/green/exp/annoting/stddev_color/Makefile.am
index ab76e18..8e204c6 100644
--- a/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
+++ b/milena/sandbox/green/exp/annoting/stddev_color/Makefile.am
@@ -6,6 +6,7 @@
# TOOLS #
#########
+LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
diff --git a/milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc b/milena/sandbox/green/exp/annoting/stddev_color/stddev_color.cc
similarity index 63%
copy from milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc
copy to milena/sandbox/green/exp/annoting/stddev_color/stddev_color.cc
index 0782e9c..652b8a8 100644
--- a/milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc
+++ b/milena/sandbox/green/exp/annoting/stddev_color/stddev_color.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
+#include <boost/filesystem.hpp>
#include <mln/img_path.hh>
@@ -11,9 +12,6 @@
#include <mln/core/macros.hh>
#include <mln/core/image/image1d.hh>
#include <mln/core/image/image2d.hh>
-#include <mln/core/image/image3d.hh>
-
-#include <mln/debug/println.hh>
#include <mln/data/compute.hh>
#include <mln/data/fill.hh>
@@ -22,8 +20,6 @@
#include <mln/fun/v2v/rgb8_to_int_u8.hh>
#include <mln/io/ppm/load.hh>
-#include <mln/io/pgm/save.hh>
-#include <mln/io/plot/save_image_sh.hh>
#include <mln/math/sqr.hh>
@@ -43,7 +39,7 @@ float r(short p, unsigned histo_p, short x, unsigned histo_x)
return result;
}
-unsigned stddev_color(const std::string& image)
+float stddev_color(const std::string& image)
{
typedef mln::point1d t_point1d;
typedef mln::value::rgb8 t_rgb8;
@@ -64,10 +60,6 @@ unsigned stddev_color(const std::string& image)
input_int_u8 = mln::data::transform(input_rgb8, t_rgb8_to_int_u8());
histo = mln::data::compute(t_histo1d_fun(), input_int_u8);
- mln::io::pgm::save(input_int_u8, "tmp.pgm");
- mln::io::plot::save_image_sh(histo, "histo.sh");
- mln::debug::println(histo);
-
// Find the peak of the histogram
unsigned v_max = mln::opt::at(histo, 0);
short p_max = 0;
@@ -102,23 +94,60 @@ unsigned stddev_color(const std::string& image)
stddev = (250 < p_max)? stddev_low : (5 > p_max)? stddev_up :
(stddev_low + stddev_up)/2;
- std::cout << "max_site : " << p_max << std::endl;
- std::cout << "h(max_site) : " << v_max << std::endl;
- std::cout << "stddev_up : " << stddev_up << std::endl;
- std::cout << "stddev_low : " << stddev_low << std::endl;
- std::cout << "stddev : " << stddev << std::endl;
-
- return 0;
+ return stddev;
}
-
int main()
{
-// unsigned val = stdev_color(ANNOTING_PHOTO_IMG_PATH "/photo01.ppm");
- unsigned val = stddev_color(ANNOTING_LOGO_IMG_PATH "/logo06.ppm");
+ typedef boost::filesystem::path t_path;
+ typedef boost::filesystem::directory_iterator t_iter_path;
+
+ t_path full_path[] = {t_path(ANNOTING_BILL_IMG_PATH),
+ t_path(ANNOTING_FAX_IMG_PATH),
+ t_path(ANNOTING_HANDWRITTEN_IMG_PATH),
+ t_path(ANNOTING_LOGO_IMG_PATH),
+ t_path(ANNOTING_MAP_IMG_PATH),
+ t_path(ANNOTING_PHOTO_IMG_PATH),
+ t_path(ANNOTING_SCREENSHOT_IMG_PATH),
+ t_path(ANNOTING_SLIDE_IMG_PATH),
+ t_path(ANNOTING_TYPED_IMG_PATH)};
+
+ for (int i = 0; i < 9; ++i)
+ {
+ std::cerr << "entering " << full_path[i] << std::endl;
+ std::cout << "entering " << full_path[i] << std::endl;
-// std::cout << "nb color : " << val << std::endl;
+ if (boost::filesystem::exists(full_path[i]) &&
+ boost::filesystem::is_directory(full_path[i]))
+ {
+ boost::filesystem::system_complete(full_path[i]);
+ const t_iter_path end_iter;
+ float count = 0;
+ float sum1 = 0;
+ float sum2 = 0;
+
+ for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter)
+ {
+ float val = stddev_color(dir_iter->path().string());
+
+ ++count;
+ sum1 += val;
+ sum2 += val*val;
+
+ std::cout << dir_iter->path().string() << " => " << val << std::endl;
+ // FIXME NB COULEURS BRUTES
+ // FIXME NB DE COULEURS
+ // FIXME LISTE DES COULEURS
+ // IMPORTANCES
+ }
+
+ float mean = sum1 / count;
+ float var = ((float)sum2 / count) - (mean * mean);
+
+ std::cout << "mean : " << mean << std::endl;
+ std::cout << "var : " << var << std::endl;
+ }
+ }
return 0;
}
-
--
1.5.6.5
1
0
24 Feb '10
Introduce clipart operators described by Millet.
* green/demo/annoting/nb_color: New demonstration directory.
* green/demo/annoting/nb_color/Makefile.am: New Makefile.
* green/demo/annoting/nb_color/nb_color.cc: New source file.
* green/demo/annoting/stddev_color: New demonstration directory.
* green/demo/annoting/stddev_color/Makefile.am: New Makefile.
* green/demo/annoting/stddev_color/stddev_color.cc: New source file.
---
milena/sandbox/ChangeLog | 12 ++
.../demo/annoting/{bic => nb_color}/Makefile.am | 0
.../green/demo/annoting/nb_color/nb_color.cc | 101 ++++++++++++++++
.../annoting/{bic => stddev_color}/Makefile.am | 0
.../demo/annoting/stddev_color/stddev_color.cc | 124 ++++++++++++++++++++
5 files changed, 237 insertions(+), 0 deletions(-)
copy milena/sandbox/green/demo/annoting/{bic => nb_color}/Makefile.am (100%)
create mode 100644 milena/sandbox/green/demo/annoting/nb_color/nb_color.cc
copy milena/sandbox/green/demo/annoting/{bic => stddev_color}/Makefile.am (100%)
create mode 100644 milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index aed61bf..db8bd10 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-15 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Introduce clipart operators described by Millet.
+
+ * green/demo/annoting/nb_color: New demonstration directory.
+ * green/demo/annoting/nb_color/Makefile.am: New Makefile.
+ * green/demo/annoting/nb_color/nb_color.cc: New source file.
+
+ * green/demo/annoting/stddev_color: New demonstration directory.
+ * green/demo/annoting/stddev_color/Makefile.am: New Makefile.
+ * green/demo/annoting/stddev_color/stddev_color.cc: New source file.
+
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Optimize regional maxima processing for statistical counts and outputs.
diff --git a/milena/sandbox/green/demo/annoting/bic/Makefile.am b/milena/sandbox/green/demo/annoting/nb_color/Makefile.am
similarity index 100%
copy from milena/sandbox/green/demo/annoting/bic/Makefile.am
copy to milena/sandbox/green/demo/annoting/nb_color/Makefile.am
diff --git a/milena/sandbox/green/demo/annoting/nb_color/nb_color.cc b/milena/sandbox/green/demo/annoting/nb_color/nb_color.cc
new file mode 100644
index 0000000..9ad5666
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/nb_color/nb_color.cc
@@ -0,0 +1,101 @@
+// COUNTING THE IMAGE COLORS
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/img_path.hh>
+
+#include <mln/accu/math/sum.hh>
+#include <mln/accu/math/count.hh>
+#include <mln/accu/stat/histo3d_rgb.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/accu/stat/variance.hh>
+
+#include <mln/algebra/vec.hh>
+
+#include <mln/arith/diff_abs.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/routine/initialize.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/labeling/mean_values.hh>
+#include <mln/labeling/compute.hh>
+
+#include <mln/literal/colors.hh>
+
+#include <mln/morpho/opening/volume.hh>
+#include <mln/morpho/elementary/dilation.hh>
+
+#include <mln/opt/at.hh>
+
+#include <mln/pw/cst.hh>
+
+#include <mln/util/array.hh>
+#include <mln/util/timer.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/int_u.hh>
+
+
+// n < 8, n is the degree of quantification
+template <unsigned n>
+unsigned count_image_color(const std::string& image)
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::meta::math::count t_count_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgbn input_rgbn;
+ t_image2d_rgbn output_rgbn;
+ t_histo3d histo;
+ t_histo3d opened;
+
+ mln::io::ppm::load(input_rgb8, image.c_str());
+
+ unsigned nb_pixel = input_rgb8.ncols() * input_rgb8.nrows();
+// unsigned min_volume = (unsigned)(nb_pixel * 0.054);
+ unsigned nb_color = 0;
+
+ input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
+ histo = mln::data::compute(t_histo3d_fun(), input_rgbn);
+ nb_color = mln::data::compute(t_count_fun(),
+ (histo | (mln::pw::value(histo) != 0)).rw());
+
+ return nb_color;
+}
+
+
+int main()
+{
+ unsigned val = count_image_color<8>(ANNOTING_PHOTO_IMG_PATH "/photo01.ppm");
+
+ std::cout << "nb color : " << val << std::endl;
+
+ return 0;
+}
+
diff --git a/milena/sandbox/green/demo/annoting/bic/Makefile.am b/milena/sandbox/green/demo/annoting/stddev_color/Makefile.am
similarity index 100%
copy from milena/sandbox/green/demo/annoting/bic/Makefile.am
copy to milena/sandbox/green/demo/annoting/stddev_color/Makefile.am
diff --git a/milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc b/milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc
new file mode 100644
index 0000000..0782e9c
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/stddev_color/stddev_color.cc
@@ -0,0 +1,124 @@
+// COMPUTING THE STDEV OF THE COLORS
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/img_path.hh>
+
+#include <mln/accu/max_site.hh>
+#include <mln/accu/stat/histo1d.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/fun/v2v/rgb8_to_int_u8.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/plot/save_image_sh.hh>
+
+#include <mln/math/sqr.hh>
+
+#include <mln/opt/at.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/int_u.hh>
+
+
+// FIXME REPARER L'ACCUMULATEUR MAX_SITE
+// FIXME PENSER LA VARIANCE SUR UN HISTOGRAMME NORMALISE, VOIR LES RESULTATS
+
+float r(short p, unsigned histo_p, short x, unsigned histo_x)
+{
+ float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p));
+
+ return result;
+}
+
+unsigned stddev_color(const std::string& image)
+{
+ typedef mln::point1d t_point1d;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image1d<unsigned> t_histo1d;
+ typedef mln::fun::v2v::rgb8_to_int_u8 t_rgb8_to_int_u8;
+ typedef mln::accu::meta::stat::histo1d t_histo1d_fun;
+ typedef mln::accu::max_site<t_histo1d> t_max_site_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_int_u8 input_int_u8;
+ t_histo1d histo;
+ t_point1d max_site;
+
+ mln::io::ppm::load(input_rgb8, image.c_str());
+ input_int_u8 = mln::data::transform(input_rgb8, t_rgb8_to_int_u8());
+ histo = mln::data::compute(t_histo1d_fun(), input_int_u8);
+
+ mln::io::pgm::save(input_int_u8, "tmp.pgm");
+ mln::io::plot::save_image_sh(histo, "histo.sh");
+ mln::debug::println(histo);
+
+ // Find the peak of the histogram
+ unsigned v_max = mln::opt::at(histo, 0);
+ short p_max = 0;
+
+ mln_piter_(t_histo1d) p(histo.domain());
+
+ for_all(p)
+ {
+ if (v_max < histo(p))
+ {
+ v_max = histo(p);
+ p_max = p.ind();
+ }
+ }
+
+ // Compute the specific stddev
+
+ float stddev_low = 0.0;
+ float stddev_up = 0.0;
+ float stddev = 0.0;
+
+ if (250 > p_max)
+ for (short i = p_max+1; i < p_max+6; ++i)
+ stddev_up += r(p_max, mln::opt::at(histo,p_max),
+ i, mln::opt::at(histo,i));
+
+ if (5 < p_max)
+ for (short i = p_max-1; i > p_max-6; --i)
+ stddev_low += r(p_max, mln::opt::at(histo,p_max),
+ i, mln::opt::at(histo,i));
+
+ stddev = (250 < p_max)? stddev_low : (5 > p_max)? stddev_up :
+ (stddev_low + stddev_up)/2;
+
+ std::cout << "max_site : " << p_max << std::endl;
+ std::cout << "h(max_site) : " << v_max << std::endl;
+ std::cout << "stddev_up : " << stddev_up << std::endl;
+ std::cout << "stddev_low : " << stddev_low << std::endl;
+ std::cout << "stddev : " << stddev << std::endl;
+
+ return 0;
+}
+
+
+int main()
+{
+// unsigned val = stdev_color(ANNOTING_PHOTO_IMG_PATH "/photo01.ppm");
+ unsigned val = stddev_color(ANNOTING_LOGO_IMG_PATH "/logo06.ppm");
+
+// std::cout << "nb color : " << val << std::endl;
+
+ return 0;
+}
+
--
1.5.6.5
1
0
24 Feb '10
Optimize regional maxima processing for statistical counts and outputs.
* green/demo/labeling/regional_maxima/Makefile.am: Add some compilation
directives.
* green/demo/labeling/regional_maxima/regional_maxima.cc
(t_channel,t_labeling_rgbn,label_image,unquant,print_count2): New.
* green/demo/labeling/regional_maxima/regional_maxima.cc
(print_count, merge, do_demo) : Update.
---
milena/sandbox/ChangeLog | 14 +-
.../demo/labeling/regional_maxima/Makefile.am | 2 +
.../labeling/regional_maxima/regional_maxima.cc | 661 ++++++++++++++------
3 files changed, 471 insertions(+), 206 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 37cce8a..aed61bf 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,9 +1,21 @@
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Optimize regional maxima processing for statistical counts and outputs.
+
+ * green/demo/labeling/regional_maxima/Makefile.am: Add some compilation
+ directives.
+ * green/demo/labeling/regional_maxima/regional_maxima.cc
+ (t_channel,t_labeling_rgbn,label_image,unquant,print_count2): New.
+ * green/demo/labeling/regional_maxima/regional_maxima.cc
+ (print_count, merge, do_demo) : Update.
+
+
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Test experimentation with regmax code on annoting database.
* green/exp/labeling/regional_maxima/Makefile.am: New Makefile.
- * green/exp/clustering/regional_maxima/regional_maxima.cc: New directory
+ * green/exp/labeling/regional_maxima/regional_maxima.cc: New directory
oriented demonstration code.
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/Makefile.am b/milena/sandbox/green/demo/labeling/regional_maxima/Makefile.am
index 91230b6..1dd1cfb 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/Makefile.am
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/Makefile.am
@@ -8,6 +8,8 @@
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
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
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
index 34801ed..266fbfe 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
@@ -1,66 +1,257 @@
// DEMO ON REGIONAL MAXIMA
-#include <mln/clustering/kmean2d.hh>
-
#include <iostream>
#include <sstream>
#include <mln/img_path.hh>
-#include <mln/pw/value.hh>
-#include <mln/value/label_8.hh>
-#include <mln/value/rgb8.hh>
+#include <mln/accu/math/sum.hh>
+#include <mln/accu/stat/histo3d_rgb.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/accu/stat/variance.hh>
+
+#include <mln/algebra/vec.hh>
+
+// #include <mln/arith/revert.hh>
+#include <mln/arith/diff_abs.hh>
#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/image/image3d.hh>
+#include <mln/core/routine/initialize.hh>
+#include <mln/data/compute.hh>
+#include <mln/data/fill.hh>
+// #include <mln/data/stretch.hh>
#include <mln/data/transform.hh>
+
+// #include <mln/display/display_histo.hh>
+
#include <mln/fun/v2v/rgb8_to_rgbn.hh>
-#include <mln/io/ppm/load.hh>
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <mln/io/plot/save_image_sh.hh>
-
-#include <mln/accu/stat/histo3d_rgb.hh>
-#include <mln/data/compute.hh>
+// #include <mln/io/plot/save_image_sh.hh>
-#include <mln/arith/revert.hh>
#include <mln/labeling/regional_maxima.hh>
-#include <mln/core/alias/neighb3d.hh>
-#include <mln/core/routine/initialize.hh>
+#include <mln/labeling/mean_values.hh>
+#include <mln/labeling/compute.hh>
+
#include <mln/literal/colors.hh>
-#include <mln/morpho/watershed/flooding.hh>
+
+// #include <mln/morpho/watershed/flooding.hh>
#include <mln/morpho/opening/volume.hh>
#include <mln/morpho/elementary/dilation.hh>
-#include <mln/data/stretch.hh>
-#include <mln/display/display_histo.hh>
-#include <mln/labeling/mean_values.hh>
+#include <mln/opt/at.hh>
+
+// #include <mln/pw/value.hh>
+
+#include <mln/util/array.hh>
+#include <mln/util/timer.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/int_u.hh>
+
+
+template <unsigned n, unsigned ch>
+struct t_channel : mln::Function_v2v< t_channel<n,ch> >
+{
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::int_u<n> t_int_un;
+ typedef t_rgbn argument;
+ typedef t_int_un result;
+
+ result operator()(const argument& c) const
+ {
+ result tmp;
+
+ switch(ch)
+ {
+ case 0: tmp = c.red(); break;
+ case 1: tmp = c.green(); break;
+ case 2: tmp = c.blue(); break;
+ }
+
+ return tmp;
+ }
+};
+
+
+// version optimisée de labeling
+
+template <unsigned n>
+struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
+{
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_rgbn argument;
+ typedef t_lbl8 result;
+ typedef mln::image3d<t_lbl8> t_label;
+
+ const t_label& _label;
+
+ t_labeling_rgbn(const t_label& label) : _label(label) {}
+
+ result operator()(const argument& c) const
+ {
+ t_lbl8 tmp = mln::opt::at(_label, c.blue(), c.red(), c.green());
+
+ return tmp;
+ }
+};
+
+// version non optimisée de label
+
+template <unsigned n>
mln::image2d<mln::value::label_8>
-label_image(const mln::image2d<mln::value::rgb<5> >& input,
- const mln::image3d<mln::value::label_8>& label)
+label_image(const mln::image2d< mln::value::rgb<n> >& input,
+ const mln::image3d< mln::value::label_8>& label)
{
- mln::image2d<mln::value::label_8> output(input.nrows(),
- input.ncols());
+ mln::image2d<mln::value::label_8> output;
+
+ initialize(output, input);
- mln_piter_(mln::image2d<mln::value::label_8>) po(output.domain());
- mln_piter_(mln::image2d<mln::value::rgb<5> >) pi(input.domain());
+ mln_piter(mln::image2d< mln::value::label_8 >) po(output.domain());
+ mln_piter(mln::image2d< mln::value::rgb<n> >) pi(input.domain());
for_all_2(po, pi)
{
- output(po) = label(mln::point3d(input(pi).blue(),
- input(pi).red(),
- input(pi).green()));
+ const mln::value::rgb<n>& vi = input(pi);
+
+ output(po) = mln::opt::at(label, vi.blue(), vi.red(), vi.green());
}
return output;
}
+template <unsigned n>
+unsigned unquant(const float& value)
+{
+ unsigned size = pow(2,(8-n));
+ unsigned result = value * size;
+
+ return result;
+}
+
+template <unsigned n>
+void print_count2(const mln::image2d<mln::value::rgb<n> >& input_rgbn,
+ const mln::image3d<unsigned>& histo,
+ const mln::image3d<mln::value::label_8>& label,
+ const unsigned n_labels)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::int_u<n> t_int_un;
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::accu::math::sum<t_vec3f,t_vec3f> t_diff;
+ typedef mln::accu::stat::variance<float,float,float> t_var;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_un> t_image2d_int_un;
+
+ mln::util::array<t_mean> mean((unsigned)(n_labels)+1);
+// mln::util::array<t_diff> diff((unsigned)(n_labels)+1);
+ mln::util::array<t_var> var_red((unsigned)(n_labels)+1);
+ mln::util::array<t_var> var_green((unsigned)(n_labels)+1);
+ mln::util::array<t_var> var_blue((unsigned)(n_labels)+1);
+ mln::util::array<t_sum> count((unsigned)(n_labels)+1);
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ count(i).init();
+ mean(i).init();
+// diff(i).init();
+ var_red(i).init();
+ var_green(i).init();
+ var_blue(i).init();
+ abs[i] = 0.0;
+ rel[i] = 0.0;
+ }
+
+ mln::labeling::compute(count, histo, label, n_labels);
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
+
+ t_image2d_lbl8 label_img = mln::data::transform(input_rgbn,
+ t_labeling_rgbn<n>(label));
+
+ mln::labeling::compute(mean, input_rgbn, label_img, n_labels);
+
+
+// t_image2d_rgbn mean_rgbn = mln::labeling::mean_values(input_rgbn,
+// label_img,
+// n_labels);
+// t_image2d_int_un mean_red =mln::data::transform(mean_rgbn,t_channel<n>());
+// t_image2d_int_un mean_green=mln::data::transform(mean_rgbn,t_channel<n>());
+// t_image2d_int_un mean_blue =mln::data::transform(mean_rgbn,t_channel<n>());
+
+ t_image2d_int_un input_red =mln::data::transform(input_rgbn,
+ t_channel<n,0>());
+ t_image2d_int_un input_green=mln::data::transform(input_rgbn,
+ t_channel<n,1>());
+ t_image2d_int_un input_blue =mln::data::transform(input_rgbn,
+ t_channel<n,2>());
+
+// FIXME VARIANCE NEGATIVE DANS LES RESULTATS !!
+
+// mln::labeling::compute(var_red, input_rgbn, label_img, n_labels);
+// mln::labeling::compute(var_green, input_rgbn, label_img, n_labels);
+// mln::labeling::compute(var_blue, input_rgbn, label_img, n_labels);
+
+// t_image2d_rgbn diff_rgbn = mln::arith::diff_abs(input_rgbn, mean_rgbn);
+
+ std::cout << mln::labeling::compute(var_red, input_red, label_img, n_labels)(29) << std::endl;
+// mln::labeling::compute(t_var(), input_red, label_img, n_labels);
+ mln::labeling::compute(var_green, input_green, label_img, n_labels);
+ mln::labeling::compute(var_blue, input_blue, label_img, n_labels);
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ if (5.0 < abs[i] && 10.0 < rel[i])
+ {
+ const t_vec3f& mean_v = mean[i];
+// const t_vec3f& diff_v = diff[i];
+
+ std::cout << i << " :[" << unquant<n>(mean_v[0])
+// << "(" << diff_v[0]
+ << "(" << var_red[i]
+ << ")," << unquant<n>(mean_v[1])
+// << "(" << diff_v[1]
+ << "(" << var_green[i]
+ << ")," << unquant<n>(mean_v[2])
+// << "(" << diff_v[2]
+ << "(" << var_blue[i]
+ << ")]- " << count[i]
+ << " - " << abs[i]
+ << " - " << rel[i]
+ << std::endl;
+ }
+ }
+}
void print_count(const mln::image3d<unsigned>& histo,
const mln::image3d<mln::value::label_8>& label,
@@ -70,66 +261,116 @@ void print_count(const mln::image3d<unsigned>& histo,
unsigned red[255];
unsigned green[255];
unsigned blue[255];
+ unsigned nb = 0;
+ unsigned tmp = 0;
- for (unsigned i = 0; i < n_labels; ++i)
+ for (unsigned i = 0; i <= n_labels; ++i)
{
count[i] = 0;
- red[i] = 0.0;
- green[i] = 0.0;
- blue[i] = 0.0;
+ red[i] = 0;
+ green[i] = 0;
+ blue[i] = 0;
}
- mln_piter_(mln::image3d<unsigned>) ph(histo.domain());
- mln_piter_(mln::image3d<mln::value::label_8>) pl(label.domain());
+ mln_piter_(mln::image3d<unsigned>) p(histo.domain());
- for_all_2(ph, pl)
+ for_all(p)
{
- count[label(pl)] += histo(ph);
- red[label(pl)] += histo(ph) * pl.row();
- green[label(pl)] += histo(ph) * pl.col();
- blue[label(pl)] += histo(ph) * pl.sli();
+ count[label(p)] += histo(p);
+ red[label(p)] += histo(p) * p.row();
+ green[label(p)] += histo(p) * p.col();
+ blue[label(p)] += histo(p) * p.sli();
+ nb += histo(p);
+ ++tmp;
}
std::cout << std::endl;
- for (unsigned i = 0; i < n_labels; ++i)
- {
- red[i] = red[i] / count[i];
- green[i] = green[i] / count[i];
- blue[i] = blue[i] / count[i];
+ std::cout << "nb : " << nb << std::endl;
+ std::cout << "tmp : " << tmp << std::endl;
- std::cout << "count[" << i << "]("
- << red[i] << ", " << green[i] << ", "
- << blue[i] << ") = " << count[i] << std::endl;
- }
+ std::cout << std::endl;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ float percentage_abs = ((float)count[i] / nb)*100.0;
+ float percentage_rel = ((float)count[i] / (nb - count[0]))*100.0;
+
+ red[i] = red[i] / count[i];
+ green[i] = green[i] / count[i];
+ blue[i] = blue[i] / count[i];
+
+ std::cout << "count[" << i << "]("
+ << red[i] << ", " << green[i] << ", "
+ << blue[i] << ") = " << count[i] << "("
+ << percentage_abs << "%)";
+
+ if (0 < i)
+ std::cout << "[" << percentage_rel << "%]";
+
+ std::cout << std::endl;
+ }
std::cout << std::endl;
}
-mln::image2d<mln::value::rgb<5> >
-merge(const mln::image2d<mln::value::rgb<5> >& input,
- const mln::image3d<mln::value::label_8>& label)
+// Version optimisée de merge
+
+template <unsigned n>
+struct t_merge_lbl8_with_rgbn : mln::Function_v2v< t_merge_lbl8_with_rgbn<n> >
{
- mln::image2d<mln::value::rgb<5> > output;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_rgbn argument;
+ typedef t_rgbn result;
+ typedef mln::image3d<t_lbl8> t_label;
+
+ const t_label& _label;
+
+ t_merge_lbl8_with_rgbn(const t_label& label) : _label(label) {}
+
+ result operator()(const argument& c) const
+ {
+ t_rgbn tmp = c;
+
+ if (0 == mln::opt::at(_label, c.blue(), c.red(), c.green()))
+ {
+ tmp = mln::literal::black;
+ }
+
+ return tmp;
+ }
+};
+
+// version non optimisée de merge
+
+template <unsigned n>
+mln::image2d< mln::value::rgb<n> >
+merge(const mln::image2d< mln::value::rgb<n> >& input,
+ const mln::image3d< mln::value::label_8 >& label)
+{
+ mln::image2d<mln::value::rgb<n> > output;
mln::initialize(output, input);
+ // mln::data::fill(output, mln::literal::green);
- mln_piter_(mln::image2d<mln::value::rgb<5> >) pi(input.domain());
- mln_piter_(mln::image2d<mln::value::rgb<5> >) po(output.domain());
+ mln_piter(mln::image2d< mln::value::rgb<n> >) pi(input.domain());
+ mln_piter(mln::image2d< mln::value::rgb<n> >) po(output.domain());
for_all_2(pi, po)
{
- if (0 < label(mln::point3d(input(pi).blue(),
- input(pi).red(),
- input(pi).green())))
+ const mln::value::rgb<n>& vi = input(pi);
+ mln::value::rgb<n>& vo = output(po);
+
+ if (0 < mln::opt::at(label,vi.blue(),vi.red(),vi.green()))
{
- output(po).red() = input(pi).red();
- output(po).green() = input(pi).green();
- output(po).blue() = input(pi).blue();
+ vo.red() = vi.red();
+ vo.green() = vi.green();
+ vo.blue() = vi.blue();
}
else
- output(po) = mln::literal::red;
- //output(po) = mln::literal::black;
+ vo = mln::literal::black;
}
return output;
@@ -137,78 +378,180 @@ merge(const mln::image2d<mln::value::rgb<5> >& input,
//
-// Regional maxima image processing chain.
-// RGB8
+// Theo regional maxima image processing chain.
//
-void do_demo(const std::string& image)
+
+// FIXME C'est la dilatation qui fait apparaître des classes < min_volume.
+// Une couleur se dilate au détriment du fond et des autres couleurs.
+
+int main2()
{
+ const unsigned min_volume = 1000;
+ //const std::string& image = OLENA_IMG_PATH"/fly.ppm";
+ const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
+ //const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
+
typedef mln::value::label_8 t_lbl8;
- typedef mln::value::int_u8 t_int_u8;
typedef mln::value::rgb8 t_rgb8;
typedef mln::value::rgb<5> t_rgb5;
- typedef mln::image3d<t_lbl8> t_image3d_lbl8;
- typedef mln::image2d<t_lbl8> t_image2d_lbl8;
typedef mln::image2d<t_rgb8> t_image2d_rgb8;
typedef mln::image2d<t_rgb5> t_image2d_rgb5;
- typedef mln::image2d<t_int_u8> t_image2d_int_u8;
- typedef mln::image3d<unsigned> t_histo3d;
- typedef mln::image2d<unsigned> t_histo2d;
- typedef mln::fun::v2v::rgb8_to_rgbn<5> t_rgb8_to_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image3d<unsigned> t_image3d_unsigned;
+ typedef mln::fun::v2v::rgb8_to_rgbn<5> t_rgb8_to_rgb5;
typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+
+ mln::util::timer timer;
+
+ // START IMAGE PROCESSING CHAIN
+ timer.start();
t_image2d_rgb8 input_rgb8;
t_image2d_rgb5 input_rgb5;
- t_image2d_rgb5 output_rgb5;
- t_image2d_rgb5 mean_rgb5;
- t_histo3d histo;
- t_image2d_int_u8 projected;
- t_image2d_int_u8 filtered;
- t_histo3d opened;
+ t_image3d_unsigned histo;
+ t_image3d_unsigned opened;
t_image3d_lbl8 label;
- t_image2d_lbl8 label_img;
t_image3d_lbl8 dilated;
t_lbl8 n_labels;
- t_rgb5 value_rgb5;
- // IMAGE LOADING PHASE
- std::cout << "Image loading phase ..." << std::endl;
mln::io::ppm::load(input_rgb8, image.c_str());
- input_rgb5 = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
- mln::io::ppm::save(input_rgb5, "input_rgb5.ppm");
+ input_rgb5 = mln::data::transform(input_rgb8, t_rgb8_to_rgb5());
+ histo = mln::data::compute(t_histo3d_fun(), input_rgb5);
+ opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
+ label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
+ dilated = mln::morpho::elementary::dilation(label, mln::c26());
+
+ mln::util::array<t_sum> length((unsigned)(n_labels)+1);
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ length(i).init();
+ mln::labeling::compute(length, histo, dilated, n_labels);
- // HISTO COMPUTING PHASE
- std::cout << "Histo computing phase ..." << std::endl;
- histo = mln::data::compute(t_histo3d_fun(), input_rgb5);
- projected = mln::display::display_histo3d_unsigned(histo);
+ timer.stop();
+ // STOP IMAGE PROCESSING CHAIN
+
+ std::cout << "Done in " << timer.read() << " ms" << std::endl;
+ std::cout << "n_labels : " << n_labels << std::endl;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ std::cout << "count[" << i << "] = " << length[i] << std::endl;
+ }
+
+ print_count(histo,label,n_labels);
- mln::io::pgm::save(projected, "histo.pgm");
//mln::io::plot::save_image_sh(histo, "histo.sh");
+ //mln::io::plot::save_image_sh(histo, "opened.sh");
+ //mln::io::plot::save_image_sh(label, "label.sh");
- // HISTO FILTERING PHASE
- std::cout << "Histo filtering phase ..." << std::endl;;
- opened = mln::morpho::opening::volume(histo, mln::c6(), 1000);
- mln::io::plot::save_image_sh(opened, "opened.sh");
- filtered = mln::display::display_histo3d_unsigned(opened);
- mln::io::pgm::save(filtered, "filtered.pgm");
+ return 0;
+}
+// n < 8, n is the degree of quantification
+template <unsigned n>
+void demo()
+{
+ const unsigned min_volume = 1000;
+ //const std::string& image = OLENA_IMG_PATH"/fly.ppm";
+ const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
+ //const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
- // HISTO LABELING PHASE
- std::cout << "Histo labeling phase ..." << std::endl;
- label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
- mln::io::plot::save_image_sh(label, "label.sh");
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image2d<unsigned> t_histo2d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ mln::util::timer timer;
- // HISTO DILATING PHASE
- std::cout << "Histo dilating phase ..." << std::endl;
- dilated = mln::morpho::elementary::dilation(label, mln::c18());
- mln::io::plot::save_image_sh(dilated, "dilated.sh");
+ // START OF IMAGE PROCESSING CHAIN
+ timer.start();
- // PRINTING PHASE
- std::cout << "Labels : " << n_labels << std::endl;
- print_count(histo, dilated, n_labels);
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgbn input_rgbn;
+ t_image2d_rgbn output_rgbn;
+ // t_image2d_rgbn mean_rgb5;
+ t_histo3d histo;
+ // t_image2d_int_u8 projected;
+ // t_image2d_int_u8 filtered;
+ t_histo3d opened;
+ t_image3d_lbl8 label;
+ t_image2d_lbl8 label_img;
+ t_image3d_lbl8 dilated;
+ t_lbl8 n_labels;
+ // t_rgbn value_rgbn;
+ mln::io::ppm::load(input_rgb8, image.c_str());
+ input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
+ histo = mln::data::compute(t_histo3d_fun(), input_rgbn);
+ opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
+ label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
+ dilated = mln::morpho::elementary::dilation(label, mln::c26());
+
+ timer.stop();
+ // END OF IMAGE PROCESSING CHAIN
+
+ std::ostringstream name;
+ std::ostringstream name2;
+ std::ostringstream name3;
+
+ name << "input_rgb" << n << ".ppm";
+ name2 << "output_rgb" << n << ".ppm";
+ name3 << "label_img" << n << ".pgm";
+
+ std::cout << "Done in : " << timer.read() << " s" << std::endl;
+ std::cout << "Labels : " << n_labels << std::endl;
+ std::cout << "Name : " << name.str() << std::endl;
+
+ mln::io::ppm::save(input_rgbn, name.str());
+
+ mln::util::timer timer2;
+
+ timer2.start();
+ print_count2(input_rgbn, histo, dilated, n_labels);
+ timer2.stop();
+ std::cout << "timer2 : " << timer2.read() << std::endl;
+ output_rgbn = mln::data::transform(input_rgbn,
+ t_merge_lbl8_with_rgbn<n>(label));
+ // output_rgbn = merge<n>(input_rgbn, dilated);
+ mln::io::ppm::save(output_rgbn, name2.str());
+
+ label_img = mln::data::transform(input_rgbn,
+ t_labeling_rgbn<n>(label));
+ // label_img = label_image<n>(input_rgbn, dilated);
+ mln::io::pgm::save(label_img, name3.str());
+
+
+ // localiser les couleurs sur l'image (fond en black, le reste)
+
+ // La dilatation englobe beaucoup plus de couleur, mais celles-ci ne
+ // sont pas forcément présentes dans l'image. Du coup, les classes ne
+ // bougent pas démeusurément.
+
+// mln::io::ppm::save(input_rgb5, "input_rgb5.ppm");
+// mln::io::plot::save_image_sh(input_rgb8, "input_rgb8.sh");
+// mln::io::plot::save_image_sh(input_rgb5, "input_rgb5.sh");
+// projected = mln::display::display_histo3d_unsigned(histo);
+// mln::io::pgm::save(projected, "histo.pgm");
+// mln::io::plot::save_image_sh(histo, "histo.sh");
+// mln::io::plot::save_image_sh(opened, "opened.sh");
+// filtered = mln::display::display_histo3d_unsigned(opened);
+// mln::io::pgm::save(filtered, "filtered.pgm");
+// mln::io::plot::save_image_sh(label, "label.sh");
+ // mln::io::plot::save_image_sh(dilated, "dilated.sh");
+
+ /*
// OUTPUT PHASE
std::cout << "Output phase ..." << std::endl;
output_rgb5 = merge(input_rgb5, dilated);
@@ -221,113 +564,21 @@ void do_demo(const std::string& image)
label_img = label_image(input_rgb5, dilated);
mln::io::pgm::save(label_img, "label_img.pgm");
-
// BUILDING MEAN VALUES
std::cout << "Building mean values phase ..." << std::endl;
mean_rgb5 = mln::labeling::mean_values(input_rgb5, label_img, n_labels);
mln::io::ppm::save(mean_rgb5, "mean.ppm");
+ */
}
-void demo(const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm",
- //const std::string& image = OLENA_IMG_PATH"/house.ppm",
- const unsigned k_center = 2,
- //const unsigned k_center = 3,
- const unsigned n_times = 10,
- const unsigned watch_dog = 10)
-{
- std::cout << "----------------------------------------" << std::endl;
- std::cout << "Launching the demo with these parameters" << std::endl;
- std::cout << "image : " << image << std::endl;
- std::cout << "k_center : " << k_center << std::endl;
- std::cout << "n_times : " << n_times << std::endl;
- std::cout << "watch_dog : " << watch_dog << std::endl;
- std::cout << "----------------------------------------" << std::endl;
-
- do_demo(image);
-}
-
-void usage(const int argc, const char *args[])
-{
- std::cout << "----------------------------------------" << std::endl;
- std::cout << "argc : " << argc << std::endl;
-
- for (int i = 0; i < argc; ++i)
- std::cout << "args[" << i << "] : " << args[i] << std::endl;
-
- std::cout << "----------------------------------------" << std::endl;
- std::cout << "usage: kmean2d [image [k_center [n_times [watch_dog]]]]"
- << std::endl;
- std::cout << "pbm image (points to work with)" << std::endl;
- std::cout << "unsigned k_center (number of centers)" << std::endl;
- std::cout << "unsigned n_times (number of launching)" << std::endl;
- std::cout << "unsigned watch_dog (convergence loop)" << std::endl;
- std::cout << "----------------------------------------" << std::endl;
-}
-
-bool char_to_unsigned(const bool status, const char *arg, unsigned& val)
-{
- bool result = false;
-
- if (status)
- {
- std::istringstream arg_stream(arg);
-
- arg_stream >> val;
-
- result = !arg_stream.fail();
- }
-
- return result;
-}
-
-bool char_to_string(const bool status, const char *arg, std::string& val)
-{
- bool result = false;
-
- if (status)
- {
- std::istringstream arg_stream(arg);
-
- arg_stream >> val;
-
- return !arg_stream.fail();
- }
-
- return result;
-}
-
-int main(const int argc, const char *args[])
+int main()
{
- std::string image("top");
- unsigned k_center;
- unsigned watch_dog;
- unsigned n_times;
- bool status = true;
-
- switch (argc)
- {
- case 5: status = char_to_unsigned(status, args[4], watch_dog);
- case 4: status = char_to_unsigned(status, args[3], n_times);
- case 3: status = char_to_unsigned(status, args[2], k_center);
- case 2: status = char_to_string(status, args[1], image); break;
- case 1: status = true; break;
- default: status = false;
- }
-
- if (status)
- {
- switch (argc)
- {
- case 1: demo(); break;
- case 2: demo(image); break;
- case 3: demo(image, k_center); break;
- case 4: demo(image, k_center, n_times); break;
- case 5: demo(image, k_center, n_times, watch_dog); break;
- }
- }
- else
- usage(argc, args);
-
- return 0;
+ demo<2>(); // 2.26 s
+ demo<3>(); // 2.29 s
+ demo<4>(); // 2.29 s
+ demo<5>(); // 2.37 s
+ demo<6>(); // 3.19 s
+ demo<7>(); // 11.43 s
+ demo<8>(); // 96.19 s
}
--
1.5.6.5
1
0
last-svn-commit-6-gc121636 Test experimentation with regmax code on annoting database.
by green 24 Feb '10
by green 24 Feb '10
24 Feb '10
* green/exp/labeling/regional_maxima/Makefile.am: New Makefile.
* green/exp/clustering/regional_maxima/regional_maxima.cc: New directory
oriented demonstration code.
---
milena/sandbox/ChangeLog | 22 ++-
.../labeling/regional_maxima}/Makefile.am | 8 +-
.../labeling/regional_maxima/regional_maxima.cc | 156 ++++++++++++++++++++
3 files changed, 175 insertions(+), 11 deletions(-)
copy milena/sandbox/green/{demo/annoting/rgb_64 => exp/labeling/regional_maxima}/Makefile.am (95%)
create mode 100644 milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index b3029e2..37cce8a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,37 +1,45 @@
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Test experimentation with regmax code on annoting database.
+
+ * green/exp/labeling/regional_maxima/Makefile.am: New Makefile.
+ * green/exp/clustering/regional_maxima/regional_maxima.cc: New directory
+ oriented demonstration code.
+
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Transform kmean object in a big function and then a canvas.
* green/mln/clustering/kmean_rgb.hh: New library source code.
- * green/demo/clustering/kmean_rgb/Makefile: New Makefile.
+ * green/demo/clustering/kmean_rgb/Makefile.am: New Makefile.
* green/demo/clustering/kmean_rgb/kmean_rgb.cc: New demo. code.
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Benchmark on distance, preliminary work before optimizing kmean.
- * green/bench/transform/distance/Makefile: New Makefile.
+ * green/bench/transform/distance/Makefile.am: New Makefile.
* green/bench/transform/distance/distance.cc: New processing chain.
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Works on Millet2008 descriptors.
- * green/mln/demo/annoting/bic/Makefile: New Makefile.
+ * green/mln/demo/annoting/bic/Makefile.am: New Makefile.
* green/mln/demo/annoting/bic/bic.cc: New impl. of the bic descriptor.
- * green/mln/demo/annoting/lep/Makefile: New Makefile.
+ * green/mln/demo/annoting/lep/Makefile.am: New Makefile.
* green/mln/demo/annoting/lep/lep.cc: New impl. of the lep descriptor.
- * green/mln/demo/annoting/project/Makefile: New Makefile.
+ * green/mln/demo/annoting/project/Makefile.am: New Makefile.
* green/mln/demo/annoting/project/project.cc: New impl. of the project
descriptor.
- * green/mln/demo/annoting/rgb_64/Makefile: New Makefile.
+ * green/mln/demo/annoting/rgb_64/Makefile.am: New Makefile.
* green/mln/demo/annoting/rgb_64/rgb_64.cc: New impl. of the rgb_64
descriptor.
- * green/mln/demo/annoting/rgb_64_9/Makefile: New Makefile.
+ * green/mln/demo/annoting/rgb_64_9/Makefile.am: New Makefile.
* green/mln/demo/annoting/rgb_64_9/rgb_64_9.cc: New impl. of the
rgb_64_9 descriptor.
diff --git a/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
similarity index 95%
copy from milena/sandbox/green/demo/annoting/rgb_64/Makefile.am
copy to milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
index 96eafb4..ab76e18 100644
--- a/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am
+++ b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am
@@ -8,15 +8,15 @@
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#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)
+#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/demo
-BUILD__PATTERN= green/build/demo
+SOURCE_PATTERN= green/exp
+BUILD__PATTERN= green/build/exp
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
new file mode 100644
index 0000000..28b6b88
--- /dev/null
+++ b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc
@@ -0,0 +1,156 @@
+// EXPERIMENTATION ON REGIONAL MAXIMA
+// COUNTING THE IMAGE COLORS
+
+#include <iostream>
+#include <sstream>
+#include <boost/filesystem.hpp>
+
+#include <mln/img_path.hh>
+
+#include <mln/accu/math/sum.hh>
+#include <mln/accu/math/count.hh>
+#include <mln/accu/stat/histo3d_rgb.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/accu/stat/variance.hh>
+
+#include <mln/algebra/vec.hh>
+
+#include <mln/arith/diff_abs.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/routine/initialize.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/labeling/mean_values.hh>
+#include <mln/labeling/compute.hh>
+
+#include <mln/literal/colors.hh>
+
+#include <mln/morpho/opening/volume.hh>
+#include <mln/morpho/elementary/dilation.hh>
+
+#include <mln/opt/at.hh>
+
+#include <mln/pw/cst.hh>
+
+#include <mln/util/array.hh>
+#include <mln/util/timer.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/int_u.hh>
+
+
+// LISTER UN REPERTOIRE
+// ECRIRE UN FICHIER DE SYNTHESE SUR LA CLASSE
+//
+
+
+// n < 8, n is the degree of quantification
+template <unsigned n>
+unsigned count_image_color(const std::string& image)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::image2d<unsigned> t_histo2d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::meta::math::count t_count_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgbn input_rgbn;
+ t_image2d_rgbn output_rgbn;
+ t_histo3d histo;
+ t_histo3d opened;
+ t_image3d_lbl8 label;
+ t_image2d_lbl8 label_img;
+ t_image3d_lbl8 dilated;
+ t_lbl8 n_labels;
+
+ mln::io::ppm::load(input_rgb8, image.c_str());
+
+ unsigned nb_pixel = input_rgb8.ncols() * input_rgb8.nrows();
+ unsigned min_volume = (unsigned)(nb_pixel * 0.054);
+
+ input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
+ // FIXME UTILISER UN PREDICAT COMME FUN::CHESS
+ histo = mln::data::compute(t_histo3d_fun(), input_rgbn | mln::pw::value(0));
+// return mln::data::compute(t_count_fun(), input_rgbn);
+ // FIXME REALISER UN COUNT AVEC UN PREDICA SUR L'IMAGE
+ return nb_pixel;
+// opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
+// label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
+
+// return n_labels;
+}
+
+
+int main()
+{
+ typedef boost::filesystem::path t_path;
+ //typedef boost::filesystem::initial_path<t_path()> t_init_path;
+ typedef boost::filesystem::directory_iterator t_iter_path;
+
+ t_path full_path(ANNOTING_TYPED_IMG_PATH);
+
+ std::cout << "entering " << full_path << std::endl;
+
+ if (//1 < argc &&
+ boost::filesystem::exists(full_path) &&
+ boost::filesystem::is_directory(full_path))
+ {
+ boost::filesystem::system_complete(full_path);
+ const t_iter_path end_iter;
+ unsigned count = 0;
+ unsigned sum1 = 0;
+ unsigned sum2 = 0;
+
+ for (t_iter_path dir_iter(full_path); end_iter != dir_iter; ++dir_iter)
+ {
+ unsigned val = count_image_color<5>(dir_iter->path().string());
+
+ ++count;
+ sum1 += val;
+ sum2 += val*val;
+
+ std::cout << dir_iter->path().string() << " => " << val << std::endl;
+ // FIXME NB COULEURS BRUTES
+ // FIXME NB DE COULEURS
+ // FIXME LISTE DES COULEURS
+ // IMPORTANCES
+ }
+
+ unsigned mean = sum1 / count;
+ unsigned var = sum2 / count - mean * mean;
+
+ std::cout << "mean : " << mean << std::endl;
+ std::cout << "var : " << var << std::endl;
+ }
+
+ return 0;
+}
+
--
1.5.6.5
1
0
last-svn-commit-5-g9e772c6 Transform kmean object in a big function and then a canvas.
by green 24 Feb '10
by green 24 Feb '10
24 Feb '10
* green/mln/clustering/kmean_rgb.hh: New library source code.
* green/demo/clustering/kmean_rgb/Makefile: New Makefile.
* green/demo/clustering/kmean_rgb/kmean_rgb.cc: New demo. code.
---
milena/sandbox/ChangeLog | 8 +
.../histo2d => clustering/kmean_rgb}/Makefile.am | 0
.../green/demo/clustering/kmean_rgb/kmean_rgb.cc | 91 ++
milena/sandbox/green/mln/clustering/kmean_rgb.hh | 973 ++++++++++++++++++++
4 files changed, 1072 insertions(+), 0 deletions(-)
copy milena/sandbox/green/demo/{accu/stat/histo2d => clustering/kmean_rgb}/Makefile.am (100%)
create mode 100644 milena/sandbox/green/demo/clustering/kmean_rgb/kmean_rgb.cc
create mode 100644 milena/sandbox/green/mln/clustering/kmean_rgb.hh
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index a2cc751..b3029e2 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,13 @@
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Transform kmean object in a big function and then a canvas.
+
+ * green/mln/clustering/kmean_rgb.hh: New library source code.
+ * green/demo/clustering/kmean_rgb/Makefile: New Makefile.
+ * green/demo/clustering/kmean_rgb/kmean_rgb.cc: New demo. code.
+
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Benchmark on distance, preliminary work before optimizing kmean.
* green/bench/transform/distance/Makefile: New Makefile.
diff --git a/milena/sandbox/green/demo/accu/stat/histo2d/Makefile.am b/milena/sandbox/green/demo/clustering/kmean_rgb/Makefile.am
similarity index 100%
copy from milena/sandbox/green/demo/accu/stat/histo2d/Makefile.am
copy to milena/sandbox/green/demo/clustering/kmean_rgb/Makefile.am
diff --git a/milena/sandbox/green/demo/clustering/kmean_rgb/kmean_rgb.cc b/milena/sandbox/green/demo/clustering/kmean_rgb/kmean_rgb.cc
new file mode 100644
index 0000000..36641b6
--- /dev/null
+++ b/milena/sandbox/green/demo/clustering/kmean_rgb/kmean_rgb.cc
@@ -0,0 +1,91 @@
+// DEMO ON KMEAN_RGB
+
+#include <mln/clustering/kmean_rgb.hh>
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/img_path.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/image/image2d.hh>
+//#include <mln/core/image/dmorph/image_if.hh>
+
+#include <mln/data/transform.hh>
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/ppm/load.hh>
+//#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+//#include <mln/io/ppm/save.hh>
+//#include <mln/io/plot/save_image_sh.hh>
+
+//#include <mln/pw/value.hh>
+
+//#include <mln/value/int_u8.hh>
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+
+int main()
+{
+ const std::string& image = OLENA_IMG_PATH"/house.ppm";
+ const unsigned k_center = 3;
+ const unsigned n_times = 10;
+ const unsigned watch_dog = 10;
+
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<5> t_rgb5;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgb5> t_image2d_rgb5;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::fun::v2v::rgb8_to_rgbn<5> t_rgb8_to_rgb5;
+
+ t_image2d_rgb8 house_rgb8;
+ t_image2d_rgb5 house_rgb5;
+ t_image2d_lbl8 house_lbl8;
+
+ mln::io::ppm::load(house_rgb8, image.c_str());
+ house_rgb5 = mln::data::transform(house_rgb8, t_rgb8_to_rgb5());
+
+ mln::trace::quiet = false;
+
+ house_lbl8 = mln::clustering::kmean_rgb<double,5>(house_rgb5,
+ k_center,
+ watch_dog,
+ n_times);
+ mln::trace::quiet = true;
+
+ mln::io::pgm::save(house_lbl8, "label.pgm");
+ /*
+
+
+
+ t_kmean kmean(house_rgb5, k_center, watch_dog, n_times);
+
+
+
+ //kmean.launch_one_time();
+ kmean.launch_n_times();
+
+ // Not safe because we don't test kmean.is_valid()
+
+ t_kmean::t_color_dbg color_img = kmean.get_color_dbg();
+ t_kmean::t_mean_dbg mean_img = kmean.get_mean_dbg();
+ t_kmean::t_label_dbg label_img = kmean.get_label_dbg();
+ t_kmean::t_variance_cnv variance_cnv = kmean.get_variance_cnv();
+ t_kmean::t_mean_cnv mean_cnv = kmean.get_mean_cnv();
+
+ mln::io::ppm::save(mean_img, "mean.ppm");
+ mln::io::ppm::save(color_img, "color.ppm");
+ mln::io::pgm::save(label_img, "label.pgm");
+
+ mln::io::plot::save_image_sh(mean_img, "mean.sh");
+ mln::io::plot::save_image_sh(mean_cnv, "mean_cnv.sh");
+ mln::io::plot::save_image_sh(variance_cnv, "variance_cnv.sh");
+
+ */
+
+ return 0;
+}
+
diff --git a/milena/sandbox/green/mln/clustering/kmean_rgb.hh b/milena/sandbox/green/mln/clustering/kmean_rgb.hh
new file mode 100644
index 0000000..253745b
--- /dev/null
+++ b/milena/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
--
1.5.6.5
1
0
last-svn-commit-4-gfd0947d Benchmark on distance, preliminary work before optimizing kmean.
by green 24 Feb '10
by green 24 Feb '10
24 Feb '10
* green/bench/transform/distance/Makefile: New Makefile.
* green/bench/transform/distance/distance.cc: New processing chain.
---
milena/sandbox/ChangeLog | 7 +
.../lep => bench/transform/distance}/Makefile.am | 8 +-
.../green/bench/transform/distance/distance.cc | 775 ++++++++++++++++++++
3 files changed, 786 insertions(+), 4 deletions(-)
copy milena/sandbox/green/{demo/annoting/lep => bench/transform/distance}/Makefile.am (95%)
create mode 100644 milena/sandbox/green/bench/transform/distance/distance.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 83bd7f7..a2cc751 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Benchmark on distance, preliminary work before optimizing kmean.
+
+ * green/bench/transform/distance/Makefile: New Makefile.
+ * green/bench/transform/distance/distance.cc: New processing chain.
+
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Works on Millet2008 descriptors.
* green/mln/demo/annoting/bic/Makefile: New Makefile.
diff --git a/milena/sandbox/green/demo/annoting/lep/Makefile.am b/milena/sandbox/green/bench/transform/distance/Makefile.am
similarity index 95%
copy from milena/sandbox/green/demo/annoting/lep/Makefile.am
copy to milena/sandbox/green/bench/transform/distance/Makefile.am
index 96eafb4..115c385 100644
--- a/milena/sandbox/green/demo/annoting/lep/Makefile.am
+++ b/milena/sandbox/green/bench/transform/distance/Makefile.am
@@ -7,16 +7,16 @@
#########
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
-#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
-CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+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/demo
-BUILD__PATTERN= green/build/demo
+SOURCE_PATTERN= green/bench
+BUILD__PATTERN= green/build/bench
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
diff --git a/milena/sandbox/green/bench/transform/distance/distance.cc b/milena/sandbox/green/bench/transform/distance/distance.cc
new file mode 100644
index 0000000..b71b6df
--- /dev/null
+++ b/milena/sandbox/green/bench/transform/distance/distance.cc
@@ -0,0 +1,775 @@
+// BENCH
+
+#include <mln/opt/at.hh>
+
+#include <mln/core/alias/box3d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/alias/point3d.hh>
+#include <mln/core/alias/w_window2d_int.hh>
+#include <mln/core/alias/w_window3d_int.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/routine/initialize.hh>
+
+#include <mln/data/fill.hh>
+
+#include <mln/io/pgm/save.hh>
+#include <mln/io/plot/save_image_sh.hh>
+
+#include <mln/literal/zero.hh>
+
+#include <mln/make/w_window2d_int.hh>
+#include <mln/make/w_window3d_int.hh>
+
+#include <mln/transform/influence_zone_geodesic.hh>
+#include <mln/transform/influence_zone_front.hh>
+
+#include <mln/util/array.hh>
+#include <mln/util/timer.hh>
+
+#include <mln/value/label_8.hh>
+
+
+//------------------------------------------------------------------------------
+// Build input, seeds and other tools
+//------------------------------------------------------------------------------
+
+mln::image2d<mln::value::label_8> build_input2d(unsigned nb_seed, unsigned size)
+{
+ typedef mln::value::label_8 t_lbl;
+ mln::image2d<t_lbl> input(mln::box2d(mln::point2d(0,0),
+ mln::point2d(size,size)));
+
+ mln::data::fill(input, mln::literal::zero);
+
+ unsigned top = size / nb_seed;
+ unsigned lbl = 0;
+
+ for (unsigned i = top/2; i < size; i += top)
+ for (unsigned j = top/2; j < size; j += top)
+ input(mln::point2d(i,j)) = ++lbl;
+
+ //mln::io::pgm::save(input, "input.pgm");
+
+ return input;
+}
+
+mln::image3d<mln::value::label_8> build_input3d(unsigned nb_seed, unsigned size)
+{
+ typedef mln::value::label_8 t_lbl;
+ mln::image3d<t_lbl> input(mln::box3d(mln::point3d(0,0,0),
+ mln::point3d(size,size,size)));
+
+ mln::data::fill(input, mln::literal::zero);
+
+ unsigned top = size / nb_seed;
+ unsigned lbl = 0;
+
+ for (unsigned i = top/2; i < size; i += top)
+ for (unsigned j = top/2; j < size; j += top)
+ for (unsigned k = top/2; k < size; k += top)
+ input(mln::point3d(k,i,j)) = ++lbl;
+
+ //mln::io::pgm::save(input, "input.pgm");
+
+ return input;
+}
+
+mln::util::array<mln::point3d> build_seed3d(unsigned nb_seed, unsigned size)
+{
+ mln::util::array<mln::point3d> result;
+ unsigned top = size / nb_seed;
+
+ for (unsigned i = top/2; i < size; i += top)
+ for (unsigned j = top/2; j < size; j += top)
+ for (unsigned k = top/2; k < size; k += top)
+ result.append(mln::point3d(k,i,j));
+
+ // std::cout << result << std::endl;
+
+ return result;
+}
+
+mln::util::array<mln::point2d> build_seed2d(unsigned nb_seed, unsigned size)
+{
+ mln::util::array<mln::point2d> result;
+ unsigned top = size / nb_seed;
+
+ for (unsigned i = top/2; i < size; i += top)
+ for (unsigned j = top/2; j < size; j += top)
+ result.append(mln::point2d(j,i));
+
+ // std::cout << result << std::endl;
+
+ return result;
+}
+
+unsigned distance(mln::point3d p1, mln::point3d p2)
+{
+ unsigned row2 = (p1.row() - p2.row())*(p1.row() - p2.row());
+ unsigned col2 = (p1.col() - p2.col())*(p1.col() - p2.col());
+ unsigned sli2 = (p1.sli() - p2.sli())*(p1.sli() - p2.sli());
+ unsigned res = row2 + col2 + sli2;
+
+ return res;
+}
+
+unsigned distance(mln::point2d p1, mln::point2d p2)
+{
+ unsigned row2 = (p1.row() - p2.row())*(p1.row() - p2.row());
+ unsigned col2 = (p1.col() - p2.col())*(p1.col() - p2.col());
+ unsigned res = row2 + col2;
+
+ return res;
+}
+
+
+//------------------------------------------------------------------------------
+// Bench geodesic distance
+//------------------------------------------------------------------------------
+
+void influence_zone_geodesic_2d(mln::util::timer& timer,
+ const mln::image2d<mln::value::label_8>& input,
+ const mln::neighb2d & neighb)
+{
+ mln::image2d<mln::value::label_8> output;
+
+ timer.start();
+ output = mln::transform::influence_zone_geodesic(input, neighb);
+ timer.stop();
+
+ //mln::io::pgm::save(output, "output.pgm");
+}
+
+void influence_zone_geodesic_3d(mln::util::timer& timer,
+ const mln::image3d<mln::value::label_8>& input,
+ const mln::neighb3d & neighb)
+{
+ mln::image3d<mln::value::label_8> output;
+
+ timer.start();
+ output = mln::transform::influence_zone_geodesic(input, neighb);
+ timer.stop();
+
+ //mln::io::pgm::save(output, "output.pgm");
+}
+
+
+int test_influence_zone_geodesic_2d()
+{
+ mln::util::timer timer;
+
+// Test the label c4
+ mln::image1d<float> chart_seed_c04(16*16+2);
+
+ mln::data::fill(chart_seed_c04, mln::literal::zero);
+
+ for (unsigned i = 1; i < 16+1; ++i)
+ {
+ influence_zone_geodesic_2d(timer,build_input2d(i,256),mln::c4());
+ std::cout << "c04|256x256|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c04, i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c04, "geodesic.c04.2d.seed.sh");
+
+ // Test the label c8
+ mln::image1d<float> chart_seed_c08(16*16+2);
+
+ mln::data::fill(chart_seed_c08, mln::literal::zero);
+
+ for (unsigned i = 1; i < 16+1; ++i)
+ {
+ influence_zone_geodesic_2d(timer,build_input2d(i,256),mln::c8());
+ std::cout << "c08|256x256|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c08, i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c08, "geodesic.c08.2d.seed.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c04(256+1);
+
+ mln::data::fill(chart_size_c04, mln::literal::zero);
+
+ for (unsigned i = 16; i < 256+1; ++i)
+ {
+ influence_zone_geodesic_2d(timer, build_input2d(4,i),mln::c4());
+ std::cout << "c04|" << i << "x" << i << "|16 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c04, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c04, "geodesic.c04.2d.size.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c08(256+1);
+
+ mln::data::fill(chart_size_c08, mln::literal::zero);
+
+ for (unsigned i = 16; i < 256+1; ++i)
+ {
+ influence_zone_geodesic_2d(timer, build_input2d(4,i),mln::c8());
+ std::cout << "c08|" << i << "x" << i << "|16 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c08, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c08, "geodesic.c08.2d.size.sh");
+
+
+ return 0;
+}
+
+
+void test_influence_zone_geodesic_3d()
+{
+ mln::util::timer timer;
+
+ // Test the number of labels c06
+ mln::image1d<float> chart_seed_c06(5*5*5+2);
+
+ mln::data::fill(chart_seed_c06, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(i,128), mln::c6());
+ std::cout << "c06|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c06, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c06, "geodesic.c06.3d.seed.sh");
+
+ // Test the number of labels c18
+ mln::image1d<float> chart_seed_c18(5*5*5+2);
+
+ mln::data::fill(chart_seed_c18, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(i,128), mln::c18());
+ std::cout << "c18|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c18, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c18, "geodesic.c18.3d.seed.sh");
+
+ // Test the number of labels c26
+ mln::image1d<float> chart_seed_c26(5*5*5+2);
+
+ mln::data::fill(chart_seed_c26, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(i,128), mln::c26());
+ std::cout << "c26|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c26, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c26, "geodesic.c26.3d.seed.sh");
+
+ // Test the size of the image c06
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c06(128+1);
+
+ mln::data::fill(chart_size_c06, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(2,i), mln::c6());
+ std::cout << "c06|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c06, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c06, "geodesic.c06.3d.size.sh");
+
+ // Test the size of the image c18
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c18(128+1);
+
+ mln::data::fill(chart_size_c18, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(2,i), mln::c18());
+ std::cout << "c18|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c18, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c18, "geodesic.c18.3d.size.sh");
+
+ // Test the size of the image c26
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c26(128+1);
+
+ mln::data::fill(chart_size_c26, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_geodesic_3d(timer, build_input3d(2,i), mln::c26());
+ std::cout << "c26|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c26, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c26, "geodesic.c26.3d.size.sh");
+}
+
+//------------------------------------------------------------------------------
+// Bench front distance
+//------------------------------------------------------------------------------
+
+void influence_zone_front_2d(mln::util::timer& timer,
+ const mln::image2d<mln::value::label_8>& input,
+ const mln::neighb2d& neighb,
+ const mln::w_window2d_int& w2d)
+{
+ mln::image2d<mln::value::label_8> output;
+
+ timer.start();
+ output = mln::transform::influence_zone_front(input, neighb, w2d);
+ timer.stop();
+
+ //mln::io::pgm::save(output, "output.pgm");
+}
+
+
+void influence_zone_front_3d(mln::util::timer& timer,
+ const mln::image3d<mln::value::label_8>& input,
+ const mln::neighb3d& neighb,
+ const mln::w_window3d_int& w3d)
+{
+ mln::image3d<mln::value::label_8> output;
+
+ timer.start();
+ output = mln::transform::influence_zone_front(input, neighb, w3d);
+ timer.stop();
+
+ //mln::io::pgm::save(output, "output.pgm");
+}
+
+
+void test_influence_zone_front_3d()
+{
+ mln::util::timer timer;
+
+ int ws_c06[] = {
+ // Internal slice
+ 0, 0, 0,
+ 0, 2, 0,
+ 0, 0, 0,
+ // Middle slice
+ 0, 2, 0,
+ 2, 0, 2,
+ 0, 2, 0,
+ // External slice
+ 0, 0, 0,
+ 0, 2, 0,
+ 0, 0, 0 };
+
+ int ws_c18[] = {
+ // Internal slice
+ 0, 6, 0,
+ 6, 4, 6,
+ 0, 6, 0,
+ // Middle slice
+ 6, 4, 6,
+ 4, 0, 4,
+ 6, 4, 6,
+ // External slice
+ 0, 6, 0,
+ 6, 4, 6,
+ 0, 6, 0 };
+
+ int ws_c26[] = {
+ // Internal slice
+ 7, 6, 7,
+ 6, 4, 6,
+ 7, 6, 7,
+ // Middle slice
+ 6, 4, 6,
+ 4, 0, 4,
+ 6, 4, 6,
+ // External slice
+ 7, 6, 7,
+ 6, 4, 6,
+ 7, 6, 7 };
+
+ mln::w_window3d_int w3d_c06 = mln::make::w_window3d_int(ws_c06);
+ mln::w_window3d_int w3d_c18 = mln::make::w_window3d_int(ws_c18);
+ mln::w_window3d_int w3d_c26 = mln::make::w_window3d_int(ws_c26);
+
+ // Test the number of labels c06
+ mln::image1d<float> chart_seed_c06(5*5*5+2);
+
+ mln::data::fill(chart_seed_c06, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(i,128), mln::c6(), w3d_c06);
+ std::cout << "c06|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c06, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c06, "front.c06.3d.seed.sh");
+
+ // Test the number of labels c18
+ mln::image1d<float> chart_seed_c18(5*5*5+2);
+
+ mln::data::fill(chart_seed_c18, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(i,128), mln::c18(), w3d_c18);
+ std::cout << "c18|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c18, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c18, "front.c18.3d.seed.sh");
+
+ // Test the number of labels c26
+ mln::image1d<float> chart_seed_c26(5*5*5+2);
+
+ mln::data::fill(chart_seed_c26, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(i,128), mln::c26(), w3d_c26);
+ std::cout << "c26|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c26, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c26, "front.c26.3d.seed.sh");
+
+ // Test the size of the image c06
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c06(128+1);
+
+ mln::data::fill(chart_size_c06, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(2,i), mln::c6(), w3d_c06);
+ std::cout << "c06|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c06, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c06, "front.c06.3d.size.sh");
+
+ // Test the size of the image c18
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c18(128+1);
+
+ mln::data::fill(chart_size_c18, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(2,i), mln::c18(), w3d_c18);
+ std::cout << "c18|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c18, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c18, "front.c18.3d.size.sh");
+
+ // Test the size of the image c26
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c26(128+1);
+
+ mln::data::fill(chart_size_c26, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_front_3d(timer, build_input3d(2,i), mln::c26(), w3d_c26);
+ std::cout << "c26|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c26, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c26, "front.c26.3d.size.sh");
+}
+
+void test_influence_zone_front_2d()
+{
+ mln::util::timer timer;
+
+ int ws_c04[] = {
+ 0, 2, 0,
+ 2, 0, 2,
+ 0, 2, 0};
+
+ int ws_c08[] = {
+ 6, 4, 6,
+ 4, 0, 4,
+ 6, 4, 6};
+
+ mln::w_window2d_int w2d_c04 = mln::make::w_window2d_int(ws_c04);
+ mln::w_window2d_int w2d_c08 = mln::make::w_window2d_int(ws_c08);
+
+ // Test the label c4
+ mln::image1d<float> chart_seed_c04(16*16+2);
+
+ mln::data::fill(chart_seed_c04, mln::literal::zero);
+
+ for (unsigned i = 1; i < 16+1; ++i)
+ {
+ influence_zone_front_2d(timer,build_input2d(i,256),mln::c4(),w2d_c04);
+ std::cout << "c04|256x256|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c04, i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c04, "front.c04.2d.seed.sh");
+
+ // Test the label c8
+ mln::image1d<float> chart_seed_c08(16*16+2);
+
+ mln::data::fill(chart_seed_c08, mln::literal::zero);
+
+ for (unsigned i = 1; i < 16+1; ++i)
+ {
+ influence_zone_front_2d(timer,build_input2d(i,256),mln::c8(),w2d_c08);
+ std::cout << "c08|256x256|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed_c08, i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed_c08, "front.c08.2d.seed.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c04(256+1);
+
+ mln::data::fill(chart_size_c04, mln::literal::zero);
+
+ for (unsigned i = 16; i < 256+1; ++i)
+ {
+ influence_zone_front_2d(timer, build_input2d(4,i),mln::c4(),w2d_c04);
+ std::cout << "c04|" << i << "x" << i << "|16 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c04, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c04, "front.c04.2d.size.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size_c08(256+1);
+
+ mln::data::fill(chart_size_c08, mln::literal::zero);
+
+ for (unsigned i = 16; i < 256+1; ++i)
+ {
+ influence_zone_front_2d(timer, build_input2d(4,i),mln::c8(),w2d_c08);
+ std::cout << "c08|" << i << "x" << i << "|16 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size_c08, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size_c08, "front.c08.2d.size.sh");
+}
+
+
+
+
+
+
+//------------------------------------------------------------------------------
+// Bench euclidian distance
+//------------------------------------------------------------------------------
+
+void influence_zone_euclidian_2d(mln::util::timer& timer,
+ const mln::image2d<mln::value::label_8>& input,
+ const mln::util::array<mln::point2d>& seed)
+{
+ mln::image2d<mln::value::label_8> output;
+
+ timer.start();
+
+ mln::initialize(output, input);
+
+ mln_piter_(mln::image2d<mln::value::label_8>) p(output.domain());
+ mln_eiter_(mln::util::array<mln::point2d>) e(seed);
+
+ for_all(p)
+ {
+ unsigned d = 0;
+ unsigned min_d = mln_max(unsigned);
+ unsigned min_l = 0;
+
+ for_all(e)
+ {
+ d = distance(p, seed(e.index_()));
+
+ if (min_d > d)
+ {
+ min_d = d;
+ min_l = input(e);
+ }
+ }
+
+ output(p) = min_l;
+ }
+
+ timer.stop();
+
+ //mln::io::pgm::save(output, "output.pgm");
+}
+
+
+void influence_zone_euclidian_3d(mln::util::timer& timer,
+ const mln::image3d<mln::value::label_8>& input,
+ const mln::util::array<mln::point3d>& seed)
+{
+ mln::image3d<mln::value::label_8> output;
+
+ timer.start();
+
+ mln::initialize(output, input);
+
+ mln_piter_(mln::image3d<mln::value::label_8>) p(output.domain());
+ mln_eiter_(mln::util::array<mln::point3d>) e(seed);
+
+ for_all(p)
+ {
+ unsigned d = 0;
+ unsigned min_d = mln_max(unsigned);
+ unsigned min_l = 0;
+
+ for_all(e)
+ {
+ d = distance(p, seed(e.index_()));
+
+ if (min_d > d)
+ {
+ min_d = d;
+ min_l = input(e);
+ }
+ }
+
+ output(p) = min_l;
+ }
+
+ timer.stop();
+}
+
+void test_influence_zone_euclidian_2d()
+{
+ mln::util::timer timer;
+/*
+ // Global test
+ mln::image2d<float> chart(mln::box2d(mln::point2d(0,0),
+ mln::point2d(16*16+2,256+1)));
+
+ mln::data::fill(chart, mln::literal::zero);
+
+ for (unsigned i = 1; i < 256+1; ++i) // size
+ for (unsigned j = 1; j < i*i && j < 16+1; ++j) // seed
+ {
+ influence_zone_euclidian_2d(timer,build_input2d(j,i),build_seed2d(j,i));
+ std::cout << "xxx|" << i << "x" << i << "|" << j << " = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart, j*j,i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart, "chart.sh");
+*/
+
+ // Test the number of labels
+ mln::image1d<float> chart_seed(16*16+2);
+
+ mln::data::fill(chart_seed, mln::literal::zero);
+
+ for (unsigned i = 1; i < 16+1; ++i)
+ {
+ influence_zone_euclidian_2d(timer,build_input2d(i,256),build_seed2d(i,256));
+ std::cout << "xxx|256x256|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed, i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed, "euclidian.2d.seed.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size(256+1);
+
+ mln::data::fill(chart_size, mln::literal::zero);
+
+ for (unsigned i = 16; i < 256+1; ++i)
+ {
+ influence_zone_euclidian_2d(timer, build_input2d(4,i), build_seed2d(4,i));
+ std::cout << "xxx|" << i << "x" << i << "|16 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size, "euclidian.2d.size.sh");
+}
+
+
+void test_influence_zone_euclidian_3d()
+{
+ mln::util::timer timer;
+
+ // Test the number of labels
+ mln::image1d<float> chart_seed(5*5*5+2);
+
+ mln::data::fill(chart_seed, mln::literal::zero);
+
+ for (unsigned i = 1; i < 5+1; ++i)
+ {
+ influence_zone_euclidian_3d(timer,build_input3d(i,128),build_seed3d(i,128));
+ std::cout << "xxx|128x128x128|" << i << " = " << timer.read() << std::endl;
+ mln::opt::at(chart_seed, i*i*i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_seed, "euclidian.3d.seed.sh");
+
+ // Test the size of the image
+ // 1, 2, 4, 8, 16, 32, 64, 128, 256
+ mln::image1d<float> chart_size(128+1);
+
+ mln::data::fill(chart_size, mln::literal::zero);
+
+ for (unsigned i = 6; i < 128+1; ++i)
+ {
+ influence_zone_euclidian_3d(timer, build_input3d(2,i), build_seed3d(2,i));
+ std::cout << "xxx|" << i << "x" << i << "x" << i << "|8 = "
+ << timer.read() << std::endl;
+ mln::opt::at(chart_size, i) = timer.read();
+ }
+
+ mln::io::plot::save_image_sh(chart_size, "euclidian.3d.size.sh");
+}
+
+
+//------------------------------------------------------------------------------
+// Main
+//
+// Point de fonctionnement du système [image de taille entre 1 et 256]
+// Moins de 16 labels
+//
+//------------------------------------------------------------------------------
+
+
+int main()
+{
+ //test_influence_zone_geodesic_3d();
+ //test_influence_zone_front_3d();
+ //test_influence_zone_euclidian_3d()
+
+/*
+ test_influence_zone_euclidian_2d();
+ test_influence_zone_front_2d();
+ test_influence_zone_geodesic_2d();
+*/
+ test_influence_zone_euclidian_3d();
+ //test_influence_zone_geodesic_3d();
+ //test_influence_zone_front_3d();
+
+ return 0;
+}
--
1.5.6.5
1
0
* green/mln/demo/annoting/bic/Makefile: New Makefile.
* green/mln/demo/annoting/bic/bic.cc: New impl. of the bic descriptor.
* green/mln/demo/annoting/lep/Makefile: New Makefile.
* green/mln/demo/annoting/lep/lep.cc: New impl. of the lep descriptor.
* green/mln/demo/annoting/project/Makefile: New Makefile.
* green/mln/demo/annoting/project/project.cc: New impl. of the project
descriptor.
* green/mln/demo/annoting/rgb_64/Makefile: New Makefile.
* green/mln/demo/annoting/rgb_64/rgb_64.cc: New impl. of the rgb_64
descriptor.
* green/mln/demo/annoting/rgb_64_9/Makefile: New Makefile.
* green/mln/demo/annoting/rgb_64_9/rgb_64_9.cc: New impl. of the
rgb_64_9 descriptor.
* green/mln/demo/annoting/class.txt: New notes on fax class.
---
milena/sandbox/ChangeLog | 25 +++
milena/sandbox/green/demo/annoting/bic/Makefile.am | 150 ++++++++++++++
milena/sandbox/green/demo/annoting/bic/bic.cc | 87 ++++++++
milena/sandbox/green/demo/annoting/class.txt | 33 +++
milena/sandbox/green/demo/annoting/lep/Makefile.am | 150 ++++++++++++++
milena/sandbox/green/demo/annoting/lep/lep.cc | 92 +++++++++
.../green/demo/annoting/project/Makefile.am | 150 ++++++++++++++
.../sandbox/green/demo/annoting/project/project.cc | 210 ++++++++++++++++++++
.../sandbox/green/demo/annoting/rgb_64/Makefile.am | 150 ++++++++++++++
.../sandbox/green/demo/annoting/rgb_64/rgb_64.cc | 47 +++++
.../green/demo/annoting/rgb_64_9/Makefile.am | 150 ++++++++++++++
.../green/demo/annoting/rgb_64_9/rgb_64_9.cc | 97 +++++++++
12 files changed, 1341 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/green/demo/annoting/bic/Makefile.am
create mode 100644 milena/sandbox/green/demo/annoting/bic/bic.cc
create mode 100644 milena/sandbox/green/demo/annoting/class.txt
create mode 100644 milena/sandbox/green/demo/annoting/lep/Makefile.am
create mode 100644 milena/sandbox/green/demo/annoting/lep/lep.cc
create mode 100644 milena/sandbox/green/demo/annoting/project/Makefile.am
create mode 100644 milena/sandbox/green/demo/annoting/project/project.cc
create mode 100644 milena/sandbox/green/demo/annoting/rgb_64/Makefile.am
create mode 100644 milena/sandbox/green/demo/annoting/rgb_64/rgb_64.cc
create mode 100644 milena/sandbox/green/demo/annoting/rgb_64_9/Makefile.am
create mode 100644 milena/sandbox/green/demo/annoting/rgb_64_9/rgb_64_9.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index e93eeb8..83bd7f7 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,30 @@
2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Works on Millet2008 descriptors.
+
+ * green/mln/demo/annoting/bic/Makefile: New Makefile.
+ * green/mln/demo/annoting/bic/bic.cc: New impl. of the bic descriptor.
+
+ * green/mln/demo/annoting/lep/Makefile: New Makefile.
+ * green/mln/demo/annoting/lep/lep.cc: New impl. of the lep descriptor.
+
+ * green/mln/demo/annoting/project/Makefile: New Makefile.
+ * green/mln/demo/annoting/project/project.cc: New impl. of the project
+ descriptor.
+
+ * green/mln/demo/annoting/rgb_64/Makefile: New Makefile.
+ * green/mln/demo/annoting/rgb_64/rgb_64.cc: New impl. of the rgb_64
+ descriptor.
+
+ * green/mln/demo/annoting/rgb_64_9/Makefile: New Makefile.
+ * green/mln/demo/annoting/rgb_64_9/rgb_64_9.cc: New impl. of the
+ rgb_64_9 descriptor.
+
+ * green/mln/demo/annoting/class.txt: New notes on fax class.
+
+
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Extend the test image database.
* green/mln/img_path.hh: Add annoting directories to experiment
diff --git a/milena/sandbox/green/demo/annoting/bic/Makefile.am b/milena/sandbox/green/demo/annoting/bic/Makefile.am
new file mode 100644
index 0000000..96eafb4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/bic/Makefile.am
@@ -0,0 +1,150 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+#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/demo
+BUILD__PATTERN= green/build/demo
+
+
+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/milena/sandbox/green/demo/annoting/bic/bic.cc b/milena/sandbox/green/demo/annoting/bic/bic.cc
new file mode 100644
index 0000000..7e15970
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/bic/bic.cc
@@ -0,0 +1,87 @@
+// Test de l'opérateur de Millet BIC
+// Composante RGB sur 6 bits, puis on distingue les points intérieurs des points
+// extérieurs. Les points intérieurs ont la même couleur que leur 4-voisinage.
+// Puis on construit les 2 histogrammes (intérieur/extérieur)
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/routine/initialize.hh>
+#include <mln/core/var.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/convert.hh>
+#include <mln/data/transform.hh>
+#include <mln/data/fill.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/img_path.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/io/plot/save_image_sh.hh>
+
+#include <mln/literal/colors.hh>
+
+#include <mln/value/rgb.hh>
+#include <mln/value/rgb8.hh>
+
+int main()
+{
+ typedef mln::value::rgb<3> t_rgb3;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::neighb2d t_neighb2d;
+ typedef mln::image2d<t_rgb3> t_image2d_rgb3;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<3> t_rgb8_to_rgb3;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgb3 input_rgb3;
+ t_image2d_rgb3 interior_rgb3;
+ t_image2d_rgb3 exterior_rgb3;
+ t_histo3d histo_exterior;
+ t_histo3d histo_interior;
+
+ // IMAGE LOADING PHASE
+ std::cout << "Image loading phase ..." << std::endl;
+ mln::io::ppm::load(input_rgb8, SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm");
+ input_rgb3 = mln::data::transform(input_rgb8, t_rgb8_to_rgb3());
+
+ mln::initialize(interior_rgb3, input_rgb3);
+ mln::initialize(exterior_rgb3, input_rgb3);
+
+ mln::data::fill(interior_rgb3, mln::literal::black);
+ mln::data::fill(exterior_rgb3, mln::literal::black);
+
+ mln_piter_(t_image2d_rgb3) p(input_rgb3.domain());
+ mln_niter_(t_neighb2d) n(mln::c4(), p);
+
+ for_all(p)
+ {
+ bool is_interior = true;
+
+ for_all(n)
+ is_interior = is_interior && (input_rgb3(p) == input_rgb3(n));
+
+ if (is_interior)
+ interior_rgb3(p) = input_rgb3(p);
+ else
+ exterior_rgb3(p) = input_rgb3(p);
+ }
+
+ histo_interior = mln::data::compute(t_histo3d_fun(), interior_rgb3);
+ histo_exterior = mln::data::compute(t_histo3d_fun(), exterior_rgb3);
+
+ //mln::io::plot::save_image_sh(histo, "histo.sh");
+
+ // PRINTING PHASE
+ mln::debug::println(histo_interior);
+ mln::debug::println(histo_exterior);
+}
diff --git a/milena/sandbox/green/demo/annoting/class.txt b/milena/sandbox/green/demo/annoting/class.txt
new file mode 100644
index 0000000..ec7e92e
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/class.txt
@@ -0,0 +1,33 @@
+Dans scribo les classes de documents sont:
+
+- image seule (photo)
+- courrier manuscrit
+- courrier dactylographié
+- facture ou feuille organisée sous forme de tableau
+- article de journal
+- document composite
+- infographie (logo, carte, dessin vectoriel)
+- slide (copie d'écran ou sauvegarde au format image)
+
+
+Où se situent les faxes ?
+
+
+Description d'un fax:
+- ratio l/L assimilable à du A4 ou US Letter
+- nombre de couleurs très petit, < 1000
+- plutôt du N & B, mais quelques faxes sont en couleurs
+- généralement un % élevé de blanc (la page vierge)
+
+
+Description d'un article de journal:
+- nombre élevés de couleurs (> 10 000) en général
+- quelques articles de conférences autour de 5000
+
+
+Description des photos:
+- un nombre très élevé de couleurs
+- ratio non A4, non US Letter
+
+
+
diff --git a/milena/sandbox/green/demo/annoting/lep/Makefile.am b/milena/sandbox/green/demo/annoting/lep/Makefile.am
new file mode 100644
index 0000000..96eafb4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/lep/Makefile.am
@@ -0,0 +1,150 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+#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/demo
+BUILD__PATTERN= green/build/demo
+
+
+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/milena/sandbox/green/demo/annoting/lep/lep.cc b/milena/sandbox/green/demo/annoting/lep/lep.cc
new file mode 100644
index 0000000..24ee7b4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/lep/lep.cc
@@ -0,0 +1,92 @@
+// Test de l'opérateur de Millet LEP
+// Composante RGB sur 6 bits, puis sobel 3x3, puis identification configuration
+// L'image histogramme des configurations est la résultante
+
+#include <iostream>
+
+#include <mln/accu/stat/histo1d.hh>
+
+#include <mln/binarization/threshold.hh>
+
+#include <mln/core/alias/w_window2d_int.hh>
+#include <mln/core/image/image2d.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/convert.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/img_path.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/plot/save_image_sh.hh>
+
+#include <mln/linear/ch_convolve.hh>
+#include <mln/linear/convolve.hh>
+#include <mln/linear/sobel_2d.hh>
+
+#include <mln/make/w_window2d.hh>
+
+#include <mln/value/rgb.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/core/var.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef mln::w_window2d_int t_win2d;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::int_u<9> t_int_u9;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_int_u9> t_image2d_int_u9;
+ typedef mln::image2d<int> t_image2d_int;
+ typedef mln::image2d<unsigned> t_image2d_unsigned;
+ typedef mln::image2d<float> t_image2d_float;
+ typedef mln::image2d<double> t_image2d_double;
+ typedef mln::image2d<bool> t_image2d_bool;
+ typedef mln::image1d<unsigned> t_histo1d;
+ typedef mln::accu::meta::stat::histo1d t_histo1d_fun;
+
+ t_image2d_int_u8 input_int_u8;
+ t_image2d_int input_int;
+ t_image2d_unsigned input_unsigned;
+ t_image2d_float sobel;
+ t_image2d_bool thresh_bool;
+ t_image2d_int_u8 thresh_int_u8;
+ t_image2d_float conf_float;
+ t_image2d_int_u9 conf_int_u9;
+ t_histo1d histo;
+
+ // IMAGE LOADING PHASE
+ std::cout << "Image loading phase ..." << std::endl;
+ mln::io::pgm::load(input_int_u8,SCRIBO_PGM_IMG_PATH"/mp00082c_50p_8bits.pgm");
+
+ sobel = mln::linear::sobel_2d_l1_norm(input_int_u8);
+
+ //mln::io::plot::save_image_sh(sobel, "sobel.sh");
+ thresh_bool = mln::binarization::threshold(sobel, 100);
+ thresh_int_u8 = mln::data::convert(mln::value::int_u8(), thresh_bool);
+ //mln::io::plot::save_image_sh(thresh, "thresh.sh");
+
+ int ws[] = { 1, 2, 4,
+ 8, 256, 16,
+ 32, 64, 128 };
+
+ t_win2d win2d = mln::make::w_window2d(ws);
+ conf_float = mln::linear::convolve(thresh_int_u8, win2d);
+ conf_int_u9 = mln::data::convert(t_int_u9(), conf_float);
+ histo = mln::data::compute(t_histo1d_fun(), conf_int_u9);
+
+ mln::io::plot::save_image_sh(histo, "histo.sh");
+
+ // PRINTING PHASE
+ mln::debug::println(histo);
+}
diff --git a/milena/sandbox/green/demo/annoting/project/Makefile.am b/milena/sandbox/green/demo/annoting/project/Makefile.am
new file mode 100644
index 0000000..96eafb4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/project/Makefile.am
@@ -0,0 +1,150 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+#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/demo
+BUILD__PATTERN= green/build/demo
+
+
+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/milena/sandbox/green/demo/annoting/project/project.cc b/milena/sandbox/green/demo/annoting/project/project.cc
new file mode 100644
index 0000000..e6b25e3
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/project/project.cc
@@ -0,0 +1,210 @@
+// Test de l'opérateur de Millet PROJECT
+// subsampling the image sur 100x100
+// Sobel, puis seuillage à 100
+// division horizontale de l'image, puis projection verticale des pixels
+// division verticale puis projection horizontale
+// assemblage des 4 vecteurs de taille 100
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/accu/image/init.hh>
+#include <mln/accu/image/take.hh>
+#include <mln/accu/image/to_result.hh>
+#include <mln/accu/stat/mean.hh>
+
+#include <mln/binarization/threshold.hh>
+
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/routine/initialize.hh>
+#include <mln/core/image/dmorph/unproject_image.hh>
+
+
+
+#include <mln/data/compute.hh>
+#include <mln/data/convert.hh>
+#include <mln/data/paste.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/fun/v2v/projection.hh>
+
+#include <mln/img_path.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/linear/sobel_2d.hh>
+
+#include <mln/opt/at.hh>
+
+const char *get_name(const char *base, const unsigned i, const unsigned j)
+{
+ std::ostringstream name;
+
+ name << base;
+ name << i;
+ name << "_";
+ name << j;
+ name << ".ppm";
+
+ return name.str().c_str();
+}
+
+
+mln::image1d<mln::value::int_u8>
+project_row(const mln::image2d<mln::value::int_u8>& img)
+{
+ typedef mln::accu::math::sum<mln::value::int_u8,mln::value::int_u8> t_sum;
+ typedef mln::fun::v2v::projection<mln::point2d,0> t_projection;
+
+ mln::image1d<t_sum> img_accu(img.ncols());
+
+ mln::accu::image::init(img_accu);
+
+ mln::accu::image::take(unproject(img_accu,
+ img.domain(),
+ t_projection()).rw(),
+ img);
+
+ return mln::accu::image::to_result(img_accu);
+}
+
+mln::image1d<mln::value::int_u8>
+project_col(const mln::image2d<mln::value::int_u8>& img)
+{
+ typedef mln::accu::math::sum<mln::value::int_u8,mln::value::int_u8> t_sum;
+ typedef mln::fun::v2v::projection<mln::point2d,1> t_projection;
+
+ mln::image1d<t_sum> img_accu(img.nrows());
+
+ mln::accu::image::init(img_accu);
+
+ mln::accu::image::take(unproject(img_accu,
+ img.domain(),
+ t_projection()).rw(),
+ img);
+
+ return mln::accu::image::to_result(img_accu);
+}
+
+
+int main()
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::algebra::vec<3,unsigned> t_vec3u;
+ typedef mln::image2d<float> t_image2d_float;
+ typedef mln::image2d<bool> t_image2d_bool;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::accu::meta::stat::mean t_mean_fun;
+ typedef mln::accu::math::sum<t_int_u8,t_int_u8> t_sum;
+ typedef mln::image1d<t_int_u8> t_image1d_int_u8;
+
+ t_image2d_int_u8 input_int_u8;
+ t_image2d_float sobel;
+ t_image2d_bool thresh_bool;
+ t_image2d_int_u8 thresh_int_u8;
+
+ // IMAGE LOADING PHASE
+ std::cout << "Image loading phase ..." << std::endl;
+ mln::io::pgm::load(input_int_u8,SCRIBO_PGM_IMG_PATH"/mp00082c_50p_8bits.pgm");
+
+
+ // IMAGE SPLITTING PHASE
+ t_image2d_int_u8 subimg_int_u8(mln::box2d(mln::point2d(0,0),
+ mln::point2d(100,100)));
+
+ mln::box2d domain = input_int_u8.domain();
+ mln::point2d pmin = domain.pmin();
+ mln::point2d pmax = domain.pmax();
+
+ unsigned sz_row = (pmax.row() - pmin.row())/ 100;
+ unsigned sz_col = (pmax.col() - pmin.col())/ 100;
+
+ std::cout << domain << std::endl;
+
+ // Subsampling in 100x100
+ // FIXME Test that is it a subsampling, not a upsampling!
+ for (unsigned i = 0; i < 100; ++i)
+ for (unsigned j = 0; j < 100; ++j)
+ {
+ mln::point2d min(pmin.row()+sz_row*i,pmin.col()+sz_col*j);
+ mln::point2d max(pmin.row()+sz_row*(i+1),pmin.col()+sz_col*(j+1));
+ mln::box2d dom(min,max);
+
+ std::cout << dom << std::endl;
+
+ // Save it
+ t_image2d_int_u8 input_part_int_u8(dom);
+
+ mln::data::paste(input_int_u8 | dom, input_part_int_u8);
+ //mln::io::pgm::save(input_part_int_u8, get_name("output",i,j));
+ float mean = mln::data::compute(t_mean_fun(), input_part_int_u8);
+ t_int_u8 val = static_cast<t_int_u8>(mean);
+ mln::opt::at(subimg_int_u8, i,j) = val;
+ }
+
+ mln::io::pgm::save(subimg_int_u8, "subimg.pgm");
+
+ sobel = mln::linear::sobel_2d_l1_norm(subimg_int_u8);
+ thresh_bool = mln::binarization::threshold(sobel, 100);
+ thresh_int_u8 = mln::data::convert(t_int_u8(), thresh_bool);
+
+ mln::io::pbm::save(thresh_bool, "subimg.pbm");
+
+ // Define img_up, img_down, img_left, img_right
+ t_image2d_int_u8 img_up(mln::box2d(mln::point2d(0,0),
+ mln::point2d(49,99)));
+
+ mln::data::paste(thresh_int_u8 | img_up.domain(), img_up);
+
+
+ t_image2d_int_u8 img_down(mln::box2d(mln::point2d(50,0),
+ mln::point2d(99,99)));
+
+ mln::data::paste(thresh_int_u8 | img_down.domain(), img_down);
+
+ t_image2d_int_u8 img_left(mln::box2d(mln::point2d(0,0),
+ mln::point2d(99,49)));
+
+ mln::data::paste(thresh_int_u8 | img_left.domain(), img_left);
+
+
+ t_image2d_int_u8 img_right(mln::box2d(mln::point2d(0,50),
+ mln::point2d(99,99)));
+
+ mln::data::paste(thresh_int_u8 | img_right.domain(), img_right);
+
+
+ // Define project_up, project_down, project_left, project_right
+ t_image1d_int_u8 project_up = project_row(img_up);
+ t_image1d_int_u8 project_down = project_row(img_down);
+ t_image1d_int_u8 project_left = project_col(img_left);
+ t_image1d_int_u8 project_right = project_col(img_right);
+
+ mln::io::pgm::save(img_up, "up.pgm");
+ mln::io::pgm::save(img_down, "down.pgm");
+ mln::io::pgm::save(img_left, "left.pgm");
+ mln::io::pgm::save(img_right, "right.pgm");
+
+ // PRINTING PHASE
+
+ std::cout << std::endl << "UP" << std::endl;
+ mln::debug::println(project_up);
+
+ std::cout << std::endl << "DOWN" << std::endl;
+ mln::debug::println(project_down);
+
+ std::cout << std::endl << "LEFT" << std::endl;
+ mln::debug::println(project_left);
+
+ std::cout << std::endl << "RIGHT" << std::endl;
+ mln::debug::println(project_right);
+}
diff --git a/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am b/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am
new file mode 100644
index 0000000..96eafb4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am
@@ -0,0 +1,150 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+#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/demo
+BUILD__PATTERN= green/build/demo
+
+
+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/milena/sandbox/green/demo/annoting/rgb_64/rgb_64.cc b/milena/sandbox/green/demo/annoting/rgb_64/rgb_64.cc
new file mode 100644
index 0000000..9ff2300
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/rgb_64/rgb_64.cc
@@ -0,0 +1,47 @@
+// Test de l'opérateur de Millet RGB-64
+// Composante RGB sur 2 bits, puis histogramme de 64 composantes
+// L'image est la résultante
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/img_path.hh>
+
+#include <mln/io/ppm/load.hh>
+
+#include <mln/value/rgb.hh>
+#include <mln/value/rgb8.hh>
+
+int main()
+{
+ typedef mln::fun::v2v::rgb8_to_rgbn<2> t_rgb8_to_rgb2;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<2> t_rgb2;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgb2> t_image2d_rgb2;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgb2 input_rgb2;
+ t_histo3d histo;
+
+ // IMAGE LOADING PHASE
+ std::cout << "Image loading phase ..." << std::endl;
+ mln::io::ppm::load(input_rgb8, SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm");
+ input_rgb2 = mln::data::transform(input_rgb8, t_rgb8_to_rgb2());
+ histo = mln::data::compute(t_histo3d_fun(), input_rgb2);
+
+ // PRINTING PHASE
+ mln::debug::println(histo);
+}
diff --git a/milena/sandbox/green/demo/annoting/rgb_64_9/Makefile.am b/milena/sandbox/green/demo/annoting/rgb_64_9/Makefile.am
new file mode 100644
index 0000000..96eafb4
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/rgb_64_9/Makefile.am
@@ -0,0 +1,150 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+#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/demo
+BUILD__PATTERN= green/build/demo
+
+
+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/milena/sandbox/green/demo/annoting/rgb_64_9/rgb_64_9.cc b/milena/sandbox/green/demo/annoting/rgb_64_9/rgb_64_9.cc
new file mode 100644
index 0000000..29e90f3
--- /dev/null
+++ b/milena/sandbox/green/demo/annoting/rgb_64_9/rgb_64_9.cc
@@ -0,0 +1,97 @@
+// Test de l'opérateur de Millet RGB-64
+// Composante RGB sur 2 bits, puis histogramme de 64 composantes
+// L'image est la résultante
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/core/routine/initialize.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/paste.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/img_path.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/value/rgb.hh>
+#include <mln/value/rgb8.hh>
+
+const char *get_name(const char *base, const unsigned i, const unsigned j)
+{
+ std::ostringstream name;
+
+ name << base;
+ name << i;
+ name << "_";
+ name << j;
+ name << ".ppm";
+
+ return name.str().c_str();
+}
+
+int main()
+{
+ typedef mln::fun::v2v::rgb8_to_rgbn<2> t_rgb8_to_rgb2;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<2> t_rgb2;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgb2> t_image2d_rgb2;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_rgb2 input_rgb2;
+ t_histo3d histo;
+
+ // IMAGE LOADING PHASE
+ std::cout << "Image loading phase ..." << std::endl;
+ mln::io::ppm::load(input_rgb8, SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm");
+
+ input_rgb2 = mln::data::transform(input_rgb8, t_rgb8_to_rgb2());
+
+ // IMAGE SPLITTING PHASE
+ mln::box2d domain = input_rgb2.domain();
+ mln::point2d pmin = domain.pmin();
+ mln::point2d pmax = domain.pmax();
+
+ unsigned sz_row = (pmax.row() - pmin.row())/ 3;
+ unsigned sz_col = (pmax.col() - pmin.col())/ 3;
+
+ std::cout << domain << std::endl;
+
+ // Divide the domain in nine sub-domains.
+ for (unsigned i = 0; i < 3; ++i)
+ for (unsigned j = 0; j < 3; ++j)
+ {
+ mln::point2d min(pmin.row()+sz_row*i,pmin.col()+sz_col*j);
+ mln::point2d max(pmin.row()+sz_row*(i+1),pmin.col()+sz_col*(j+1));
+ mln::box2d dom(min,max);
+
+ std::cout << dom << std::endl;
+
+ // Save it
+ t_image2d_rgb2 input_1o9_rgb2(dom);
+
+ mln::data::paste(input_rgb2 | dom, input_1o9_rgb2);
+ mln::io::ppm::save(input_1o9_rgb2, get_name("output",i,j));
+
+ histo = mln::data::compute(t_histo3d_fun(), input_1o9_rgb2);
+
+ // PRINTING PHASE
+ mln::debug::println(histo);
+ }
+
+}
--
1.5.6.5
1
0
* green/mln/img_path.hh: Add annoting directories to experiment
algorithms on fax, handwritten, typed, logo, bill, map, screenshot,
slide image.
---
milena/sandbox/ChangeLog | 8 ++++++++
milena/sandbox/green/mln/img_path.hh | 14 ++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 9e7f25b..e93eeb8 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Extend the test image database.
+
+ * green/mln/img_path.hh: Add annoting directories to experiment
+ algorithms on fax, handwritten, typed, logo, bill, map, screenshot,
+ slide image.
+
2009-11-17 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add some bench + canvas + subsampling + browsing code.
diff --git a/milena/sandbox/green/mln/img_path.hh b/milena/sandbox/green/mln/img_path.hh
index 90cdb49..188b813 100644
--- a/milena/sandbox/green/mln/img_path.hh
+++ b/milena/sandbox/green/mln/img_path.hh
@@ -33,10 +33,24 @@
#define INIM_IMG_PATH IMG_PATH"/inim"
#define INIM_FG_BG_IMG_PATH INIM_IMG_PATH"/fg_bg"
#define INIM_IN_IMG_PATH INIM_IMG_PATH"/in"
+
#define OLENA_IMG_PATH IMG_PATH"/olena"
+
#define SCRIBO_IMG_PATH IMG_PATH"/scribo"
#define SCRIBO_JPG_IMG_PATH SCRIBO_IMG_PATH"/jpg_50p"
#define SCRIBO_PGM_IMG_PATH SCRIBO_IMG_PATH"/pgm_50p"
#define SCRIBO_PPM_IMG_PATH SCRIBO_IMG_PATH"/ppm_50p"
+#define ANNOTING_IMG_PATH IMG_PATH"/annoting"
+#define ANNOTING_BILL_IMG_PATH ANNOTING_IMG_PATH"/bill"
+#define ANNOTING_FAX_IMG_PATH ANNOTING_IMG_PATH"/fax"
+#define ANNOTING_HANDWRITTEN_IMG_PATH ANNOTING_IMG_PATH"/handwritten"
+#define ANNOTING_LOGO_IMG_PATH ANNOTING_IMG_PATH"/logo"
+#define ANNOTING_MAP_IMG_PATH ANNOTING_IMG_PATH"/map"
+#define ANNOTING_SCREENSHOT_IMG_PATH ANNOTING_IMG_PATH"/screenshot"
+#define ANNOTING_SLIDE_IMG_PATH ANNOTING_IMG_PATH"/slide"
+#define ANNOTING_TYPED_IMG_PATH ANNOTING_IMG_PATH"/typed"
+
+
+
#endif // ! MLN_IMG_PATH_HH
--
1.5.6.5
1
0
last-svn-commit-1-g4ee2f2a Fix the outside template use case for the convolve macros.
by green 24 Feb '10
by green 24 Feb '10
24 Feb '10
* mln/linear/ch_convolve.hh (mln_ch_convolve_, mln_ch_convolve_grad_):
Define new macros to work outside templates.
---
milena/ChangeLog | 7 +++++++
milena/mln/linear/ch_convolve.hh | 9 ++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b3cd42e..10c5def 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-02 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix the outside template use case for the convolve macros.
+
+ * mln/linear/ch_convolve.hh (mln_ch_convolve_, mln_ch_convolve_grad_):
+ Define new macros to work outside templates.
+
2009-11-18 Guillaume Lazzara <z(a)lrde.epita.fr>
* doc/white_paper/white_paper.tex: Fix an invalid URL.
diff --git a/milena/mln/linear/ch_convolve.hh b/milena/mln/linear/ch_convolve.hh
index ef9fb42..9ea45e5 100644
--- a/milena/mln/linear/ch_convolve.hh
+++ b/milena/mln/linear/ch_convolve.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -44,9 +45,15 @@
# define mln_ch_convolve(I, W) \
typename mln::linear::ch_convolve<I, W>::ret
+# define mln_ch_convolve_(I, W) \
+ mln::linear::ch_convolve<I, W>::ret
+
+
# define mln_ch_convolve_grad(I, W) \
typename mln::trait::ch_value< I, algebra::vec< I::site::dim, typename mln::linear::ch_convolve<I,W>::ret::value > >::ret
+# define mln_ch_convolve_grad_(I, W) \
+ mln::trait::ch_value< I, algebra::vec< I::site::dim, mln::linear::ch_convolve<I,W>::ret::value > >::ret
namespace mln
--
1.5.6.5
1
0