* green/tools/annotating/histo: New directory.
* green/tools/annotating/histo/Makefile.am: New Makefile.
* green/tools/annotating/histo/histo.cc: New source file.
* green/tools/annotating/opening: New directory.
* green/tools/annotating/opening/Makefile.am: New Makefile.
* green/tools/annotating/opening/opening.cc: New source file.
* green/tools/annotating/regmax: New directory.
* green/tools/annotating/regmax/Makefile.am: New Makefile.
* green/tools/annotating/regmax/regmax.cc: New source file.
---
milena/sandbox/ChangeLog | 14 ++
.../annotating/histo}/Makefile.am | 9 +-
.../sandbox/green/tools/annotating/histo/histo.cc | 121 ++++++++++++++++++
.../annotating/opening}/Makefile.am | 9 +-
.../green/tools/annotating/opening/opening.cc | 79 ++++++++++++
.../annotating/regmax}/Makefile.am | 9 +-
.../green/tools/annotating/regmax/regmax.cc | 133 ++++++++++++++++++++
7 files changed, 359 insertions(+), 15 deletions(-)
copy milena/sandbox/green/{exp/annotating/nb_color =>
tools/annotating/histo}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/histo/histo.cc
copy milena/sandbox/green/{exp/annotating/nb_color =>
tools/annotating/opening}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/opening/opening.cc
copy milena/sandbox/green/{exp/annotating/nb_color =>
tools/annotating/regmax}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/regmax/regmax.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 9c7bef7..6b0a1ac 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Split the regional maxima binary in small atomic binaries.
+
+ * green/tools/annotating/histo: New directory.
+ * green/tools/annotating/histo/Makefile.am: New Makefile.
+ * green/tools/annotating/histo/histo.cc: New source file.
+ * green/tools/annotating/opening: New directory.
+ * green/tools/annotating/opening/Makefile.am: New Makefile.
+ * green/tools/annotating/opening/opening.cc: New source file.
+ * green/tools/annotating/regmax: New directory.
+ * green/tools/annotating/regmax/Makefile.am: New Makefile.
+ * green/tools/annotating/regmax/regmax.cc: New source file.
+
2009-12-23 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Write the opening volume thresholds for the scribo image mp00082c.ppm.
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
b/milena/sandbox/green/tools/annotating/histo/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/histo/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/histo/Makefile.am
@@ -6,7 +6,6 @@
# 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)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/histo/histo.cc
b/milena/sandbox/green/tools/annotating/histo/histo.cc
new file mode 100644
index 0000000..ab0b8af
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/histo/histo.cc
@@ -0,0 +1,121 @@
+// TOOLS ==> Color histogram
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/macros.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/display/display_histo.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/dump/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.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/opt/at.hh>
+
+#include <mln/pw/value.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+
+
+template <unsigned n>
+void mk_histo(const std::string& input,
+ const std::string& output,
+ const std::string& histo,
+ const std::string& mask)
+{
+ 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_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<bool> t_image2d_bool;
+ 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;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_image2d_rgbn i1_input; // input rgbn
+ t_image2d_bool m0_input; // mask input
+ t_histo3d h1_input; // histo input
+ t_image2d_int_u8 p1_histo; // histo proj
+
+ mln::io::ppm::load(i0_input, input.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+
+ if (0 < mask.size())
+ {
+ mln::io::pbm::load(m0_input, mask.c_str());
+ h1_input = mln::data::compute(t_histo3d_fun(),
+ (i1_input | mln::pw::value(m0_input)).rw());
+ }
+ else
+ {
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+ }
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ p1_histo = mln::display::display_histo3d_unsigned(h1_input);
+ mln::io::dump::save(h1_input, histo.c_str());
+ mln::io::pgm::save(p1_histo, output.c_str());
+ // END DUMPING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "histo input.ppm q out.ppm histo.dump [msk.pbm]"
<< std::endl;
+ std::cout << "where"
<< std::endl;
+ std::cout << "input.ppm is the 8 bits color ppm image"
<< std::endl;
+ std::cout << "q is the degree of quanification {2,3,4,5,6,7,8}"
<< std::endl;
+ std::cout << "out.pgm is the r/g projection of the histogram"
<< std::endl;
+ std::cout << "out.dump is the quantified color histogram"
<< std::endl;
+ std::cout << "msk.pbm is the mask which select the pixels"
<< std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (5 == argc || 6 == argc)
+ {
+ const std::string input(args[1]);
+ const char q = args[2][0];
+ const std::string output(args[3]);
+ const std::string histo(args[4]);
+ const std::string mask(6 == argc? args[5] : "");
+
+ switch(q)
+ {
+ case '2': mk_histo<2>(input, output, histo, mask); break;
+ case '3': mk_histo<3>(input, output, histo, mask); break;
+ case '4': mk_histo<4>(input, output, histo, mask); break;
+ case '5': mk_histo<5>(input, output, histo, mask); break;
+ case '6': mk_histo<6>(input, output, histo, mask); break;
+ case '7': mk_histo<7>(input, output, histo, mask); break;
+ case '8': mk_histo<8>(input, output, histo, mask); break;
+ default: usage(); break;
+ }
+ }
+ else
+ usage();
+
+ return 0;
+}
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
b/milena/sandbox/green/tools/annotating/opening/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/opening/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/opening/Makefile.am
@@ -6,7 +6,6 @@
# 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)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/opening/opening.cc
b/milena/sandbox/green/tools/annotating/opening/opening.cc
new file mode 100644
index 0000000..3e1dbf2
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/opening/opening.cc
@@ -0,0 +1,79 @@
+// TOOLS ==> histogram filtering
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.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/data/compute.hh>
+
+#include <mln/display/display_histo.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/opening/volume.hh>
+
+#include <mln/value/int_u8.hh>
+
+void mk_opening(const std::string& input,
+ const unsigned min_vol,
+ const std::string& output,
+ const std::string& opened)
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_histo3d h1_input; // histo input
+ t_histo3d h2_input; // histo input
+ t_image2d_int_u8 p1_histo; // histo proj
+
+ mln::io::dump::load(h1_input, input.c_str());
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ p1_histo = mln::display::display_histo3d_unsigned(h2_input);
+ mln::io::dump::save(h2_input, opened.c_str());
+ mln::io::pgm::save(p1_histo, output.c_str());
+ // END DUMPING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "opening input.dump v out.dump out.ppm"
<< std::endl;
+ std::cout << "where"
<< std::endl;
+ std::cout << "input.dump is the 3d color input histo"
<< std::endl;
+ std::cout << "v is the minimum size of each composant"
<< std::endl;
+ std::cout << "out.pgm is the r/g proj of the opened histogram"
<< std::endl;
+ std::cout << "out.dump is the opened histogram"
<< std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (5 == argc)
+ {
+ const std::string input(args[1]);
+ const unsigned min_vol = atoi(args[2]);
+ const std::string output(args[3]);
+ const std::string opened(args[4]);
+
+ mk_opening(input, min_vol, output, opened);
+ }
+ else
+ usage();
+
+ return 0;
+}
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
b/milena/sandbox/green/tools/annotating/regmax/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/regmax/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/regmax/Makefile.am
@@ -6,7 +6,6 @@
# 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)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/regmax/regmax.cc
b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
new file mode 100644
index 0000000..2079bc4
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
@@ -0,0 +1,133 @@
+// TOOLS ==> regmax on histo
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.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/data/compute.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/display/display_histo.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/labeling/regional_maxima.hh>
+
+#include <mln/morpho/opening/volume.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+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;
+ }
+};
+
+void mk_regmax(const std::string& input,
+ const std::string& quant,
+ const std::string& histo,
+ const std::string& label,
+ const std::string& output)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgbn t_rgbn;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::algebra::vec<3,float> t_v3f;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::stat::mean<t_v3f,t_v3f,t_v3f> t_mean;
+ typedef mln::util::array<t_v3f> t_mean_array;
+
+ t_image2d_rgb8 i0_input; // input img
+ t_image2d_rgbn i1_input; // quant img
+ t_histo3d h2_input; // opened histo
+// t_image2d_int_u8 p2_label; // histo proj
+ t_image2d_lbl8 p2_label; // histo proj
+// t_image2d_rgb8 p2_label; // histo proj
+ t_image3d_lbl8 l2_histo; // label histo
+ t_mean_array m2_label; // palette
+
+ t_lbl8 n_lbl; // nb class
+
+ // BEGIN LOADING
+ mln::io::ppm::load(i0_input, input.c_str());
+ mln::io::ppm::load(i1_input, quant.c_str());
+ mln::io::dump::load(h2_input, histo.c_str());
+ // END LOADING
+
+ // BEGIN IMAGE PROCESSING
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ // END IMAGE PROCESSING
+
+ // BEGIN SAVING
+ mln::debug::println(h2_input);
+ mln::io::dump::save(l2_histo, labeled.c_str());
+
+ l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
+ m2_label = mln::labeling::compute(t_mean(), i0_input, l2_input, n_labels);
+ p2_label =mln::display::display3_histo3d_unsigned(h2_input,l2_histo,m2_label);
+
+// mln::io::pgm::save(p2_label, output.c_str());
+ mln::io::ppm::save(p2_label, output.c_str());
+ std::cout << "Nb classes : " << n_lbl << std::endl;
+ // END SAVING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "regmax input.dump out.dump out.ppm"
<< std::endl;
+ std::cout << "where"
<< std::endl;
+ std::cout << "input.dump is opened histo"
<< std::endl;
+ std::cout << "out.pgm is the r/g proj of the opened histogram"
<< std::endl;
+ std::cout << "out.dump is the labeled histogram"
<< std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (4 == argc)
+ {
+ const std::string input(args[1]);
+ const std::string output(args[2]);
+ const std::string labeled(args[3]);
+
+ mk_regmax(input, output, labeled);
+ }
+ else
+ usage();
+
+ return 0;
+}
--
1.5.6.5