* green/exp/annotating/stddev_color_16: New directory.
* green/exp/annotating/stddev_color_16/Makefile.am: New Makefile.
* green/exp/annotating/stddev_color_16/stddev_color_16.cc: New demo.
---
milena/sandbox/ChangeLog | 8 ++
.../{nb_color => stddev_color_16}/Makefile.am | 0
.../annotating/stddev_color_16/stddev_color_16.cc | 87 ++++++++++++--------
3 files changed, 60 insertions(+), 35 deletions(-)
copy milena/sandbox/green/exp/annotating/{nb_color => stddev_color_16}/Makefile.am
(100%)
copy milena/sandbox/green/{demo => exp}/annotating/stddev_color_16/stddev_color_16.cc
(70%)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 423c61b..7ec7a8a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,14 @@
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Test the local deviation operator (Millet2008) on the annotating base.
+
+ * green/exp/annotating/stddev_color_16: New directory.
+ * green/exp/annotating/stddev_color_16/Makefile.am: New Makefile.
+ * green/exp/annotating/stddev_color_16/stddev_color_16.cc: New demo.
+
+2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Introduce the local deviation operator (Millet2008) which
subdivise the image in 16 parts.
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
b/milena/sandbox/green/exp/annotating/stddev_color_16/Makefile.am
similarity index 100%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/exp/annotating/stddev_color_16/Makefile.am
diff --git a/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
b/milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
similarity index 70%
copy from milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
copy to milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
index 5e95c76..c196595 100644
--- a/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
+++ b/milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
+#include <boost/filesystem.hpp>
#include <mln/img_path.hh>
@@ -27,6 +28,7 @@
#include <mln/io/plot/save_image_sh.hh>
#include <mln/math/sqr.hh>
+#include <mln/math/max.hh>
#include <mln/opt/at.hh>
@@ -41,9 +43,7 @@ float r(short p, unsigned histo_p, short x, unsigned histo_x)
return result;
}
-unsigned stddev_color(mln::image2d<mln::value::int_u8> input_int_u8,
- const char *name_histo,
- const char *name_image)
+float stddev_color(mln::image2d<mln::value::int_u8> input_int_u8)
{
typedef mln::point1d t_point1d;
typedef mln::value::rgb8 t_rgb8;
@@ -57,15 +57,8 @@ unsigned stddev_color(mln::image2d<mln::value::int_u8>
input_int_u8,
t_histo1d histo;
- std::cout << "histo : " << name_histo << std::endl;
- std::cout << "image : " << name_image << std::endl;
-
histo = mln::data::compute(t_histo1d_fun(), input_int_u8);
- mln::io::pgm::save(input_int_u8, name_image);
- mln::io::plot::save_image_sh(histo, name_histo);
- mln::debug::println(histo);
-
// Find the peak of the histogram
unsigned v_max = mln::opt::at(histo, 0);
short p_max = 0;
@@ -100,16 +93,10 @@ unsigned stddev_color(mln::image2d<mln::value::int_u8>
input_int_u8,
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;
}
-unsigned stddev_color_16(const std::string& image)
+float stddev_color_16(const std::string& image)
{
typedef mln::point1d t_point1d;
typedef mln::value::rgb8 t_rgb8;
@@ -134,8 +121,7 @@ unsigned stddev_color_16(const std::string& image)
unsigned sz_row = (pmax.row() - pmin.row())/ 4;
unsigned sz_col = (pmax.col() - pmin.col())/ 4;
-
- std::cout << domain << std::endl;
+ float stddev = 0.0;
// Divide the domain in nine sub-domains.
for (unsigned i = 0; i < 4; ++i)
@@ -145,34 +131,65 @@ unsigned stddev_color_16(const std::string& image)
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_1o16_int_u8(dom);
- std::ostringstream name_histo("");
- std::ostringstream name_image("");
-
- name_histo << "histo" << i << "_" << j
<< ".sh";
- name_image << "image" << i << "_" << j
<< ".ppm";
mln::data::paste(input_int_u8 | dom, input_1o16_int_u8);
- stddev_color(input_1o16_int_u8,
- name_histo.str().c_str(),
- name_image.str().c_str());
+ stddev = mln::math::max(stddev, stddev_color(input_1o16_int_u8));
}
- return 0;
+ return stddev;
}
int main()
{
-// unsigned val = stddev_color_16(ANNOTATING_PHOTO_IMG_PATH "/photo01.ppm");
- unsigned val = stddev_color_16(ANNOTATING_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(ANNOTATING_BILL_IMG_PATH),
+ t_path(ANNOTATING_FAX_IMG_PATH),
+ t_path(ANNOTATING_HANDWRITTEN_IMG_PATH),
+ t_path(ANNOTATING_LOGO_IMG_PATH),
+ t_path(ANNOTATING_MAP_IMG_PATH),
+ t_path(ANNOTATING_PHOTO_IMG_PATH),
+ t_path(ANNOTATING_SCREENSHOT_IMG_PATH),
+ t_path(ANNOTATING_SLIDE_IMG_PATH),
+ t_path(ANNOTATING_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_16(dir_iter->path().string());
+
+ ++count;
+ sum1 += val;
+ sum2 += val*val;
+
+ std::cout << dir_iter->path().string() << " => " <<
val << std::endl;
+ }
+
+ 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