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
March 2009
- 9 participants
- 202 discussions
* lazzara/igr/irm/irm_seg_with_mm_and_rag.cc: rename as...
* lazzara/igr/irm/grad_clo: ... this.
* lazzara/igr/irm/wst_rag.cc,
* lazzara/igr/registration_3d.cc: make it compile.
---
milena/sandbox/ChangeLog | 10 +++++
...seg_with_mm_and_rag.cc => grad_clo_and_wshd.cc} | 8 ++--
milena/sandbox/lazzara/igr/irm/wst_rag.cc | 37 +++++++++++---------
milena/sandbox/lazzara/igr/registration_3d.cc | 28 ++++++++++-----
4 files changed, 53 insertions(+), 30 deletions(-)
rename milena/sandbox/lazzara/igr/irm/{irm_seg_with_mm_and_rag.cc => grad_clo_and_wshd.cc} (89%)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index d1fba6c..6d60f7a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,13 @@
+2009-03-04 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Cleanup IGR's code.
+
+ * lazzara/igr/irm/irm_seg_with_mm_and_rag.cc: rename as...
+ * lazzara/igr/irm/grad_clo: ... this.
+
+ * lazzara/igr/irm/wst_rag.cc,
+ * lazzara/igr/registration_3d.cc: make it compile.
+
2009-03-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Create small tools for IGR.
diff --git a/milena/sandbox/lazzara/igr/irm/irm_seg_with_mm_and_rag.cc b/milena/sandbox/lazzara/igr/irm/grad_clo_and_wshd.cc
similarity index 89%
rename from milena/sandbox/lazzara/igr/irm/irm_seg_with_mm_and_rag.cc
rename to milena/sandbox/lazzara/igr/irm/grad_clo_and_wshd.cc
index 9647986..960d03f 100644
--- a/milena/sandbox/lazzara/igr/irm/irm_seg_with_mm_and_rag.cc
+++ b/milena/sandbox/lazzara/igr/irm/grad_clo_and_wshd.cc
@@ -22,7 +22,7 @@
#include <mln/convert/to_fun.hh>
#include <mln/morpho/gradient.hh>
-#include <mln/morpho/closing_area.hh>
+#include <mln/morpho/closing/area.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/fun/l2l/wrap.hh>
@@ -64,11 +64,11 @@ int main(int argc, char *argv[])
image2d<int_u8> grad = morpho::gradient(irm, win_c4p());
io::pgm::save(grad, "tmp_grad_c4p.pgm");
-// image2d<int_u8> clo = morpho::closing_area(grad, c4(), atoi(argv[3]));
-// io::pgm::save(clo, "tmp_clo_a100.pgm");
+ image2d<int_u8> clo = morpho::closing::area(grad, c4(), atoi(argv[3]));
+ io::pgm::save(clo, "tmp_clo_a100.pgm");
label_16 nbasins;
- image2d<label_16> wshed = morpho::meyer_wst(grad, c4(), nbasins);
+ image2d<label_16> wshed = morpho::meyer_wst(clo, c4(), nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
io::pgm::save(level::transform(wshed, fun::l2l::wrap<int_u8>()),
diff --git a/milena/sandbox/lazzara/igr/irm/wst_rag.cc b/milena/sandbox/lazzara/igr/irm/wst_rag.cc
index b88b8ec..c88b435 100644
--- a/milena/sandbox/lazzara/igr/irm/wst_rag.cc
+++ b/milena/sandbox/lazzara/igr/irm/wst_rag.cc
@@ -12,7 +12,6 @@
#include <mln/core/alias/dpoint2d.hh>
#include <mln/draw/box.hh>
#include <mln/level/stretch.hh>
-#include <mln/canvas/morpho/algebraic_union_find.hh>
#include <mln/fun/v2v/id.hh>
#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/morpho/elementary/dilation.hh>
@@ -20,6 +19,7 @@
#include <mln/extension/adjust_fill.hh>
#include <mln/extract/all.hh>
#include <mln/make/region_adjacency_graph.hh>
+#include <mln/make/graph.hh>
// Given a color image and a wshed image, computes the component graph.
// Vertex values are computed thanks to a RGB image.
@@ -223,20 +223,20 @@ int main(int argc, char *argv[])
I input;
io::ppm::load(input, argv[1]);
-// image2d<rgb16> input = level::convert(rgb16(), input_);
- J vol;
- io::dump::load(vol, argv[2]);
+ J wsd;
+ io::dump::load(wsd, argv[2]);
label_16 nbasins = atoi(argv[3]);
std::cout << "nbasins = " << nbasins << std::endl;
- util::graph g = make::graph(vol, c4(), nbasins);
-
- // Compute value distances with a RGB image.
- mln_VAR(ima_v, make_vertex_graph_image(g, input, vol, nbasins));
+ /// Build graph
+ util::graph g = make::graph(wsd, c4(), nbasins);
+ // Build graph images and compute distance values with a RGB image.
+ mln_VAR(ima_v, make_vertex_graph_image(g, input, wsd, nbasins));
mln_VAR(ima_e, make_edge_graph_image(ima_v, g));
+
//DEBUG
io::ppm::save(make_debug_graph_image(input, ima_v, ima_e, box_size, literal::white),
"wst_rag_graph_image_white.ppm");
@@ -244,6 +244,7 @@ int main(int argc, char *argv[])
"wst_rag_graph_image_black.ppm");
+ /// Try to merge vertices.
mln_piter_(ima_e_t) e(ima_e.domain());
util::array<label_16> parent(g.v_nmax());
for (unsigned i = 0; i < parent.nelements(); ++i)
@@ -272,21 +273,23 @@ int main(int argc, char *argv[])
mln_invariant(f(0) == 0u);
--nbasins2; //nbasins2 does not count the basin with label 0.
std::cout << "nbasins2 = " << nbasins2 << std::endl;
+ J wsd2 = level::transform(wsd, f);
+
- J vol2 = level::transform(vol, f);
- util::graph g2 = make::graph(vol2, c4(), nbasins2);
- // Compute value distances with a RGB image.
- mln_VAR(ima_v2, make_vertex_graph_image(g2, input, vol2, nbasins2));
+ /// Reconstruct a graph from the simplified image.
+ util::graph g2 = make::graph(wsd2, c4(), nbasins2);
+ // Compute distance values with a RGB image.
+ mln_VAR(ima_v2, make_vertex_graph_image(g2, input, wsd2, nbasins2));
mln_VAR(ima_e2, make_edge_graph_image(ima_v2, g2));
- mln_VAR(vol2_,
- morpho::elementary::dilation(extend(vol2 | (pw::value(vol2) == 0u),
- vol2),
+ mln_VAR(wsd2_,
+ morpho::elementary::dilation(extend(wsd2 | (pw::value(wsd2) == 0u),
+ wsd2),
c8()));
- data::fill((vol2 | (pw::value(vol2) == 0u)).rw(), vol2_);
+ data::fill((wsd2 | (pw::value(wsd2) == 0u)).rw(), wsd2_);
- io::ppm::save(labeling::mean_values(input, vol2, nbasins2),
+ io::ppm::save(labeling::mean_values(input, wsd2, nbasins2),
"wst_rag_mean_colors.ppm");
io::ppm::save(make_debug_graph_image(input, ima_v2, ima_e2, box_size, literal::white),
"wst_rag_graph_image2_white.ppm");
diff --git a/milena/sandbox/lazzara/igr/registration_3d.cc b/milena/sandbox/lazzara/igr/registration_3d.cc
index f049d88..d144b5c 100644
--- a/milena/sandbox/lazzara/igr/registration_3d.cc
+++ b/milena/sandbox/lazzara/igr/registration_3d.cc
@@ -16,33 +16,43 @@ int main(int, char *argv[])
arr_t ref;
io::cloud::load(ref, argv[2]);
+ box3d bbox = geom::bbox(ref);
+ bbox.enlarge(1, bbox.nrows() / 2);
+ bbox.enlarge(2, bbox.ncols() / 2);
+ bbox.enlarge(0, bbox.nslis() / 2);
+
+
// Starting registration.
util::timer t;
t.start();
-
typedef fun::x2x::rotation<3u,float> rot_t;
typedef fun::x2x::translation<3u,float> trans_t;
- fun::x2x::composed<trans_t,rot_t> qk = registration::registration3(in, ref);
+ fun::x2x::composed<trans_t,rot_t> qk = registration::registration2(bbox, in, ref);
std::cout << "igr.cc - Registration - " << t << "s" << std::endl;
- box3d bbox = geom::bbox(ref);
- bbox.enlarge(1, 50);
- bbox.enlarge(2, 50);
image3d<value::rgb8> ima_in(bbox);
data::fill(ima_in, literal::black);
data::fill((ima_in | in).rw(), literal::green);
- mln_VAR(ext_ima, extended_with(ima_in, pw::cst(value::rgb8(literal::black))));
+ mln_VAR(ext_ima, extend(ima_in, pw::cst(value::rgb8(literal::black))));
mln_VAR(trima, transposed_image(bbox, ext_ima, qk));
+ p_array<point3d> arr;
+ mln_VAR(tmp, (ima_in | in));
+ mln_piter_(tmp_t) p(tmp.domain());
+ for_all(p)
+ arr.insert(qk(p));
+ std::cout << arr.nsites() << std::endl;
+ io::cloud::save(arr, "registered.txt");
+
image3d<value::rgb8> ima_ref(geom::bbox(ref));
- mln_VAR(ext_ima_ref, extended_with(ima_ref, pw::cst(value::rgb8(literal::black))));
+ mln_VAR(ext_ima_ref, extend(ima_ref, pw::cst(value::rgb8(literal::black))));
data::fill(ext_ima_ref, literal::black);
data::fill((ext_ima_ref | ref).rw(), literal::white);
data::fill((ext_ima_ref | pw::value(trima) == pw::cst(literal::green)).rw(), literal::green);
-// io::cloud::save(res, "registered.txt");
+// io::cloud::save(trima, "registered.txt");
- io::ppm::save(debug::slices_2d(ima_ref, 5, 3, literal::black), "registration_3d.ppm");
+// io::ppm::save(debug::slices_2d(ima_ref, 5, 3, literal::black), "registration_3d.ppm");
}
--
1.5.6.5
1
0
* mln/canvas/morpho/attribute_filter.hh: move MLN_INCLUDE_ONLY guards.
* mln/registration/icp.hh: add missing to_vec(). Fix use of the new
closest_point_functor.
* mln/transform/internal/closest_point_functor.hh: fix a wrong index
propagation.
---
milena/ChangeLog | 12 +++
milena/mln/canvas/morpho/attribute_filter.hh | 18 ++++-
milena/mln/registration/icp.hh | 80 +++++++++++---------
.../transform/internal/closest_point_functor.hh | 14 +++-
4 files changed, 82 insertions(+), 42 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c1c56a1..7040630 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Fix compilation issues.
+
+ * mln/canvas/morpho/attribute_filter.hh: move MLN_INCLUDE_ONLY guards.
+
+ * mln/registration/icp.hh: add missing to_vec(). Fix use of the new
+ closest_point_functor.
+
+ * mln/transform/internal/closest_point_functor.hh: fix a wrong index
+ propagation.
+
2009-03-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add standard deviation accumulator.
diff --git a/milena/mln/canvas/morpho/attribute_filter.hh b/milena/mln/canvas/morpho/attribute_filter.hh
index e605f18..298c236 100644
--- a/milena/mln/canvas/morpho/attribute_filter.hh
+++ b/milena/mln/canvas/morpho/attribute_filter.hh
@@ -47,9 +47,14 @@
# include <mln/data/fill.hh>
# include <mln/level/sort_psites.hh>
-namespace mln {
- namespace canvas {
- namespace morpho {
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace morpho
+ {
// Facade Fwd Declaration
template <typename I, typename N, typename A>
@@ -433,10 +438,10 @@ namespace mln {
};
return attribute_filter_dispatch(metal::bool_<test>(), input, nbh, a, lambda, increasing);
}
+
} // end of namespace mln::canvas::morpho::internal
-# endif // ! MLN_INCLUDE_ONLY
// Facade.
@@ -451,8 +456,13 @@ namespace mln {
return internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
}
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln::canvas::morpho
+
} // end of namespace mln::canvas
+
} // end of namespace mln
diff --git a/milena/mln/registration/icp.hh b/milena/mln/registration/icp.hh
index a5ad215..6adc0b3 100644
--- a/milena/mln/registration/icp.hh
+++ b/milena/mln/registration/icp.hh
@@ -55,7 +55,7 @@
# include <mln/core/alias/neighb3d.hh>
-# include <mln/transform/internal/closest_point_functor.hh>
+# include <mln/transform/distance_and_closest_point_geodesic.hh>
# include <mln/canvas/distance_geodesic.hh>
# include <mln/pw/all.hh>
@@ -76,6 +76,8 @@
# include <mln/util/timer.hh>
+# include <mln/io/cloud/save.hh>
+
namespace mln
{
@@ -165,17 +167,15 @@ namespace mln
data::fill(model, false);
data::fill((model | X).rw(), true);
- transform::internal::closest_point_functor<model_t> f(X);
- util::timer t;
- t.start();
- dmap_X_ = canvas::distance_geodesic(model, c6(),
- mln_max(value::int_u16),
- f);
- std::cout << "distance_geodesic = " << t << "s" << std::endl;
+ typedef util::couple<mln_ch_value(model_t, value::int_u16),
+ mln_ch_value(model_t, unsigned)> couple_t;
+ couple_t cpl = transform::distance_and_closest_point_geodesic(X, box,
+ c6(),
+ mln_max(value::int_u16));
- initialize(this->cp_ima_, f.cp_ima);
- this->cp_ima_ = f.cp_ima;
+ dmap_X_ = cpl.first();
+ cp_ima_ = cpl.second();
mln_postcondition(cp_ima_.is_valid());
mln_postcondition(cp_ima_.domain().is_valid());
@@ -183,27 +183,27 @@ namespace mln
std::cout << "pmax = " << cp_ima_.domain().pmax() << std::endl;;
#ifndef NDEBUG
-// mln_ch_value(I, bool) debug2(box);
-// data::fill(debug2, false);
-// mln_ch_value(I, value::rgb8) debug(box);
-// mln_piter(p_array<P>) p(X);
-// for_all(p)
-// {
-// debug(p) = debug::internal::random_color(value::rgb8());
-// debug2(p) = true;
-// }
-// io::pbm::save(slice(debug2,0), "debug2-a.ppm");
-//
-// mln_piter(I) pi(cp_ima_.domain());
-// for_all(pi)
-// {
-// debug(pi) = debug(cp_ima_(pi));
-// debug2(pi) = debug2(cp_ima_(pi));
-// }
-//
-// io::pbm::save(slice(debug2,0), "debug2-b.ppm");
-// io::ppm::save(slice(debug,0), "debug.ppm");
-// std::cout << "map saved" << std::endl;
+ mln_ch_value(I, bool) debug2(box);
+ data::fill(debug2, false);
+ mln_ch_value(I, value::rgb8) debug(box);
+ mln_piter(p_array<P>) p(X);
+ for_all(p)
+ {
+ debug(p) = debug::internal::random_color(value::rgb8());
+ debug2(p) = true;
+ }
+ io::pbm::save(slice(debug2,0), "debug2-a.ppm");
+
+ mln_piter(I) pi(cp_ima_.domain());
+ for_all(pi)
+ {
+ debug(pi) = debug(cp_ima_(pi));
+ debug2(pi) = debug2(cp_ima_(pi));
+ }
+
+ io::pbm::save(slice(debug2,0), "debug2-b.ppm");
+ io::ppm::save(slice(debug,0), "debug.ppm");
+ std::cout << "map saved" << std::endl;
#endif
}
@@ -278,11 +278,11 @@ namespace mln
mln_piter(p_array<P>) p(kept);
for_all(p)
- ext_result(qR.rotate(p) + qT) = literal::green;
+ ext_result(qR.rotate(p.to_vec()) + qT) = literal::green;
mln_piter(p_array<P>) p2(removed);
for_all(p2)
- ext_result(qR.rotate(p2) + qT) = literal::red;
+ ext_result(qR.rotate(p2.to_vec()) + qT) = literal::red;
io::ppm::save(slice(ext_result,0), "registered-2.ppm");
}
@@ -427,6 +427,16 @@ namespace mln
}
}
+ {
+ std::ostringstream ss2;
+ ss2 << method << "_" << r << "_removed_sites" << ".cloud";
+ io::cloud::save(removed_set, ss2.str());
+ }
+ {
+ std::ostringstream ss2;
+ ss2 << method << "_" << r << "_kept_sites" << ".cloud";
+ io::cloud::save(tmp, ss2.str());
+ }
# ifndef NDEBUG
std::ostringstream ss2;
@@ -458,14 +468,14 @@ namespace mln
mln_piter(p_array<P>) p1(P_);
for_all(p1)
{
- vec3d_f Pk_i = pair.first.rotate(p1) + pair.second;
+ vec3d_f Pk_i = pair.first.rotate(p1.to_vec()) + pair.second;
out(Pk_i) = literal::red;
}
mln_piter(p_array<P>) p2(P_sub);
for_all(p2)
{
- vec3d_f Pk_i = pair.first.rotate(p2) + pair.second;
+ vec3d_f Pk_i = pair.first.rotate(p2.to_vec()) + pair.second;
out(Pk_i) = c;
}
diff --git a/milena/mln/transform/internal/closest_point_functor.hh b/milena/mln/transform/internal/closest_point_functor.hh
index 8df47b7..a1ab93c 100644
--- a/milena/mln/transform/internal/closest_point_functor.hh
+++ b/milena/mln/transform/internal/closest_point_functor.hh
@@ -46,6 +46,11 @@ namespace mln
namespace internal
{
+
+ /// Functor to be passed to a canvas.
+ /// Computes an image of closest points.
+ ///
+ /// The image values are initialized with \p pset.nsites().
template <typename I>
struct closest_point_functor_with_indexes
{
@@ -72,7 +77,10 @@ namespace mln
void process_(unsigned p, unsigned n);
};
-
+ /// Functor to be passed to a canvas.
+ /// Computes an image of closest points.
+ ///
+ /// The image values are initialized with \p literal::origin.
template <typename I>
struct closest_point_functor_with_sites
{
@@ -115,11 +123,11 @@ namespace mln
closest_point_functor_with_indexes<I>::init(const I& input)
{
initialize(cp_ima, input);
- data::fill(cp_ima, 0u);
+ data::fill(cp_ima, pset_.nsites());
mln_piter(p_array<mln_psite(I)>) p(pset_);
for_all(p)
- cp_ima(p) = cp_ima.index_of_point(p);
+ cp_ima(p) = p.index();
}
template <typename I>
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add standard deviation accumulator.
* mln/accu/stat/deviation.hh: New accumulator for standard
deviation.
---
deviation.hh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
Index: trunk/milena/mln/accu/stat/deviation.hh
===================================================================
--- trunk/milena/mln/accu/stat/deviation.hh (revision 0)
+++ trunk/milena/mln/accu/stat/deviation.hh (revision 3472)
@@ -0,0 +1,188 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ACCU_STAT_DEVIATION_HH
+# define MLN_ACCU_STAT_DEVIATION_HH
+
+/// \file mln/accu/stat/deviation.hh
+///
+/// Define an accumulator that computes a standard deviation.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/accu/count.hh>
+# include <mln/accu/sum.hh>
+# include <mln/math/sqr.hh>
+# include <mln/math/sqrt.hh>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ /// Generic standard deviation accumulator class.
+ /*!
+ * Parameter \c T is the type of values that we sum. Parameter \c
+ * S is the type to store the standard deviation; the default type of
+ * \c S is the summation type (property) of \c T. Parameter \c M
+ * is the type of the mean value; the default type of \c M is \c
+ * S.
+ */
+ template <typename T,
+ typename S = mln_sum(T),
+ typename M = S>
+ struct deviation : public mln::accu::internal::base< M , deviation<T,S,M> >
+ {
+ typedef T argument;
+ typedef M result;
+
+ deviation(const T mean);
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take(const argument& t);
+ void take(const deviation<T,S,M>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ M to_result() const;
+ operator M () const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ accu::count<T> count_;
+ accu::sum<T,S> sum_;
+ T mean_;
+ };
+
+
+
+ template <typename I, typename S, typename M>
+ struct deviation< util::pix<I>, S,M >;
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for deviation.
+ struct deviation : public Meta_Accumulator< deviation >
+ {
+ template < typename T,
+ typename S = mln_sum(T),
+ typename M = S >
+ struct with
+ {
+ typedef accu::stat::deviation<T,S,M> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename S, typename M>
+ inline
+ deviation<T,S,M>::deviation(const T mean)
+ {
+ init();
+ mean_ = mean;
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ void
+ deviation<T,S,M>::init()
+ {
+ count_.init();
+ sum_.init();
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ void deviation<T,S,M>::take(const argument& t)
+ {
+ count_.take(t);
+ sum_.take(math::sqr(t - mean_));
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ void
+ deviation<T,S,M>::take(const deviation<T,S,M>& other)
+ {
+ // FIXME
+ count_.take(other.count_);
+ sum_.take(other.sum_);
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ M
+ deviation<T,S,M>::to_result() const
+ {
+ unsigned n = count_.to_result();
+ if (n == 0u)
+ return M(); // Safety.
+ return static_cast<M>(math::sqrt(sum_.to_result() / n));
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ deviation<T,S,M>::operator M() const
+ {
+ return to_result();
+ }
+
+ template <typename T, typename S, typename M>
+ inline
+ bool
+ deviation<T,S,M>::is_valid() const
+ {
+ return count_.to_result() != 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_STAT_DEVIATION_HH
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-03 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Create small tools for IGR.
* fabien/TODO: New.
* fabien/igr/dump2pbm.cc: Move this...
* fabien/bin/dump2pbm.cc: ...here.
* fabien/igr/dump2ppm.cc: Move this...
* fabien/bin/dump2ppm.cc: ...here.
* fabien/igr/Makefile: Update.
* fabien/igr/launch.sh: New tool.
* fabien/igr/launch2d.sh: New tool.
* fabien/igr/launch3d.sh: New tool.
* fabien/igr/seg2d.cc: New tool.
* fabien/igr/seg3d.cc: New tool.
* fabien/igr/seg_vol_irm.cc: Rename this...
* fabien/igr/seg_vol_irm.hh: ...into this.
---
TODO | 13 ++
bin/dump2pbm.cc | 35 ++++++
bin/dump2ppm.cc | 35 ++++++
igr/Makefile | 23 ++-
igr/launch.sh | 4
igr/launch2d.sh | 26 ++++
igr/launch3d.sh | 24 ++++
igr/seg2d.cc | 40 ++++++
igr/seg3d.cc | 42 +++++++
igr/seg_vol_irm.hh | 309 +++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 542 insertions(+), 9 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/dump2ppm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/seg_vol_irm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/dump2pbm.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fabien/igr/launch.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch.sh (revision 3471)
@@ -0,0 +1,4 @@
+#!/bin/zsh
+
+./launch2d.sh
+./launch3d.sh
Property changes on: trunk/milena/sandbox/fabien/igr/launch.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 3471)
@@ -0,0 +1,309 @@
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb1d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/alias/neighb3d.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/pgm/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/io/cloud/all.hh>
+#include <mln/io/dump/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/labeling/flat_zones.hh>
+#include <mln/labeling/background.hh>
+#include <mln/literal/colors.hh>
+#include <mln/norm/l1.hh>
+
+#include <mln/geom/bbox.hh>
+
+#include <mln/labeling/blobs.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/labeling/fill_holes.hh>
+#include <mln/labeling/n_max.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/level/compute.hh>
+#include <mln/level/convert.hh>
+#include <mln/level/stretch.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/fun/internal/selector.hh>
+
+#include <mln/fun/v2b/threshold.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/center.hh>
+#include <mln/accu/max.hh>
+#include <mln/accu/sum.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/stat/deviation.hh>
+
+#include <mln/histo/compute.hh>
+
+#include <mln/set/compute.hh>
+#include <mln/value/label_16.hh>
+#include <mln/data/fill.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/morpho/elementary/gradient_internal.hh>
+#include <mln/morpho/closing.hh>
+#include <mln/morpho/dilation.hh>
+#include <mln/morpho/erosion.hh>
+
+#include <mln/win/disk2d.hh>
+#include <mln/win/sphere3d.hh>
+
+#include <mln/math/diff_abs.hh>
+
+#include <mln/convert/from_to.hh>
+
+#include <mln/metal/int.hh>
+
+#include <iostream>
+#include <fstream>
+#include <mln/debug/println.hh>
+
+using namespace mln;
+using value::int_u8;
+using value::int_u12;
+using value::int_u16;
+using value::rgb8;
+using value::label_16;
+
+
+
+template <typename T>
+struct L_to_int_u8
+: mln::fun::internal::selector_<int_u8, T, L_to_int_u8<T> >::ret
+{
+ typedef int_u8 result;
+ int_u8 operator()(const T& t) const;
+};
+
+
+
+template <typename T>
+inline
+int_u8
+L_to_int_u8<T>::operator()(const T& t) const
+{
+ return static_cast<int_u8>(t == 0 ? 0 : 1 + ((unsigned) t - 1) % 255);
+}
+
+
+
+template <typename I>
+I
+close_threshold(const Image<I>& input, metal::int_<2>, int dil, int ero)
+{
+ return morpho::erosion(morpho::dilation(input, win::disk2d(dil)), win::disk2d(ero));
+}
+
+
+
+template <typename I>
+I
+close_threshold(const Image<I>& input, metal::int_<3>, int dil, int ero)
+{
+ return morpho::erosion(morpho::dilation(input, win::sphere3d(dil)), win::sphere3d(ero));
+}
+
+
+
+template <typename I, typename N>
+unsigned
+find_threshold_value(const Image<I>& input, const Neighborhood<N>& nbh)
+{
+ int bg_thres = 30;
+ int obj_thres = 15;
+
+ mln_ch_value(I, bool) ima_bg;
+ initialize(ima_bg, input);
+ data::fill(ima_bg, false);
+
+ mln_ch_value(I, bool) ima_obj;
+ initialize(ima_obj, input);
+ data::fill(ima_obj, false);
+
+ unsigned result = 0;
+
+ histo::array<mln_value(I)> arr_histo = histo::compute(input);
+ image1d<unsigned> ima_histo;
+ convert::from_to(arr_histo, ima_histo);
+
+ // We remove the 0 value because it is not part of the image.
+ ima_histo(point1d(0)) = 0;
+
+ for (unsigned int i = 1; i < ima_histo.nelements(); ++i)
+ {
+ ima_histo(point1d(i)) += ima_histo(point1d(i - 1));
+ }
+ accu::max<unsigned> max_accu;
+ unsigned max = level::compute(max_accu, ima_histo);
+ bool low_done = false;
+ bool high_done = false;
+ for (unsigned int i = 0; i < ima_histo.nelements(); ++i)
+ {
+ if (!low_done && ((ima_histo(point1d(i)) * 100) / max) > bg_thres)
+ {
+ data::fill((ima_bg | pw::value(input) < pw::cst(i)).rw(), true);
+ low_done = true;
+ }
+ if (!high_done && ((ima_histo(point1d(i)) * 100) / max) > (100 - obj_thres))
+ {
+ data::fill((ima_obj | pw::value(input) > pw::cst(i)).rw(), true);
+ high_done = true;
+ }
+ }
+
+ // Debug output images
+ if (I::site::dim == 2)
+ {
+ io::pbm::save(ima_bg, "bg.pbm");
+ io::pbm::save(ima_obj, "obj.pbm");
+ }
+ if (I::site::dim == 3)
+ {
+ io::dump::save(ima_bg, "bg.dump");
+ io::dump::save(ima_obj, "obj.dump");
+ }
+
+ ima_bg = close_threshold(ima_bg, metal::int_<I::site::dim>(), 3, 5); // 5, 7?
+ ima_obj = close_threshold(ima_obj, metal::int_<I::site::dim>(), 3, 5);
+
+ // Debug output images
+ mln_ch_value(I, rgb8) out = level::convert(rgb8(), level::stretch(int_u8(), input));
+ data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_bg, nbh)) == true).rw(), literal::red);
+ data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_obj, nbh)) == true).rw(), literal::green);
+ if (I::site::dim == 2)
+ {
+ io::pbm::save(ima_bg, "bg_closed.pbm");
+ io::pbm::save(ima_obj, "obj_closed.pbm");
+ io::ppm::save(out, "regions_color.ppm");
+ }
+ if (I::site::dim == 3)
+ {
+ io::dump::save(ima_bg, "bg_closed.dump");
+ io::dump::save(ima_obj, "obj_closed.dump");
+ io::dump::save(out, "regions_color.dump");
+ }
+
+ histo::array<mln_value(I)> bg_histo = histo::compute(input | pw::value(ima_bg) == true);
+ histo::array<mln_value(I)> obj_histo = histo::compute(input | pw::value(ima_obj) == true);
+
+ accu::sum<unsigned> sum_accu;
+ image1d<unsigned> ima_bg_histo;
+ convert::from_to(bg_histo, ima_bg_histo);
+ ima_bg_histo(point1d(0)) = 0;
+ unsigned bg_sum = level::compute(sum_accu, ima_bg_histo);
+ // We remove the 0 value because it is not part of the image.
+ std::ofstream fout_bg("bg_histo_norm.plot");
+ for (unsigned int i = 0; i < ima_bg_histo.nelements(); ++i)
+ {
+ ima_bg_histo(point1d(i)) *= 10000;
+ ima_bg_histo(point1d(i)) /= bg_sum;
+ fout_bg << i << " " << ima_bg_histo(point1d(i)) << std::endl;
+ }
+
+ image1d<unsigned> ima_obj_histo;
+ convert::from_to(obj_histo, ima_obj_histo);
+ unsigned obj_sum = level::compute(sum_accu, ima_obj_histo);
+ std::ofstream fout_obj("obj_histo_norm.plot");
+ for (unsigned int i = 0; i < ima_obj_histo.nelements(); ++i)
+ {
+ ima_obj_histo(point1d(i)) *= 10000;
+ ima_obj_histo(point1d(i)) /= obj_sum;
+ fout_obj << i << " " << ima_obj_histo(point1d(i)) << std::endl;
+ }
+
+ // Search for the index with the min distance between histogrammes.
+ unsigned min = math::diff_abs<unsigned>(ima_bg_histo(point1d(1)), ima_obj_histo(point1d(1)));
+ for (unsigned int i = 1; i < ima_bg_histo.nelements(); ++i)
+ {
+ if (math::diff_abs<unsigned>(ima_bg_histo(point1d(i)), ima_obj_histo(point1d(i))) < min)
+ {
+ min = math::diff_abs<unsigned>(ima_bg_histo(point1d(i)), ima_obj_histo(point1d(i)));
+ result = i;
+ }
+ }
+
+ return result;
+}
+
+
+
+template <typename I, typename N>
+unsigned
+find_threshold_mean(const Image<I>& input, const Neighborhood<N>& nbh)
+{
+ unsigned result = 0;
+
+ accu::mean<unsigned> mean_accu;
+ unsigned mean = level::compute(mean_accu, (input | (pw::value(input) != 0)));
+
+ accu::stat::deviation<unsigned, unsigned, float> dev_accu(mean);
+ float deviation = level::compute(dev_accu, (input | pw::value(input) != 0));
+
+ std::cout << "mean = " << mean << std::endl << "deviation = " << deviation << std::endl;
+ return floor(deviation);
+}
+
+
+
+template <typename I, typename N, typename L>
+mln_ch_value(I, bool)
+igr_seg(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nlabels)
+{
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ // Threshold.
+
+ mln_ch_value(I, bool) ima_thres;
+ initialize(ima_thres, input);
+ data::fill(ima_thres, false);
+ //unsigned threshold_value = find_threshold_value(input, nbh);
+ unsigned threshold_value = find_threshold_mean(input, nbh);
+ data::fill((ima_thres | pw::value(input) < pw::cst(threshold_value)).rw(), true);
+
+ return ima_thres;
+}
Index: trunk/milena/sandbox/fabien/igr/seg2d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 3471)
@@ -0,0 +1,40 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/pbm/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/value/label_16.hh>
+
+#include "seg_vol_irm.hh"
+
+using namespace mln;
+using value::int_u12;
+using value::label_16;
+
+
+
+int usage()
+{
+ std::cout << "Usage: ./seg2d image.dcm" << std::endl;
+
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2)
+ return usage();
+
+ label_16 nlabels;
+ image2d<int_u12> ima;
+ io::dicom::load(ima, argv[1]);
+ io::pbm::save(igr_seg(ima, c4(), nlabels), "result.pbm");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/launch2d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 3471)
@@ -0,0 +1,26 @@
+#!/bin/zsh
+
+process_file ()
+{
+ ./seg2d $1
+ if [ -f result.pbm ]; then
+ mv result.pbm results/${2}_06_result.pbm
+ fi
+
+ if [ -f bg.pbm ]; then
+ mv bg.pbm results/${2}_01_bg.pbm
+ mv obj.pbm results/${2}_03_obj.pbm
+
+ mv bg_closed.pbm results/${2}_02_bg_closed.pbm
+ mv obj_closed.pbm results/${2}_04_obj_closed.pbm
+
+ mv regions_color.ppm results/${2}_05_regions_color.ppm
+
+ mv bg_histo_norm.plot results/${2}_bg.plot
+ mv obj_histo_norm.plot results/${2}_obj.plot
+ fi
+}
+
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0049.dcm" "49"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0055.dcm" "55"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0058.dcm" "58"
Property changes on: trunk/milena/sandbox/fabien/igr/launch2d.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/seg3d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 3471)
@@ -0,0 +1,42 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
+#include <mln/core/alias/neighb3d.hh>
+
+#include <mln/core/image/image3d.hh>
+
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/dump/all.hh>
+#include <mln/io/dicom/load.hh>
+
+#include <mln/value/label_16.hh>
+
+#include "seg_vol_irm.hh"
+
+using namespace mln;
+using value::int_u12;
+using value::label_16;
+
+template <typename I, typename N, typename L>
+mln_ch_value(I, bool)
+igr_seg(const Image<I>& input_, const mln::Neighborhood<N>& nbh_, L& nlabels);
+
+int usage()
+{
+ std::cout << "Usage: ./seg3d image.dcm" << std::endl;
+
+ return 1;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2)
+ return usage();
+
+ label_16 nlabels;
+ image3d<int_u12> ima;
+ io::dicom::load(ima, argv[1]);
+ io::dump::save(igr_seg(ima, c6(), nlabels), "result.dump");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/launch3d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 0)
+++ trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 3471)
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+process_file ()
+{
+ ./seg3d $1
+ ../bin/dump2pbm result.dump results/${2}_06_result.pbm
+
+ ../bin/dump2pbm bg.dump results/${2}_01_bg.pbm
+ ../bin/dump2pbm obj.dump results/${2}_03_obj.pbm
+
+ ../bin/dump2pbm bg_closed.dump results/${2}_02_bg_closed.pbm
+ ../bin/dump2pbm obj_closed.dump results/${2}_04_obj_closed.pbm
+
+#../bin/dump2ppm regions_color.dump results/${2}_05_colors.ppm
+
+ rm *.dump
+
+ mv bg_histo_norm.plot results/${2}_bg.plot
+ mv obj_histo_norm.plot results/${2}_obj.plot
+}
+
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0061.dcm" "61"
+process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0064.dcm" "64"
Property changes on: trunk/milena/sandbox/fabien/igr/launch3d.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3470)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3471)
@@ -1,15 +1,20 @@
-all: seg_vol_irm.cc
- g++ -I../../../ \
- -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/Common/ \
+DICOM_INC = -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/Common/ \
-I/Users/HiSoKa/Downloads/gdcmbin/Source/Common/ \
-I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataDictionary/ \
-I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/MediaStorageAndFileFormat/ \
- -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataStructureAndEncodingDefinition/ \
- -L/Users/HiSoKa/Downloads/gdcmbin/bin \
+ -I/Users/HiSoKa/Downloads/gdcm-2.0.10/Source/DataStructureAndEncodingDefinition/
+DICOM_LIB = -L/Users/HiSoKa/Downloads/gdcmbin/bin \
-lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
- -framework CoreFoundation \
- -DNDEBUG -O1 \
- seg_vol_irm.cc -o seg_vol_irm
+ -framework CoreFoundation
+CXXFLAGS = -DNDEBUG -O1
+
+all: 2d 3d
+
+2d: seg_vol_irm.hh seg2d.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} seg2d.cc -o seg2d
+
+3d: seg_vol_irm.hh seg3d.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} seg3d.cc -o seg3d
clean:
- rm -rf *.dump *.p?m
+ rm -rf *.dump *.p?m *.plot *.log *.csv
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 0)
+++ trunk/milena/sandbox/fabien/TODO (revision 3471)
@@ -0,0 +1,13 @@
+ ___________
+< TODO list >
+ -----------
+ \ ^__^
+ \ (oo)\_______
+ (__)\ )\/\
+ ||----w |
+ || ||
+
+[X] Create binaries
+[X] Create scripts shell
+[ ] Check standard deviation
+
Index: trunk/milena/sandbox/fabien/bin/dump2ppm.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dump2ppm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dump2ppm.cc (revision 3471)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump output.ppm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::rgb8;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<rgb8> vol;
+ io::dump::load(vol, argv[1]);
+
+ rgb8 bg = literal::black;
+ image2d<rgb8> ima = debug::slices_2d(vol, 1.f, bg);
+ io::ppm::save(ima, argv[2]);
+}
Index: trunk/milena/sandbox/fabien/bin/dump2pbm.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dump2pbm.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dump2pbm.cc (revision 3471)
@@ -0,0 +1,35 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/int_u16.hh>
+#include <mln/io/dump/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dump output.pbm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u16;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<bool> vol;
+ io::dump::load(vol, argv[1]);
+
+ int_u16 bg = 0;
+ image2d<bool> ima = debug::slices_2d(vol, 1.f, bg);
+ io::pbm::save(ima, argv[2]);
+}
1
0
* mln/level/approx/median.hh: call diameter() instead of length() on
win::ball.
* mln/level/convert.hh: fix a return type.
* mln/morpho/closing/essential.hh,
* mln/morpho/essential.hh,
* mln/morpho/opening/essential.hh: Fix includes.
---
milena/ChangeLog | 13 +++++++++++++
milena/mln/level/approx/median.hh | 2 +-
milena/mln/level/convert.hh | 2 +-
milena/mln/morpho/closing/essential.hh | 5 +++--
milena/mln/morpho/essential.hh | 2 --
milena/mln/morpho/opening/essential.hh | 5 +++--
6 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6e55f81..16c404d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes (again).
+
+ * mln/level/approx/median.hh: call diameter() instead of length() on
+ win::ball.
+
+ * mln/level/convert.hh: fix a return type.
+
+ * mln/morpho/closing/essential.hh,
+ * mln/morpho/essential.hh,
+ * mln/morpho/opening/essential.hh: Fix includes.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Small fixes related to morpho.
* mln/morpho/closing/area.hh: update copyright.
diff --git a/milena/mln/level/approx/median.hh b/milena/mln/level/approx/median.hh
index 5bf1a9e..d950ccb 100644
--- a/milena/mln/level/approx/median.hh
+++ b/milena/mln/level/approx/median.hh
@@ -136,7 +136,7 @@ namespace mln
{
trace::entering("level::approx::median");
- const unsigned len = win.length() / 3 + 1;
+ const unsigned len = win.diameter() / 3 + 1;
mln_concrete(I) output;
win::diag2d win1(len);
diff --git a/milena/mln/level/convert.hh b/milena/mln/level/convert.hh
index 39da091..e3149ff 100644
--- a/milena/mln/level/convert.hh
+++ b/milena/mln/level/convert.hh
@@ -99,7 +99,7 @@ namespace mln
template <typename V, typename I>
inline
- mln_concrete(I)
+ mln_ch_value(I,V)
convert_identity(const V& v, const Image<I>& input)
{
trace::entering("level::impl::convert_identity");
diff --git a/milena/mln/morpho/closing/essential.hh b/milena/mln/morpho/closing/essential.hh
index a478a2c..a0f8055 100644
--- a/milena/mln/morpho/closing/essential.hh
+++ b/milena/mln/morpho/closing/essential.hh
@@ -34,10 +34,11 @@
/// File that includes essential closing attributes.
#include <mln/morpho/closing/algebraic.hh>
-#include <mln/morpho/closing/leveling.hh>
#include <mln/morpho/closing/area.hh>
-#include <mln/morpho/closing/volume.hh>
#include <mln/morpho/closing/height.hh>
+#include <mln/morpho/closing/leveling.hh>
+#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/closing/volume.hh>
#endif // ! MLN_MORPHO_CLOSING_ESSENTIAL_HH
diff --git a/milena/mln/morpho/essential.hh b/milena/mln/morpho/essential.hh
index d16fcce..8034b86 100644
--- a/milena/mln/morpho/essential.hh
+++ b/milena/mln/morpho/essential.hh
@@ -33,7 +33,6 @@
/// File that includes essential morpho-related routines.
-# include <mln/morpho/closing.hh>
# include <mln/morpho/dilation.hh>
# include <mln/morpho/erosion.hh>
# include <mln/morpho/gradient.hh>
@@ -41,7 +40,6 @@
# include <mln/morpho/includes.hh>
# include <mln/morpho/laplacian.hh>
# include <mln/morpho/meyer_wst.hh>
-# include <mln/morpho/opening.hh>
# include <mln/morpho/rank_filter.hh>
# include <mln/morpho/top_hat.hh>
diff --git a/milena/mln/morpho/opening/essential.hh b/milena/mln/morpho/opening/essential.hh
index 45fbdae..77bcf16 100644
--- a/milena/mln/morpho/opening/essential.hh
+++ b/milena/mln/morpho/opening/essential.hh
@@ -34,10 +34,11 @@
/// File that includes essential opening attributes.
#include <mln/morpho/opening/algebraic.hh>
-#include <mln/morpho/opening/leveling.hh>
#include <mln/morpho/opening/area.hh>
-#include <mln/morpho/opening/volume.hh>
#include <mln/morpho/opening/height.hh>
+#include <mln/morpho/opening/leveling.hh>
+#include <mln/morpho/opening/structural.hh>
+#include <mln/morpho/opening/volume.hh>
#endif // ! MLN_MORPHO_OPENING_ESSENTIAL_HH
--
1.5.6.5
1
0
* mln/morpho/closing/area.hh: update copyright.
* mln/morpho/closing/leveling.hh: fix guard and revamp.
* mln/morpho/rank_filter.hh: update forward declaration.
* tests/morpho/Makefile.am: run tests in morpho/closing and
morpho/opening.
* tests/morpho/closing/area.cc,
* tests/morpho/closing/height.cc,
* tests/morpho/closing/sum.cc,
* tests/morpho/closing/volume.cc,
* tests/morpho/opening/area.cc,
* tests/morpho/opening/height.cc,
* tests/morpho/opening/sum.cc,
* tests/morpho/opening/volume.cc: use tiny.ppm instead of lena.ppm, it
is faster.
---
milena/ChangeLog | 23 +++++++++++++
milena/mln/morpho/closing/area.hh | 2 +-
milena/mln/morpho/closing/leveling.hh | 59 ++++++++++++++++++--------------
milena/mln/morpho/rank_filter.hh | 5 ++-
milena/tests/morpho/Makefile.am | 2 +
milena/tests/morpho/closing/area.cc | 2 +-
milena/tests/morpho/closing/height.cc | 2 +-
milena/tests/morpho/closing/sum.cc | 2 +-
milena/tests/morpho/closing/volume.cc | 2 +-
milena/tests/morpho/opening/area.cc | 2 +-
milena/tests/morpho/opening/height.cc | 2 +-
milena/tests/morpho/opening/sum.cc | 2 +-
milena/tests/morpho/opening/volume.cc | 2 +-
13 files changed, 70 insertions(+), 37 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d961175..6e55f81 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,28 @@
2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes related to morpho.
+
+ * mln/morpho/closing/area.hh: update copyright.
+
+ * mln/morpho/closing/leveling.hh: fix guard and revamp.
+
+ * mln/morpho/rank_filter.hh: update forward declaration.
+
+ * tests/morpho/Makefile.am: run tests in morpho/closing and
+ morpho/opening.
+
+ * tests/morpho/closing/area.cc,
+ * tests/morpho/closing/height.cc,
+ * tests/morpho/closing/sum.cc,
+ * tests/morpho/closing/volume.cc,
+ * tests/morpho/opening/area.cc,
+ * tests/morpho/opening/height.cc,
+ * tests/morpho/opening/sum.cc,
+ * tests/morpho/opening/volume.cc: use tiny.ppm instead of lena.ppm, it
+ is faster.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add a specialization of level::convert.
* mln/level/convert.hh: Add a specialization while the conversion
diff --git a/milena/mln/morpho/closing/area.hh b/milena/mln/morpho/closing/area.hh
index a351262..f805c31 100644
--- a/milena/mln/morpho/closing/area.hh
+++ b/milena/mln/morpho/closing/area.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
diff --git a/milena/mln/morpho/closing/leveling.hh b/milena/mln/morpho/closing/leveling.hh
index 32a34c8..7825166 100644
--- a/milena/mln/morpho/closing/leveling.hh
+++ b/milena/mln/morpho/closing/leveling.hh
@@ -26,7 +26,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_LEVELING_HH
+#ifndef MLN_MORPHO_CLOSING_LEVELING_HH
# define MLN_MORPHO_CLOSING_LEVELING_HH
/// \file mln/morpho/closing/leveling.hh
@@ -37,15 +37,20 @@
# include <mln/morpho/leveling_filter.hh>
-namespace mln {
- namespace morpho {
- namespace closing {
+namespace mln
+{
- /// Morphological leveling closing.
- template <typename I, typename N, typename A>
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& accu, const mln_result(A)& lambda);
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological leveling closing.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
@@ -53,33 +58,35 @@ namespace mln {
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N, typename A>
- inline
- mln_concrete(I)
- leveling(const Image<I>& input, const Neighborhood<N>& nbh,
- const Accumulator<A>& accu, const mln_result(A)& lambda)
- {
- trace::entering("morpho::closing::leveling");
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ trace::entering("morpho::closing::leveling");
- mln_precondition(exact(input).is_valid());
- mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A),
- trait::accumulator::when_pix::not_ok)::value);
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::not_ok)::value);
- mln_concrete(I) output;
- output = leveling_filter(input, nbh, accu, lambda,
- /* increasing = */ true);
+ mln_concrete(I) output;
+ output = leveling_filter(input, nbh, accu, lambda,
+ /* increasing = */ true);
- mln_postcondition(output >= input);
+ mln_postcondition(output >= input);
- trace::exiting("morpho::closing::leveling");
- return output;
- }
+ trace::exiting("morpho::closing::leveling");
+ return output;
+ }
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho::closing
+
} // end of namespace mln::morpho
+
} // end of namespace mln
diff --git a/milena/mln/morpho/rank_filter.hh b/milena/mln/morpho/rank_filter.hh
index fe99eb9..4b36695 100644
--- a/milena/mln/morpho/rank_filter.hh
+++ b/milena/mln/morpho/rank_filter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -44,7 +45,7 @@ namespace mln
/// Morphological rank_filter.
template <typename I, typename W>
mln_concrete(I)
- rank_filter(const Image<I>& input, const Window<W>& win);
+ rank_filter(const Image<I>& input, const Window<W>& win, unsigned k);
# ifndef MLN_INCLUDE_ONLY
diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am
index 4775e6f..909488f 100644
--- a/milena/tests/morpho/Makefile.am
+++ b/milena/tests/morpho/Makefile.am
@@ -4,7 +4,9 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
attribute \
+ closing \
elementary \
+ opening \
tree \
watershed
diff --git a/milena/tests/morpho/closing/area.cc b/milena/tests/morpho/closing/area.cc
index 711f178..c26f49f 100644
--- a/milena/tests/morpho/closing/area.cc
+++ b/milena/tests/morpho/closing/area.cc
@@ -49,6 +49,6 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::area(lena, c4(), 510), "out.pgm");
}
diff --git a/milena/tests/morpho/closing/height.cc b/milena/tests/morpho/closing/height.cc
index 6a9561e..575a080 100644
--- a/milena/tests/morpho/closing/height.cc
+++ b/milena/tests/morpho/closing/height.cc
@@ -48,6 +48,6 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::height(lena, c4(), 20), "out.pgm");
}
diff --git a/milena/tests/morpho/closing/sum.cc b/milena/tests/morpho/closing/sum.cc
index c933da9..269b36d 100644
--- a/milena/tests/morpho/closing/sum.cc
+++ b/milena/tests/morpho/closing/sum.cc
@@ -51,7 +51,7 @@ int main()
typedef image2d<int_u8> I;
I lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
typedef morpho::attribute::sum<I> A;
io::pgm::save(morpho::closing::leveling(lena, c4(), A(), 10000),
diff --git a/milena/tests/morpho/closing/volume.cc b/milena/tests/morpho/closing/volume.cc
index fccfa8e..d26bb6f 100644
--- a/milena/tests/morpho/closing/volume.cc
+++ b/milena/tests/morpho/closing/volume.cc
@@ -50,7 +50,7 @@ int main()
typedef image2d<int_u8> I;
I lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::closing::volume(lena, c4(), 10000),
"ref.pgm");
diff --git a/milena/tests/morpho/opening/area.cc b/milena/tests/morpho/opening/area.cc
index bfa0df7..cd9eacf 100644
--- a/milena/tests/morpho/opening/area.cc
+++ b/milena/tests/morpho/opening/area.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::area(lena, c4(), 510);
diff --git a/milena/tests/morpho/opening/height.cc b/milena/tests/morpho/opening/height.cc
index cebfd2e..eb46824 100644
--- a/milena/tests/morpho/opening/height.cc
+++ b/milena/tests/morpho/opening/height.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::height(lena, c4(), 20);
diff --git a/milena/tests/morpho/opening/sum.cc b/milena/tests/morpho/opening/sum.cc
index 0be3b8e..6eaaafc 100644
--- a/milena/tests/morpho/opening/sum.cc
+++ b/milena/tests/morpho/opening/sum.cc
@@ -52,7 +52,7 @@ int main()
I lena;
typedef morpho::attribute::sum<I> A;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
io::pgm::save(morpho::opening::leveling(lena, c4(), A(), 10000),
"out.pgm");
}
diff --git a/milena/tests/morpho/opening/volume.cc b/milena/tests/morpho/opening/volume.cc
index 0fb7f64..c72b88c 100644
--- a/milena/tests/morpho/opening/volume.cc
+++ b/milena/tests/morpho/opening/volume.cc
@@ -48,7 +48,7 @@ int main()
using value::int_u8;
image2d<int_u8> lena;
- io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
image2d<int_u8> out(lena.domain());
out = morpho::opening::volume(lena, c4(), 10000);
--
1.5.6.5
1
0
* mln/level/convert.hh: Add a specialization while the conversion
value type is equal to the image value type.
* tests/level/convert.cc: add a new test.
---
milena/ChangeLog | 15 ++++-
milena/mln/level/convert.hh | 115 ++++++++++++++++++++++++++++++++++++----
milena/tests/level/convert.cc | 23 ++++++---
3 files changed, 131 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8216a5f..d961175 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add a specialization of level::convert.
+
+ * mln/level/convert.hh: Add a specialization while the conversion
+ value type is equal to the image value type.
+
+ * tests/level/convert.cc: add a new test.
+
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Introduce distance_and_closest_point_geodesic.
@@ -24,7 +33,7 @@
Update according modifications in
distance_and_closest_point_geodesic.hh.
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Add util::couple.
@@ -33,7 +42,7 @@
* mln/util/all.hh,
* mln/util/essential.hh: include new header.
-2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-03 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
configure.ac: configure milena/tests/transform.
diff --git a/milena/mln/level/convert.hh b/milena/mln/level/convert.hh
index 3c7a827..39da091 100644
--- a/milena/mln/level/convert.hh
+++ b/milena/mln/level/convert.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -8,7 +9,7 @@
// This library 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.
+// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
@@ -34,6 +35,7 @@
///
/// \todo Re-write doc.
+# include <mln/core/routine/duplicate.hh>
# include <mln/fun/v2v/convert.hh>
# include <mln/level/transform.hh>
@@ -44,12 +46,11 @@ namespace mln
namespace level
{
- /*! Convert the image \p input by changing the value type.
- *
- * \param[in] v A value of the destination type.
- * \param[in] input The input image.
- * \param[out] output The result image.
- */
+ /// Convert the image \p input by changing the value type.
+ ///
+ /// \param[in] v A value of the destination type.
+ /// \param[in] input The input image.
+ /// \param[out] output The result image.
template <typename V, typename I>
mln_ch_value(I, V)
convert(const V&, const Image<I>& input);
@@ -58,18 +59,108 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
+ template <typename V, typename I>
+ inline
+ void
+ convert_tests(const V&, const Image<I>& input)
+ {
+ mln_precondition(exact(input).is_valid());
+ (void) input;
+ }
+
+ } // using namespace mln::level::internal
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert(const V& v, const Image<I>& input)
+ {
+ trace::entering("level::impl::generic::convert");
+ internal::convert_tests(v, input);
+
+ fun::v2v::convert<V> f;
+ mln_ch_value(I, V) output = level::transform(input, f);
+
+ trace::exiting("level::impl::generic::convert");
+ return output;
+ }
+
+ } // end of namespace mln::level::impl::generic
+
+
+ template <typename V, typename I>
+ inline
+ mln_concrete(I)
+ convert_identity(const V& v, const Image<I>& input)
+ {
+ trace::entering("level::impl::convert_identity");
+ internal::convert_tests(v, input);
+
+ mln_concrete(I) output = duplicate(input);
+
+ trace::exiting("level::impl::convert_identity");
+ return output;
+ }
+
+
+ } // end of namespace mln::level::impl
+
+ namespace internal
+ {
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(metal::bool_<true>,
+ const V& v, const Image<I>& input)
+ {
+ return impl::convert_identity(v, input);
+ }
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(metal::bool_<false>,
+ const V& v, const Image<I>& input)
+ {
+ return impl::generic::convert(v, input);
+ }
+
+ template <typename V, typename I>
+ inline
+ mln_ch_value(I, V)
+ convert_dispatch(const V& v, const Image<I>& input)
+ {
+ enum {
+ test = mlc_equal(V, mln_value(I))::value
+ };
+ return convert_dispatch(metal::bool_<test>(),
+ v, input);
+ }
+
+ } // end of namespace mln::level::internal
+
// Facade.
template <typename V, typename I>
inline
mln_ch_value(I, V)
- convert(const V&, const Image<I>& input)
+ convert(const V& v, const Image<I>& input)
{
trace::entering("level::convert");
- mln_precondition(exact(input).is_valid());
- fun::v2v::convert<V> f;
- mln_ch_value(I, V) output = level::transform(input, f);
+ internal::convert_tests(v, input);
+
+ mln_ch_value(I, V) output = internal::convert_dispatch(v, input);
trace::exiting("level::convert");
return output;
diff --git a/milena/tests/level/convert.cc b/milena/tests/level/convert.cc
index 9b1fd1f..f9b42ab 100644
--- a/milena/tests/level/convert.cc
+++ b/milena/tests/level/convert.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,13 +26,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/convert.cc
- *
- * \brief Tests on mln::level::convert
- */
+/// \file tests/level/convert.cc
+///
+/// Tests on mln::level::convert
#include <mln/core/image/image2d.hh>
#include <mln/level/convert.hh>
+#include <mln/level/compare.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/grays.hh>
@@ -43,8 +44,6 @@ int main()
using namespace mln;
using value::rgb8;
-// trace::quiet = false;
-
// bool -> rgb8
{
image2d<bool> ima(1, 2);
@@ -54,4 +53,14 @@ int main()
mln_assertion(opt::at(out, 0, 0) == literal::black);
mln_assertion(opt::at(out, 0, 1) == literal::white);
}
+ // bool -> bool
+ {
+ image2d<bool> ima(1, 2);
+ data::fill(ima, true);
+ opt::at(ima, 0, 0) = false;
+ image2d<bool> out = level::convert(bool(), ima);
+ mln_assertion(out == ima);
+ mln_assertion(out.buffer() != ima.buffer());
+ }
+
}
--
1.5.6.5
1
0
* mln/transform/closest_point_geodesic.hh: rename as...
* mln/transform/distance_and_closest_point_geodesic.hh: ... this.
Now returns both dmap and closest point images.
Add a version returning a closest point image containing indexes.
* mln/transform/all.hh: update includes.
* mln/transform/internal/closest_point_functor.hh: add a new functor
which build a closest point image containing sites.
* tests/Makefile.am: run transform tests.
* tests/transform/Makefile.am: update test names
.
* tests/transform/bench_closest_point_geodesic.cc: fix missing
include.
* tests/transform/closest_point_geodesic.cc: rename as...
* tests/transform/distance_and_closest_point_geodesic.cc: ... this.
Update according modifications in
distance_and_closest_point_geodesic.hh.
---
milena/ChangeLog | 26 +++
milena/mln/transform/all.hh | 2 +-
milena/mln/transform/closest_point_geodesic.hh | 81 --------
.../distance_and_closest_point_geodesic.hh | 143 ++++++++++++++
.../transform/internal/closest_point_functor.hh | 196 ++++++++++++++++++--
milena/tests/Makefile.am | 1 +
milena/tests/transform/Makefile.am | 4 +-
.../transform/bench_closest_point_geodesic.cc | 1 +
milena/tests/transform/closest_point_geodesic.cc | 54 ------
.../distance_and_closest_point_geodesic.cc | 95 ++++++++++
10 files changed, 446 insertions(+), 157 deletions(-)
delete mode 100644 milena/mln/transform/closest_point_geodesic.hh
create mode 100644 milena/mln/transform/distance_and_closest_point_geodesic.hh
delete mode 100644 milena/tests/transform/closest_point_geodesic.cc
create mode 100644 milena/tests/transform/distance_and_closest_point_geodesic.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c8b7f2c..8216a5f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Introduce distance_and_closest_point_geodesic.
+
+ * mln/transform/closest_point_geodesic.hh: rename as...
+ * mln/transform/distance_and_closest_point_geodesic.hh: ... this.
+ Now returns both dmap and closest point images.
+ Add a version returning a closest point image containing indexes.
+
+ * mln/transform/all.hh: update includes.
+
+ * mln/transform/internal/closest_point_functor.hh: add a new functor
+ which build a closest point image containing sites.
+
+ * tests/Makefile.am: run transform tests.
+
+ * tests/transform/Makefile.am: update test names
+ .
+ * tests/transform/bench_closest_point_geodesic.cc: fix missing
+ include.
+
+ * tests/transform/closest_point_geodesic.cc: rename as...
+ * tests/transform/distance_and_closest_point_geodesic.cc: ... this.
+ Update according modifications in
+ distance_and_closest_point_geodesic.hh.
+
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add util::couple.
* mln/util/couple.hh: New. behaves like a std::pair.
diff --git a/milena/mln/transform/all.hh b/milena/mln/transform/all.hh
index 256a4e8..4967197 100644
--- a/milena/mln/transform/all.hh
+++ b/milena/mln/transform/all.hh
@@ -42,7 +42,7 @@ namespace mln
} // end of namespace mln
-# include <mln/transform/closest_point_geodesic.hh>
+# include <mln/transform/distance_and_closest_point_geodesic.hh>
# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
# include <mln/transform/influence_zone_front.hh>
diff --git a/milena/mln/transform/closest_point_geodesic.hh b/milena/mln/transform/closest_point_geodesic.hh
deleted file mode 100644
index 0761d00..0000000
--- a/milena/mln/transform/closest_point_geodesic.hh
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library 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 this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library 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_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-# define MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
-
-/// \file mln/transform/closest_point_geodesic.hh
-///
-/// Geodesic closest point transform.
-///
-/// \todo Add a version to retrieve both distance and closest point
-/// maps.
-
-# include <mln/canvas/distance_geodesic.hh>
-# include <mln/transform/internal/closest_point_functor.hh>
-
-
-
-namespace mln
-{
-
- namespace transform
- {
-
- /// Discrete geodesic distance transform.
- template <typename I, typename N, typename D>
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename I, typename N, typename D>
- inline
- mln_ch_value(I, mln_psite(I))
- closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
- {
- trace::entering("transform::closest_point_geodesic");
-
- mln_precondition(exact(input).is_valid());
- mln_precondition(exact(nbh).is_valid());
-
- internal::closest_point_functor<I> f;
- (void) mln::canvas::distance_geodesic(input, nbh, max, f);
-
- trace::exiting("transform::closest_point_geodesic");
- return f.cp_ima;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::transform
-
-} // end of namespace mln
-
-
-#endif // ! MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/distance_and_closest_point_geodesic.hh b/milena/mln/transform/distance_and_closest_point_geodesic.hh
new file mode 100644
index 0000000..efc63ab
--- /dev/null
+++ b/milena/mln/transform/distance_and_closest_point_geodesic.hh
@@ -0,0 +1,143 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+# define MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
+
+/// \file mln/transform/distance_and_closest_point_geodesic.hh
+///
+/// Distance and geodesic closest point transform.
+
+# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/closest_point_functor.hh>
+
+# include <mln/data/fill.hh>
+# include <mln/util/couple.hh>
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] input Image from which the geodesic distance is computed.
+ /// \param[in] nbh Neighborhood
+ /// \param[in] max Max distance of propagation.
+ ///
+ /// \return a couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains sites.
+ ///
+ /// \post The returned images have the same domain as \p input.
+ template <typename I, typename N, typename D>
+ util::couple<mln_ch_value(I,D), mln_ch_value(I,mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+ /// Discrete geodesic distance transform
+ ///
+ /// \param[in] pset an array of sites.
+ /// \param[in] closest_point_domain domain of the returned image.
+ /// \param[in] nbh neighborhood
+ /// \param[in] max max distance of propagation.
+ ///
+ /// \return A couple of images. The first one is the distance map and the
+ /// second one is the closest point image. The closest point image
+ /// contains site indexes.
+ ///
+ /// \post The returned image domains are defined on \p closest_point_domain.
+ template <typename P, typename N, typename D>
+ util::couple<mln_image_from_grid(mln_grid(P),D),
+ mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename D>
+ inline
+ util::couple<mln_ch_value(I,D), mln_ch_value(I, mln_psite(I))>
+ distance_and_closest_point_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_closest_point_geodesic");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
+
+ internal::closest_point_functor_with_sites<I> f;
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(input, nbh,
+ max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+ template <typename P, typename N, typename D>
+ inline
+ util::couple<mln_image_from_grid(mln_grid(P),D), mln_image_from_grid(mln_grid(P),unsigned)>
+ distance_and_closest_point_geodesic(const p_array<P>& pset,
+ const box<P>& closest_point_domain,
+ const Neighborhood<N>& nbh,
+ D max)
+ {
+ trace::entering("transform::distance_and_closest_point_geodesic");
+
+ mln_precondition(closest_point_domain.is_valid());
+ mln_precondition(exact(nbh).is_valid());
+ mln_precondition(geom::bbox(pset) <= closest_point_domain);
+
+ typedef mln_image_from_grid(mln_grid(P), bool) I;
+ internal::closest_point_functor_with_indexes<I> f(pset);
+
+ I ima(closest_point_domain);
+ data::fill(ima, false);
+ data::fill((ima | pset).rw(), true);
+
+ mln_ch_value(I,D) dmap = mln::canvas::distance_geodesic(ima, nbh, max, f);
+
+ trace::exiting("transform::distance_and_closest_point_geodesic");
+ return make::couple(dmap, f.cp_ima);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_DISTANCE_AND_CLOSEST_POINT_GEODESIC_HH
diff --git a/milena/mln/transform/internal/closest_point_functor.hh b/milena/mln/transform/internal/closest_point_functor.hh
index 5cbac15..8df47b7 100644
--- a/milena/mln/transform/internal/closest_point_functor.hh
+++ b/milena/mln/transform/internal/closest_point_functor.hh
@@ -47,31 +47,55 @@ namespace mln
{
template <typename I>
- struct closest_point_functor
+ struct closest_point_functor_with_indexes
{
typedef mln_value(I) V;
- typedef mln_psite(I) P;
+ typedef mln_psite(I) P;
- closest_point_functor(const p_array<P>& pset);
+ closest_point_functor_with_indexes(const p_array<P>& pset);
mln_ch_value(I,unsigned) cp_ima;
const p_array<P>& pset_;
+ /// Generic version interface.
void init(const I&);
bool inqueue_p_wrt_input_p(const V& input_p);
void init_p(const P&);
bool inqueue_p_wrt_input_n(const V& input_n);
void process(const P&, const P&);
- void init_(const I& input)
- {
- init(input);
- }
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
+ };
+
+
+ template <typename I>
+ struct closest_point_functor_with_sites
+ {
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ closest_point_functor_with_sites();
+
+ mln_ch_value(I,P) cp_ima;
- bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p == true; }
- void init_p_(unsigned) { }//cp_ima.element(p) = pset_(cp_ima.point_at_index(p)); }
- bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == false; }
- void process_(unsigned p, unsigned n) { cp_ima.element(n) = cp_ima.element(p); }
+ /// Generic version interface.
+ void init(const I&);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ void init_p(const P&);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P&, const P&);
+
+ /// Fast version interface.
+ void init_(const I& input);
+ bool inqueue_p_wrt_input_p_(const V& input_p);
+ void init_p_(unsigned p);
+ bool inqueue_p_wrt_input_n_(const V& input_n);
+ void process_(unsigned p, unsigned n);
};
@@ -79,7 +103,8 @@ namespace mln
template <typename I>
inline
- closest_point_functor<I>::closest_point_functor(const p_array<mln_psite(I)>& pset)
+ closest_point_functor_with_indexes<I>::closest_point_functor_with_indexes(
+ const p_array<mln_psite(I)>& pset)
: pset_(pset)
{
}
@@ -87,20 +112,111 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init(const I& input)
+ closest_point_functor_with_indexes<I>::init(const I& input)
{
initialize(cp_ima, input);
data::fill(cp_ima, 0u);
mln_piter(p_array<mln_psite(I)>) p(pset_);
for_all(p)
- cp_ima(p) = p.index();
+ cp_ima(p) = cp_ima.index_of_point(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_p(const P&)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::process(const P& p, const P& n)
+ {
+ cp_ima(n) = cp_ima(p);
+ }
+
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_indexes<I>::init_p_(unsigned)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_indexes<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_indexes<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
+
+ /// ///
+ /// closest_point_functor_with_sites ///
+ /// ///
+
+
+ template <typename I>
+ inline
+ closest_point_functor_with_sites<I>::closest_point_functor_with_sites()
+ {
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init(const I& input)
+ {
+ initialize(cp_ima, input);
+ data::fill(cp_ima, literal::origin);
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p(const V& input_p)
{
return input_p == true;
}
@@ -108,26 +224,68 @@ namespace mln
template <typename I>
inline
void
- closest_point_functor<I>::init_p(const P&)
+ closest_point_functor_with_sites<I>::init_p(const P& p)
{
-// cp_ima(p) = p;
+ cp_ima(p) = p;
}
template <typename I>
inline
bool
- closest_point_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n(const V& input_n)
{
return input_n == false;
}
template <typename I>
inline
- void closest_point_functor<I>::process(const P& p, const P& n)
+ void
+ closest_point_functor_with_sites<I>::process(const P& p, const P& n)
{
cp_ima(n) = cp_ima(p);
}
+
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::init_(const I& input)
+ {
+ init(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_p_(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ void closest_point_functor_with_sites<I>::init_p_(unsigned p)
+ {
+ cp_ima.element(p) = cp_ima.point_at_index(p);
+ }
+
+ template <typename I>
+ inline
+ bool
+ closest_point_functor_with_sites<I>::inqueue_p_wrt_input_n_(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void
+ closest_point_functor_with_sites<I>::process_(unsigned p, unsigned n)
+ {
+ cp_ima.element(n) = cp_ima.element(p);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform::internal
diff --git a/milena/tests/Makefile.am b/milena/tests/Makefile.am
index 523af72..0e05a0f 100644
--- a/milena/tests/Makefile.am
+++ b/milena/tests/Makefile.am
@@ -41,6 +41,7 @@ SUBDIRS = \
topo \
trace \
trait \
+ transform \
unit_test \
util \
value \
diff --git a/milena/tests/transform/Makefile.am b/milena/tests/transform/Makefile.am
index 4ee9cfd..04087f7 100644
--- a/milena/tests/transform/Makefile.am
+++ b/milena/tests/transform/Makefile.am
@@ -4,14 +4,14 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
bench_closest_point_geodesic \
- closest_point_geodesic \
+ distance_and_closest_point_geodesic \
distance_front \
distance_geodesic \
influence_zone_front \
influence_zone_geodesic
bench_closest_point_geodesic_SOURCES = bench_closest_point_geodesic.cc
-closest_point_geodesic_SOURCES = closest_point_geodesic.cc
+distance_and_closest_point_geodesic_SOURCES = distance_and_closest_point_geodesic.cc
distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
influence_zone_front_SOURCES = influence_zone_front.cc
diff --git a/milena/tests/transform/bench_closest_point_geodesic.cc b/milena/tests/transform/bench_closest_point_geodesic.cc
index 974a734..06a6b44 100644
--- a/milena/tests/transform/bench_closest_point_geodesic.cc
+++ b/milena/tests/transform/bench_closest_point_geodesic.cc
@@ -36,6 +36,7 @@
#include <mln/data/fill.hh>
#include <mln/opt/at.hh>
#include <mln/transform/closest_point_geodesic.hh>
+#include <mln/value/int_u8.hh>
int main()
diff --git a/milena/tests/transform/closest_point_geodesic.cc b/milena/tests/transform/closest_point_geodesic.cc
deleted file mode 100644
index c9bb97c..0000000
--- a/milena/tests/transform/closest_point_geodesic.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library 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 this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library 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.
-
-/// \file tests/transform/closest_point_geodesic.cc
-///
-/// Test on mln::transform::closest_point_geodesic.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/data/fill.hh>
-#include <mln/debug/println.hh>
-#include <mln/opt/at.hh>
-
-#include <mln/transform/closest_point_geodesic.hh>
-
-
-int main()
-{
- using namespace mln;
- using value::int_u8;
-
- image2d<bool> input(9, 9);
- data::fill(input, false);
- opt::at(input, 2, 4) = true;
- opt::at(input, 4, 2) = true;
-
- image2d<point2d> output = transform::closest_point_geodesic(input, c4(), int_u8(4));
- debug::println(output);
-}
diff --git a/milena/tests/transform/distance_and_closest_point_geodesic.cc b/milena/tests/transform/distance_and_closest_point_geodesic.cc
new file mode 100644
index 0000000..d3544ab
--- /dev/null
+++ b/milena/tests/transform/distance_and_closest_point_geodesic.cc
@@ -0,0 +1,95 @@
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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.
+
+/// \file tests/transform/closest_point_geodesic.cc
+///
+/// Test on mln::transform::closest_point_geodesic.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/opt/at.hh>
+#include <mln/level/compare.hh>
+
+#include <mln/transform/distance_and_closest_point_geodesic.hh>
+
+unsigned dmap_ref[] = { 4, 4, 4, 3, 2, 3, 4, 4, 4,
+ 4, 4, 3, 2, 1, 2, 3, 4, 4,
+ 4, 3, 2, 1, 0, 1, 2, 3, 4,
+ 3, 2, 1, 2, 1, 2, 3, 4, 4,
+ 2, 1, 0, 1, 2, 3, 4, 4, 4,
+ 3, 2, 1, 2, 3, 4, 4, 4, 4,
+ 4, 3, 2, 3, 4, 4, 4, 4, 4,
+ 4, 4, 3, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4 };
+
+
+unsigned cp_idx_ref[] = { 0 , 0 , 82 , 82 , 82 , 82, 82, 0 , 0 ,
+ 0 , 82 , 82 , 82 , 82 , 82, 82, 82, 0 ,
+ 110, 82 , 82 , 82 , 82 , 82, 82, 82, 82,
+ 110, 110, 110, 82 , 82 , 82, 82, 82, 0 ,
+ 110, 110, 110, 110, 82 , 82, 82, 0 , 0 ,
+ 110, 110, 110, 110, 82 , 82, 0 , 0 , 0 ,
+ 110, 110, 110, 110, 110, 0 , 0 , 0 , 0 ,
+ 0 , 110, 110, 110, 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 110, 0 , 0 , 0 , 0 , 0 , 0 };
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input(9, 9);
+ data::fill(input, false);
+ opt::at(input, 2, 4) = true;
+ opt::at(input, 4, 2) = true;
+
+ {
+ typedef util::couple<image2d<int_u8>, image2d<point2d> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(input,
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ ///FIXME: test the closest point image here.
+ }
+
+ {
+ p_array<point2d> arr;
+ arr.insert(point2d(2, 4));
+ arr.insert(point2d(4, 2));
+ typedef util::couple<image2d<int_u8>, image2d<unsigned> > output_t;
+ output_t output = transform::distance_and_closest_point_geodesic(arr,
+ input.domain(),
+ c4(),
+ int_u8(4));
+ mln_assertion(output.first() == make::image2d(dmap_ref));
+ mln_assertion(output.second() == make::image2d(cp_idx_ref));
+ }
+}
--
1.5.6.5
1
0
* mln/util/couple.hh: New. behaves like a std::pair.
* mln/util/all.hh,
* mln/util/essential.hh: include new header.
---
milena/ChangeLog | 9 ++
milena/mln/util/all.hh | 3 +-
milena/mln/util/couple.hh | 253 ++++++++++++++++++++++++++++++++++++++++++
milena/mln/util/essential.hh | 10 +-
4 files changed, 269 insertions(+), 6 deletions(-)
create mode 100644 milena/mln/util/couple.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1bd69d2..c8b7f2c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add util::couple.
+
+ * mln/util/couple.hh: New. behaves like a std::pair.
+
+ * mln/util/all.hh,
+ * mln/util/essential.hh: include new header.
+
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
configure.ac: configure milena/tests/transform.
2009-03-03 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
diff --git a/milena/mln/util/all.hh b/milena/mln/util/all.hh
index 4eb7f2f..180b8a1 100644
--- a/milena/mln/util/all.hh
+++ b/milena/mln/util/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -50,6 +50,7 @@ namespace mln
# include <mln/util/array.hh>
# include <mln/util/branch_iter.hh>
# include <mln/util/branch_iter_ind.hh>
+# include <mln/util/couple.hh>
# include <mln/util/dindex.hh>
# include <mln/util/eat.hh>
# include <mln/util/edge.hh>
diff --git a/milena/mln/util/couple.hh b/milena/mln/util/couple.hh
new file mode 100644
index 0000000..00b69d4
--- /dev/null
+++ b/milena/mln/util/couple.hh
@@ -0,0 +1,253 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_UTIL_COUPLE_HH
+# define MLN_UTIL_COUPLE_HH
+
+/// \file mln/util/couple.hh
+///
+/// Definition of a couple.
+///
+/// \todo revamp and refactor with util::site_pair or ord_pair.
+
+# include <mln/core/concept/object.hh>
+# include <mln/util/ord.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ template <typename T, typename U>
+ struct couple : public mln::Object< couple<T,U> >
+ {
+ public:
+ couple();
+ couple(const T& val1, const U& val2);
+
+ public:
+ /// Get the first member of the couple.
+ /// \{
+ const T& first() const;
+ T& first();
+ /// \}
+
+ /// Get the second member of the couple.
+ /// \{
+ const U& second() const;
+ U& second();
+ /// \}
+
+ /// Replace the first member of the couple by \a val.
+ void change_first(const T& val);
+
+ /// Replace the second member of the couple by \a val.
+ void change_second(const U& val);
+
+ /// Replace both members of the couple by \a val.
+ void change_both(const T& first, const U& second);
+
+ private:
+ T first_;
+ U second_;
+ };
+
+
+ template <typename T, typename U>
+ bool operator==(const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+ template <typename T, typename U>
+ bool operator< (const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+ template <typename T, typename U>
+ bool operator<=(const couple<T,U>& lhs, const couple<T,U>& rhs);
+
+
+ template <typename T, typename U>
+ std::ostream& operator<<(std::ostream& ostr, const couple<T,U>& op);
+
+ } // end of namespace mln::util
+
+
+ namespace make
+ {
+ /// Construct an mln::util::couple on-the-fly.
+ template <typename T, typename U>
+ util::couple<T,U> couple(const T& val1, const T& val2);
+ }
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace util
+ {
+
+ /*---------------.
+ | Construction. |
+ `---------------*/
+
+ template <typename T, typename U>
+ inline
+ couple<T,U>::couple()
+ {
+ }
+
+ template <typename T, typename U>
+ inline
+ couple<T,U>::couple(const T& val1, const U& val2)
+ {
+ change_both(val1, val2);
+ }
+
+ /*---------.
+ | Access. |
+ `---------*/
+
+ template <typename T, typename U>
+ inline
+ const T&
+ couple<T,U>::first() const
+ {
+ return first_;
+ }
+
+ template <typename T, typename U>
+ inline
+ T&
+ couple<T,U>::first()
+ {
+ return first_;
+ }
+
+ template <typename T, typename U>
+ inline
+ const U&
+ couple<T,U>::second() const
+ {
+ return second_;
+ }
+
+ template <typename T, typename U>
+ inline
+ U&
+ couple<T,U>::second()
+ {
+ return second_;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_first(const T& val)
+ {
+ first_ = val;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_second(const U& val)
+ {
+ second_ = val;
+ }
+
+ template <typename T, typename U>
+ inline
+ void
+ couple<T,U>::change_both(const T& val1, const U& val2)
+ {
+ first_ = val1;
+ second_ = val2;
+ }
+
+ /*-------------.
+ | Comparison. |
+ `-------------*/
+
+ template <typename T, typename U>
+ inline
+ bool operator==(const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return lhs.first() == rhs.first() && lhs.second() == rhs.second();
+ }
+
+ template <typename T, typename U>
+ inline
+ bool operator< (const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return
+ util::ord_strict(lhs.first(), rhs.first()) ||
+ (lhs.first() == rhs.first() &&
+ util::ord_strict(lhs.second(), rhs.second()));
+ }
+
+ template <typename T, typename U>
+ inline
+ bool operator<=(const couple<T,U>& lhs, const couple<T,U>& rhs)
+ {
+ return
+ util::ord_strict(lhs.first(), rhs.first()) ||
+ (lhs.first() == rhs.first() &&
+ util::ord_weak(lhs.second(), rhs.second()));
+ }
+
+ /*------------------.
+ | Pretty-printing. |
+ `------------------*/
+
+ template <typename T, typename U>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const couple<T,U>& op)
+ {
+ return ostr << '(' << op.first() << ',' << op.second() << ')';
+ }
+
+ } // end of namespace mln::util
+
+
+ namespace make
+ {
+
+ template <typename T, typename U>
+ inline
+ util::couple<T,U>
+ couple(const T& val1, const U& val2)
+ {
+ util::couple<T,U> tmp(val1, val2);
+ return tmp;
+ }
+
+ } // end of namespace mln::make
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_COUPLE_HH
diff --git a/milena/mln/util/essential.hh b/milena/mln/util/essential.hh
index b041f2a..3c9b74f 100644
--- a/milena/mln/util/essential.hh
+++ b/milena/mln/util/essential.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,12 @@
#ifndef MLN_UTIL_ESSENTIAL_HH
# define MLN_UTIL_ESSENTIAL_HH
-/*! \file mln/util/essential.hh
- *
- * \brief File that includes essential util-related routines.
- */
+/// \file mln/util/essential.hh
+///
+/// File that includes essential util-related routines.
# include <mln/util/array.hh>
+# include <mln/util/couple.hh>
# include <mln/util/lazy_set.hh>
# include <mln/util/lemmings.hh>
# include <mln/util/ord.hh>
--
1.5.6.5
1
0
---
configure.ac | 1 +
milena/ChangeLog | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index f65fe88..018fec3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -260,6 +260,7 @@ AC_CONFIG_FILES([
milena/tests/trait/image/Makefile
milena/tests/trait/op/Makefile
milena/tests/trait/value/Makefile
+ milena/tests/transform/Makefile
milena/tests/util/Makefile
milena/tests/unit_test/Makefile
milena/tests/value/Makefile
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0540c31..1bd69d2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-02 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ configure.ac: configure milena/tests/transform.
+
2009-03-03 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing tests in morpho.
--
1.5.6.5
1
0