URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-05-29 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Plot all points of a specific label.
* fabien/igr/plot_points/int2rgb.hh: Convert a unsigned value
to a rgb8 value, used for visualization.
* fabien/igr/plot_points/plot_points_of_label.cc: Small update.
* fabien/igr/wst_edges.cc: Output watershed dump.
---
plot_points/Makefile | 2 +-
plot_points/int2rgb.hh | 36 ++++++++++++++++++++++++++++++++++++
plot_points/plot_points_of_label.cc | 13 ++++++++++---
wst_edges.cc | 11 ++++++-----
4 files changed, 53 insertions(+), 9 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/wst_edges.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/wst_edges.cc (revision 3931)
+++ trunk/milena/sandbox/fabien/igr/wst_edges.cc (revision 3932)
@@ -5,8 +5,8 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/core/image/image3d.hh>
-#include <mln/core/image/slice_image.hh>
-#include <mln/core/image/image_if.hh>
+#include <mln/core/image/dmorph/slice_image.hh>
+#include <mln/core/image/dmorph/image_if.hh>
#include <mln/core/routine/duplicate.hh>
#include <mln/core/routine/extend.hh>
#include <mln/core/var.hh>
@@ -56,6 +56,8 @@
#include <mln/debug/println.hh>
#include <mln/trace/quiet.hh>
+#include "plot_points/int2rgb.hh"
+
using namespace mln;
using value::int_u8;
@@ -126,7 +128,6 @@
mln_VAR(w_all, wst.unmorph_());
- //io::dump::save(w_all, "watershed_edges.dump");
//data::fill((w | (!world::inter_pixel::is_separator())).rw(), nbasins.next());
mln_VAR(w_pixels, w_all | world::inter_pixel::is_pixel());
data::paste(morpho::dilation(extend(w_pixels, pw::value(w_all)), c4().win()), w_all);
@@ -134,8 +135,8 @@
mln_VAR(w_dots, w_all | world::inter_pixel::dim2::is_dot());
data::paste(morpho::erosion(extend(w_dots, pw::value(w_all)), c4().win()), w_all);
- //io::ppm::save(labeling::colorize(value::rgb8(), w, nbasins.next()),
"result.ppm");
- io::pgm::save(labeling::wrap(int_u8(), w_all), "watershed.pgm");
+ io::dump::save(w_all, "watershed.dump");
+ io::ppm::save(debug::int2rgb(w_all), "watershed.ppm");
return 0;
Index: trunk/milena/sandbox/fabien/igr/plot_points/plot_points_of_label.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/plot_points/plot_points_of_label.cc (revision 3931)
+++ trunk/milena/sandbox/fabien/igr/plot_points/plot_points_of_label.cc (revision 3932)
@@ -41,7 +41,7 @@
// Initialization.
- typedef int_u12 V;
+ typedef float V;
image3d<V> input;
io::dump::load(input, argv[1]);
typedef image2d<util::array<V> > I;
@@ -55,8 +55,15 @@
ima_arr(p).append(tmp_slice(p));
}
+ image2d<label_16> wst;
+ io::dump::load(wst, argv[2]);
image2d<label_16> ima_labels;
- io::dump::load(ima_labels, argv[2]);
+ initialize(ima_labels, ima_arr);
+ mln_piter_(image2d<label_16>) q(ima_labels.domain());
+ for_all(q)
+ {
+ ima_labels(q) = wst.at_(q.row() * 2, q.col() * 2);
+ }
// Plot points.
int origin_x = ima_arr.bbox().pmin()[1];
@@ -69,7 +76,7 @@
int x = p[1] - origin_x;
int y = p[0] - origin_y;
std::ostringstream slabel;
- slabel << "x";
+ slabel << "l" << label << "_x";
if (x < 100)
slabel << "0";
if (x < 10)
Index: trunk/milena/sandbox/fabien/igr/plot_points/int2rgb.hh
===================================================================
--- trunk/milena/sandbox/fabien/igr/plot_points/int2rgb.hh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/plot_points/int2rgb.hh (revision 3932)
@@ -0,0 +1,36 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/value/rgb8.hh>
+
+
+namespace mln
+{
+
+ namespace debug
+ {
+
+ using value::rgb8;
+
+ template <typename V>
+ image2d<rgb8>
+ int2rgb(const image2d<V>& input)
+ {
+ image2d<rgb8> output;
+ initialize(output, input);
+
+ mln_piter(image2d<V>) p(input.domain());
+ for_all(p)
+ {
+ unsigned value = input(p);
+ output(p).blue() = value % 256;
+ value /= 256;
+ output(p).green() = value % 256;
+ value /= 256;
+ output(p).red() = value % 256;
+ }
+
+ return output;
+ }
+
+} // end of namespace mln::debug
+
+} // end of namespace mln
Index: trunk/milena/sandbox/fabien/igr/plot_points/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/plot_points/Makefile (revision 3931)
+++ trunk/milena/sandbox/fabien/igr/plot_points/Makefile (revision 3932)
@@ -4,7 +4,7 @@
${CXX} -I../../../../ ${CXXFLAGS} $^ -o plot_all_points
plot_points_of_label: plot_points_of_label.cc
- ${CXX} -I../../../../ ${CXXFLAGS} $^ -o plot_points_all_label
+ ${CXX} -I../../../../ ${CXXFLAGS} $^ -o plot_points_of_label
clean: