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
April 2009
- 11 participants
- 187 discussions
* mln/accu/stat/variance.hh,
* mln/io/plot/save.hh: fix missing includes.
* mln/level/abs.hh: fix invalid assignment.
* mln/make/rag_and_labeled_wsl.hh: add more doc.
* mln/util/tree_to_image.hh: fix a typo.
* tests/labeling/n_max.cc: use a smaller image.
* tests/make/rag_and_labeled_wsl.cc: Fix an invalid test and make the
test more readable.
---
milena/ChangeLog | 18 ++++++++++++++++++
milena/mln/accu/stat/variance.hh | 1 +
milena/mln/io/plot/save.hh | 2 ++
milena/mln/level/abs.hh | 2 +-
milena/mln/make/rag_and_labeled_wsl.hh | 24 ++++++++++++++++++++++++
milena/mln/util/tree_to_image.hh | 4 ++--
milena/tests/labeling/n_max.cc | 19 +++++++++----------
milena/tests/make/rag_and_labeled_wsl.cc | 19 +++++++++++--------
8 files changed, 68 insertions(+), 21 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0e13e64..20968b2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix tests.
+
+ * mln/accu/stat/variance.hh,
+ * mln/io/plot/save.hh: fix missing includes.
+
+ * mln/level/abs.hh: fix invalid assignment.
+
+ * mln/make/rag_and_labeled_wsl.hh: add more doc.
+
+ * mln/util/tree_to_image.hh: fix a typo.
+
+ * tests/labeling/n_max.cc: use a smaller image.
+
+ * tests/make/rag_and_labeled_wsl.cc: Fix an invalid test and make the
+ test more readable.
+
+2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add new tests.
* tests/make/Makefile.am,
diff --git a/milena/mln/accu/stat/variance.hh b/milena/mln/accu/stat/variance.hh
index 5c2ca3a..0b4dc0b 100644
--- a/milena/mln/accu/stat/variance.hh
+++ b/milena/mln/accu/stat/variance.hh
@@ -34,6 +34,7 @@
# include <cmath>
# include <mln/accu/internal/base.hh>
+# include <mln/util/pix.hh>
namespace mln
diff --git a/milena/mln/io/plot/save.hh b/milena/mln/io/plot/save.hh
index ecec666..a86e3f7 100644
--- a/milena/mln/io/plot/save.hh
+++ b/milena/mln/io/plot/save.hh
@@ -33,6 +33,8 @@
///
/// Define a routine which saves in a plot format.
+# include <iostream>
+# include <fstream>
# include <mln/core/image/image1d.hh>
# include <mln/metal/equal.hh>
# include <mln/util/array.hh>
diff --git a/milena/mln/level/abs.hh b/milena/mln/level/abs.hh
index d2b48b4..8889d1a 100644
--- a/milena/mln/level/abs.hh
+++ b/milena/mln/level/abs.hh
@@ -72,7 +72,7 @@ namespace mln
trace::entering("level::abs");
mln_precondition(exact(input).domain() == exact(output).domain());
- output = level::transform(input, fun::v2v::abs<mln_value(I)>());
+ exact(output) = level::transform(input, fun::v2v::abs<mln_value(I)>());
trace::exiting("level::abs");
}
diff --git a/milena/mln/make/rag_and_labeled_wsl.hh b/milena/mln/make/rag_and_labeled_wsl.hh
index d80b954..7ace36f 100644
--- a/milena/mln/make/rag_and_labeled_wsl.hh
+++ b/milena/mln/make/rag_and_labeled_wsl.hh
@@ -63,6 +63,30 @@ namespace mln
///
/// \return A couple. First element is the graph, second element is an
/// image with a labeled watershed line.
+ /*!
+ **
+ ** |-----------------| |-----------------| \n
+ ** | 1 1 1 0 2 2 0 3 | | . . . 1 . . 2 . | \n
+ ** | 1 1 0 2 2 2 0 3 | | . . 1 . . . 2 . | \n
+ ** | 1 0 4 0 2 0 3 3 | ----> | . 1 . 3 . 4 . . | \n
+ ** | 0 4 4 4 0 5 0 3 | | 1 . . . 5 . 6 . | \n
+ ** |-----------------| |-----------------| \n
+ ** \n
+ ** Watershed image Labeled watershed line \n
+ ** (watershed line labeled with 0) \n
+ ** \n
+ ** \n
+ ** | \n
+ ** | \n
+ ** | \n
+ ** v \n
+ ** \n
+ ** 1 -- 2 - 3 \n
+ ** \ / / \n
+ ** 4 -- 5 \n
+ ** \n
+ ** Region Adjacency graph (RAG) \n
+ */
template <typename I, typename N>
util::couple<util::graph,mln_concrete(I)>
rag_and_labeled_wsl(const Image<I>& wshd_,
diff --git a/milena/mln/util/tree_to_image.hh b/milena/mln/util/tree_to_image.hh
index f2364de..55f89e8 100644
--- a/milena/mln/util/tree_to_image.hh
+++ b/milena/mln/util/tree_to_image.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
@@ -56,7 +56,7 @@ namespace mln
/// Convert a tree into an image.
///
/// \param[in] tree The tree to convert.
- /// \param[out] output_ The image containing tree informations.
+ /// \param[out] output_ The image containing tree information.
///
template <typename T, typename I>
void
diff --git a/milena/tests/labeling/n_max.cc b/milena/tests/labeling/n_max.cc
index 10b0ff9..6900f40 100644
--- a/milena/tests/labeling/n_max.cc
+++ b/milena/tests/labeling/n_max.cc
@@ -32,7 +32,7 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/value/int_u8.hh>
-#include <mln/value/label_16.hh>
+#include <mln/value/label_8.hh>
#include <mln/labeling/flat_zones.hh>
#include <mln/labeling/compute.hh>
@@ -47,24 +47,23 @@
#include "tests/data.hh"
-
int main()
{
using namespace mln;
using value::int_u8;
- using value::label_16;
+ using value::label_8;
- image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
image2d<bool> threshold = level::transform(lena, fun::v2b::threshold<int_u8>(100));
- label_16 nlabels;
- image2d<label_16> labels = labeling::flat_zones(threshold, c4(), nlabels);
+ label_8 nlabels;
+ image2d<label_8> labels = labeling::flat_zones(threshold, c4(), nlabels);
accu::count<int_u8> a_;
util::array<unsigned> a = labeling::compute(a_, threshold, labels, nlabels);
- util::array<label_16> arr_big = labeling::n_max<label_16>(a, 3);
+ util::array<label_8> arr_big = labeling::n_max<label_8>(a, 3);
- mln_assertion(arr_big[1] == 4);
- mln_assertion(arr_big[2] == 6);
- mln_assertion(arr_big[3] == 323);
+ mln_assertion(arr_big[1] == 1u);
+ mln_assertion(arr_big[2] == 4u);
+ mln_assertion(arr_big[3] == 5u);
}
diff --git a/milena/tests/make/rag_and_labeled_wsl.cc b/milena/tests/make/rag_and_labeled_wsl.cc
index 5abb031..602bca6 100644
--- a/milena/tests/make/rag_and_labeled_wsl.cc
+++ b/milena/tests/make/rag_and_labeled_wsl.cc
@@ -55,11 +55,14 @@ int main()
util::couple<util::graph, wst_t>
res = make::rag_and_labeled_wsl(ima, c4(), 4u);
+ wst_t& lwsl = res.second();
+ util::graph& g = res.first();
+
// check that adjacency labels map edge labels.
- mln_piter_(wst_t) p(res.second().domain());
+ mln_piter_(wst_t) p(lwsl.domain());
mln_niter_(neighb2d) n(c4(),p);
for_all(p)
- if (res.second()(p) != mln_max(value::label_8))
+ if (lwsl(p) != mln_max(value::label_8).prev())
{
value::label_8 l1 = 0, l2 = 0;
for_all(n)
@@ -77,14 +80,14 @@ int main()
}
if (l2 < l1)
std::swap(l1, l2);
- mln_assertion(res.first().v1(res.second()(p)) == l1);
- mln_assertion(res.first().v2(res.second()(p)) == l2);
+ mln_assertion(g.v1(lwsl(p)) == l1);
+ mln_assertion(g.v2(lwsl(p)) == l2);
}
- mln_assertion(res.first().e_nmax() == 4u);
- mln_assertion(res.first().v_nmax() == 5u);
- mln_assertion(res.first().v_nmax_nbh_edges(0) == 0);
+ mln_assertion(g.e_nmax() == 4u);
+ mln_assertion(g.v_nmax() == 5u);
+ mln_assertion(g.v_nmax_nbh_edges(0) == 0);
for (unsigned i = 1; i < 4; ++i)
- mln_assertion(res.first().v_nmax_nbh_edges(i) == 2);
+ mln_assertion(g.v_nmax_nbh_edges(i) == 2);
}
--
1.5.6.5
1
0
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d14ea6a..71ec83b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * configure.ac: Configure milena/tests/tiff.
+
2009-04-06 Roland Levillain <roland(a)lrde.epita.fr>
* configure.ac: Configure milena/apps/statues/test-mesh-complex-skel.
diff --git a/configure.ac b/configure.ac
index 00a99c0..ad824f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,7 @@ AC_CONFIG_FILES([
milena/tests/io/pgm/Makefile
milena/tests/io/pnm/Makefile
milena/tests/io/ppm/Makefile
+ milena/tests/io/tiff/Makefile
milena/tests/labeling/Makefile
milena/tests/level/Makefile
milena/tests/level/approx/Makefile
--
1.5.6.5
1
0
* tests/make/Makefile.am,
* tests/core/image/vertex_image.cc,
* tests/make/dummy_p_edges.cc,
* tests/make/dummy_p_vertices.cc,
* tests/make/p_edges_with_mass_centers.cc,
* tests/make/p_vertices_with_mass_centers.cc: new test for the newly
added routines.
---
milena/ChangeLog | 12 +
milena/tests/core/image/vertex_image.cc | 231 ++++++++++++++-------
milena/tests/make/Makefile.am | 8 +
milena/tests/make/dummy_p_edges.cc | 75 +++++++
milena/tests/make/dummy_p_vertices.cc | 75 +++++++
milena/tests/make/p_edges_with_mass_centers.cc | 86 ++++++++
milena/tests/make/p_vertices_with_mass_centers.cc | 84 ++++++++
7 files changed, 499 insertions(+), 72 deletions(-)
create mode 100644 milena/tests/make/dummy_p_edges.cc
create mode 100644 milena/tests/make/dummy_p_vertices.cc
create mode 100644 milena/tests/make/p_edges_with_mass_centers.cc
create mode 100644 milena/tests/make/p_vertices_with_mass_centers.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0b743d3..0e13e64 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add new tests.
+
+ * tests/make/Makefile.am,
+ * tests/core/image/vertex_image.cc,
+ * tests/make/dummy_p_edges.cc,
+ * tests/make/dummy_p_vertices.cc,
+ * tests/make/p_edges_with_mass_centers.cc,
+ * tests/make/p_vertices_with_mass_centers.cc: new test for the newly
+ added routines.
+
+2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add small routines to help while constructing graph images.
* mln/make/dummy_p_edges.hh,
diff --git a/milena/tests/core/image/vertex_image.cc b/milena/tests/core/image/vertex_image.cc
index 3531420..8dcd980 100644
--- a/milena/tests/core/image/vertex_image.cc
+++ b/milena/tests/core/image/vertex_image.cc
@@ -32,6 +32,7 @@
#include <vector>
#include <mln/core/image/vertex_image.hh>
+#include <mln/make/vertex_image.hh>
#include <mln/core/image/image2d.hh>
#include <mln/accu/bbox.hh>
@@ -113,113 +114,199 @@ int main()
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- typedef vertex_image<point2d,unsigned> ima_t;
- ima_t ima(g, sites, iota);
+
+
+ /// Vertices are associated to image sites.
{
- // FIXME: Move this part to a special test case.
+ typedef vertex_image<point2d,unsigned> ima_t;
+ ima_t ima = make::vertex_image(g, sites, iota);
+
+ {
+ // FIXME: Move this part to a special test case.
+
+ // Compute the bounding box of 'ima'.
+ accu::bbox<point2d> a;
+ mln_piter_(ima_t) p(ima.domain());
+ for_all(p)
+ a.take(p);
+ box2d bbox = a.to_result();
+ mln_assertion(bbox == make::box2d(5, 5));
+
+ // Print the image.
+ /* FIXME: Unfortunately, displaying graph images is not easy right
+ now(2008-02-05). We could use
+
+ debug::println(ima);
+
+ but there's not specialization working for graph_image; the one
+ selected by the compiler is based on a 2-D bbox, and expects the
+ interface of graph_image to work with points(not psites).
+ Moreover, this implementation only shows *values*, not the graph
+ itslef.
+
+ An alternative is to use debug::graph,
+ but it doesn't show the values, only the vertices and edges of the
+ graph.
+
+ The current solution is a mix between debug::graph and hand-made
+ iterations. */
+ image2d<int> ima_rep(bbox);
+
+ // We use the value 9 in debug::graph to represent edges to distinguish it
+ // from vertices holding a value of 1.
+ debug::draw_graph(ima_rep, ima.domain(), 1, 9);
+ }
- // Compute the bounding box of 'ima'.
- accu::bbox<point2d> a;
+ /*------------.
+ | Iterators. |
+ `------------*/
+
+ // iteration over the domain of IMA.
mln_piter_(ima_t) p(ima.domain());
+ unsigned i = 10;
for_all(p)
- a.take(p);
- box2d bbox = a.to_result();
- mln_assertion(bbox == make::box2d(5, 5));
+ mln_assertion(ima(p) == i++);
- // Print the image.
- /* FIXME: Unfortunately, displaying graph images is not easy right
- now(2008-02-05). We could use
+ typedef ima_t::win_t win_t;
+ win_t win;
- debug::println(ima);
+ {
+ // Window - Forward iteration
+ mln_qiter_(win_t) q(win, p);
+ for_all(p)
+ {
+ i = 0;
+ for_all(q)
+ {
+ mln_assertion(expected_fwd_nb[p.id()][i] == q.id());
+ ++i;
+ }
+ }
+ }
- but there's not specialization working for graph_image; the one
- selected by the compiler is based on a 2-D bbox, and expects the
- interface of graph_image to work with points(not psites).
- Moreover, this implementation only shows *values*, not the graph
- itslef.
+ {
+ // Window - Backward iteration
+ mln_bkd_qiter_(win_t) q(win, p);
+ for_all(p)
+ {
+ i = 0;
+ for_all(q)
+ {
+ mln_assertion(expected_bkd_nb[p.id()][i] == q.id());
+ ++i;
+ }
+ }
+ }
- An alternative is to use debug::graph,
- but it doesn't show the values, only the vertices and edges of the
- graph.
+ typedef ima_t::nbh_t nbh_t;
+ nbh_t neigh;
+ {
+ // Neighborhood - Forward iteration
+ mln_niter_(nbh_t) n(neigh, p);
- The current solution is a mix between debug::graph and hand-made
- iterations. */
- image2d<int> ima_rep(bbox);
+ for_all(p)
+ {
+ i = 0;
+ for_all(n)
+ {
+ mln_assertion(expected_fwd_nb[p.id()][i] == n.id());
+ ++i;
+ }
+ }
+ }
- // We use the value 9 in debug::graph to represent edges to distinguish it
- // from vertices holding a value of 1.
- debug::draw_graph(ima_rep, ima.domain(), 1, 9);
+ {
+ // Neighborhood - Backward iteration
+ mln_bkd_niter_(nbh_t) n(neigh, p);
+ for_all(p)
+ {
+ i = 0;
+ for_all(n)
+ {
+ mln_assertion(expected_bkd_nb[p.id()][i] == n.id());
+ ++i;
+ }
+ }
+ }
}
- /*------------.
- | Iterators. |
- `------------*/
- // iteration over the domain of IMA.
- mln_piter_(ima_t) p(ima.domain());
- unsigned i = 10;
- for_all(p)
- mln_assertion(ima(p) == i++);
- typedef ima_t::win_t win_t;
- win_t win;
+ /// Vertices do not have image site information.
+ /// The associated sites are the vertex themselves.
{
- // Window - Forward iteration
- mln_qiter_(win_t) q(win, p);
+ typedef vertex_image<void,unsigned> ima_void_t;
+ ima_void_t ima_void(g, iota);
+
+ // iteration over the domain of IMA.
+ mln_piter_(ima_void_t) p(ima_void.domain());
+ unsigned i = 10;
for_all(p)
+ mln_assertion(ima_void(p) == i++);
+
+ typedef ima_void_t::win_t win_t;
+ win_t win;
+
{
- i = 0;
- for_all(q)
+ // Window - Forward iteration
+ mln_qiter_(win_t) q(win, p);
+ for_all(p)
{
- mln_assertion(expected_fwd_nb[p.id()][i] == q.id());
- ++i;
+ i = 0;
+ for_all(q)
+ {
+ mln_assertion(expected_fwd_nb[p.id()][i] == q.id());
+ ++i;
+ }
}
}
- }
- {
- // Window - Backward iteration
- mln_bkd_qiter_(win_t) q(win, p);
- for_all(p)
{
- i = 0;
- for_all(q)
+ // Window - Backward iteration
+ mln_bkd_qiter_(win_t) q(win, p);
+ for_all(p)
{
- mln_assertion(expected_bkd_nb[p.id()][i] == q.id());
- ++i;
+ i = 0;
+ for_all(q)
+ {
+ mln_assertion(expected_bkd_nb[p.id()][i] == q.id());
+ ++i;
+ }
}
}
- }
- typedef ima_t::nbh_t nbh_t;
- nbh_t neigh;
- {
- // Neighborhood - Forward iteration
- mln_niter_(nbh_t) n(neigh, p);
-
- for_all(p)
+ typedef ima_void_t::nbh_t nbh_t;
+ nbh_t neigh;
{
- i = 0;
- for_all(n)
+ // Neighborhood - Forward iteration
+ mln_niter_(nbh_t) n(neigh, p);
+
+ for_all(p)
{
- mln_assertion(expected_fwd_nb[p.id()][i] == n.id());
- ++i;
+ i = 0;
+ for_all(n)
+ {
+ //FIXME: Ambiguities with n.id()!!!!
+ mln_assertion(expected_fwd_nb[p.id()][i] == n.element().id());
+ ++i;
+ }
}
}
- }
- {
- // Neighborhood - Backward iteration
- mln_bkd_niter_(nbh_t) n(neigh, p);
- for_all(p)
{
- i = 0;
- for_all(n)
+ // Neighborhood - Backward iteration
+ mln_bkd_niter_(nbh_t) n(neigh, p);
+ for_all(p)
{
- mln_assertion(expected_bkd_nb[p.id()][i] == n.id());
- ++i;
+ i = 0;
+ for_all(n)
+ {
+ //FIXME: Ambiguities with n.id()!!!!
+ mln_assertion(expected_bkd_nb[p.id()][i] == n.element().id());
+ ++i;
+ }
}
}
}
diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am
index 7e4c12b..ba517cd 100644
--- a/milena/tests/make/Makefile.am
+++ b/milena/tests/make/Makefile.am
@@ -4,22 +4,30 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
dual_neighb \
+ dummy_p_edges \
+ dummy_p_vertices \
graph \
h_mat \
image2d \
image3d \
mat \
+ p_edges_with_mass_centers \
+ p_vertices_with_mass_centers \
region_adjacency_graph \
rag_and_labeled_wsl \
w_window \
w_window_directional
dual_neighb_SOURCES = dual_neighb.cc
+dummy_p_edges_SOURCES = dummy_p_edges.cc
+dummy_p_vertices_SOURCES = dummy_p_vertices.cc
graph_SOURCES = graph.cc
h_mat_SOURCES = h_mat.cc
image2d_SOURCES = image2d.cc
image3d_SOURCES = image3d.cc
mat_SOURCES = mat.cc
+p_edges_with_mass_centers_SOURCES = p_edges_with_mass_centers.cc
+p_vertices_with_mass_centers_SOURCES = p_vertices_with_mass_centers.cc
region_adjacency_graph_SOURCES = region_adjacency_graph.cc
rag_and_labeled_wsl_SOURCES = rag_and_labeled_wsl.cc
w_window_SOURCES = w_window.cc
diff --git a/milena/tests/make/dummy_p_edges.cc b/milena/tests/make/dummy_p_edges.cc
new file mode 100644
index 0000000..b04e6d4
--- /dev/null
+++ b/milena/tests/make/dummy_p_edges.cc
@@ -0,0 +1,75 @@
+// 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.
+
+/// \file tests/make/dummy_p_edges.cc
+///
+/// Tests on mln::make::dummy_p_edges.
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/util/graph.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/make/dummy_p_edges.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef util::graph G;
+ G g;
+ g.add_vertices(5);
+ g.add_edge(1,2);
+ g.add_edge(1,3);
+ g.add_edge(4,3);
+ g.add_edge(4,2);
+
+ {
+ typedef p_edges<G, pw::cst_<int> > pe_t;
+ pe_t pe = make::dummy_p_edges(g);
+
+ mln_assertion(pe.nsites() == 4);
+ mln_piter_(pe_t) p(pe);
+ for_all(p)
+ mln_assertion(p == 0);
+ }
+
+ {
+ typedef p_edges<G, pw::cst_<point2d> > pe_t;
+ pe_t pe = make::dummy_p_edges(g, point2d::plus_infty());
+
+ mln_assertion(pe.nsites() == 4);
+ mln_piter_(pe_t) p(pe);
+ for_all(p)
+ mln_assertion(p == point2d::plus_infty());
+ }
+
+}
+
diff --git a/milena/tests/make/dummy_p_vertices.cc b/milena/tests/make/dummy_p_vertices.cc
new file mode 100644
index 0000000..6cfa2b8
--- /dev/null
+++ b/milena/tests/make/dummy_p_vertices.cc
@@ -0,0 +1,75 @@
+// 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.
+
+/// \file tests/make/dummy_p_vertices.cc
+///
+/// Tests on mln::make::dummy_p_vertices.
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/util/graph.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/make/dummy_p_vertices.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef util::graph G;
+ G g;
+ g.add_vertices(5);
+ g.add_edge(1,2);
+ g.add_edge(1,3);
+ g.add_edge(4,3);
+ g.add_edge(4,2);
+
+ {
+ typedef p_vertices<G, pw::cst_<int> > pe_t;
+ pe_t pe = make::dummy_p_vertices(g);
+
+ mln_assertion(pe.nsites() == 4);
+ mln_piter_(pe_t) p(pe);
+ for_all(p)
+ mln_assertion(p == 0);
+ }
+
+ {
+ typedef p_vertices<G, pw::cst_<point2d> > pe_t;
+ pe_t pe = make::dummy_p_vertices(g, point2d::plus_infty());
+
+ mln_assertion(pe.nsites() == 4);
+ mln_piter_(pe_t) p(pe);
+ for_all(p)
+ mln_assertion(p == point2d::plus_infty());
+ }
+
+}
+
diff --git a/milena/tests/make/p_edges_with_mass_centers.cc b/milena/tests/make/p_edges_with_mass_centers.cc
new file mode 100644
index 0000000..967320c
--- /dev/null
+++ b/milena/tests/make/p_edges_with_mass_centers.cc
@@ -0,0 +1,86 @@
+// 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.
+
+/// \file tests/make/p_edges_with_mass_centers.cc
+///
+/// Tests on mln::make::p_edges_with_mass_centers.
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/util/graph.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/make/p_edges_with_mass_centers.hh>
+
+#include <mln/util/site_pair.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef value::label_8 L;
+
+ L data[] = {
+ 1, 1, 1, 0, 2, 2, 2,
+ 1, 1, 1, 0, 2, 2, 2,
+ 1, 1, 1, 0, 2, 2, 2,
+ 0, 0, 0, 0, 0, 0, 0,
+ 3, 3, 3, 0, 4, 4, 4,
+ 3, 3, 3, 0, 4, 4, 4,
+ 3, 3, 3, 0, 4, 4, 4
+ };
+
+ image2d<L> wst = make::image2d(data);
+ typedef util::graph G;
+ G g;
+ g.add_vertices(5);
+ g.add_edge(1,2);
+ g.add_edge(1,3);
+ g.add_edge(4,3);
+ g.add_edge(4,2);
+
+ L nbasins = 4;
+ typedef p_edges<G,fun::i2v::array<util::site_pair<point2d> > > pe_t;
+ pe_t pe = make::p_edges_with_mass_centers(wst, nbasins, g);
+
+ typedef util::site_pair<point2d> P;
+ typedef p_array<P> arr_t;
+ arr_t arr;
+ arr.insert(P(point2d(1,1), point2d(1,5)));
+ arr.insert(P(point2d(1,1), point2d(5,1)));
+ arr.insert(P(point2d(5,1), point2d(5,5)));
+ arr.insert(P(point2d(1,5), point2d(5,5)));
+
+ mln_piter_(pe_t) p1(pe);
+ mln_piter_(arr_t) p2(arr);
+ for_all_2(p1,p2)
+ mln_assertion(p1 == p2);
+}
+
diff --git a/milena/tests/make/p_vertices_with_mass_centers.cc b/milena/tests/make/p_vertices_with_mass_centers.cc
new file mode 100644
index 0000000..2d103df
--- /dev/null
+++ b/milena/tests/make/p_vertices_with_mass_centers.cc
@@ -0,0 +1,84 @@
+// 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.
+
+/// \file tests/make/p_vertices_with_mass_centers.cc
+///
+/// Tests on mln::make::p_vertices_with_mass_centers.
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+
+#include <mln/util/graph.hh>
+
+#include <mln/value/label_8.hh>
+
+#include <mln/make/p_vertices_with_mass_centers.hh>
+
+int main()
+{
+ using namespace mln;
+
+ typedef value::label_8 L;
+
+ L data[] = {
+ 1, 1, 1, 0, 2, 2, 2,
+ 1, 1, 1, 0, 2, 2, 2,
+ 1, 1, 1, 0, 2, 2, 2,
+ 0, 0, 0, 0, 0, 0, 0,
+ 3, 3, 3, 0, 4, 4, 4,
+ 3, 3, 3, 0, 4, 4, 4,
+ 3, 3, 3, 0, 4, 4, 4
+ };
+
+ image2d<L> wst = make::image2d(data);
+ typedef util::graph G;
+ G g;
+ g.add_vertices(5);
+ g.add_edge(1,2);
+ g.add_edge(1,3);
+ g.add_edge(4,3);
+ g.add_edge(4,2);
+
+ L nbasins = 4;
+ typedef p_vertices<G,fun::i2v::array<point2d> > pv_t;
+ pv_t pv = make::p_vertices_with_mass_centers(wst, nbasins, g);
+
+ typedef p_array<point2d> arr_t;
+ arr_t arr;
+ arr.insert(point2d(3,3));
+ arr.insert(point2d(1,1));
+ arr.insert(point2d(1,5));
+ arr.insert(point2d(5,1));
+ arr.insert(point2d(5,5));
+
+ mln_piter_(pv_t) p1(pv);
+ mln_piter_(arr_t) p2(arr);
+ for_all_2(p1,p2)
+ mln_assertion(p1 == p2);
+}
+
--
1.5.6.5
1
0
14 Apr '09
* mln/make/dummy_p_edges.hh,
* mln/make/dummy_p_vertices.hh: create graph site sets without
localization.
* mln/make/all.hh: update includes.
* mln/make/graph.hh: rename as...
* mln/make/influence_zone_adjacency_graph.hh: ...this.
* mln/make/p_edges_with_mass_centers.hh,
* mln/make/p_vertices_with_mass_centers.hh: new routines to construct
common graph site sets.
---
milena/ChangeLog | 17 +++
milena/mln/make/all.hh | 5 +-
milena/mln/make/dummy_p_edges.hh | 107 +++++++++++++++++
milena/mln/make/dummy_p_vertices.hh | 107 +++++++++++++++++
...{graph.hh => influence_zone_adjacency_graph.hh} | 0
milena/mln/make/p_edges_with_mass_centers.hh | 121 ++++++++++++++++++++
milena/mln/make/p_vertices_with_mass_centers.hh | 111 ++++++++++++++++++
7 files changed, 467 insertions(+), 1 deletions(-)
create mode 100644 milena/mln/make/dummy_p_edges.hh
create mode 100644 milena/mln/make/dummy_p_vertices.hh
rename milena/mln/make/{graph.hh => influence_zone_adjacency_graph.hh} (100%)
create mode 100644 milena/mln/make/p_edges_with_mass_centers.hh
create mode 100644 milena/mln/make/p_vertices_with_mass_centers.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7f69bb3..0b743d3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,20 @@
+2009-04-14 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add small routines to help while constructing graph images.
+
+ * mln/make/dummy_p_edges.hh,
+ * mln/make/dummy_p_vertices.hh: create graph site sets without
+ localization.
+
+ * mln/make/all.hh: update includes.
+
+ * mln/make/graph.hh: rename as...
+ * mln/make/influence_zone_adjacency_graph.hh: ...this.
+
+ * mln/make/p_edges_with_mass_centers.hh,
+ * mln/make/p_vertices_with_mass_centers.hh: new routines to construct
+ common graph site sets.
+
2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Make util::array a Function_i2v.
diff --git a/milena/mln/make/all.hh b/milena/mln/make/all.hh
index 9665f14..52571ca 100644
--- a/milena/mln/make/all.hh
+++ b/milena/mln/make/all.hh
@@ -48,7 +48,6 @@ namespace mln
# include <mln/make/box3d.hh>
# include <mln/make/dpoint2d_h.hh>
# include <mln/make/dual_neighb.hh>
-# include <mln/make/graph.hh>
# include <mln/make/image.hh>
# include <mln/make/image2d.hh>
# include <mln/make/image3d.hh>
@@ -68,4 +67,8 @@ namespace mln
# include <mln/make/w_window_directional.hh>
# include <mln/make/win_chamfer.hh>
+# include <mln/make/influence_zone_adjacency_graph.hh>
+# include <mln/make/region_adjacency_graph.hh>
+# include <mln/make/rag_and_labeled_wsl.hh>
+
#endif // ! MLN_MAKE_ALL_HH
diff --git a/milena/mln/make/dummy_p_edges.hh b/milena/mln/make/dummy_p_edges.hh
new file mode 100644
index 0000000..927d0d8
--- /dev/null
+++ b/milena/mln/make/dummy_p_edges.hh
@@ -0,0 +1,107 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_DUMMY_P_EDGES_HH
+# define MLN_MAKE_DUMMY_P_EDGES_HH
+
+/// \file mln/make/dummy_p_edges.hh
+///
+/// Create a p_edges which associate a graph element to a constant site.
+///
+/// \sa edge_image, p_edges
+
+
+# include <mln/core/concept/graph.hh>
+# include <mln/core/site_set/p_edges.hh>
+# include <mln/pw/cst.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+
+ /// Create a p_edges which associate a graph element to a constant site.
+ ///
+ /// \param[in] g_ A graph.
+ /// \param[in] dummy_site The dummy site mapped to graph edges.
+ ///
+ /// \return A p_edges.
+ //
+ template <typename G, typename P>
+ p_edges< G, pw::cst_<P> >
+ dummy_p_edges(const Graph<G>& g_, const P& dummy_site);
+
+
+ /// Create a p_edges which associate a graph element to a constant site.
+ /// \c 0 (int) is used as dummy site.
+ ///
+ /// \param[in] g_ A graph.
+ ///
+ /// \return A p_edges.
+ //
+ template <typename G>
+ p_edges< G, pw::cst_<int> >
+ dummy_p_edges(const Graph<G>& g);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename G, typename P>
+ p_edges<G,pw::cst_<P> >
+ dummy_p_edges(const Graph<G>& g_, const P& dummy_site)
+ {
+ trace::entering("dummy_p_edges");
+
+ const G& g = exact(g_);
+ mln_precondition(g.is_valid());
+
+ p_edges< G, pw::cst_<P> > pe(g, pw::cst(dummy_site));
+
+ trace::exiting("dummy_p_edges");
+ return pe;
+ }
+
+
+ template <typename G>
+ p_edges< G, pw::cst_<int> >
+ dummy_p_edges(const Graph<G>& g)
+ {
+ return dummy_p_edges(g, 0);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+#endif // ! MLN_MAKE_DUMMY_P_EDGES_HH
diff --git a/milena/mln/make/dummy_p_vertices.hh b/milena/mln/make/dummy_p_vertices.hh
new file mode 100644
index 0000000..910d02e
--- /dev/null
+++ b/milena/mln/make/dummy_p_vertices.hh
@@ -0,0 +1,107 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_DUMMY_P_VERTICES_HH
+# define MLN_MAKE_DUMMY_P_VERTICES_HH
+
+/// \file mln/make/dummy_p_vertices.hh
+///
+/// Create a p_vertices which associate a graph element to a constant site.
+///
+/// \sa edge_image, p_vertices
+
+
+# include <mln/core/concept/graph.hh>
+# include <mln/core/site_set/p_vertices.hh>
+# include <mln/pw/cst.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+
+ /// Create a p_vertices which associate a graph element to a constant site.
+ ///
+ /// \param[in] g_ A graph.
+ /// \param[in] dummy_site The dummy site mapped to graph vertices.
+ ///
+ /// \return A p_vertices.
+ //
+ template <typename G, typename P>
+ p_vertices< G, pw::cst_<P> >
+ dummy_p_vertices(const Graph<G>& g_, const P& dummy_site);
+
+
+ /// Create a p_vertices which associate a graph element to a constant site.
+ /// \c 0 (int) is used as dummy site.
+ ///
+ /// \param[in] g_ A graph.
+ ///
+ /// \return A p_vertices.
+ //
+ template <typename G>
+ p_vertices< G, pw::cst_<int> >
+ dummy_p_vertices(const Graph<G>& g);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename G, typename P>
+ p_vertices<G,pw::cst_<P> >
+ dummy_p_vertices(const Graph<G>& g_, const P& dummy_site)
+ {
+ trace::entering("dummy_p_vertices");
+
+ const G& g = exact(g_);
+ mln_precondition(g.is_valid());
+
+ p_vertices< G, pw::cst_<P> > pe(g, pw::cst(dummy_site));
+
+ trace::exiting("dummy_p_vertices");
+ return pe;
+ }
+
+
+ template <typename G>
+ p_vertices< G, pw::cst_<int> >
+ dummy_p_vertices(const Graph<G>& g)
+ {
+ return dummy_p_vertices(g, 0);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+#endif // ! MLN_MAKE_DUMMY_P_VERTICES_HH
diff --git a/milena/mln/make/graph.hh b/milena/mln/make/influence_zone_adjacency_graph.hh
similarity index 100%
rename from milena/mln/make/graph.hh
rename to milena/mln/make/influence_zone_adjacency_graph.hh
diff --git a/milena/mln/make/p_edges_with_mass_centers.hh b/milena/mln/make/p_edges_with_mass_centers.hh
new file mode 100644
index 0000000..06a2376
--- /dev/null
+++ b/milena/mln/make/p_edges_with_mass_centers.hh
@@ -0,0 +1,121 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+# define MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+
+/// \file mln/make/p_edges_with_mass_centers.hh
+///
+/// Construct a p_edges from a watershed image and a region adjacency
+/// graph (RAG). Map each graph edge to a pair of mass centers of two
+/// adjacent regions.
+///
+/// \sa edge_image, p_edges
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/graph.hh>
+# include <mln/core/site_set/p_edges.hh>
+
+# include <mln/labeling/compute.hh>
+
+# include <mln/accu/center.hh>
+
+# include <mln/fun/i2v/array.hh>
+
+# include <mln/util/site_pair.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /// Construct a p_edges from a watershed image and a region adjacency
+ /// graph (RAG). Map each graph edge to a pair of mass centers of two
+ /// adjacent regions.
+ ///
+ /// \param wst_ A watershed image.
+ /// \param nbasins The number of basins.
+ /// \param g_ A region adjacency graph.
+ ///
+ /// \return A p_edges.
+ ///
+ /// \sa edge_image, p_edges, make::region_adjacency_graph
+ //
+ template <typename W, typename G>
+ inline
+ p_edges<G, fun::i2v::array<util::site_pair<mln_site(W)> > >
+ p_edges_with_mass_centers(const Image<W>& wst_,
+ const mln_value(W)& nbasins,
+ const Graph<G>& g_);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename W, typename G>
+ inline
+ p_edges<G, fun::i2v::array<util::site_pair<mln_site(W)> > >
+ p_edges_with_mass_centers(const Image<W>& wst_,
+ const mln_value(W)& nbasins,
+ const Graph<G>& g_)
+ {
+ trace::entering("make::p_edges_with_mass_centers");
+
+ const W& wst = exact(wst_);
+ const G& g = exact(g_);
+ mln_precondition(wst.is_valid());
+ mln_precondition(g.is_valid());
+
+ typedef mln_site(W) P;
+
+ util::array<mln_vec(P)>
+ mass_centers = labeling::compute(accu::center<P>(), wst, nbasins);
+
+ typedef fun::i2v::array< util::site_pair<P> > edge_sites_t;
+ edge_sites_t edge_sites(g.e_nmax());
+
+ mln_edge_iter(G) e(g);
+ for_all(e)
+ edge_sites(e.id()) = util::site_pair<P>(mass_centers[e.v1()],
+ mass_centers[e.v2()]);
+
+ p_edges<G, edge_sites_t> pe(g, edge_sites);
+
+ trace::exiting("make::p_edges_with_mass_centers");
+ return pe;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+#endif // ! MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
diff --git a/milena/mln/make/p_vertices_with_mass_centers.hh b/milena/mln/make/p_vertices_with_mass_centers.hh
new file mode 100644
index 0000000..064cdbc
--- /dev/null
+++ b/milena/mln/make/p_vertices_with_mass_centers.hh
@@ -0,0 +1,111 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+# define MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
+
+/// \file mln/make/p_vertices_with_mass_centers.hh
+///
+/// Create a p_vertices using region mass centers as vertex site.
+///
+/// \sa vertex_image, p_vertices
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/graph.hh>
+# include <mln/core/site_set/p_vertices.hh>
+
+# include <mln/labeling/compute.hh>
+
+# include <mln/accu/center.hh>
+
+# include <mln/fun/i2v/array.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ /// Construct a p_vertices from a watershed image and a region adjacency
+ /// graph (RAG). Map each graph vertex to the mass center of its
+ /// corresponding region.
+ ///
+ /// \param wst_ A watershed image.
+ /// \param nbasins The number of basins.
+ /// \param g_ A region adjacency graph.
+ ///
+ /// \return A p_vertices.
+ ///
+ /// \sa edge_image, vertex_image, p_vertices, p_edges, make::region_adjacency_graph
+ //
+ template <typename W, typename G>
+ inline
+ p_vertices<G, fun::i2v::array<mln_site(W)> >
+ p_vertices_with_mass_centers(const Image<W>& wst_,
+ const mln_value(W)& nbasins,
+ const Graph<G>& g_);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename W, typename G>
+ inline
+ p_vertices<G, fun::i2v::array<mln_site(W)> >
+ p_vertices_with_mass_centers(const Image<W>& wst_,
+ const mln_value(W)& nbasins,
+ const Graph<G>& g_)
+ {
+ trace::entering("make::p_vertices_with_mass_centers");
+
+ const W& wst = exact(wst_);
+ const G& g = exact(g_);
+ mln_precondition(wst.is_valid());
+ mln_precondition(g.is_valid());
+
+ typedef mln_site(W) P;
+ typedef fun::i2v::array<P> vertex_sites_t;
+
+ vertex_sites_t vertex_sites;
+ convert::from_to(labeling::compute(accu::center<P>(), wst, nbasins),
+ vertex_sites);
+
+ p_vertices<G, vertex_sites_t> pv(g, vertex_sites);
+
+ trace::exiting("make::p_vertices_with_mass_centers");
+ return pv;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+#endif // ! MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH
--
1.5.6.5
1
0
* mln/fun/i2v/array.hh: fix doc.
* mln/labeling/mean_values.hh: do not use convert::to anymore.
* mln/util/array.hh: now inherits from Function_i2v.
---
milena/ChangeLog | 10 ++++
milena/mln/fun/i2v/array.hh | 3 +-
milena/mln/labeling/mean_values.hh | 4 +-
milena/mln/util/array.hh | 89 ++++++++++++++++++++++++++++++++++--
4 files changed, 98 insertions(+), 8 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 99e16b5..7f69bb3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Make util::array a Function_i2v.
+
+ * mln/fun/i2v/array.hh: fix doc.
+
+ * mln/labeling/mean_values.hh: do not use convert::to anymore.
+
+ * mln/util/array.hh: now inherits from Function_i2v.
+
+2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Remove l2l::relabel.
* mln/convert/from_to.hxx,
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 4058e48..f8030a9 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -116,9 +116,10 @@ namespace mln
public:
/// Returned value types
- /// \{
+ /// @{
typedef T result;
typedef typename std::vector<T>::reference mutable_result;
+ /// @}
/// Constructors
/// \{
diff --git a/milena/mln/labeling/mean_values.hh b/milena/mln/labeling/mean_values.hh
index 0565abb..3f6b8f1 100644
--- a/milena/mln/labeling/mean_values.hh
+++ b/milena/mln/labeling/mean_values.hh
@@ -119,9 +119,7 @@ namespace mln
convert::from_to(m_3f, m);
m[0] = 150u; //FIXME: handle label 0 correctly.
- mln_concrete(I) output = level::transform(lbl,
- convert::to< fun::i2v::array<IV> >(m));
-
+ mln_concrete(I) output = level::transform(lbl, m);
trace::exiting("mln::labeling::impl::generic::mean_values");
return output;
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index 0363727..5eb5fc4 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -38,6 +38,7 @@
# include <vector>
# include <iostream>
+# include <mln/core/concept/function.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/iterator.hh>
@@ -87,14 +88,23 @@ namespace mln
/// The parameter \c T is the element type, which shall not be
/// const-qualified.
template <typename T>
- class array : public Object< mln::util::array<T> >
+ class array : public Function_i2v< mln::util::array<T> >
{
public:
/// Element associated type.
typedef T element;
+ /// Returned value types.
+ /// Related to the Function_i2v concept.
+ /// @{
+ typedef T result;
+ typedef typename std::vector<T>::reference mutable_result;
+ /// @}
+
+ /// Iterator types
+ /// @{
/// Forward iterator associated type.
typedef array_fwd_iter<T> fwd_eiter;
@@ -103,8 +113,11 @@ namespace mln
/// Iterator associated type.
typedef fwd_eiter eiter;
+ /// @}
+ /// Constructors
+ /// @{
/// Constructor without arguments.
array();
@@ -114,7 +127,7 @@ namespace mln
/// Construct a new array, resize it to \n elements and fill it
/// with \p default_value.
array(unsigned n, const T& value);
-
+ /// @}
/// Reserve memory for \p n elements.
void reserve(unsigned n);
@@ -137,12 +150,25 @@ namespace mln
/// Return the number of elements of the array.
unsigned nelements() const;
+ /// Return the number of elements of the array.
+ /// Added for compatibility with fun::i2v::array.
+ /// \sa nelements
+ unsigned size() const;
+
/// Test if the array is empty.
bool is_empty() const;
/// \brief Return the \p i-th element of the array.
/// \pre i < nelements()
+ const T& operator()(unsigned i) const;
+
+ /// \brief Return the \p i-th element of the array.
+ /// \pre i < nelements()
+ T& operator()(unsigned i);
+
+ /// \brief Return the \p i-th element of the array.
+ /// \pre i < nelements()
const T& operator[](unsigned i) const;
/// \brief Return the \p i-th element of the array.
@@ -165,7 +191,6 @@ namespace mln
std::size_t memory_size() const;
private:
-
std::vector<T> v_;
};
@@ -190,11 +215,14 @@ namespace mln
{
public:
+ /// Constructors
+ /// @{
/// Constructor without argument.
array_fwd_iter();
/// Constructor from an array \p a.
array_fwd_iter(const array<T>& a);
+ /// @}
/// Change the array it iterates on to \p a.
void change_target(const array<T>& a);
@@ -236,12 +264,14 @@ namespace mln
array_bkd_iter<T> >
{
public:
-
+ /// Constructors
+ /// @{
/// Constructor without argument.
array_bkd_iter();
/// Constructor from an array \p a.
array_bkd_iter(const array<T>& a);
+ /// @}
/// Change the array it iterates on to \p a.
void change_target(const array<T>& a);
@@ -282,7 +312,9 @@ namespace mln
struct subject_impl<const util::array<T>&, E>
{
unsigned nelements() const;
+ unsigned size() const;
bool is_empty() const;
+ const T& operator()(unsigned i) const;
const T& operator[](unsigned i) const;
const std::vector<T>& std_vector() const;
@@ -304,6 +336,7 @@ namespace mln
template <typename U>
util::array<T>& append(const util::array<U>& other);
+ T& operator()(unsigned i);
T& operator[](unsigned i);
void clear();
@@ -431,6 +464,14 @@ namespace mln
template <typename T>
inline
unsigned
+ array<T>::size() const
+ {
+ return nelements();
+ }
+
+ template <typename T>
+ inline
+ unsigned
array<T>::nelements() const
{
return v_.size();
@@ -439,6 +480,22 @@ namespace mln
template <typename T>
inline
const T&
+ array<T>::operator()(unsigned i) const
+ {
+ return (*this)[i];
+ }
+
+ template <typename T>
+ inline
+ T&
+ array<T>::operator()(unsigned i)
+ {
+ return (*this)(i);
+ }
+
+ template <typename T>
+ inline
+ const T&
array<T>::operator[](unsigned i) const
{
mln_precondition(i < nelements());
@@ -750,6 +807,14 @@ namespace mln
template <typename T, typename E>
inline
T&
+ subject_impl<util::array<T>&, E>::operator()(unsigned i)
+ {
+ return exact_().get_subject()(i);
+ }
+
+ template <typename T, typename E>
+ inline
+ T&
subject_impl<util::array<T>&, E>::operator[](unsigned i)
{
return exact_().get_subject()[i];
@@ -783,6 +848,14 @@ namespace mln
template <typename T, typename E>
inline
unsigned
+ subject_impl<const util::array<T>&, E>::size() const
+ {
+ return exact_().get_subject().size();
+ }
+
+ template <typename T, typename E>
+ inline
+ unsigned
subject_impl<const util::array<T>&, E>::nelements() const
{
return exact_().get_subject().nelements();
@@ -799,6 +872,14 @@ namespace mln
template <typename T, typename E>
inline
const T&
+ subject_impl<const util::array<T>&, E>::operator()(unsigned i) const
+ {
+ return exact_().get_subject()(i);
+ }
+
+ template <typename T, typename E>
+ inline
+ const T&
subject_impl<const util::array<T>&, E>::operator[](unsigned i) const
{
return exact_().get_subject()[i];
--
1.5.6.5
1
0
* mln/convert/from_to.hxx,
* mln/core/routine/init.hxx: remove forward declarations related to
l2l::relabel.
* mln/fun/i2v/array.hh: do not inherit from array_base anymore.
* mln/fun/l2l/all.hh: do not include relabel.hh anymore.
* mln/labeling/relabel.hh,
* mln/make/relabelfun.hh: use i2v::array instead.
* mln/value/lut_vec.hh: remove a constructor overload for
l2l::relabel.
* mln/fun/internal/array_base.hh,
* mln/fun/l2l/relabel.hh: not used anymore. Removed.
---
milena/ChangeLog | 21 +++
milena/mln/convert/from_to.hxx | 27 +---
milena/mln/core/routine/init.hxx | 9 -
milena/mln/fun/i2v/array.hh | 155 +++++++++++++++----
milena/mln/fun/internal/array_base.hh | 246 ------------------------------
milena/mln/fun/l2l/all.hh | 1 -
milena/mln/fun/l2l/relabel.hh | 269 ---------------------------------
milena/mln/labeling/relabel.hh | 4 +-
milena/mln/make/relabelfun.hh | 14 +-
milena/mln/value/lut_vec.hh | 19 ---
10 files changed, 156 insertions(+), 609 deletions(-)
delete mode 100644 milena/mln/fun/internal/array_base.hh
delete mode 100644 milena/mln/fun/l2l/relabel.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a52c977..99e16b5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,26 @@
2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Remove l2l::relabel.
+
+ * mln/convert/from_to.hxx,
+ * mln/core/routine/init.hxx: remove forward declarations related to
+ l2l::relabel.
+
+ * mln/fun/i2v/array.hh: do not inherit from array_base anymore.
+
+ * mln/fun/l2l/all.hh: do not include relabel.hh anymore.
+
+ * mln/labeling/relabel.hh,
+ * mln/make/relabelfun.hh: use i2v::array instead.
+
+ * mln/value/lut_vec.hh: remove a constructor overload for
+ l2l::relabel.
+
+ * mln/fun/internal/array_base.hh,
+ * mln/fun/l2l/relabel.hh: not used anymore. Removed.
+
+2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add labeling::pack.
* mln/labeling/all.hh: include new header.
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index 38cb062..ded3998 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -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
@@ -76,10 +77,6 @@ namespace mln
namespace i2v {
template <typename T> class array;
}
-
- namespace l2l {
- template <typename T> class relabel;
- }
}
namespace histo {
@@ -373,26 +370,6 @@ namespace mln
- // util::array<T> -> fun::l2l::relabel<T>
- template <typename T>
- void
- from_to_(const util::array<T>& from, fun::l2l::relabel<T>& to);
-
- // util::array<T> -> fun::l2l::relabel<U>
- template <typename T, typename U>
- void
- from_to_(const util::array<T>& from, fun::l2l::relabel<U>& to);
-
- // std::vector<T> -> fun::l2l::relabel<T>
- template <typename T>
- void
- from_to_(const std::vector<T>& from, fun::l2l::relabel<T>& to);
-
- // std::vector<T> -> fun::l2l::relabel<U>
- template <typename T, typename U>
- void
- from_to_(const std::vector<T>& from, fun::l2l::relabel<U>& to);
-
// util::array<T1> -> util::array<T2>
template <typename T1, typename T2>
void
diff --git a/milena/mln/core/routine/init.hxx b/milena/mln/core/routine/init.hxx
index 46b4045..baaa9cd 100644
--- a/milena/mln/core/routine/init.hxx
+++ b/milena/mln/core/routine/init.hxx
@@ -39,7 +39,6 @@ namespace mln
// Forward declarations.
namespace fun { namespace i2v { template <typename T> class array; } }
- namespace fun { namespace l2l { template <typename T> class relabel; } }
namespace pw { namespace internal { template <typename F, typename S, typename E> class image_base; } }
namespace pw { template <typename F, typename S> class image; }
template <typename I, typename F> class image_if;
@@ -85,14 +84,6 @@ namespace mln
fun::i2v::array<T1>& f,
const fun::i2v::array<T2>& model);
- /// Kind: function_t
- /// Type: fun::l2l::relabel<T1>
- /// From: fun::l2l::relabel<T2>
- template <typename T1, typename T2>
- void init_(tag::function_t,
- fun::l2l::relabel<T1>& f,
- const fun::l2l::relabel<T2>& model);
-
} // end of namespace mln
#endif // ! MLN_CORE_ROUTINE_INIT_HXX
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 91fe792..4058e48 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.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
@@ -31,35 +32,23 @@
/// \file mln/fun/i2v/array.hh
///
/// Function mapping an Id i to a value v.
-///
-/// \todo Change design so that there is no multiple inheritance:
-/// array<T> : internal::array_base<T, E==array<T> > : Function_i2v<E>
-///
-/// \todo We should convert (with from_to) arrays that do not hold the
-/// same element type, e.g., int_u8 -> int or vec<3,f> -> rgb8.
# include <vector>
# include <algorithm>
# include <mln/core/concept/function.hh>
-# include <mln/fun/internal/array_base.hh>
# include <mln/util/array.hh>
# include <mln/metal/equal.hh>
+# include <mln/tag/init.hh>
+
namespace mln
{
/// Forward declaration.
- namespace fun
- {
-
- namespace i2v
- {
-
- template <typename T>
- class array;
-
+ namespace fun {
+ namespace i2v {
+ template <typename T> class array;
} // end of namespace mln::fun::i2v
-
} // end of namespace mln::fun
@@ -122,16 +111,14 @@ namespace mln
template <typename T>
- class array : public internal::array_selector_<T,mlc_equal(T,bool)::value>,
- public fun::internal::array_base<T>
+ class array : public internal::array_selector_<T,mlc_equal(T,bool)::value>
{
- typedef fun::internal::array_base<T> super_base_;
-
public:
- /// Mutable result type. The function results can be modified.
- typedef typename super_base_::mutable_result mutable_result;
- typedef typename fun::internal::array_base<T>::result result;
+ /// Returned value types
+ /// \{
+ typedef T result;
+ typedef typename std::vector<T>::reference mutable_result;
/// Constructors
/// \{
@@ -151,6 +138,36 @@ namespace mln
array(const std::vector<T>& from);
/// \}
+
+ /// Pre-allocate space.
+ void reserve(unsigned n);
+
+ /// Set the function size to \p n.
+ void resize(unsigned n);
+ /// Set the function size to \p n and initialize the value with
+ /// \p val.
+ void resize(unsigned n, const T& val);
+
+ /// Append a new value in the function.
+ void append(const T& val);
+
+ /// Return the number of values.
+ unsigned size() const;
+
+ /// Const access to the ith value.
+ result operator()(unsigned i) const;
+ /// Read-Write access to the ith value.
+ mutable_result operator()(unsigned i);
+
+ /// Initialize an empty function.
+ void init_(unsigned n);
+
+ /// Return the underlying std::vector.
+ const std::vector<T>& std_vector() const;
+
+ protected:
+ std::vector<T> v_;
+
};
} // end of namespace mln::fun::i2v
@@ -244,21 +261,21 @@ namespace mln
template <typename T>
inline
array<T>::array(unsigned n)
- : super_base_(n)
+ : v_(n)
{
}
template <typename T>
inline
array<T>::array(unsigned n, const T& val)
- : super_base_(n, val)
+ : v_(n, val)
{
}
template <typename T>
inline
array<T>::array(const util::array<T>& from)
- : super_base_(from)
+ : v_(from.std_vector())
{
}
@@ -266,20 +283,96 @@ namespace mln
template <typename T>
inline
array<T>::array(const std::vector<T>& from)
- : super_base_(from)
+ : v_(from)
{
}
+ template <typename T>
+ inline
+ void
+ array<T>::reserve(unsigned n)
+ {
+ v_.reserve(n);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::resize(unsigned n)
+ {
+ v_.resize(n);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::append(const T& val)
+ {
+ v_.push_back(val);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::resize(unsigned n, const T& val)
+ {
+ v_.resize(n, val);
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ array<T>::size() const
+ {
+ return v_.size();
+ }
+
+ template <typename T>
+ inline
+ typename array<T>::result
+ array<T>::operator()(unsigned i) const
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename T>
+ inline
+ typename array<T>::mutable_result
+ array<T>::operator()(unsigned i)
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::init_(unsigned n)
+ {
+ v_.resize(n);
+ }
+
+ template <typename T>
+ inline
+ const std::vector<T>&
+ array<T>::std_vector() const
+ {
+ return v_;
+ }
+
+
} // end of namespace mln::fun::i2v
} // end of namespace mln::fun
+
template <typename T>
inline
- fun::i2v::array<T> array(T t)
+ fun::i2v::array<T> array(unsigned n, const T& t)
{
- fun::i2v::array<T> tmp(t);
+ fun::i2v::array<T> tmp(n, t);
return tmp;
}
diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh
deleted file mode 100644
index 577b36f..0000000
--- a/milena/mln/fun/internal/array_base.hh
+++ /dev/null
@@ -1,246 +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_FUN_INTERNAL_ARRAY_BASE_HH
-# define MLN_FUN_INTERNAL_ARRAY_BASE_HH
-
-/// \file mln/fun/internal/array_base.hh
-///
-/// Function mapping an Id i to a value v.
-
-# include <vector>
-# include <algorithm>
-# include <mln/util/array.hh>
-# include <mln/tag/init.hh>
-
-
-namespace mln
-{
-
- namespace fun
- {
-
- namespace internal
- {
-
- template <typename T>
- class array_base
- {
- public:
-
- /// Returned value types
- /// \{
- typedef T result;
- typedef typename std::vector<T>::reference mutable_result;
-
- /// Pre-allocate space.
- void reserve(unsigned n);
-
- /// Set the function size to \p n.
- void resize(unsigned n);
- /// Set the function size to \p n and initialize the value with
- /// \p val.
- void resize(unsigned n, const T& val);
-
- /// Append a new value in the function.
- void append(const T& val);
-
- /// Return the number of values.
- unsigned size() const;
-
- /// Const access to the ith value.
- result operator()(unsigned i) const;
- /// Read-Write access to the ith value.
- mutable_result operator()(unsigned i);
-
- /// Initialize an empty function.
- void init_(unsigned n);
-
- /// Return the underlying std::vector.
- const std::vector<T>& std_vector() const;
-
- protected:
- std::vector<T> v_;
-
- /// Constructors
- /// \{
-
- /// Default.
- array_base();
- /// Constructs an array with \p nvalues.
- array_base(unsigned n);
-
- /// Constructs an array with \p nvalues and \p val as value.
- array_base(unsigned n, const T& val);
-
- /// Used in from_to(). Constructs that object from an util::array.
- /// Always prefer using from_to instead of this constructor.
- array_base(const util::array<T>& from);
- /// Used in from_to(). Constructs that object from an std::vector.
- /// Always prefer using from_to instead of this constructor.
- array_base(const std::vector<T>& from);
-
- /// \}
-
- };
-
- } // end of namespace mln::fun::internal
-
- } // end of namespace mln::fun
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- /// fun::internal::array_base
-
- namespace fun
- {
-
- namespace internal
- {
-
- template <typename T>
- inline
- array_base<T>::array_base()
- {
- }
-
- template <typename T>
- inline
- array_base<T>::array_base(unsigned n)
- : v_(n)
- {
- }
-
- template <typename T>
- inline
- array_base<T>::array_base(unsigned n, const T& val)
- : v_(n, val)
- {
- }
-
- template <typename T>
- inline
- array_base<T>::array_base(const util::array<T>& from)
- : v_(from.std_vector())
- {
-
- }
-
- template <typename T>
- inline
- array_base<T>::array_base(const std::vector<T>& from)
- : v_(from)
- {
-
- }
-
- template <typename T>
- inline
- void
- array_base<T>::reserve(unsigned n)
- {
- v_.reserve(n);
- }
-
- template <typename T>
- inline
- void
- array_base<T>::resize(unsigned n)
- {
- v_.resize(n);
- }
-
- template <typename T>
- inline
- void
- array_base<T>::append(const T& val)
- {
- v_.push_back(val);
- }
-
- template <typename T>
- inline
- void
- array_base<T>::resize(unsigned n, const T& val)
- {
- v_.resize(n, val);
- }
-
- template <typename T>
- inline
- unsigned
- array_base<T>::size() const
- {
- return v_.size();
- }
-
- template <typename T>
- inline
- typename array_base<T>::result
- array_base<T>::operator()(unsigned i) const
- {
- mln_precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename T>
- inline
- typename array_base<T>::mutable_result
- array_base<T>::operator()(unsigned i)
- {
- mln_precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename T>
- inline
- void
- array_base<T>::init_(unsigned n)
- {
- v_.resize(n);
- }
-
- template <typename T>
- inline
- const std::vector<T>&
- array_base<T>::std_vector() const
- {
- return v_;
- }
-
- } // end of namespace mln::fun::internal
-
- } // end of namespace mln::fun
-
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of namespace mln
-
-
-#endif // ! MLN_FUN_INTERNAL_ARRAY_BASE_HH
diff --git a/milena/mln/fun/l2l/all.hh b/milena/mln/fun/l2l/all.hh
index a3eccee..c6d2328 100644
--- a/milena/mln/fun/l2l/all.hh
+++ b/milena/mln/fun/l2l/all.hh
@@ -49,7 +49,6 @@ namespace mln
}
-# include <mln/fun/l2l/relabel.hh>
# include <mln/fun/l2l/wrap.hh>
diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh
deleted file mode 100644
index ef03973..0000000
--- a/milena/mln/fun/l2l/relabel.hh
+++ /dev/null
@@ -1,269 +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_FUN_L2L_RELABEL_HH
-# define MLN_FUN_L2L_RELABEL_HH
-
-/// \file mln/fun/l2l/relabel.hh
-///
-/// Function mapping a label to a new one.
-/// \sa mln::labeling::relabel
-
-# include <vector>
-# include <algorithm>
-# include <mln/core/concept/function.hh>
-# include <mln/fun/internal/array_base.hh>
-# include <mln/util/array.hh>
-# include <mln/metal/converts_to.hh>
-
-
-namespace mln
-{
-
- /// Forward declaration.
- namespace fun
- {
-
- namespace l2l
- {
-
- template <typename L>
- class relabel;
-
- } // end of namespace mln::fun::l2l
-
- } // end of namespace mln::fun
-
-
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename L>
- inline
- void
- from_to_(const util::array<L>& from,
- fun::l2l::relabel<L>& to);
-
- template <typename T, typename L>
- inline
- void
- from_to_(const util::array<T>& from,
- fun::l2l::relabel<L>& to);
-
- template <typename L>
- inline
- void
- from_to_(const std::vector<L>& from,
- fun::l2l::relabel<L>& to);
-
- template <typename T, typename L>
- inline
- void
- from_to_(const std::vector<T>& from,
- fun::l2l::relabel<L>& to);
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
- namespace fun
- {
-
- namespace l2l
- {
-
- template <typename L>
- class relabel : public Function_l2l< relabel<L> >,
- public internal::array_base<L>
- {
- typedef internal::array_base<L> super_base_;
-
- public:
-
- /// Mutable result type. The function results can be modified.
- typedef typename super_base_::mutable_result mutable_result;
-
- /// Constructors
- /// \{
-
- /// Default.
- relabel();
- /// Constructs a function with \p nvalues.
- relabel(unsigned n);
- /// Constructs a function with \p nvalues and \p label as default label.
- relabel(unsigned n, const L& label);
-
- /// Used in from_to(). Constructs that function from an util::array.
- /// Always prefer using from_to instead of this constructor.
- relabel(const util::array<L>& from);
- /// Used in from_to(). Constructs that function from an std::vector.
- /// Always prefer using from_to instead of this constructor.
- relabel(const std::vector<L>& from);
- /// \}
-
- };
-
- } // end of namespace mln::fun::l2l
-
- } // end of namespace mln::fun
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- // Init.
-
- template <typename T1, typename T2>
- void init_(tag::function_t,
- fun::l2l::relabel<T1>& f,
- const fun::l2l::relabel<T2>& model)
- {
- f.init_(model.size());
- }
-
-
- // convert::from_to
-
- namespace convert
- {
-
- namespace over_load
- {
-
- template <typename L>
- inline
- void
- from_to_(const util::array<L>& from, fun::l2l::relabel<L>& to)
- {
- to = fun::l2l::relabel<L>(from);
- }
-
- template <typename T, typename L>
- inline
- void
- from_to_(const util::array<T>& from, fun::l2l::relabel<L>& to)
- {
- mlc_converts_to(T,L)::check();
-
- to.reserve(from.nelements());
- for (unsigned i = 0; i < from.nelements(); ++i)
- to.append(convert::to<L>(from[i]));
- }
-
- template <typename L>
- inline
- void
- from_to_(const std::vector<L>& from, fun::l2l::relabel<L>& to)
- {
- to = fun::l2l::relabel<L>(from);
- }
-
- template <typename T, typename L>
- inline
- void
- from_to_(const std::vector<T>& from, fun::l2l::relabel<L>& to)
- {
- mlc_converts_to(T,L)::check();
-
- to.reserve(from.size());
- for (unsigned i = 0; i < from.size(); ++i)
- to.append(convert::to<L>(from[i]));
- }
-
- } // end of namespace mln::convert::over_load
-
- } // end of namespace mln::convert
-
-
-
- /// fun::l2l::relabel
-
- namespace fun
- {
-
- namespace l2l
- {
-
- template <typename L>
- inline
- relabel<L>::relabel()
- {
- // FIXME: Too restrictive?
- mlc_converts_to(L, unsigned)::check();
- }
-
- template <typename L>
- inline
- relabel<L>::relabel(unsigned n)
- : super_base_(n)
- {
- // FIXME: Too restrictive?
- mlc_converts_to(L, unsigned)::check();
- }
-
- template <typename L>
- inline
- relabel<L>::relabel(unsigned n, const L& label)
- : super_base_(n, label)
- {
- // FIXME: Too restrictive?
- mlc_converts_to(L, unsigned)::check();
- }
-
- template <typename L>
- inline
- relabel<L>::relabel(const util::array<L>& from)
- : super_base_(from)
- {
- // FIXME: Too restrictive?
- mlc_converts_to(L, unsigned)::check();
- }
-
- template <typename L>
- inline
- relabel<L>::relabel(const std::vector<L>& from)
- : super_base_(from)
- {
- // FIXME: Too restrictive?
- mlc_converts_to(L, unsigned)::check();
- }
-
- } // end of namespace mln::fun::l2l
-
- } // end of namespace mln::fun
-
-# endif // ! MLN_INCLUDE_ONLY
-
-} // end of namespace mln
-
-
-#endif // ! MLN_FUN_L2L_RELABEL_HH
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index e811db1..a775bfa 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -208,7 +208,7 @@ namespace mln
internal::relabel_tests(label, nlabels, new_nlabels, fv2b);
- typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+ typedef fun::i2v::array<mln_value(I)> fv2v_t;
fv2v_t fv2v = make::relabelfun(fv2b, nlabels, new_nlabels);
mln_concrete(I) output = labeling::relabel(label, new_nlabels, fv2v);
@@ -246,7 +246,7 @@ namespace mln
internal::relabel_inplace_tests(label, nlabels, fv2b);
- typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+ typedef fun::i2v::array<mln_value(I)> fv2v_t;
fv2v_t fv2v = make::relabelfun(fv2b, nlabels, nlabels);
labeling::relabel_inplace(label, nlabels, fv2v);
diff --git a/milena/mln/make/relabelfun.hh b/milena/mln/make/relabelfun.hh
index 612e3a6..0e0ff3e 100644
--- a/milena/mln/make/relabelfun.hh
+++ b/milena/mln/make/relabelfun.hh
@@ -33,7 +33,7 @@
/// Routines to construct a function in order to relabel a labeled image.
# include <mln/core/concept/function.hh>
-# include <mln/fun/l2l/relabel.hh>
+# include <mln/fun/i2v/array.hh>
# include <mln/value/label.hh>
namespace mln
@@ -51,7 +51,7 @@ namespace mln
///
/// \sa mln::labeling::relabel
template <unsigned n, typename F>
- fun::l2l::relabel< value::label<n> >
+ fun::i2v::array< value::label<n> >
relabelfun(const Function_v2b<F>& fv2b,
const value::label<n>& nlabels,
value::label<n>& new_nlabels);
@@ -65,7 +65,7 @@ namespace mln
///
/// \sa mln::labeling::relabel
template <unsigned n, typename F>
- fun::l2l::relabel< value::label<n> >
+ fun::i2v::array< value::label<n> >
relabelfun(const Function_v2v<F>& fv2v,
const value::label<n>& nlabels,
value::label<n>& new_nlabels);
@@ -75,7 +75,7 @@ namespace mln
template <unsigned n, typename F>
inline
- fun::l2l::relabel< value::label<n> >
+ fun::i2v::array< value::label<n> >
relabelfun(const Function_v2b<F>& fv2b_,
const value::label<n>& nlabels,
value::label<n>& new_nlabels)
@@ -86,7 +86,7 @@ namespace mln
value::label<n> tmp_nlabels = literal::zero;
typedef value::label<n> label_t;
- fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
+ fun::i2v::array<label_t> fl2l(nlabels.next(), literal::zero);
for (label_t i = 1; i <= nlabels; ++i)
if (fv2b(i))
{
@@ -100,7 +100,7 @@ namespace mln
template <unsigned n, typename F>
inline
- fun::l2l::relabel< value::label<n> >
+ fun::i2v::array< value::label<n> >
relabelfun(const Function_v2v<F>& fv2v_,
const value::label<n>& nlabels,
value::label<n>& new_nlabels)
@@ -111,7 +111,7 @@ namespace mln
value::label<n> tmp_nlabels = literal::zero;
typedef value::label<n> label_t;
- fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
+ fun::i2v::array<label_t> fl2l(nlabels.next(), literal::zero);
for (label_t i = 1; i < nlabels.next(); ++i)
if (fl2l(fv2v(i)) == literal::zero)
{
diff --git a/milena/mln/value/lut_vec.hh b/milena/mln/value/lut_vec.hh
index 6aa2e32..8c817a2 100644
--- a/milena/mln/value/lut_vec.hh
+++ b/milena/mln/value/lut_vec.hh
@@ -50,9 +50,6 @@ namespace mln
namespace i2v {
template <typename T> class array;
} // end of namespace mln::fun::i2v
- namespace l2l {
- template <typename L> class relabel;
- } // end of namespace mln::fun::l2l
} // end of namespace mln::fun
namespace value
@@ -104,10 +101,6 @@ namespace mln
template <typename V>
lut_vec(const S& vset, const Function_v2v< fun::i2v::array<V> >& f);
- /// Ctor. FIXME!
- template <typename V>
- lut_vec(const S& vset, const Function_v2v< fun::l2l::relabel<V> >& f);
-
protected:
const S& vset_;
@@ -166,17 +159,6 @@ namespace mln
}
template <typename S, typename T>
- template <typename V>
- inline
- lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v< fun::l2l::relabel<V> >& f)
- : vset_(vset)
- {
- const fun::l2l::relabel<V>& f_ = exact(f);
- n_ = f_.size();
- vec_ = f_.std_vector();
- }
-
- template <typename S, typename T>
inline
T
lut_vec<S,T>::operator()(const mln_value(S)& val) const
@@ -202,7 +184,6 @@ namespace mln
return vec_.size();
}
-
template <typename S, typename T>
inline
std::ostream&
--
1.5.6.5
1
0
* mln/labeling/all.hh: include new header.
* mln/labeling/relabel.hh: move an overload...
* mln/labeling/pack.hh: ... in this new routine.
* tests/labeling/Makefile.am,
* tests/labeling/pack.cc: add a new test.
---
milena/ChangeLog | 14 ++-
milena/mln/labeling/all.hh | 1 +
milena/mln/labeling/pack.hh | 151 ++++++++++++++++++++
milena/mln/labeling/relabel.hh | 78 ++---------
milena/tests/labeling/Makefile.am | 2 +
.../labeling/all.hh => tests/labeling/pack.cc} | 68 +++++-----
6 files changed, 214 insertions(+), 100 deletions(-)
create mode 100644 milena/mln/labeling/pack.hh
copy milena/{mln/labeling/all.hh => tests/labeling/pack.cc} (56%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 76e2c32..a52c977 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,16 @@
-2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add labeling::pack.
+
+ * mln/labeling/all.hh: include new header.
+
+ * mln/labeling/relabel.hh: move an overload...
+ * mln/labeling/pack.hh: ... in this new routine.
+
+ * tests/labeling/Makefile.am,
+ * tests/labeling/pack.cc: add a new test.
+
+2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes.
diff --git a/milena/mln/labeling/all.hh b/milena/mln/labeling/all.hh
index 798ee02..2931427 100644
--- a/milena/mln/labeling/all.hh
+++ b/milena/mln/labeling/all.hh
@@ -61,6 +61,7 @@ namespace mln
# include <mln/labeling/foreground.hh>
# include <mln/labeling/level.hh>
# include <mln/labeling/n_max.hh>
+# include <mln/labeling/pack.hh>
# include <mln/labeling/regional_maxima.hh>
# include <mln/labeling/regional_minima.hh>
diff --git a/milena/mln/labeling/pack.hh b/milena/mln/labeling/pack.hh
new file mode 100644
index 0000000..45a08e3
--- /dev/null
+++ b/milena/mln/labeling/pack.hh
@@ -0,0 +1,151 @@
+// 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_LABELING_PACK_HH
+# define MLN_LABELING_PACK_HH
+
+/// \file mln/labeling/pack.hh
+///
+/// Remove components and relabel a labeled image in order to have a
+/// contiguous labeling.
+
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/make/relabelfun.hh>
+
+# include <mln/level/compute.hh>
+# include <mln/level/transform.hh>
+
+# include <mln/accu/label_used.hh>
+
+
+
+namespace mln
+{
+
+ namespace labeling
+ {
+
+ /// Relabel a labeled image in order to have a contiguous labeling.
+ /// \input[in] label The labeled image.
+ /// \input[out] new_nlabels The number of labels after relabeling.
+ ///
+ /// \return The relabeled image.
+ //
+ template <typename I>
+ mln_concrete(I)
+ pack(const Image<I>& label, mln_value(I)& new_nlabels);
+
+
+
+ /// Relabel inplace a labeled image in order to have a contiguous
+ /// labeling.
+ /// \input[in] label The labeled image.
+ /// \input[out] new_nlabels The number of labels after relabeling.
+ //
+ template <typename I>
+ void
+ relabel_inplace(Image<I>& label, mln_value(I)& new_nlabels);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace internal
+ {
+
+ template <typename I>
+ void
+ pack_tests(const Image<I>& label, mln_value(I)& new_nlabels)
+ {
+ // FIXME: we may want to check that it is exactly a label.
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_precondition(exact(label).is_valid());
+ (void) label;
+ (void) new_nlabels;
+ }
+
+ } // end of mln::labeling::internal
+
+
+
+ template <typename I>
+ mln_concrete(I)
+ pack(const Image<I>& label, mln_value(I)& new_nlabels)
+ {
+ trace::entering("labeling::pack");
+
+ internal::pack_tests(label, new_nlabels);
+
+ fun::i2v::array<bool>
+ fv2b = level::compute(accu::meta::label_used(), label);
+
+ mln_value(I) tmp_nlabels = fv2b.size() - 1;
+ mln_concrete(I)
+ output = level::transform(label,
+ make::relabelfun(fv2b,
+ tmp_nlabels,
+ new_nlabels));
+
+ trace::exiting("labeling::pack");
+ return output;
+ }
+
+
+
+ template <typename I>
+ void
+ pack_inplace(Image<I>& label, mln_value(I)& new_nlabels)
+ {
+ trace::entering("labeling::pack_inplace");
+
+ internal::pack_tests(label, new_nlabels);
+
+ fun::i2v::array<bool>
+ fv2b = level::compute(accu::meta::label_used(), label);
+
+ mln_value(I) tmp_nlabels = fv2b.size() - 1;
+ exact(label) = level::transform(label,
+ make::relabelfun(fv2b,
+ tmp_nlabels,
+ new_nlabels));
+
+ trace::exiting("labeling::pack_inplace");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::labeling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LABELING_PACK_HH
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index c24c0dd..e811db1 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -33,28 +33,23 @@
///
/// Remove components and relabel a labeled image.
+
# include <mln/core/concept/image.hh>
+
# include <mln/make/relabelfun.hh>
-# include <mln/level/compute.hh>
+
# include <mln/level/transform.hh>
# include <mln/level/transform_inplace.hh>
+
# include <mln/value/label.hh>
-# include <mln/accu/label_used.hh>
+
+
namespace mln
{
namespace labeling
{
- /// Relabel a labeled image in order to have a contiguous labeling.
- /// \input[in] label The labeled image.
- /// \input[out] new_nlabels The number of labels after relabeling.
- ///
- /// \return The relabeled image.
- template <typename I>
- mln_concrete(I)
- relabel(const Image<I>& label,
- mln_value(I)& new_nlabels);
/// Remove components and relabel a labeled image.
/// \input[in] label the labeled image.
@@ -64,6 +59,7 @@ namespace mln
/// by the background.
///
/// \return the relabeled image.
+ //
template <typename I, typename F>
mln_concrete(I)
relabel(const Image<I>& label,
@@ -71,6 +67,7 @@ namespace mln
mln_value(I)& new_nlabels,
const Function_v2b<F>& fv2b);
+
/// Remove components and relabel a labeled image.
/// \input[in] label the labeled image.
/// \input[in] nlabels the number of labels in \p label.
@@ -78,39 +75,33 @@ namespace mln
/// value.
///
/// \return the relabeled image.
+ //
template <typename I, typename F>
mln_concrete(I)
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
const Function_v2v<F>& fv2v);
- /// Relabel inplace a labeled image in order to have a contiguous
- /// labeling.
- /// \input[in] label The labeled image.
- /// \input[out] new_nlabels The number of labels after relabeling.
- template <typename I>
- void
- relabel_inplace(Image<I>& label,
- mln_value(I)& new_nlabels);
/// Remove components and relabel a labeled image inplace.
/// \input[in, out] label the labeled image.
/// \input[in, out] nlabels the number of labels in \p label.
/// \input[in] f function returning whether a label must be replaced
/// by the background.
- ///
+ //
template <typename I, typename F>
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
const Function_v2b<F>& fv2b);
+
/// Remove components and relabel a labeled image inplace.
/// \input[in, out] label the labeled image.
/// \input[in, out] nlabels the number of labels in \p label.
/// \input[in] f function returning the new component id for each
/// pixel value.
- ///
+ //
template <typename I, typename F>
void
relabel_inplace(Image<I>& label,
@@ -185,29 +176,6 @@ namespace mln
} // end of namespace mln::labeling::internal
- template <typename I>
- mln_concrete(I)
- relabel(const Image<I>& label,
- mln_value(I)& new_nlabels)
- {
- trace::entering("labeling::relabel");
-
- internal::relabel_tests(label, new_nlabels);
-
- fun::i2v::array<bool>
- fv2b = level::compute(accu::meta::label_used(), label);
-
- mln_value(I) tmp_nlabels = fv2b.size() - 1;
- mln_concrete(I)
- output = level::transform(label,
- make::relabelfun(fv2b,
- tmp_nlabels,
- new_nlabels));
-
- trace::exiting("labeling::relabel");
- return output;
- }
-
template <typename I, typename F>
inline
@@ -249,28 +217,6 @@ namespace mln
}
- template <typename I>
- void
- relabel_inplace(Image<I>& label,
- mln_value(I)& new_nlabels)
- {
- trace::entering("labeling::relabel_inplace");
-
- internal::relabel_tests(label, new_nlabels);
-
- fun::i2v::array<bool>
- fv2b = level::compute(accu::meta::label_used(), label);
-
- mln_value(I) tmp_nlabels = fv2b.size() - 1;
- exact(label) = level::transform(label,
- make::relabelfun(fv2b,
- tmp_nlabels,
- new_nlabels));
-
- trace::exiting("labeling::relabel_inplace");
- }
-
-
template <typename I, typename F>
inline
void
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index f436f63..411674e 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -12,6 +12,7 @@ check_PROGRAMS = \
level \
mean_values \
n_max \
+ pack \
regional_maxima \
regional_minima \
relabel \
@@ -26,6 +27,7 @@ foreground_SOURCES = foreground.cc
level_SOURCES = level.cc
mean_values_SOURCES = mean_values.cc
n_max_SOURCES = n_max.cc
+pack_SOURCES = pack.cc
regional_maxima_SOURCES = regional_maxima.cc
regional_minima_SOURCES = regional_minima.cc
relabel_SOURCES = relabel.cc
diff --git a/milena/mln/labeling/all.hh b/milena/tests/labeling/pack.cc
similarity index 56%
copy from milena/mln/labeling/all.hh
copy to milena/tests/labeling/pack.cc
index 798ee02..b839d64 100644
--- a/milena/mln/labeling/all.hh
+++ b/milena/tests/labeling/pack.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
+// 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
@@ -26,43 +26,45 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_LABELING_ALL_HH
-# define MLN_LABELING_ALL_HH
-
-/// \file mln/labeling/all.hh
-///
-/// File that includes all labeling routines.
+/// \file tests/labeling/pack.cc
///
-/// \todo Many files in this directory have to be updated with the
-/// test and dispatch mechanisms.
+/// Tests on mln::labeling::pack.
-namespace mln
-{
+#include <mln/core/image/image2d.hh>
+#include <mln/labeling/pack.hh>
+#include <mln/level/compare.hh>
+#include <mln/value/label_16.hh>
+#include <mln/debug/println.hh>
- /// Namespace of labeling routines.
- namespace labeling
- {
- /// Implementation namespace of labeling namespace.
- namespace impl {
+int main()
+{
+ using namespace mln;
+ using value::label_16;
- /// Generic implementation namespace of labeling namespace.
- namespace generic {}
+ label_16 vals2[6][5] = {
+ { 0, 10, 10, 0, 0},
+ { 0, 10, 10, 4, 0},
+ { 0, 0, 0, 0, 0},
+ {12, 12, 0, 3, 0},
+ {12, 50, 3, 3, 3},
+ {12, 50, 50, 0, 0}
+ };
- }
- }
-}
+ label_16 vals_ref[6][5] = {
+ { 0, 3, 3, 0, 0},
+ { 0, 3, 3, 2, 0},
+ { 0, 0, 0, 0, 0},
+ { 4, 4, 0, 1, 0},
+ { 4, 5, 1, 1, 1},
+ { 4, 5, 5, 0, 0}
+ };
-# include <mln/labeling/background.hh>
-# include <mln/labeling/blobs.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/labeling/fill_holes.hh>
-# include <mln/labeling/flat_zones.hh>
-# include <mln/labeling/foreground.hh>
-# include <mln/labeling/level.hh>
-# include <mln/labeling/n_max.hh>
-# include <mln/labeling/regional_maxima.hh>
-# include <mln/labeling/regional_minima.hh>
+ image2d<label_16> lbl2 = make::image(vals2);
+ image2d<label_16> lbl_ref = make::image(vals_ref);
+ label_16 nlabels;
+ image2d<label_16> relbl = labeling::pack(lbl2, nlabels);
-#endif // ! MLN_LABELING_ALL_HH
+ mln_assertion(lbl_ref == relbl);
+}
--
1.5.6.5
1
0
* Makefile.am,
* tests/img/test_bw.tif,
* tests/img/test_gl.tif,
* tests/img/test_rgb8.tif: add new test images.
* headers.mk: update list of distributed files.
* mln/value/rgb.hh,
* mln/convert/from_to.hxx: add from_to overload from rgb8 to bool.
* mln/io/magick/load.hh: update doc.
* mln/io/tiff/load.hh: Fix loading of rgb files.
* tests/data.hh.in: add a new macro for test images directory.
* tests/io/Makefile.am,
* tests/io/tiff/Makefile.am,
* tests/io/tiff/load.cc: new test for io::tiff::load.
* tests/unit_test/unit-tests.mk: update unit test list.
---
milena/ChangeLog | 26 +++++++
milena/Makefile.am | 5 +
milena/headers.mk | 29 +++++++-
milena/mln/convert/from_to.hxx | 4 +
milena/mln/io/magick/load.hh | 2 +-
milena/mln/io/tiff/load.hh | 129 +++++++++++++++++++-------------
milena/mln/value/rgb.hh | 11 +++
milena/tests/data.hh.in | 10 ++-
milena/tests/img/test_bw.tif | Bin 0 -> 332 bytes
milena/tests/img/test_gl.tif | Bin 0 -> 352 bytes
milena/tests/img/test_rgb8.tif | Bin 0 -> 416 bytes
milena/tests/io/Makefile.am | 3 +-
milena/tests/io/{ => tiff}/Makefile.am | 17 ++--
milena/tests/io/tiff/load.cc | 97 ++++++++++++++++++++++++
milena/tests/unit_test/unit-tests.mk | 58 +++++++++++++-
15 files changed, 318 insertions(+), 73 deletions(-)
create mode 100644 milena/tests/img/test_bw.tif
create mode 100644 milena/tests/img/test_gl.tif
create mode 100644 milena/tests/img/test_rgb8.tif
copy milena/tests/io/{ => tiff}/Makefile.am (51%)
create mode 100644 milena/tests/io/tiff/load.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7e6190d..76e2c32 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Small fixes.
+
+ * Makefile.am,
+ * tests/img/test_bw.tif,
+ * tests/img/test_gl.tif,
+ * tests/img/test_rgb8.tif: add new test images.
+
+ * headers.mk: update list of distributed files.
+
+ * mln/value/rgb.hh,
+ * mln/convert/from_to.hxx: add from_to overload from rgb8 to bool.
+
+ * mln/io/magick/load.hh: update doc.
+
+ * mln/io/tiff/load.hh: Fix loading of rgb files.
+
+ * tests/data.hh.in: add a new macro for test images directory.
+
+ * tests/io/Makefile.am,
+ * tests/io/tiff/Makefile.am,
+ * tests/io/tiff/load.cc: new test for io::tiff::load.
+
+ * tests/unit_test/unit-tests.mk: update unit test list.
+
+2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Remove an invalid conversion operator from a morpher to a concrete
image.
diff --git a/milena/Makefile.am b/milena/Makefile.am
index a2b83c6..ffb87cc 100644
--- a/milena/Makefile.am
+++ b/milena/Makefile.am
@@ -55,6 +55,11 @@ img/tiny.ppm \
img/toto.pbm
EXTRA_DIST += \
+tests/img/test_rgb8.tif \
+tests/img/test_bw.tif \
+tests/img/test_gl.tif
+
+EXTRA_DIST += \
generate_dist_headers.sh\
tools \
tools/area_flooding.cc \
diff --git a/milena/headers.mk b/milena/headers.mk
index fd5844c..590621d 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -38,6 +38,7 @@ mln/draw/plot.hh \
mln/draw/line.hh \
mln/draw/essential.hh \
mln/pw/image.hh \
+mln/pw/internal/image_base.hh \
mln/pw/all.hh \
mln/pw/value.hh \
mln/pw/cst.hh \
@@ -139,10 +140,12 @@ mln/make/double_neighb2d.hh \
mln/make/image3d.hh \
mln/make/dpoint2d_h.hh \
mln/make/w_window.hh \
+mln/make/cell.hh \
mln/make/image.hh \
mln/make/vec.hh \
mln/make/all.hh \
mln/make/dual_neighb.hh \
+mln/make/attachment.hh \
mln/make/w_window3d.hh \
mln/make/mat.hh \
mln/make/win_chamfer.hh \
@@ -153,6 +156,7 @@ mln/make/box2d.hh \
mln/make/h_mat.hh \
mln/make/w_window2d.hh \
mln/make/box3d.hh \
+mln/make/detachment.hh \
mln/make/region_adjacency_graph.hh \
mln/make/relabelfun.hh \
mln/make/pixel.hh \
@@ -161,6 +165,7 @@ mln/make/box2d_h.hh \
mln/make/w_window1d.hh \
mln/make/image2d.hh \
mln/make/w_window_directional.hh \
+mln/make/rag_and_labeled_wsl.hh \
mln/make/w_window3d_int.hh \
mln/make/essential.hh \
mln/make/w_window1d_int.hh \
@@ -183,8 +188,10 @@ mln/extension/adjust_fill.hh \
mln/extension/fill.hh \
mln/extension/essential.hh \
mln/fun/p2b/chess.hh \
+mln/fun/p2b/tautology.hh \
mln/fun/p2b/all.hh \
mln/fun/p2b/has.hh \
+mln/fun/p2b/antilogy.hh \
mln/fun/p2b/big_chess.hh \
mln/fun/p2b/essential.hh \
mln/fun/p2p/all.hh \
@@ -378,6 +385,7 @@ mln/accu/min_h.hh \
mln/accu/site_set/rectangularity.hh \
mln/accu/site_set/all.hh \
mln/accu/site_set/essential.hh \
+mln/accu/stat/variance.hh \
mln/accu/stat/deviation.hh \
mln/accu/max.hh \
mln/accu/lor.hh \
@@ -399,11 +407,13 @@ mln/accu/transform.hh \
mln/accu/median_alt.hh \
mln/accu/volume.hh \
mln/accu/sum.hh \
+mln/accu/label_used.hh \
mln/accu/height.hh \
mln/accu/land.hh \
mln/accu/take.hh \
mln/accu/histo.hh \
mln/accu/pair.hh \
+mln/accu/count_labels.hh \
mln/accu/count_adjacent_vertices.hh \
mln/accu/convolve.hh \
mln/accu/v.hh \
@@ -458,9 +468,11 @@ mln/level/median.hh \
mln/math/jacobi.hh \
mln/math/max.hh \
mln/math/sqr.hh \
+mln/math/pi.hh \
mln/math/all.hh \
mln/math/sign.hh \
mln/math/abs.hh \
+mln/math/sin.hh \
mln/math/cos.hh \
mln/math/diff_abs.hh \
mln/math/round.hh \
@@ -612,10 +624,12 @@ mln/algebra/mat.hh \
mln/algebra/h_mat.hh \
mln/algebra/quat.hh \
mln/algebra/essential.hh \
+mln/linear/gaussian_directional_2d.hh \
mln/linear/convolve_2x1d.hh \
mln/linear/all.hh \
mln/linear/ch_convolve.hh \
mln/linear/gaussian.hh \
+mln/linear/gaussian_1d.hh \
mln/linear/convolve.hh \
mln/linear/sobel_2d.hh \
mln/linear/local/convolve.hh \
@@ -708,7 +722,9 @@ mln/morpho/essential.hh \
mln/topo/n_face_iter.hh \
mln/topo/face_iter.hh \
mln/topo/is_simple_2d.hh \
+mln/topo/detach.hh \
mln/topo/centered_iter_adapter.hh \
+mln/topo/is_n_face.hh \
mln/topo/internal/complex_set_iterator_base.hh \
mln/topo/internal/complex_iterator_base.hh \
mln/topo/internal/complex_relative_iterator_base.hh \
@@ -717,6 +733,7 @@ mln/topo/algebraic_n_face.hh \
mln/topo/attic/faces_iter.hh \
mln/topo/adj_lower_dim_connected_n_face_iter.hh \
mln/topo/n_face.hh \
+mln/topo/is_facet.hh \
mln/topo/adj_lower_higher_face_iter.hh \
mln/topo/all.hh \
mln/topo/face_data.hh \
@@ -724,9 +741,11 @@ mln/topo/static_n_face_iter.hh \
mln/topo/face.hh \
mln/topo/adj_m_face_iter.hh \
mln/topo/complex.hh \
+mln/topo/is_simple_cell.hh \
mln/topo/adj_higher_face_iter.hh \
mln/topo/adj_lower_face_iter.hh \
mln/topo/complex_iterators.hh \
+mln/topo/skeleton/breadth_first_thinning.hh \
mln/topo/center_only_iter.hh \
mln/topo/adj_higher_dim_connected_n_face_iter.hh \
mln/topo/algebraic_face.hh \
@@ -968,6 +987,7 @@ mln/core/image/interpolated.hh \
mln/core/image/lazy_image.hh \
mln/core/image/t_image.hh \
mln/core/image/hexa_piter.hh \
+mln/core/image/edge_image.hh \
mln/core/image/value_enc_image.hh \
mln/core/image/fun_image.hh \
mln/core/image/graph_elt_neighborhood.hh \
@@ -981,13 +1001,13 @@ mln/core/image/complex_window_piter.hh \
mln/core/image/tr_image.hh \
mln/core/image/sub_image.hh \
mln/core/image/rle_image.hh \
-mln/core/image/line_graph_elt_window.hh \
mln/core/image/mono_rle_encode.hh \
mln/core/image/bgraph_psite.hh \
mln/core/image/sparse_image.hh \
mln/core/image/bgraph_image.hh \
mln/core/image/complex_neighborhoods.hh \
mln/core/image/graph_window_piter.hh \
+mln/core/image/vertex_image.hh \
mln/core/image/sparse_encode.hh \
mln/core/image/safe.hh \
mln/core/image/extension_fun.hh \
@@ -995,7 +1015,6 @@ mln/core/image/image1d.hh \
mln/core/image/extension_val.hh \
mln/core/image/image_if.hh \
mln/core/image/hexa.hh \
-mln/core/image/line_graph_elt_neighborhood.hh \
mln/core/image/extended.hh \
mln/core/image/p2p_image.hh \
mln/core/image/slice_image.hh \
@@ -1022,6 +1041,7 @@ mln/labeling/level.hh \
mln/labeling/flat_zones.hh \
mln/labeling/foreground.hh \
mln/labeling/regional_maxima.hh \
+mln/labeling/wrap.hh \
mln/labeling/compute.hh \
mln/labeling/regional_minima.hh \
mln/labeling/essential.hh \
@@ -1069,6 +1089,7 @@ mln/io/cloud/save.hh \
mln/io/all.hh \
mln/io/magick/load.hh \
mln/io/magick/all.hh \
+mln/io/magick/save.hh \
mln/io/dump/load.hh \
mln/io/dump/all.hh \
mln/io/dump/save.hh \
@@ -1084,6 +1105,9 @@ mln/io/pnm/save.hh \
mln/io/pnm/save_header.hh \
mln/io/txt/all.hh \
mln/io/txt/save.hh \
+mln/io/tiff/load.hh \
+mln/io/tiff/all.hh \
+mln/io/tiff/save.hh \
mln/io/dicom/load.hh \
mln/io/abort.hh \
mln/io/fits/load.hh \
@@ -1091,6 +1115,7 @@ mln/io/fits/all.hh \
mln/io/off/load.hh \
mln/io/off/all.hh \
mln/io/off/save.hh \
+mln/io/plot/save.hh \
mln/io/essential.hh \
mln/logical/includes.hh \
mln/logical/and_not.hh \
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index d21304c..38cb062 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -197,6 +197,10 @@ namespace mln
void
from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
+ // rgb -> bool.
+ template <unsigned m>
+ void from_to_(const value::rgb<m>& from, bool& to);
+
// C-array -> Image.
template <typename V, unsigned S, typename I>
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index c67e1fa..e3a7659 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -29,7 +29,7 @@
# define MLN_IO_MAGICK_LOAD_HH
///
-/// \file mln/io/magick/load.hh
+/// \file mln/io/magick/load.hh
///
/// Define a function which loads an image of kind magick with
/// given path.
diff --git a/milena/mln/io/tiff/load.hh b/milena/mln/io/tiff/load.hh
index 1ee2ea1..5d33bd9 100644
--- a/milena/mln/io/tiff/load.hh
+++ b/milena/mln/io/tiff/load.hh
@@ -34,7 +34,8 @@
/// Load TIFF images to Milena images.
///
/// \todo Add support for several tiles.
-/// \todo Handle TIFFTAG_ORIENTATION (origin of the image).
+/// \todo Use ReadScanline instead of ReadRGBAImage in order to avoid a
+/// dispatch and share the same code whatever is the value type.
# include <iostream>
@@ -68,10 +69,11 @@ namespace mln
namespace internal
{
-
+
inline
point2d ij2rc_1(int i, int j, int ni_1, int nj_1)
{
+ (void) nj_1;
return point2d(ni_1 - i, j);
}
@@ -84,36 +86,43 @@ namespace mln
inline
point2d ij2rc_3(int i, int j, int ni_1, int nj_1)
{
+ (void) ni_1;
return point2d(i, nj_1 - j);
}
inline
point2d ij2rc_4(int i, int j, int ni_1, int nj_1)
{
+ (void) ni_1;
+ (void) nj_1;
return point2d(i, j);
}
inline
point2d ij2rc_5(int i, int j, int ni_1, int nj_1)
{
+ (void) nj_1;
return point2d(j, ni_1 - i);
}
inline
point2d ij2rc_6(int i, int j, int ni_1, int nj_1)
{
- return point2d(nj_1 - j, ni_1 - i);
+ return point2d(nj_1 - j, ni_1 - i);
}
inline
point2d ij2rc_7(int i, int j, int ni_1, int nj_1)
{
+ (void) ni_1;
return point2d(nj_1 - j, i);
}
inline
point2d ij2rc_8(int i, int j, int ni_1, int nj_1)
{
+ (void) ni_1;
+ (void) nj_1;
return point2d(j, i);
}
@@ -121,7 +130,7 @@ namespace mln
template <typename I>
inline
- void load_header(I& ima, TIFF *file)
+ I load_header(TIFF *file)
{
uint32 width, height;
@@ -129,7 +138,8 @@ namespace mln
TIFFGetField(file, TIFFTAG_IMAGELENGTH, &height);
mln_concrete(I) new_ima(height, width, 0);
- exact(ima) = new_ima;
+
+ return new_ima;
}
@@ -143,7 +153,7 @@ namespace mln
TIFFGetField(file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
uint16 data_size = bits_per_sample * samples_per_pixel;
- if (data_size != 24 || data_size != 32)
+ if (data_size != 24 && data_size != 32)
{
std::cout << "Trying to load a non color TIFF "
<< "image into a color Milena image." << std::endl;
@@ -160,26 +170,51 @@ namespace mln
abort();
}
- unsigned i = ima.nrows() - 1;
- unsigned j = 0;
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- unsigned idx = i * ima.ncols() + j;
- value::rgb8 v;
+ uint16 orientation;
+ TIFFGetField(file, TIFFTAG_ORIENTATION, &orientation);
- v.red() = (unsigned char) TIFFGetR(raster[idx]);
- v.green() = (unsigned char) TIFFGetG(raster[idx]);
- v.blue() = (unsigned char) TIFFGetB(raster[idx]);
- ima(p) = v;
+ typedef point2d (*fun_t)(int, int, int, int);
+ fun_t funs[] = { 0, ij2rc_1, ij2rc_2, ij2rc_3, ij2rc_4,
+ ij2rc_5, ij2rc_6, ij2rc_7, ij2rc_8 };
+ fun_t fun = funs[orientation];
+
+ int ni_1, nj_1;
+ unsigned idx = 0;
- ++j;
- if (!(j%ima.ncols()))
+ if (orientation <= 4)
{
- --i;
- j = 0;
+ ni_1 = ima.nrows() - 1;
+ nj_1 = ima.ncols() - 1;
+ for (int i = 0; i <= ni_1; ++i)
+ for (int j = 0; j <= nj_1; ++j)
+ {
+ value::rgb8 v;
+
+ v.red() = (unsigned char) TIFFGetR(raster[idx]);
+ v.green() = (unsigned char) TIFFGetG(raster[idx]);
+ v.blue() = (unsigned char) TIFFGetB(raster[idx]);
+ ima((*fun)(i, j, ni_1, nj_1)) = v;
+
+ ++idx;
+ }
+ }
+ else
+ {
+ nj_1 = ima.nrows() - 1;
+ ni_1 = ima.ncols() - 1;
+ for (int j = 0; j <= nj_1; ++j)
+ for (int i = 0; i <= ni_1; ++i)
+ {
+ value::rgb8 v;
+
+ v.red() = (unsigned char) TIFFGetR(raster[idx]);
+ v.green() = (unsigned char) TIFFGetG(raster[idx]);
+ v.blue() = (unsigned char) TIFFGetB(raster[idx]);
+ ima((*fun)(i, j, ni_1, nj_1)) = v;
+
+ ++idx;
+ }
}
- }
_TIFFfree(raster);
}
@@ -200,29 +235,33 @@ namespace mln
abort();
}
-
uint32 npixels = ima.ncols() * ima.nrows();
uint32 *raster = (uint32 *) _TIFFmalloc(npixels * sizeof (uint32));
- TIFFReadRGBAImage(file, ima.ncols(), ima.nrows(), raster, 0);
-
+ if (!TIFFReadRGBAImage(file, ima.ncols(), ima.nrows(), raster, 0))
+ {
+ std::cout << "Error while reading the image file. Is it corrupted?"
+ << std::endl;
+ abort();
+ }
uint16 orientation;
TIFFGetField(file, TIFFTAG_ORIENTATION, &orientation);
typedef point2d (*fun_t)(int, int, int, int);
- fun_t funs[] = { 0, ij2rc_1, ij2rc_2, ij2rc_3, ij2rc_4, ij2rc_5, ij2rc_6, ij2rc_7, ij2rc_8 };
+ fun_t funs[] = { 0, ij2rc_1, ij2rc_2, ij2rc_3, ij2rc_4,
+ ij2rc_5, ij2rc_6, ij2rc_7, ij2rc_8 };
fun_t fun = funs[orientation];
int ni_1, nj_1;
unsigned idx = 0;
- if (orientation <= 4)
+ if (orientation <= 4)
{
ni_1 = ima.nrows() - 1;
nj_1 = ima.ncols() - 1;
- for (unsigned i = 0; i <= ni_1; ++i)
- for (unsigned j = 0; j <= nj_1; ++j)
+ for (int i = 0; i <= ni_1; ++i)
+ for (int j = 0; j <= nj_1; ++j)
{
ima((*fun)(i, j, ni_1, nj_1)) = (unsigned char) TIFFGetR(raster[idx++]);
}
@@ -231,31 +270,13 @@ namespace mln
{
nj_1 = ima.nrows() - 1;
ni_1 = ima.ncols() - 1;
- for (unsigned j = 0; j <= nj_1; ++j)
- for (unsigned i = 0; i <= ni_1; ++i)
+ for (int j = 0; j <= nj_1; ++j)
+ for (int i = 0; i <= ni_1; ++i)
{
ima((*fun)(i, j, ni_1, nj_1)) = (unsigned char) TIFFGetR(raster[idx++]);
}
}
- std::cout << std::endl;
-
-
-// unsigned i = ima.nrows() - 1;
-// unsigned j = 0;
-// mln_piter(I) p(ima.domain());
-// for_all(p)
-// {
-// unsigned idx = i * ima.ncols() + j;
-// ima(p) = (unsigned char) TIFFGetR(raster[idx]);
-// ++j;
-// if (!(j%ima.ncols()))
-// {
-// --i;
-// j = 0;
-// }
-// }
-
_TIFFfree(raster);
}
@@ -301,10 +322,12 @@ namespace mln
template <typename I>
inline
- void load(Image<I>& ima, const std::string& filename)
+ void load(Image<I>& ima_, const std::string& filename)
{
trace::entering("mln::io::tiff::load");
+ I& ima = exact(ima_);
+
TIFF *file = TIFFOpen(filename.c_str(), "r");
if (file == 0)
{
@@ -314,10 +337,10 @@ namespace mln
abort();
}
- internal::load_header(exact(ima), file);
- internal::load_data_dispatch(exact(ima), file);
+ ima = internal::load_header<I>(file);
+ internal::load_data_dispatch(ima, file);
- mln_postcondition(exact(ima).is_valid());
+ mln_postcondition(ima.is_valid());
(void) TIFFClose(file);
trace::exiting("mln::io::tiff::load");
diff --git a/milena/mln/value/rgb.hh b/milena/mln/value/rgb.hh
index a751c65..ebeeb5e 100644
--- a/milena/mln/value/rgb.hh
+++ b/milena/mln/value/rgb.hh
@@ -135,6 +135,10 @@ namespace mln
template <typename H, typename S, typename L>
void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
+ // rgb -> bool.
+ template <unsigned m>
+ void from_to_(const value::rgb<m>& from, bool& to);
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
@@ -796,6 +800,13 @@ namespace mln
to = fun::v2v::f_hsl_to_rgb_3x16(from);
}
+ template <unsigned m>
+ void
+ from_to_(const value::rgb<m>& from, bool& to)
+ {
+ to = (from.red() != 0 && from.green() != 0 && from.blue() != 0);
+ }
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
diff --git a/milena/tests/data.hh.in b/milena/tests/data.hh.in
index f26299b..de0257e 100644
--- a/milena/tests/data.hh.in
+++ b/milena/tests/data.hh.in
@@ -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
@@ -33,10 +34,13 @@
/* Macros are evil, but they save us an extra compilation unit here
(as well as additional burden in Makefiles, too.). */
-/// \brief The absolute path to the img directory of Milena.
+/// The absolute path to the img directory of Milena.
# define MLN_IMG_DIR "@abs_top_srcdir@/milena/img"
-/// \brief The absolute path to the mesh directory of Milena.
+/// The absolute path to the img directory of Milena.
+# define MLN_TESTS_IMG_DIR "@abs_top_srcdir@/milena/tests/img"
+
+/// The absolute path to the mesh directory of Milena.
# define MLN_MESH_DIR "@abs_top_srcdir@/milena/mesh"
#endif // ! TESTS_DATA_HH
diff --git a/milena/tests/img/test_bw.tif b/milena/tests/img/test_bw.tif
new file mode 100644
index 0000000000000000000000000000000000000000..5a84c6a4c7e7044b25bd9497024f7ece35e819ac
GIT binary patch
literal 332
zcmYk2zY4-I5XLX{4>~9)sGtsY69*4>2SG(U2)=<t8*Q*@!3G5<@lkv>U&2Ma#0)(+
z?swt)zJvt92$}%!7*w9K*W|;X0beKrqcdBqV7W{S%dzL!=n9TY#AV0ETVoz9X}+oJ
z#O9t685-=LU!lF3%W37f?RZ9-j?-6(yR2m2Go_rK;{|a)=N&rsNN)<c3Nh2^;T)y0
z!YEY&V}8H$3&-r5U>b{r<4J0w1eLU_R43FT)4Tm`tmP44ei2-Y(7#C?`Kw^FHPLHo
I^96SP0N%bR?EnA(
literal 0
HcmV?d00001
diff --git a/milena/tests/img/test_gl.tif b/milena/tests/img/test_gl.tif
new file mode 100644
index 0000000000000000000000000000000000000000..1d9d0763c05a6263c8eb8b2222847e503eb88093
GIT binary patch
literal 352
zcmebD)M8L$U|?uqkpEzA!o|wWpf~?<`fnw^|IKU<3K>|!bQl^M7z7#qF|aT&0@Z;5
zBQu!I2IMdzv6-N34xl(Ql+6lcvq9M){k)7!46Z=>2N3fC*+M|t4k#hW2r(a|R|rYH
zC=y!?%60&%5r?Xm1+t|WS;6iJ0GcBWWk&$nGDvzgpll|fdJxc0%uUfRF3C^M&dATn
z)z8S!P1Vmytg1>ZO4Khd%hS)#NzF^tPtPm?vhwtEGr`=<+;sht)Z&u(^c=mC%rpiD
e=c3falGGH1^30M91$R&10FcohKn(IKm<9mHT`$}K
literal 0
HcmV?d00001
diff --git a/milena/tests/img/test_rgb8.tif b/milena/tests/img/test_rgb8.tif
new file mode 100644
index 0000000000000000000000000000000000000000..0bfc2fdfd69f8ba24c559c39e6cb752a8b87ef18
GIT binary patch
literal 416
zcmebD)M9XAU|?uqQ1Jhu!o|x}-Qb|GfJN{>7sKHNA2eD_68<w79}rlPW5e*hw`ozJ
zMT?b!R@>HOL5n*@k^0jQI4}q?{9|BYU<8^028_&LHXD$`h{R?BvYCNm3P6R-P;piu
zpAE`p0<w7-nHVB~v>H$iACN5sWY+=Nf{YOJIe>g2sCtlnqEI%-Trnuy0mv4Is<#BP
zr5IVk?wJ78APr^D0J3F}%+Y|dL2j@`VgtDh9AK!Qn46+sT#}!hosplDtDljdo2s9a
zSXGr+l&D`^mZzVelbV;PpPpF)Waa7SW`emTsl_G5`kDFqC7EgZdU{ZlnVYT;lF<W-
fGB_8dCYGe8D3oWGWGJ|M`UZfk^Z;Uz_rNp&W|u+T
literal 0
HcmV?d00001
diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/Makefile.am
index 78986bd..cc4a0f8 100644
--- a/milena/tests/io/Makefile.am
+++ b/milena/tests/io/Makefile.am
@@ -10,4 +10,5 @@ SUBDIRS = \
pfm \
pgm \
pnm \
- ppm
+ ppm \
+ tiff
diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/tiff/Makefile.am
similarity index 51%
copy from milena/tests/io/Makefile.am
copy to milena/tests/io/tiff/Makefile.am
index 78986bd..92fc55c 100644
--- a/milena/tests/io/Makefile.am
+++ b/milena/tests/io/tiff/Makefile.am
@@ -2,12 +2,11 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- dump \
- fits \
- off \
- pbm \
- pfm \
- pgm \
- pnm \
- ppm
+load_LDFLAGS=-ltiff
+
+check_PROGRAMS = \
+ load
+
+load_SOURCES = load.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/tiff/load.cc b/milena/tests/io/tiff/load.cc
new file mode 100644
index 0000000..d516828
--- /dev/null
+++ b/milena/tests/io/tiff/load.cc
@@ -0,0 +1,97 @@
+// 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.
+
+/// \file tests/io/tiff/load.cc
+///
+/// Test on mln::io::tiff::load.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/tiff/load.hh>
+
+#include <mln/level/compare.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+
+using mln::value::rgb8;
+using mln::value::int_u8;
+
+rgb8 ref_rgb[6][6] = { { rgb8(0,0,0), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,246,0), rgb8(0,0,0) },
+ { rgb8(255,255,255), rgb8(0,0,0), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0) },
+ { rgb8(0,255,48), rgb8(255,255,255), rgb8(255,0,0), rgb8(255,255,255), rgb8(0,255,246), rgb8(0,0,0) },
+ { rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0), rgb8(255,255,255), rgb8(0,0,0) },
+ { rgb8(42,0,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(255,255,255), rgb8(0,0,0), rgb8(0,0,0) },
+ { rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0), rgb8(0,0,0) } };
+
+int_u8 ref_gl[6][6] = { { 0, 255, 255, 255, 230, 0 },
+ { 255, 0, 255, 255, 255, 0 },
+ { 186, 255, 54, 255, 200, 0 },
+ { 255, 255, 255, 0, 255, 0 },
+ { 27, 255, 255, 255, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 } };
+
+bool ref_bw[6][6] = { { 0, 1, 1, 1, 1, 0 },
+ { 1, 0, 1, 1, 1, 0 },
+ { 1, 1, 0, 1, 1, 0 },
+ { 1, 1, 1, 0, 1, 0 },
+ { 0, 1, 1, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 } };
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ /// Value: rgb8
+ {
+ image2d<rgb8> ref = make::image(ref_rgb);
+ image2d<rgb8> pic;
+ io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_rgb8.tif");
+ mln_assertion(pic == ref);
+ }
+
+ {
+ image2d<int_u8> ref = make::image(ref_gl);
+ image2d<int_u8> pic;
+ io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_gl.tif");
+ mln_assertion(pic == ref);
+ }
+
+ {
+ image2d<bool> ref = make::image(ref_bw);
+ image2d<bool> pic;
+ io::tiff::load(pic, MLN_TESTS_IMG_DIR "/test_bw.tif");
+ mln_assertion(pic == ref);
+ }
+
+}
+
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index c6bf5dd..15c6fcd 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -36,6 +36,7 @@ mln_draw_plot \
mln_draw_line \
mln_draw_essential \
mln_pw_image \
+mln_pw_internal_image_base \
mln_pw_all \
mln_pw_value \
mln_pw_cst \
@@ -134,10 +135,12 @@ mln_make_double_neighb2d \
mln_make_image3d \
mln_make_dpoint2d_h \
mln_make_w_window \
+mln_make_cell \
mln_make_image \
mln_make_vec \
mln_make_all \
mln_make_dual_neighb \
+mln_make_attachment \
mln_make_w_window3d \
mln_make_mat \
mln_make_win_chamfer \
@@ -148,6 +151,7 @@ mln_make_box2d \
mln_make_h_mat \
mln_make_w_window2d \
mln_make_box3d \
+mln_make_detachment \
mln_make_region_adjacency_graph \
mln_make_relabelfun \
mln_make_pixel \
@@ -156,6 +160,7 @@ mln_make_box2d_h \
mln_make_w_window1d \
mln_make_image2d \
mln_make_w_window_directional \
+mln_make_rag_and_labeled_wsl \
mln_make_w_window3d_int \
mln_make_essential \
mln_make_w_window1d_int \
@@ -178,8 +183,10 @@ mln_extension_adjust_fill \
mln_extension_fill \
mln_extension_essential \
mln_fun_p2b_chess \
+mln_fun_p2b_tautology \
mln_fun_p2b_all \
mln_fun_p2b_has \
+mln_fun_p2b_antilogy \
mln_fun_p2b_big_chess \
mln_fun_p2b_essential \
mln_fun_p2p_all \
@@ -373,6 +380,7 @@ mln_accu_min_h \
mln_accu_site_set_rectangularity \
mln_accu_site_set_all \
mln_accu_site_set_essential \
+mln_accu_stat_variance \
mln_accu_stat_deviation \
mln_accu_max \
mln_accu_lor \
@@ -394,11 +402,13 @@ mln_accu_transform \
mln_accu_median_alt \
mln_accu_volume \
mln_accu_sum \
+mln_accu_label_used \
mln_accu_height \
mln_accu_land \
mln_accu_take \
mln_accu_histo \
mln_accu_pair \
+mln_accu_count_labels \
mln_accu_count_adjacent_vertices \
mln_accu_convolve \
mln_accu_v \
@@ -451,9 +461,11 @@ mln_level_median \
mln_math_jacobi \
mln_math_max \
mln_math_sqr \
+mln_math_pi \
mln_math_all \
mln_math_sign \
mln_math_abs \
+mln_math_sin \
mln_math_cos \
mln_math_diff_abs \
mln_math_round \
@@ -605,10 +617,12 @@ mln_algebra_mat \
mln_algebra_h_mat \
mln_algebra_quat \
mln_algebra_essential \
+mln_linear_gaussian_directional_2d \
mln_linear_convolve_2x1d \
mln_linear_all \
mln_linear_ch_convolve \
mln_linear_gaussian \
+mln_linear_gaussian_1d \
mln_linear_convolve \
mln_linear_sobel_2d \
mln_linear_local_convolve \
@@ -700,7 +714,9 @@ mln_morpho_essential \
mln_topo_n_face_iter \
mln_topo_face_iter \
mln_topo_is_simple_2d \
+mln_topo_detach \
mln_topo_centered_iter_adapter \
+mln_topo_is_n_face \
mln_topo_internal_complex_set_iterator_base \
mln_topo_internal_complex_iterator_base \
mln_topo_internal_complex_relative_iterator_base \
@@ -709,6 +725,7 @@ mln_topo_algebraic_n_face \
mln_topo_attic_faces_iter \
mln_topo_adj_lower_dim_connected_n_face_iter \
mln_topo_n_face \
+mln_topo_is_facet \
mln_topo_adj_lower_higher_face_iter \
mln_topo_all \
mln_topo_face_data \
@@ -716,9 +733,11 @@ mln_topo_static_n_face_iter \
mln_topo_face \
mln_topo_adj_m_face_iter \
mln_topo_complex \
+mln_topo_is_simple_cell \
mln_topo_adj_higher_face_iter \
mln_topo_adj_lower_face_iter \
mln_topo_complex_iterators \
+mln_topo_skeleton_breadth_first_thinning \
mln_topo_center_only_iter \
mln_topo_adj_higher_dim_connected_n_face_iter \
mln_topo_algebraic_face \
@@ -943,6 +962,7 @@ mln_core_image_interpolated \
mln_core_image_lazy_image \
mln_core_image_t_image \
mln_core_image_hexa_piter \
+mln_core_image_edge_image \
mln_core_image_value_enc_image \
mln_core_image_fun_image \
mln_core_image_graph_elt_neighborhood \
@@ -956,13 +976,13 @@ mln_core_image_complex_window_piter \
mln_core_image_tr_image \
mln_core_image_sub_image \
mln_core_image_rle_image \
-mln_core_image_line_graph_elt_window \
mln_core_image_mono_rle_encode \
mln_core_image_bgraph_psite \
mln_core_image_sparse_image \
mln_core_image_bgraph_image \
mln_core_image_complex_neighborhoods \
mln_core_image_graph_window_piter \
+mln_core_image_vertex_image \
mln_core_image_sparse_encode \
mln_core_image_safe \
mln_core_image_extension_fun \
@@ -970,7 +990,6 @@ mln_core_image_image1d \
mln_core_image_extension_val \
mln_core_image_image_if \
mln_core_image_hexa \
-mln_core_image_line_graph_elt_neighborhood \
mln_core_image_extended \
mln_core_image_p2p_image \
mln_core_image_slice_image \
@@ -996,6 +1015,7 @@ mln_labeling_level \
mln_labeling_flat_zones \
mln_labeling_foreground \
mln_labeling_regional_maxima \
+mln_labeling_wrap \
mln_labeling_compute \
mln_labeling_regional_minima \
mln_labeling_essential \
@@ -1040,6 +1060,7 @@ mln_io_cloud_save \
mln_io_all \
mln_io_magick_load \
mln_io_magick_all \
+mln_io_magick_save \
mln_io_dump_load \
mln_io_dump_all \
mln_io_dump_save \
@@ -1055,6 +1076,9 @@ mln_io_pnm_save \
mln_io_pnm_save_header \
mln_io_txt_all \
mln_io_txt_save \
+mln_io_tiff_load \
+mln_io_tiff_all \
+mln_io_tiff_save \
mln_io_dicom_load \
mln_io_abort \
mln_io_fits_load \
@@ -1062,6 +1086,7 @@ mln_io_fits_all \
mln_io_off_load \
mln_io_off_all \
mln_io_off_save \
+mln_io_plot_save \
mln_io_essential \
mln_logical_includes \
mln_logical_and_not \
@@ -1155,6 +1180,7 @@ mln_draw_plot_SOURCES = mln_draw_plot.cc
mln_draw_line_SOURCES = mln_draw_line.cc
mln_draw_essential_SOURCES = mln_draw_essential.cc
mln_pw_image_SOURCES = mln_pw_image.cc
+mln_pw_internal_image_base_SOURCES = mln_pw_internal_image_base.cc
mln_pw_all_SOURCES = mln_pw_all.cc
mln_pw_value_SOURCES = mln_pw_value.cc
mln_pw_cst_SOURCES = mln_pw_cst.cc
@@ -1253,10 +1279,12 @@ mln_make_double_neighb2d_SOURCES = mln_make_double_neighb2d.cc
mln_make_image3d_SOURCES = mln_make_image3d.cc
mln_make_dpoint2d_h_SOURCES = mln_make_dpoint2d_h.cc
mln_make_w_window_SOURCES = mln_make_w_window.cc
+mln_make_cell_SOURCES = mln_make_cell.cc
mln_make_image_SOURCES = mln_make_image.cc
mln_make_vec_SOURCES = mln_make_vec.cc
mln_make_all_SOURCES = mln_make_all.cc
mln_make_dual_neighb_SOURCES = mln_make_dual_neighb.cc
+mln_make_attachment_SOURCES = mln_make_attachment.cc
mln_make_w_window3d_SOURCES = mln_make_w_window3d.cc
mln_make_mat_SOURCES = mln_make_mat.cc
mln_make_win_chamfer_SOURCES = mln_make_win_chamfer.cc
@@ -1267,6 +1295,7 @@ mln_make_box2d_SOURCES = mln_make_box2d.cc
mln_make_h_mat_SOURCES = mln_make_h_mat.cc
mln_make_w_window2d_SOURCES = mln_make_w_window2d.cc
mln_make_box3d_SOURCES = mln_make_box3d.cc
+mln_make_detachment_SOURCES = mln_make_detachment.cc
mln_make_region_adjacency_graph_SOURCES = mln_make_region_adjacency_graph.cc
mln_make_relabelfun_SOURCES = mln_make_relabelfun.cc
mln_make_pixel_SOURCES = mln_make_pixel.cc
@@ -1275,6 +1304,7 @@ mln_make_box2d_h_SOURCES = mln_make_box2d_h.cc
mln_make_w_window1d_SOURCES = mln_make_w_window1d.cc
mln_make_image2d_SOURCES = mln_make_image2d.cc
mln_make_w_window_directional_SOURCES = mln_make_w_window_directional.cc
+mln_make_rag_and_labeled_wsl_SOURCES = mln_make_rag_and_labeled_wsl.cc
mln_make_w_window3d_int_SOURCES = mln_make_w_window3d_int.cc
mln_make_essential_SOURCES = mln_make_essential.cc
mln_make_w_window1d_int_SOURCES = mln_make_w_window1d_int.cc
@@ -1297,8 +1327,10 @@ mln_extension_adjust_fill_SOURCES = mln_extension_adjust_fill.cc
mln_extension_fill_SOURCES = mln_extension_fill.cc
mln_extension_essential_SOURCES = mln_extension_essential.cc
mln_fun_p2b_chess_SOURCES = mln_fun_p2b_chess.cc
+mln_fun_p2b_tautology_SOURCES = mln_fun_p2b_tautology.cc
mln_fun_p2b_all_SOURCES = mln_fun_p2b_all.cc
mln_fun_p2b_has_SOURCES = mln_fun_p2b_has.cc
+mln_fun_p2b_antilogy_SOURCES = mln_fun_p2b_antilogy.cc
mln_fun_p2b_big_chess_SOURCES = mln_fun_p2b_big_chess.cc
mln_fun_p2b_essential_SOURCES = mln_fun_p2b_essential.cc
mln_fun_p2p_all_SOURCES = mln_fun_p2p_all.cc
@@ -1492,6 +1524,7 @@ mln_accu_min_h_SOURCES = mln_accu_min_h.cc
mln_accu_site_set_rectangularity_SOURCES = mln_accu_site_set_rectangularity.cc
mln_accu_site_set_all_SOURCES = mln_accu_site_set_all.cc
mln_accu_site_set_essential_SOURCES = mln_accu_site_set_essential.cc
+mln_accu_stat_variance_SOURCES = mln_accu_stat_variance.cc
mln_accu_stat_deviation_SOURCES = mln_accu_stat_deviation.cc
mln_accu_max_SOURCES = mln_accu_max.cc
mln_accu_lor_SOURCES = mln_accu_lor.cc
@@ -1513,11 +1546,13 @@ mln_accu_transform_SOURCES = mln_accu_transform.cc
mln_accu_median_alt_SOURCES = mln_accu_median_alt.cc
mln_accu_volume_SOURCES = mln_accu_volume.cc
mln_accu_sum_SOURCES = mln_accu_sum.cc
+mln_accu_label_used_SOURCES = mln_accu_label_used.cc
mln_accu_height_SOURCES = mln_accu_height.cc
mln_accu_land_SOURCES = mln_accu_land.cc
mln_accu_take_SOURCES = mln_accu_take.cc
mln_accu_histo_SOURCES = mln_accu_histo.cc
mln_accu_pair_SOURCES = mln_accu_pair.cc
+mln_accu_count_labels_SOURCES = mln_accu_count_labels.cc
mln_accu_count_adjacent_vertices_SOURCES = mln_accu_count_adjacent_vertices.cc
mln_accu_convolve_SOURCES = mln_accu_convolve.cc
mln_accu_v_SOURCES = mln_accu_v.cc
@@ -1570,9 +1605,11 @@ mln_level_median_SOURCES = mln_level_median.cc
mln_math_jacobi_SOURCES = mln_math_jacobi.cc
mln_math_max_SOURCES = mln_math_max.cc
mln_math_sqr_SOURCES = mln_math_sqr.cc
+mln_math_pi_SOURCES = mln_math_pi.cc
mln_math_all_SOURCES = mln_math_all.cc
mln_math_sign_SOURCES = mln_math_sign.cc
mln_math_abs_SOURCES = mln_math_abs.cc
+mln_math_sin_SOURCES = mln_math_sin.cc
mln_math_cos_SOURCES = mln_math_cos.cc
mln_math_diff_abs_SOURCES = mln_math_diff_abs.cc
mln_math_round_SOURCES = mln_math_round.cc
@@ -1724,10 +1761,12 @@ mln_algebra_mat_SOURCES = mln_algebra_mat.cc
mln_algebra_h_mat_SOURCES = mln_algebra_h_mat.cc
mln_algebra_quat_SOURCES = mln_algebra_quat.cc
mln_algebra_essential_SOURCES = mln_algebra_essential.cc
+mln_linear_gaussian_directional_2d_SOURCES = mln_linear_gaussian_directional_2d.cc
mln_linear_convolve_2x1d_SOURCES = mln_linear_convolve_2x1d.cc
mln_linear_all_SOURCES = mln_linear_all.cc
mln_linear_ch_convolve_SOURCES = mln_linear_ch_convolve.cc
mln_linear_gaussian_SOURCES = mln_linear_gaussian.cc
+mln_linear_gaussian_1d_SOURCES = mln_linear_gaussian_1d.cc
mln_linear_convolve_SOURCES = mln_linear_convolve.cc
mln_linear_sobel_2d_SOURCES = mln_linear_sobel_2d.cc
mln_linear_local_convolve_SOURCES = mln_linear_local_convolve.cc
@@ -1819,7 +1858,9 @@ mln_morpho_essential_SOURCES = mln_morpho_essential.cc
mln_topo_n_face_iter_SOURCES = mln_topo_n_face_iter.cc
mln_topo_face_iter_SOURCES = mln_topo_face_iter.cc
mln_topo_is_simple_2d_SOURCES = mln_topo_is_simple_2d.cc
+mln_topo_detach_SOURCES = mln_topo_detach.cc
mln_topo_centered_iter_adapter_SOURCES = mln_topo_centered_iter_adapter.cc
+mln_topo_is_n_face_SOURCES = mln_topo_is_n_face.cc
mln_topo_internal_complex_set_iterator_base_SOURCES = mln_topo_internal_complex_set_iterator_base.cc
mln_topo_internal_complex_iterator_base_SOURCES = mln_topo_internal_complex_iterator_base.cc
mln_topo_internal_complex_relative_iterator_base_SOURCES = mln_topo_internal_complex_relative_iterator_base.cc
@@ -1828,6 +1869,7 @@ mln_topo_algebraic_n_face_SOURCES = mln_topo_algebraic_n_face.cc
mln_topo_attic_faces_iter_SOURCES = mln_topo_attic_faces_iter.cc
mln_topo_adj_lower_dim_connected_n_face_iter_SOURCES = mln_topo_adj_lower_dim_connected_n_face_iter.cc
mln_topo_n_face_SOURCES = mln_topo_n_face.cc
+mln_topo_is_facet_SOURCES = mln_topo_is_facet.cc
mln_topo_adj_lower_higher_face_iter_SOURCES = mln_topo_adj_lower_higher_face_iter.cc
mln_topo_all_SOURCES = mln_topo_all.cc
mln_topo_face_data_SOURCES = mln_topo_face_data.cc
@@ -1835,9 +1877,11 @@ mln_topo_static_n_face_iter_SOURCES = mln_topo_static_n_face_iter.cc
mln_topo_face_SOURCES = mln_topo_face.cc
mln_topo_adj_m_face_iter_SOURCES = mln_topo_adj_m_face_iter.cc
mln_topo_complex_SOURCES = mln_topo_complex.cc
+mln_topo_is_simple_cell_SOURCES = mln_topo_is_simple_cell.cc
mln_topo_adj_higher_face_iter_SOURCES = mln_topo_adj_higher_face_iter.cc
mln_topo_adj_lower_face_iter_SOURCES = mln_topo_adj_lower_face_iter.cc
mln_topo_complex_iterators_SOURCES = mln_topo_complex_iterators.cc
+mln_topo_skeleton_breadth_first_thinning_SOURCES = mln_topo_skeleton_breadth_first_thinning.cc
mln_topo_center_only_iter_SOURCES = mln_topo_center_only_iter.cc
mln_topo_adj_higher_dim_connected_n_face_iter_SOURCES = mln_topo_adj_higher_dim_connected_n_face_iter.cc
mln_topo_algebraic_face_SOURCES = mln_topo_algebraic_face.cc
@@ -2062,6 +2106,7 @@ mln_core_image_interpolated_SOURCES = mln_core_image_interpolated.cc
mln_core_image_lazy_image_SOURCES = mln_core_image_lazy_image.cc
mln_core_image_t_image_SOURCES = mln_core_image_t_image.cc
mln_core_image_hexa_piter_SOURCES = mln_core_image_hexa_piter.cc
+mln_core_image_edge_image_SOURCES = mln_core_image_edge_image.cc
mln_core_image_value_enc_image_SOURCES = mln_core_image_value_enc_image.cc
mln_core_image_fun_image_SOURCES = mln_core_image_fun_image.cc
mln_core_image_graph_elt_neighborhood_SOURCES = mln_core_image_graph_elt_neighborhood.cc
@@ -2075,13 +2120,13 @@ mln_core_image_complex_window_piter_SOURCES = mln_core_image_complex_window_pite
mln_core_image_tr_image_SOURCES = mln_core_image_tr_image.cc
mln_core_image_sub_image_SOURCES = mln_core_image_sub_image.cc
mln_core_image_rle_image_SOURCES = mln_core_image_rle_image.cc
-mln_core_image_line_graph_elt_window_SOURCES = mln_core_image_line_graph_elt_window.cc
mln_core_image_mono_rle_encode_SOURCES = mln_core_image_mono_rle_encode.cc
mln_core_image_bgraph_psite_SOURCES = mln_core_image_bgraph_psite.cc
mln_core_image_sparse_image_SOURCES = mln_core_image_sparse_image.cc
mln_core_image_bgraph_image_SOURCES = mln_core_image_bgraph_image.cc
mln_core_image_complex_neighborhoods_SOURCES = mln_core_image_complex_neighborhoods.cc
mln_core_image_graph_window_piter_SOURCES = mln_core_image_graph_window_piter.cc
+mln_core_image_vertex_image_SOURCES = mln_core_image_vertex_image.cc
mln_core_image_sparse_encode_SOURCES = mln_core_image_sparse_encode.cc
mln_core_image_safe_SOURCES = mln_core_image_safe.cc
mln_core_image_extension_fun_SOURCES = mln_core_image_extension_fun.cc
@@ -2089,7 +2134,6 @@ mln_core_image_image1d_SOURCES = mln_core_image_image1d.cc
mln_core_image_extension_val_SOURCES = mln_core_image_extension_val.cc
mln_core_image_image_if_SOURCES = mln_core_image_image_if.cc
mln_core_image_hexa_SOURCES = mln_core_image_hexa.cc
-mln_core_image_line_graph_elt_neighborhood_SOURCES = mln_core_image_line_graph_elt_neighborhood.cc
mln_core_image_extended_SOURCES = mln_core_image_extended.cc
mln_core_image_p2p_image_SOURCES = mln_core_image_p2p_image.cc
mln_core_image_slice_image_SOURCES = mln_core_image_slice_image.cc
@@ -2115,6 +2159,7 @@ mln_labeling_level_SOURCES = mln_labeling_level.cc
mln_labeling_flat_zones_SOURCES = mln_labeling_flat_zones.cc
mln_labeling_foreground_SOURCES = mln_labeling_foreground.cc
mln_labeling_regional_maxima_SOURCES = mln_labeling_regional_maxima.cc
+mln_labeling_wrap_SOURCES = mln_labeling_wrap.cc
mln_labeling_compute_SOURCES = mln_labeling_compute.cc
mln_labeling_regional_minima_SOURCES = mln_labeling_regional_minima.cc
mln_labeling_essential_SOURCES = mln_labeling_essential.cc
@@ -2159,6 +2204,7 @@ mln_io_cloud_save_SOURCES = mln_io_cloud_save.cc
mln_io_all_SOURCES = mln_io_all.cc
mln_io_magick_load_SOURCES = mln_io_magick_load.cc
mln_io_magick_all_SOURCES = mln_io_magick_all.cc
+mln_io_magick_save_SOURCES = mln_io_magick_save.cc
mln_io_dump_load_SOURCES = mln_io_dump_load.cc
mln_io_dump_all_SOURCES = mln_io_dump_all.cc
mln_io_dump_save_SOURCES = mln_io_dump_save.cc
@@ -2174,6 +2220,9 @@ mln_io_pnm_save_SOURCES = mln_io_pnm_save.cc
mln_io_pnm_save_header_SOURCES = mln_io_pnm_save_header.cc
mln_io_txt_all_SOURCES = mln_io_txt_all.cc
mln_io_txt_save_SOURCES = mln_io_txt_save.cc
+mln_io_tiff_load_SOURCES = mln_io_tiff_load.cc
+mln_io_tiff_all_SOURCES = mln_io_tiff_all.cc
+mln_io_tiff_save_SOURCES = mln_io_tiff_save.cc
mln_io_dicom_load_SOURCES = mln_io_dicom_load.cc
mln_io_abort_SOURCES = mln_io_abort.cc
mln_io_fits_load_SOURCES = mln_io_fits_load.cc
@@ -2181,6 +2230,7 @@ mln_io_fits_all_SOURCES = mln_io_fits_all.cc
mln_io_off_load_SOURCES = mln_io_off_load.cc
mln_io_off_all_SOURCES = mln_io_off_all.cc
mln_io_off_save_SOURCES = mln_io_off_save.cc
+mln_io_plot_save_SOURCES = mln_io_plot_save.cc
mln_io_essential_SOURCES = mln_io_essential.cc
mln_logical_includes_SOURCES = mln_logical_includes.cc
mln_logical_and_not_SOURCES = mln_logical_and_not.cc
--
1.5.6.5
1
0
3656: Remove an invalid conversion operator from a morpher to a concrete image.
by Guillaume Lazzara 14 Apr '09
by Guillaume Lazzara 14 Apr '09
14 Apr '09
* mln/core/internal/image_morpher.hh: remove operator I().
---
milena/ChangeLog | 7 ++++++
milena/mln/core/internal/image_morpher.hh | 31 ++++++++--------------------
2 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4a24f51..7e6190d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Remove an invalid conversion operator from a morpher to a concrete
+ image.
+
+ * mln/core/internal/image_morpher.hh: remove operator I().
+
+2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Introduce edge_image and vertex_image types.
* mln/core/site_set/p_graph_piter.hh,
diff --git a/milena/mln/core/internal/image_morpher.hh b/milena/mln/core/internal/image_morpher.hh
index ab50ea8..fd170ea 100644
--- a/milena/mln/core/internal/image_morpher.hh
+++ b/milena/mln/core/internal/image_morpher.hh
@@ -1,4 +1,5 @@
-// 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
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +29,11 @@
#ifndef MLN_CORE_INTERNAL_IMAGE_MORPHER_HH
# define MLN_CORE_INTERNAL_IMAGE_MORPHER_HH
-/*! \file mln/core/internal/image_morpher.hh
- *
- * \brief Definition of a base class for image morphers.
- *
- * \todo Add the appropriate checks in .rw().
- */
+/// \file mln/core/internal/image_morpher.hh
+///
+/// Definition of a base class for image morphers.
+///
+/// \todo Add the appropriate checks in .rw().
# include <mln/core/internal/image_base.hh>
# include <mln/metal/const.hh>
@@ -47,9 +47,8 @@ namespace mln
namespace internal
{
- /*! A base class for images that are morphers. Parameter
- * \c I is the underlying-morphed image type.
- */
+ /// A base class for images that are morphers. Parameter
+ /// \c I is the underlying-morphed image type.
template <typename I, typename T, typename S, typename E>
class image_morpher : public image_base<T, S, E>
{
@@ -80,9 +79,6 @@ namespace mln
*/
bool is_valid() const;
- /// Conversion to the underlying (morphed) image.
- operator I() const; // FIXME: Very dangerous? Remove?
-
/// State that the morpher is writable. This allows for C++ to
/// use it as a mutable object even if it is a temporary object.
@@ -165,15 +161,6 @@ namespace mln
return *ptr;
}
-
- template <typename I, typename T, typename S, typename E>
- inline
- image_morpher<I, T, S, E>::operator I() const
- {
- mln_precondition(exact(this)->is_valid());
- return * this->delegatee_();
- }
-
template <typename I, typename T, typename S, typename E>
inline
bool
--
1.5.6.5
1
0
* mln/core/site_set/p_graph_piter.hh,
* mln/core/internal/image_base.hh,
* mln/core/image/essential.hh: update doc.
* mln/core/image/all.hh: include new headers.
* mln/core/image/vertex_image.hh
* mln/core/image/edge_image.hh: new image types.
* mln/core/image/graph_elt_neighborhood.hh,
* mln/core/image/graph_elt_window.hh: update according new image
types.
* mln/core/image/line_graph_elt_neighborhood.hh,
* mln/core/image/line_graph_elt_window.hh: not needed anymore.
Removed.
* mln/core/internal/neighb_niter_impl.hh: update template parameter
names.
* mln/core/routine/init.hxx: add new init routines for new image
types.
* mln/core/site_set/p_edges.hh,
* mln/core/site_set/p_vertices.hh: use Graph concept in constructor
instead of exact type.
* mln/debug/draw_graph.hh: add missing traces.
* mln/morpho/attribute/count_adjacent_vertices.hh: make it more
generic.
* mln/morpho/closing/area_on_vertices.hh,
* mln/morpho/line_gradient.hh: use the new types.
* mln/pw/image.hh: revamp and move most of the code...
* mln/pw/internal/image_base.hh: ... here.
* mln/tag/skeleton.hh: add tag::graph.
* mln/trait/ch_value.hh: add traits for new image types.
* mln/util/graph.hh: Add a method returning the edge vector.
* tests/core/image/Makefile.am,
* tests/core/image/vertex_image.cc,
* tests/core/image/edge_image.cc: new tests.
* tests/core/image/graph_image.cc,
* tests/core/image/line_graph_image.cc,
* tests/core/site_set/p_edges.cc,
* tests/morpho/artificial_line_graph_image_wst.cc,
* tests/morpho/graph_image_morpho.cc,
* tests/morpho/graph_image_wst.cc,
* tests/morpho/lena_line_graph_image_wst1.cc,
* tests/morpho/lena_line_graph_image_wst2.cc,
* tests/morpho/line_graph_image_morpho.cc,
* tests/morpho/line_graph_image_wst.cc,
* tests/util/graph.cc: update graph related tests. Use the new image
types.
---
milena/ChangeLog | 65 +++++
milena/mln/core/image/all.hh | 3 +-
milena/mln/core/image/edge_image.hh | 254 +++++++++++++++++++
milena/mln/core/image/essential.hh | 10 +-
milena/mln/core/image/graph_elt_neighborhood.hh | 10 +-
milena/mln/core/image/graph_elt_window.hh | 60 ++++--
.../mln/core/image/line_graph_elt_neighborhood.hh | 67 -----
milena/mln/core/image/line_graph_elt_window.hh | 109 ---------
milena/mln/core/image/vertex_image.hh | 250 +++++++++++++++++++
milena/mln/core/internal/image_base.hh | 23 +-
milena/mln/core/internal/neighb_niter_impl.hh | 8 +-
milena/mln/core/routine/init.hxx | 34 ++-
milena/mln/core/site_set/p_edges.hh | 55 ++++-
milena/mln/core/site_set/p_graph_piter.hh | 6 +-
milena/mln/core/site_set/p_vertices.hh | 53 ++++-
milena/mln/debug/draw_graph.hh | 17 ++
.../morpho/attribute/count_adjacent_vertices.hh | 48 ++--
milena/mln/morpho/closing/area_on_vertices.hh | 30 ++--
milena/mln/morpho/line_gradient.hh | 24 +-
milena/mln/pw/image.hh | 191 +++------------
milena/mln/pw/internal/image_base.hh | 257 ++++++++++++++++++++
milena/mln/tag/skeleton.hh | 14 +-
milena/mln/trait/ch_value.hh | 32 +++-
milena/mln/util/graph.hh | 11 +
milena/tests/core/image/Makefile.am | 6 +-
.../core/image/{graph_image.cc => edge_image.cc} | 80 +++----
milena/tests/core/image/graph_image.cc | 4 +-
milena/tests/core/image/line_graph_image.cc | 50 ++--
.../core/image/{graph_image.cc => vertex_image.cc} | 40 +--
milena/tests/core/site_set/p_edges.cc | 4 +-
.../morpho/artificial_line_graph_image_wst.cc | 12 +-
milena/tests/morpho/graph_image_morpho.cc | 23 +--
milena/tests/morpho/graph_image_wst.cc | 23 +--
milena/tests/morpho/lena_line_graph_image_wst1.cc | 17 +-
milena/tests/morpho/lena_line_graph_image_wst2.cc | 12 +-
milena/tests/morpho/line_graph_image_morpho.cc | 64 +++---
milena/tests/morpho/line_graph_image_wst.cc | 71 +++---
milena/tests/util/graph.cc | 7 +-
38 files changed, 1346 insertions(+), 698 deletions(-)
create mode 100644 milena/mln/core/image/edge_image.hh
delete mode 100644 milena/mln/core/image/line_graph_elt_neighborhood.hh
delete mode 100644 milena/mln/core/image/line_graph_elt_window.hh
create mode 100644 milena/mln/core/image/vertex_image.hh
create mode 100644 milena/mln/pw/internal/image_base.hh
copy milena/tests/core/image/{graph_image.cc => edge_image.cc} (73%)
copy milena/tests/core/image/{graph_image.cc => vertex_image.cc} (84%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7f95505..4a24f51 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,68 @@
+2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Introduce edge_image and vertex_image types.
+
+ * mln/core/site_set/p_graph_piter.hh,
+ * mln/core/internal/image_base.hh,
+ * mln/core/image/essential.hh: update doc.
+
+ * mln/core/image/all.hh: include new headers.
+
+ * mln/core/image/vertex_image.hh,
+ * mln/core/image/edge_image.hh: new image types.
+
+ * mln/core/image/graph_elt_neighborhood.hh,
+ * mln/core/image/graph_elt_window.hh: update according new image
+ types.
+
+ * mln/core/image/line_graph_elt_neighborhood.hh,
+ * mln/core/image/line_graph_elt_window.hh: not needed anymore.
+ Removed.
+
+ * mln/core/internal/neighb_niter_impl.hh: update template parameter
+ names.
+
+ * mln/core/routine/init.hxx: add new init routines for new image
+ types.
+
+ * mln/core/site_set/p_edges.hh,
+ * mln/core/site_set/p_vertices.hh: use Graph concept in constructor
+ instead of exact type.
+
+ * mln/debug/draw_graph.hh: add missing traces.
+
+ * mln/morpho/attribute/count_adjacent_vertices.hh: make it more
+ generic.
+
+ * mln/morpho/closing/area_on_vertices.hh,
+ * mln/morpho/line_gradient.hh: use the new types.
+
+ * mln/pw/image.hh: revamp and move most of the code...
+ * mln/pw/internal/image_base.hh: ... here.
+
+ * mln/tag/skeleton.hh: add tag::graph.
+
+ * mln/trait/ch_value.hh: add traits for new image types.
+
+ * mln/util/graph.hh: Add a method returning the edge vector.
+
+ * tests/core/image/Makefile.am,
+ * tests/core/image/vertex_image.cc,
+ * tests/core/image/edge_image.cc: new tests.
+
+ * tests/core/image/graph_image.cc,
+ * tests/core/image/line_graph_image.cc,
+ * tests/core/site_set/p_edges.cc,
+ * tests/morpho/artificial_line_graph_image_wst.cc,
+ * tests/morpho/graph_image_morpho.cc,
+ * tests/morpho/graph_image_wst.cc,
+ * tests/morpho/lena_line_graph_image_wst1.cc,
+ * tests/morpho/lena_line_graph_image_wst2.cc,
+ * tests/morpho/line_graph_image_morpho.cc,
+ * tests/morpho/line_graph_image_wst.cc,
+ * tests/util/graph.cc: update graph related tests. Use the new image
+ types.
+
2009-04-10 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Merge changes in component tree file.
diff --git a/milena/mln/core/image/all.hh b/milena/mln/core/image/all.hh
index 0de14fc..c4094af 100644
--- a/milena/mln/core/image/all.hh
+++ b/milena/mln/core/image/all.hh
@@ -41,6 +41,7 @@
# include <mln/core/image/complex_neighborhoods.hh>
# include <mln/core/image/complex_window_piter.hh>
# include <mln/core/image/complex_windows.hh>
+# include <mln/core/image/edge_image.hh>
# include <mln/core/image/image2d.hh>
# include <mln/core/image/flat_image.hh>
# include <mln/core/image/image_if.hh>
@@ -60,7 +61,6 @@
# include <mln/core/image/image_if.hh>
# include <mln/core/image/interpolated.hh>
# include <mln/core/image/lazy_image.hh>
-# include <mln/core/image/line_graph_elt_window.hh>
# include <mln/core/image/p2p_image.hh>
# include <mln/core/image/plain.hh>
# include <mln/core/image/safe.hh>
@@ -73,6 +73,7 @@
# include <mln/core/image/tr_image.hh>
# include <mln/core/image/tr_mesh.hh>
# include <mln/core/image/unproject_image.hh>
+# include <mln/core/image/vertex_image.hh>
//# include <mln/core/image/bgraph_image.hh>
//# include <mln/core/image/bgraph_psite.hh>
diff --git a/milena/mln/core/image/edge_image.hh b/milena/mln/core/image/edge_image.hh
new file mode 100644
index 0000000..68e7227
--- /dev/null
+++ b/milena/mln/core/image/edge_image.hh
@@ -0,0 +1,254 @@
+// 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_CORE_IMAGE_EDGE_IMAGE_HH
+# define MLN_CORE_IMAGE_EDGE_IMAGE_HH
+
+/// \file mln/core/image/edge_image.hh
+///
+/// Image based on graph edges.
+
+# include <mln/core/concept/graph.hh>
+# include <mln/core/site_set/p_edges.hh>
+# include <mln/core/image/graph_elt_window.hh>
+# include <mln/core/image/graph_elt_neighborhood.hh>
+# include <mln/pw/internal/image_base.hh>
+# include <mln/fun/i2v/array.hh>
+
+
+
+namespace mln
+{
+ // Forward declaration.
+ template <typename P, typename V, typename G> class edge_image;
+ namespace util { class graph; }
+
+
+ // Properties
+
+ namespace trait
+ {
+
+ template <typename P, typename V, typename G>
+ struct image_< edge_image<P,V,G> >
+ : pw_image_<fun::i2v::array<V>,
+ p_edges<util::graph, fun::i2v::array<P> >,
+ edge_image<P,V,G> >
+ {
+ };
+
+ } // end of namespace mln::traits.
+
+
+
+ namespace internal
+ {
+
+ /// Data structure for mln::pw::internal::image
+ template <typename P, typename V, typename G>
+ struct data< mln::edge_image<P,V,G> >
+ {
+ data(const fun::i2v::array<V>& edge_values,
+ const p_edges<G,fun::i2v::array<P> >& pv);
+
+ fun::i2v::array<V> f_;
+ p_edges<G,fun::i2v::array<P> > pset_;
+ };
+
+ } // end of namespace mln::internal
+
+
+
+
+ /// Construct a edge image from a fun::i2v::array and a p_edges.
+ /// image = fun::i2v::array | p_edges.
+ template <typename V, typename G, typename P>
+ edge_image<P,V,G>
+ operator | (const fun::i2v::array<V>& edge_values,
+ const p_edges<G,fun::i2v::array<P> >& pv);
+
+
+
+
+ template <typename P, typename V, typename G = util::graph>
+ class edge_image
+ : public pw::internal::image_base<fun::i2v::array<V>,
+ p_edges<G, fun::i2v::array<P> >,
+ edge_image<P,V,G> >
+ {
+ typedef pw::internal::image_base<fun::i2v::array<V>,
+ p_edges<G, fun::i2v::array<P> >,
+ edge_image<P,V,G> > super_;
+
+ public:
+ /// Skeleton type.
+ typedef edge_image< tag::psite_<P>,
+ tag::value_<V>,
+ tag::graph_<G> > skeleton;
+
+ /// Function mapping graph elements to sites.
+ typedef fun::i2v::array<P> site_function_t;
+
+ /// Window type
+ typedef graph_elt_window<G,p_edges<G,site_function_t> > win_t;
+ /// Neighborhood type.
+ typedef graph_elt_neighborhood<G,p_edges<G,site_function_t> > nbh_t;
+
+ /// Constructors.
+ /// @{
+ edge_image();
+
+ edge_image(const Graph<G>& g,
+ const Function_i2v< fun::i2v::array<P> >& edge_sites,
+ const Function_i2v< fun::i2v::array<V> >& edge_values);
+
+ edge_image(const p_edges<G,fun::i2v::array<P> >& pe,
+ const Function_i2v< fun::i2v::array<V> >& edge_values);
+
+ template <typename FP, typename FV>
+ edge_image(const Graph<G>& g,
+ const Function_i2v<FP>& edge_sites,
+ const Function_i2v<FV>& edge_values);
+
+ template <typename FV>
+ edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ const Function_i2v<FV>& edge_values);
+ /// @}
+
+ };
+
+ template <typename P, typename V, typename G, typename J>
+ void init_(tag::image_t, edge_image<P,V,G>& target, const Image<J>& model);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename V, typename G, typename J>
+ void init_(tag::image_t, edge_image<P,V,G>& target, const Image<J>& model)
+ {
+ fun::i2v::array<V> f;
+ init_(tag::function, f, exact(model));
+ p_edges<G,fun::i2v::array<P> > s;
+ init_(tag::domain, s, exact(model));
+ target.init_(f, s);
+ }
+
+ // Operator.
+
+ template <typename V, typename G, typename P>
+ inline
+ edge_image<P,V,G>
+ operator | (const fun::i2v::array<V>& edge_values,
+ const p_edges<G,fun::i2v::array<P> >& pv)
+ {
+ edge_image<P,V,G> tmp(edge_values, pv);
+ return tmp;
+ }
+
+
+
+ // data< pw::image >
+
+ namespace internal
+ {
+
+ template <typename P, typename V, typename G>
+ inline
+ data< mln::edge_image<P,V,G> >::data(const fun::i2v::array<V>& f,
+ const p_edges<G,fun::i2v::array<P> >& ps)
+ : f_(exact(f)),
+ pset_(ps)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+
+
+ // vertex_image<P,V,G>
+ template <typename P, typename V, typename G>
+ inline
+ edge_image<P,V,G>::edge_image()
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ inline
+ edge_image<P,V,G>::edge_image(const Graph<G>& g,
+ const Function_i2v< fun::i2v::array<P> >& edge_sites,
+ const Function_i2v< fun::i2v::array<V> >& edge_values)
+ : super_(exact(edge_values),
+ p_edges<G,fun::i2v::array<P> >(g, exact(edge_sites)))
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ inline
+ edge_image<P,V,G>::edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ const Function_i2v< fun::i2v::array<V> >& edge_values)
+ : super_(exact(edge_values), pv)
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ template <typename FP, typename FV>
+ inline
+ edge_image<P,V,G>::edge_image(const Graph<G>& g,
+ const Function_i2v<FP>& edge_sites,
+ const Function_i2v<FV>& edge_values)
+ : super_(convert::to<fun::i2v::array<V> >(exact(edge_values)),
+ p_edges<G,fun::i2v::array<P> >(g, exact(edge_sites)))
+ {
+ mlc_converts_to(FV,fun::i2v::array<V>)::check();
+ mlc_equal(mln_result(FP),P)::check();
+ mlc_equal(mln_result(FV),V)::check();
+ }
+
+
+
+ template <typename P, typename V, typename G>
+ template <typename FV>
+ inline
+ edge_image<P,V,G>::edge_image(const p_edges<G,fun::i2v::array<P> >& pv,
+ const Function_i2v<FV>& edge_values)
+ : super_(convert::to<fun::i2v::array<V> >(exact(edge_values)), pv)
+ {
+ mlc_converts_to(FV,fun::i2v::array<V>)::check();
+ mlc_equal(mln_result(FV),V)::check();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_IMAGE_EDGE_IMAGE_HH
diff --git a/milena/mln/core/image/essential.hh b/milena/mln/core/image/essential.hh
index 5b67315..31ab653 100644
--- a/milena/mln/core/image/essential.hh
+++ b/milena/mln/core/image/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,11 +28,9 @@
#ifndef MLN_CORE_IMAGE_ESSENTIAL_HH
# define MLN_CORE_IMAGE_ESSENTIAL_HH
-/*! \file mln/core/image/essential.hh
- *
- * \brief File that includes essential image types.
- *
- */
+/// \file mln/core/image/essential.hh
+///
+/// File that includes essential image types.
# include <mln/core/image/cast_image.hh>
# include <mln/core/image/image2d.hh>
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh b/milena/mln/core/image/graph_elt_neighborhood.hh
index 4de7669..e6bc46c 100644
--- a/milena/mln/core/image/graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/graph_elt_neighborhood.hh
@@ -41,11 +41,11 @@ namespace mln
{
/// Elementary neighborhood on graph class.
- template <typename G, typename F>
+ template <typename G, typename S>
struct graph_elt_neighborhood
- : public neighb< graph_elt_window<G,F> >
+ : public neighb< graph_elt_window<G,S> >
{
- typedef neighb< graph_elt_window<G,F> > super_;
+ typedef neighb< graph_elt_window<G,S> > super_;
graph_elt_neighborhood();
};
@@ -53,9 +53,9 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
-template <typename G, typename F>
+template <typename G, typename S>
inline
-graph_elt_neighborhood<G,F>::graph_elt_neighborhood()
+graph_elt_neighborhood<G,S>::graph_elt_neighborhood()
{
}
diff --git a/milena/mln/core/image/graph_elt_window.hh b/milena/mln/core/image/graph_elt_window.hh
index 6143c9e..9ca8f60 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_window.hh
@@ -1,5 +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
@@ -37,33 +37,55 @@
# include <mln/core/internal/neighborhood_base.hh>
# include <mln/core/internal/graph_window_base.hh>
# include <mln/core/image/graph_window_piter.hh>
-# include <mln/core/site_set/p_vertices.hh>
namespace mln
{
/// Forward declaration
- template <typename G, typename F> class graph_elt_window;
+ template <typename G, typename S> class graph_elt_window;
+ template <typename G, typename F> struct p_edges;
+ template <typename G, typename F> struct p_vertices;
namespace internal
{
- template <typename G, typename F, typename E>
- struct neighborhood_impl<graph_elt_window<G,F>,E>
- : public neighborhood_extra_impl<graph_elt_window<G,F>,E>
+ template <typename G, typename S, typename E>
+ struct neighborhood_impl<graph_elt_window<G,S>,E>
+ : public neighborhood_extra_impl<graph_elt_window<G,S>,E>
{
};
+
+ /// Default
+ /// The given site set parameter is not supported yet!
+ template <typename G, typename S>
+ struct graph_window_iter_dispatch;
+
+ template <typename G, typename F>
+ struct graph_window_iter_dispatch<G, p_edges<G,F> >
+ {
+ typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
+ typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
+ };
+
+ template <typename G, typename F>
+ struct graph_window_iter_dispatch<G, p_vertices<G,F> >
+ {
+ typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
+ typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
+ };
+
+
} // end of namespace mln::internal
namespace trait
{
- template <typename G, typename F>
- struct window_< mln::graph_elt_window<G, F> >
+ template <typename G, typename S>
+ struct window_< mln::graph_elt_window<G,S> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -74,20 +96,24 @@ namespace mln
/// Elementary window on graph class.
- template <typename G, typename F>
- class graph_elt_window : public graph_window_base<mln_result(F),
- graph_elt_window<G,F> >
-
+ /// \p G is the graph type.
+ /// \p S is the image site set.
+ template <typename G, typename S>
+ class graph_elt_window
+ : public graph_window_base<mln_result(S::fun_t),
+ graph_elt_window<G,S> >,
+ public internal::graph_window_iter_dispatch<G,S>
{
- typedef graph_elt_window<G, F> self_;
- typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
- typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
+ typedef graph_elt_window<G,S> self_;
+ typedef internal::graph_window_iter_dispatch<G,S> super_;
+ typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
+ typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
public:
/// Associated types.
/// \{
- typedef p_vertices<G,F> target;
+ typedef S target;
/// The type of psite corresponding to the window.
typedef mln_psite(target) psite;
diff --git a/milena/mln/core/image/line_graph_elt_neighborhood.hh b/milena/mln/core/image/line_graph_elt_neighborhood.hh
deleted file mode 100644
index da49fdf..0000000
--- a/milena/mln/core/image/line_graph_elt_neighborhood.hh
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
-# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
-
-/// \file mln/core/image/line_graph_elt_neighborhood.hh
-///
-/// Definition of the elementary ``neighborhood'' on a line graph.
-
-# include <mln/core/neighb.hh>
-# include <mln/core/image/line_graph_elt_window.hh>
-
-
-namespace mln
-{
-
- /// Elementary neighborhood on line graph class.
- template <typename G, typename F>
- struct line_graph_elt_neighborhood
- : public neighb< line_graph_elt_window<G,F> >
- {
- typedef neighb< line_graph_elt_window<G,F> > super_;
-
- line_graph_elt_neighborhood();
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-template <typename G, typename F>
-inline
-line_graph_elt_neighborhood<G,F>::line_graph_elt_neighborhood()
-{
-}
-
-# endif // ! MLN_INCLUDE_ONLY
-
-}
-
-#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
-
diff --git a/milena/mln/core/image/line_graph_elt_window.hh b/milena/mln/core/image/line_graph_elt_window.hh
deleted file mode 100644
index 1cb3fee..0000000
--- a/milena/mln/core/image/line_graph_elt_window.hh
+++ /dev/null
@@ -1,109 +0,0 @@
-// 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.
-
-#ifndef MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
-# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
-
-/// \file mln/core/image/line_graph_elt_window.hh
-///
-/// Definition of the elementary ``window'' on a line graph.
-
-# include <mln/core/concept/window.hh>
-# include <mln/core/internal/neighborhood_base.hh>
-# include <mln/core/internal/graph_window_base.hh>
-# include <mln/core/image/graph_window_piter.hh>
-# include <mln/core/site_set/p_edges.hh>
-
-
-namespace mln
-{
-
- /// Forward declaration
- template <typename G, typename F> class line_graph_elt_window;
-
-
- namespace internal
- {
-
- template <typename G, typename F, typename E>
- struct neighborhood_impl<line_graph_elt_window<G,F>,E>
- : public neighborhood_extra_impl<line_graph_elt_window<G,F>,E>
- {
- };
-
- } // end of namespace mln::internal
-
-
- namespace trait
- {
-
- template <typename G, typename F>
- struct window_< mln::line_graph_elt_window<G, F> >
- {
- typedef trait::window::size::unknown size;
- typedef trait::window::support::irregular support;
- typedef trait::window::definition::varying definition;
- };
-
- } // end of namespace mln::trait
-
-
- /// Elementary window on line graph class.
- template <typename G, typename F>
- class line_graph_elt_window : public graph_window_base<mln_result(F),
- line_graph_elt_window<G, F> >
- {
- typedef line_graph_elt_window<G, F> self_;
- typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
- typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
-
- public:
- /// Associated types.
- /// \{
- typedef p_edges<G,F> target;
- // The type of psite corresponding to the window.
- typedef mln_psite(target) psite;
-
- /// Site_Iterator type to browse the psites of the window
- /// w.r.t. the ordering of edges.
- typedef graph_window_piter<target,self_,nbh_fwd_iter_> fwd_qiter;
-
- /// Site_Iterator type to browse the psites of the window
- /// w.r.t. the reverse ordering of edges.
- typedef graph_window_piter<target,self_,nbh_bkd_iter_> bkd_qiter;
-
- /// The default qiter type.
- typedef fwd_qiter qiter;
- /// \}
-
- };
-
-} // end of namespace mln
-
-
-#endif // ! MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
diff --git a/milena/mln/core/image/vertex_image.hh b/milena/mln/core/image/vertex_image.hh
new file mode 100644
index 0000000..09aa15b
--- /dev/null
+++ b/milena/mln/core/image/vertex_image.hh
@@ -0,0 +1,250 @@
+// 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_CORE_IMAGE_VERTEX_IMAGE_HH
+# define MLN_CORE_IMAGE_VERTEX_IMAGE_HH
+
+/// \file mln/core/image/vertex_image.hh
+///
+/// Image based on graph vertices.
+
+# include <mln/core/concept/graph.hh>
+# include <mln/core/image/graph_elt_window.hh>
+# include <mln/core/image/graph_elt_neighborhood.hh>
+# include <mln/core/site_set/p_vertices.hh>
+# include <mln/pw/internal/image_base.hh>
+# include <mln/fun/i2v/array.hh>
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename P, typename V, typename G> class vertex_image;
+ namespace util { class graph; }
+
+
+ // Properties
+
+ namespace trait
+ {
+
+ template <typename P, typename V, typename G>
+ struct image_< vertex_image<P,V,G> >
+ : pw_image_<fun::i2v::array<V>,
+ p_vertices<util::graph, fun::i2v::array<P> >,
+ vertex_image<P,V,G> >
+ {
+ };
+
+ } // end of namespace mln::traits.
+
+
+
+ namespace internal
+ {
+
+ /// Data structure for mln::pw::internal::image
+ template <typename P, typename V, typename G>
+ struct data< mln::vertex_image<P,V,G> >
+ {
+ data(const fun::i2v::array<V>& vertex_values,
+ const p_vertices<G,fun::i2v::array<P> >& pv);
+
+ fun::i2v::array<V> f_;
+ p_vertices<G,fun::i2v::array<P> > pset_;
+ };
+
+ } // end of namespace mln::internal
+
+
+
+ /// Construct a vertex image from a fun::i2v::array and a p_vertices.
+ /// image = fun::i2v::array | p_vertices.
+ template <typename V, typename G, typename P>
+ vertex_image<P,V,G>
+ operator | (const fun::i2v::array<V>& vertex_values,
+ const p_vertices<G,fun::i2v::array<P> >& pv);
+
+
+ template <typename P, typename V, typename G = util::graph>
+ class vertex_image
+ : public pw::internal::image_base<fun::i2v::array<V>,
+ p_vertices<G, fun::i2v::array<P> >,
+ vertex_image<P,V,G> >
+ {
+ typedef pw::internal::image_base<fun::i2v::array<V>,
+ p_vertices<G, fun::i2v::array<P> >,
+ vertex_image<P,V,G> > super_;
+
+ public:
+ /// Skeleton type.
+ typedef vertex_image< tag::psite_<P>,
+ tag::value_<V>,
+ tag::graph_<G> > skeleton;
+
+ /// Function mapping graph elements to sites.
+ typedef fun::i2v::array<P> site_function_t;
+
+ /// Window type
+ typedef graph_elt_window<G,p_vertices<G,site_function_t> > win_t;
+ /// Neighborhood type.
+ typedef graph_elt_neighborhood<G,p_vertices<G,site_function_t> > nbh_t;
+
+ /// Constructors.
+ /// @{
+ vertex_image();
+ vertex_image(const Graph<G>& g,
+ const Function_i2v< fun::i2v::array<P> >& vertex_sites,
+ const Function_i2v< fun::i2v::array<V> >& vertex_values);
+
+ vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ const Function_i2v< fun::i2v::array<V> >& vertex_values);
+
+ template <typename FP, typename FV>
+ vertex_image(const Graph<G>& g,
+ const Function_i2v<FP>& vertex_sites,
+ const Function_i2v<FV>& vertex_values);
+
+ template <typename FV>
+ vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ const Function_i2v<FV>& vertex_values);
+ /// @}
+
+ };
+
+ template <typename P, typename V, typename G, typename J>
+ void init_(tag::image_t, vertex_image<P,V,G>& target, const Image<J>& model);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename V, typename G, typename J>
+ void init_(tag::image_t, vertex_image<P,V,G>& target, const Image<J>& model)
+ {
+ fun::i2v::array<V> f;
+ init_(tag::function, f, exact(model));
+ p_vertices<G,fun::i2v::array<P> > s;
+ init_(tag::domain, s, exact(model));
+ target.init_(f, s);
+ }
+
+ // Operator.
+
+ template <typename V, typename G, typename P>
+ inline
+ vertex_image<P,V,G>
+ operator | (const fun::i2v::array<V>& vertex_values,
+ const p_vertices<G,fun::i2v::array<P> >& pv)
+ {
+ vertex_image<P,V,G> tmp(vertex_values, pv);
+ return tmp;
+ }
+
+
+
+ // data< pw::image >
+
+ namespace internal
+ {
+
+ template <typename P, typename V, typename G>
+ inline
+ data< mln::vertex_image<P,V,G> >::data(const fun::i2v::array<V>& f,
+ const p_vertices<G,fun::i2v::array<P> >& ps)
+ : f_(f),
+ pset_(ps)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+
+
+ // vertex_image<P,V,G>
+
+ template <typename P, typename V, typename G>
+ inline
+ vertex_image<P,V,G>::vertex_image()
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ inline
+ vertex_image<P,V,G>::vertex_image(const Graph<G>& g,
+ const Function_i2v< fun::i2v::array<P> >& vertex_sites,
+ const Function_i2v< fun::i2v::array<V> >& vertex_values)
+ : super_(exact(vertex_values),
+ p_vertices<G,fun::i2v::array<P> >(g, exact(vertex_sites)))
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ inline
+ vertex_image<P,V,G>::vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ const Function_i2v< fun::i2v::array<V> >& vertex_values)
+ : super_(exact(vertex_values), pv)
+ {
+ }
+
+
+ template <typename P, typename V, typename G>
+ template <typename FP, typename FV>
+ inline
+ vertex_image<P,V,G>::vertex_image(const Graph<G>& g,
+ const Function_i2v<FP>& vertex_sites,
+ const Function_i2v<FV>& vertex_values)
+ : super_(convert::to<fun::i2v::array<V> >(exact(vertex_values)),
+ p_vertices<G,fun::i2v::array<P> >(g, vertex_sites))
+ {
+ mlc_converts_to(FV,fun::i2v::array<V>)::check();
+ mlc_equal(mln_result(FP),P)::check();
+ mlc_equal(mln_result(FV),V)::check();
+ }
+
+
+
+ template <typename P, typename V, typename G>
+ template <typename FV>
+ inline
+ vertex_image<P,V,G>::vertex_image(const p_vertices<G,fun::i2v::array<P> >& pv,
+ const Function_i2v<FV>& vertex_values)
+ : super_(convert::to<fun::i2v::array<V> >(exact(vertex_values)), pv)
+ {
+ mlc_converts_to(FV,fun::i2v::array<V>)::check();
+ mlc_equal(mln_result(FV),V)::check();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+#endif // ! MLN_CORE_IMAGE_VERTEX_IMAGE_HH
diff --git a/milena/mln/core/internal/image_base.hh b/milena/mln/core/internal/image_base.hh
index 74be188..a254b54 100644
--- a/milena/mln/core/internal/image_base.hh
+++ b/milena/mln/core/internal/image_base.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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,11 @@
#ifndef MLN_CORE_INTERNAL_IMAGE_BASE_HH
# define MLN_CORE_INTERNAL_IMAGE_BASE_HH
-/*! \file mln/core/internal/image_base.hh
- *
- * \brief Definition of the common base class for all images.
- *
- * \todo Provide coord iff the site is a grid point.
- */
+/// \file mln/core/internal/image_base.hh
+///
+/// Definition of the common base class for all images.
+///
+/// \todo Provide coord iff the site is a grid point.
# include <mln/core/concept/image.hh>
# include <mln/core/grids.hh>
@@ -51,11 +50,11 @@
// ---------------------------
// | |
// image_primary image_morpher
-// ^
-// |
-// -----------------------------------------
-// | | |
-// image_domain_morpher image_value_morpher image_identity
+// ^ ^
+// | |
+// | -----------------------------------------
+// | | | |
+// pw_image_base image_domain_morpher image_value_morpher image_identity
namespace mln
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index d80789f..c17ae1d 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -82,10 +82,10 @@ namespace mln
/// Add more implementation for neighborhoods made from a
/// graph_window_piter.
- template <typename G, typename F, typename E>
- struct neighb_niter_impl<graph_elt_window<G,F>, E>
- : public neighb_niter_impl< graph_window_base< mln_result(F),
- graph_elt_window<G, F> >,
+ template <typename G, typename S, typename E>
+ struct neighb_niter_impl<graph_elt_window<G,S>, E>
+ : public neighb_niter_impl< graph_window_base< mln_result(S::fun_t),
+ graph_elt_window<G,S> >,
E >
{
diff --git a/milena/mln/core/routine/init.hxx b/milena/mln/core/routine/init.hxx
index cfeb5ea..46b4045 100644
--- a/milena/mln/core/routine/init.hxx
+++ b/milena/mln/core/routine/init.hxx
@@ -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
@@ -39,38 +40,43 @@ namespace mln
// Forward declarations.
namespace fun { namespace i2v { template <typename T> class array; } }
namespace fun { namespace l2l { template <typename T> class relabel; } }
+ namespace pw { namespace internal { template <typename F, typename S, typename E> class image_base; } }
namespace pw { template <typename F, typename S> class image; }
template <typename I, typename F> class image_if;
/// Kind: function_t
- /// Type: F,
+ /// Type: F1,
/// From: pw::image<F,S>
- template <typename F, typename S>
- void init_(tag::function_t, F& f, const pw::image<F,S>& model);
+ template <typename F, typename S, typename E, typename J>
+ void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model);
+ /// Kind: image_t
+ /// Type: vertex_image<P,V,G>
+ /// From: J
+ template <typename P, typename V, typename G, typename J>
+ void init_(tag::image_t, vertex_image<P,V,G>& target, const Image<J>& model);
/// Kind: image_t
- /// Type: pw::image<F,S>
+ /// Type: F
/// From: J
- template <typename F, typename S, typename J>
- void init_(tag::image_t, mln::pw::image<F,S>& target, const J& model);
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, image_if<I,F>& target, const J& model);
/// Kind: function_t
+ /// Type: F,
+ /// From: pw::internal::image_base<F,S,E>
+ template <typename F, typename S, typename E>
+ void init_(tag::function_t, F& f, const pw::internal::image_base<F,S,E>& model);
+
+ /// Kind: function_t
/// Type: F
/// From: image_if<I,F>
template <typename I, typename F>
void init_(tag::function_t, F& f, const image_if<I,F>& model);
- /// Kind: image_t
- /// Type: F
- /// From: J
- template <typename I, typename F, typename J>
- void init_(tag::image_t, image_if<I,F>& target, const J& model);
-
-
/// Kind: function_t
/// Type: fun::i2v::array<T1>
/// From: fun::i2v::array<T2>
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index 5111c93..ad07474 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -33,6 +33,8 @@
///
/// Definition of a site set based on graph edges.
+# include <mln/core/concept/function.hh>
+# include <mln/core/concept/graph.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
# include <mln/core/site_set/p_edges_psite.hh>
@@ -82,14 +84,25 @@ namespace mln
/// Type of graph element this site set focuses on.
typedef util::edge<G> graph_element;
+ /// Constructors
+ /// @{
+ /// Default constructor.
+ p_edges();
/// Construct a graph edge psite set from a graph and a function.
///
/// \param gr The graph upon which the graph edge psite set is built.
/// \param f the function mapping edges and sites.
- p_edges(const G& gr, const F& f);
- /// Default constructor.
- p_edges();
+ p_edges(const Graph<G>& gr, const Function<F>& f);
+
+ /// Construct a graph edge psite set from a graph and a function.
+ ///
+ /// \param gr The graph upon which the graph edge psite set is built.
+ /// \param f the function mapping edges and sites.
+ /// It must be convertible towards the function type \c F.
+ template <typename F2>
+ p_edges(const Graph<G>& gr, const Function<F2>& f);
+ ///@}
/// Associated types.
/// \{
@@ -128,6 +141,10 @@ namespace mln
template <typename G2>
bool has(const util::edge<G2>& e) const;
+ /// Does this site set has \a vertex_id?
+ /// FIXME: causes ambiguities while calling has(mln::neighb_fwd_niter<>);
+ /// bool has(unsigned vertex_id) const;
+
// FIXME: Dummy.
std::size_t memory_size() const;
@@ -171,19 +188,35 @@ namespace mln
namespace mln
{
+
template <typename G, typename F>
inline
- p_edges<G, F>::p_edges(const G& g, const F& f)
- : g_ (g), f_(f)
+ p_edges<G, F>::p_edges()
{
}
template <typename G, typename F>
inline
- p_edges<G, F>::p_edges()
+ p_edges<G, F>::p_edges(const Graph<G>& g, const Function<F>& f)
+ {
+ mln_precondition(exact(g).is_valid());
+ g_ = exact(g);
+ f_ = exact(f);
+ }
+
+ template <typename G, typename F>
+ template <typename F2>
+ inline
+ p_edges<G, F>::p_edges(const Graph<G>& g, const Function<F2>& f)
{
+ mln_precondition(exact(g).is_valid());
+ mlc_converts_to(F2,F)::check();
+
+ g_ = exact(g);
+ convert::from_to(f, f_);
}
+
template <typename G, typename F>
inline
unsigned
@@ -235,6 +268,16 @@ namespace mln
return e.graph().is_subgraph_of(g_) && g_.has(e) && e.is_valid();
}
+// template <typename G, typename F>
+// inline
+// bool
+// p_edges<G,F>::has(unsigned edge_id) const
+// {
+// mln_precondition(is_valid());
+// util::edge<G> e(g_, edge_id);
+// return has(e);
+// }
+
template <typename G, typename F>
inline
std::size_t
diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh
index e6f4ce8..5642446 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -1,5 +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
@@ -85,7 +85,7 @@ namespace mln
/// Return the graph associated to the target S.
const typename S::graph_t& graph() const;
- /// Return the underlying iterator.
+ /// Return the underlying graph element iterator.
const iter& hook_elt_() const;
/// Convert towards the graph element id.
diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh
index a095af3..b20d19b 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -33,6 +33,7 @@
///
/// Definition of a point set based on a graph.
+# include <mln/core/concept/function.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
# include <mln/core/site_set/p_vertices_psite.hh>
@@ -94,7 +95,14 @@ namespace mln
/// Construct a graph psite set from a graph of points.
/// \param gr The graph upon which the graph psite set is built.
/// \param f the function which maps a vertex to a site.
- p_vertices(const G& gr, const F& f);
+ p_vertices(const Graph<G>& gr, const Function<F>& f);
+
+ /// Construct a graph psite set from a graph of points.
+ /// \param gr The graph upon which the graph psite set is built.
+ /// \param f the function which maps a vertex to a site.
+ /// It must be convertible to the function type \c F.
+ template <typename F2>
+ p_vertices(const Graph<G>& gr, const Function<F2>& f);
/// \}
@@ -139,7 +147,11 @@ namespace mln
/// Does this site set has \a v?
template <typename G2>
- bool has(const util::vertex<G2>& p) const;
+ bool has(const util::vertex<G2>& v) const;
+
+ /// Does this site set has \a vertex_id?
+ /// FIXME: causes ambiguities while calling has(mln::neighb_fwd_niter<>);
+ /// bool has(unsigned vertex_id) const;
// FIXME: Dummy.
std::size_t memory_size() const;
@@ -202,9 +214,23 @@ namespace mln
template <typename G, typename F>
inline
- p_vertices<G,F>::p_vertices(const G& g, const F& f)
- : g_ (g), f_(f)
+ p_vertices<G,F>::p_vertices(const Graph<G>& g, const Function<F>& f)
+ {
+ mln_precondition(exact(g).is_valid());
+ g_ = exact(g);
+ f_ = exact(f);
+ }
+
+ template <typename G, typename F>
+ template <typename F2>
+ inline
+ p_vertices<G,F>::p_vertices(const Graph<G>& g, const Function<F2>& f)
{
+ mln_precondition(exact(g).is_valid());
+ mlc_converts_to(F2,F)::check();
+
+ g_ = exact(g);
+ convert::from_to(f, f_);
}
template <typename G, typename F>
@@ -252,17 +278,28 @@ namespace mln
template <typename G2>
inline
bool
- p_vertices<G,F>::has(const util::vertex<G2>& p) const
+ p_vertices<G,F>::has(const util::vertex<G2>& v) const
{
mln_precondition(is_valid());
return
- // Check whether P is compatible with this psite set.
- (p.graph() == g_) &&
+ // Check whether if the graph is 'compatible'.
+ v.graph().is_subgraph_of(g_) &&
+ g_.has(v) &&
// Check that the vertex id of P belongs to the range of valid
// vertex ids.
- (p.is_valid());
+ (v.is_valid());
}
+// template <typename G, typename F>
+// inline
+// bool
+// p_vertices<G,F>::has(unsigned vertex_id) const
+// {
+// mln_precondition(is_valid());
+// util::vertex<G> v(g_, vertex_id);
+// return has(v);
+// }
+
template <typename G, typename F>
inline
std::size_t
diff --git a/milena/mln/debug/draw_graph.hh b/milena/mln/debug/draw_graph.hh
index abc96a4..7584b4e 100644
--- a/milena/mln/debug/draw_graph.hh
+++ b/milena/mln/debug/draw_graph.hh
@@ -38,8 +38,10 @@
# include <mln/core/site_set/p_vertices.hh>
# include <mln/core/site_set/p_edges.hh>
# include <mln/util/line_graph.hh>
+# include <mln/util/site_pair.hh>
# include <mln/draw/line.hh>
# include <mln/data/fill.hh>
+# include <mln/metal/equal.hh>
namespace mln
{
@@ -92,6 +94,8 @@ namespace mln
mln_value(I) vertex_v,
mln_value(I) edge_v)
{
+ trace::entering("debug::draw_graph");
+
// Draw edges.
typedef p_edges<G, F> pe_t;
mln_piter(pe_t) p(pe);
@@ -105,6 +109,7 @@ namespace mln
exact(ima)(p.second()) = vertex_v;
}
+ trace::exiting("debug::draw_graph");
}
@@ -116,6 +121,8 @@ namespace mln
mln_value(I) vertex_v,
mln_value(I) edge_v)
{
+ trace::entering("debug::draw_graph");
+
// Draw edges.
const G& g = pv.graph();
typedef p_vertices<G, F> pv_t;
@@ -128,6 +135,8 @@ namespace mln
for_all(p)
if (exact(ima).has(p))
exact(ima)(p) = vertex_v;
+
+ trace::exiting("debug::draw_graph");
}
// FIXME: Refactor + be more restrictive on the function type.
@@ -138,6 +147,8 @@ namespace mln
const p_vertices<G, F>& pv,
const Function<V>& vcolor_, const Function<E>& ecolor_)
{
+ trace::entering("debug::draw_graph");
+
const V& vcolor = exact(vcolor_);
const E& ecolor = exact(ecolor_);
@@ -153,6 +164,8 @@ namespace mln
for_all(p)
if (exact(ima).has(p))
exact(ima)(p) = vcolor(p);
+
+ trace::exiting("debug::draw_graph");
}
// FIXME: Refactor + be more restrictive on the function type.
@@ -163,6 +176,8 @@ namespace mln
const p_vertices<util::line_graph<G>, F>& pv,
const Function<V>& vcolor_, const Function<E>& ecolor_)
{
+ trace::entering("debug::draw_graph");
+
const V& vcolor = exact(vcolor_);
const E& ecolor = exact(ecolor_);
@@ -184,6 +199,8 @@ namespace mln
if (exact(ima).has(l.end()))
exact(ima)(l.end()) = vcolor(g.edge(vi).v2());
}
+
+ trace::exiting("debug::draw_graph");
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/morpho/attribute/count_adjacent_vertices.hh b/milena/mln/morpho/attribute/count_adjacent_vertices.hh
index 8c8df76..49e08b3 100644
--- a/milena/mln/morpho/attribute/count_adjacent_vertices.hh
+++ b/milena/mln/morpho/attribute/count_adjacent_vertices.hh
@@ -25,6 +25,7 @@
// 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_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_
# define MLN_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_
@@ -32,7 +33,10 @@
///
/// Define an accumulator that counts the vertices adjacent to a
/// set of p_edges psites.
+///
+/// \todo Check that the image is based on a graph.
+# include <mln/pw/internal/image_base.hh>
# include <mln/accu/internal/base.hh>
# include <mln/pw/image.hh>
# include <mln/util/pix.hh>
@@ -76,12 +80,12 @@ namespace mln
///
/// The parameter \p I is the image type on which the accumulator
/// of pixels is built.
-
- template <typename F, typename S>
- struct count_adjacent_vertices< pw::image<F, S> >
- : public accu::internal::base< unsigned , count_adjacent_vertices< pw::image<F, S> > >
+ //
+ template <typename I>
+ struct count_adjacent_vertices
+ : public accu::internal::base< unsigned ,
+ count_adjacent_vertices<I> >
{
- typedef pw::image<F, S> I;
typedef mln_psite(I) argument;
count_adjacent_vertices();
@@ -117,70 +121,70 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- template <typename F, typename S>
+ template <typename I>
inline
- count_adjacent_vertices< pw::image<F, S> >::count_adjacent_vertices()
+ count_adjacent_vertices<I>::count_adjacent_vertices()
{
init();
}
- template <typename F, typename S>
+ template <typename I>
inline
void
- count_adjacent_vertices< pw::image<F, S> >::init()
+ count_adjacent_vertices<I>::init()
{
vertices_.clear();
update_();
}
- template <typename F, typename S>
+ template <typename I>
inline
void
- count_adjacent_vertices< pw::image<F,S> >::take(const argument& p)
+ count_adjacent_vertices<I>::take(const argument& p)
{
vertices_.insert(p.v1());
vertices_.insert(p.v2());
update_();
}
- template <typename F, typename S>
+ template <typename I>
inline
void
- count_adjacent_vertices< pw::image<F,S> >::take(const count_adjacent_vertices< pw::image <F,S> >& other)
+ count_adjacent_vertices<I>::take(const count_adjacent_vertices<I>& other)
{
vertices_.insert (other.vertices_.begin(), other.vertices_.end());
update_();
}
- template <typename F, typename S>
+ template <typename I>
inline
void
- count_adjacent_vertices< pw::image<F,S> >::take_as_init(const argument& px)
+ count_adjacent_vertices<I>::take_as_init(const argument& px)
{
vertices_.clear();
take(px);
}
- template <typename F, typename S>
+ template <typename I>
inline
unsigned
- count_adjacent_vertices< pw::image<F,S> >::to_result() const
+ count_adjacent_vertices<I>::to_result() const
{
return count__;
}
- template <typename F, typename S>
+ template <typename I>
inline
void
- count_adjacent_vertices< pw::image<F,S> >::update_()
+ count_adjacent_vertices<I>::update_()
{
count__ = vertices_.size();
}
- template <typename F, typename S>
+ template <typename I>
inline
bool
- count_adjacent_vertices< pw::image<F,S> >::is_valid() const
+ count_adjacent_vertices<I>::is_valid() const
{
return true;
}
@@ -194,4 +198,4 @@ namespace mln
} // end of namespace mln
-#endif /* !MLN_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_ */
+#endif // ! MLN_MORPHO_ATTRIBUTE_COUNT_ADJACENT_VERTICES_HH_
diff --git a/milena/mln/morpho/closing/area_on_vertices.hh b/milena/mln/morpho/closing/area_on_vertices.hh
index 6087112..099e473 100644
--- a/milena/mln/morpho/closing/area_on_vertices.hh
+++ b/milena/mln/morpho/closing/area_on_vertices.hh
@@ -1,5 +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
@@ -35,7 +35,7 @@
/// the area in terms of adjacent vertices.
# include <mln/pw/image.hh>
-# include <mln/core/site_set/p_edges.hh>
+# include <mln/core/image/edge_image.hh>
# include <mln/morpho/closing/algebraic.hh>
# include <mln/morpho/attribute/count_adjacent_vertices.hh>
@@ -49,38 +49,38 @@ namespace mln
namespace closing
{
- /// Morphological area closing on a mln::line_graph_image computing
- /// the area in terms of adjacent vertices.
- template <typename P2V, typename G, typename V2P, typename N>
- pw::image<P2V, p_edges<G, V2P> >
- area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ /// Morphological area closing on a mln::line_graph_image computing
+ /// the area in terms of adjacent vertices.
+ template <typename P, typename V, typename G, typename N>
+ edge_image<P,V,G>
+ area_on_vertices(const edge_image<P,V,G>& input,
const Neighborhood<N>& nbh,
unsigned lambda);
# ifndef MLN_INCLUDE_ONLY
- template <typename P2V, typename G, typename V2P, typename N>
+ template <typename P, typename V, typename G, typename N>
inline
- pw::image<P2V, p_edges<G, V2P> >
- area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
+ edge_image<P,V,G>
+ area_on_vertices(const edge_image<P,V,G>& input,
const Neighborhood<N>& nbh,
unsigned lambda)
{
trace::entering("morpho::closing::area_on_vertices");
mln_precondition(exact(input).is_valid());
- typedef p_edges<G, V2P> pe_t;
- typedef attribute::count_adjacent_vertices< pw::image<P2V, pe_t> > attribute_t;
+ typedef attribute::count_adjacent_vertices< edge_image<P,V,G> > attribute_t;
- pw::image<P2V, p_edges<G, V2P> > output;
- output = closing::algebraic(input, nbh, attribute_t(), lambda);
+ edge_image<P,V,G>
+ output = closing::algebraic(input, nbh, attribute_t(), lambda);
trace::exiting("morpho::closing::area_on_vertices");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln::morpho::closing
} // end of namespace mln::morpho
diff --git a/milena/mln/morpho/line_gradient.hh b/milena/mln/morpho/line_gradient.hh
index 4b12d4a..32b5975 100644
--- a/milena/mln/morpho/line_gradient.hh
+++ b/milena/mln/morpho/line_gradient.hh
@@ -1,4 +1,4 @@
-// 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
@@ -43,10 +43,9 @@
# include <mln/util/ord.hh>
# include <mln/core/image/image2d.hh>
+# include <mln/core/image/edge_image.hh>
# include <mln/core/alias/window2d.hh>
-# include <mln/core/site_set/p_edges.hh>
-
# include <mln/util/graph.hh>
# include <mln/util/site_pair.hh>
@@ -65,22 +64,25 @@ namespace mln
/* FIXME: Currently, the adjacency is set to 4-c and cannot be
changed. */
template <typename V>
- pw::image<fun::i2v::array<V>, p_edges<util::graph, fun::i2v::array< util::site_pair<point2d> > > >
+ edge_image<util::site_pair<point2d>, V, util::graph>
line_gradient(const mln::image2d<V>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename V>
- pw::image<fun::i2v::array<V>, p_edges<util::graph, fun::i2v::array< util::site_pair<point2d> > > >
+ edge_image<util::site_pair<point2d>, V, util::graph>
line_gradient(const mln::image2d<V>& ima)
{
+ trace::entering("morpho::line_gradient");
+ mln_precondition(ima.is_valid());
+
// FIXME: Precondition: Ensure the image is scalar.
util::graph g;
// Vertices.
image2d<unsigned> vpsite(ima.domain());
- fun::i2v::array<mln::point2d> fv2p(ima.domain().nsites());
+ fun::i2v::array<point2d> fv2p(ima.domain().nsites());
fun::i2v::array<V> vertex_values(ima.domain().nsites());
mln_fwd_piter(image2d<V>) p(ima.domain());
@@ -111,12 +113,10 @@ namespace mln
edge_sites.append(util::site_pair<point2d>(p, q));
}
- // Line graph point set.
- typedef p_edges<util::graph, edge_sites_t> pe_t;
- pe_t plg(g, edge_sites);
- // Line graph image.
- typedef pw::image<edge_values_t, pe_t> ima_t;
- ima_t lg_ima = (edge_values | plg);
+ edge_image<util::site_pair<point2d>, V, util::graph>
+ lg_ima(g, edge_sites, edge_values);
+
+ trace::exiting("morpho::line_gradient");
return lg_ima;
}
diff --git a/milena/mln/pw/image.hh b/milena/mln/pw/image.hh
index 49a0afa..e96233e 100644
--- a/milena/mln/pw/image.hh
+++ b/milena/mln/pw/image.hh
@@ -1,5 +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
@@ -31,14 +31,11 @@
/// \file mln/pw/image.hh
///
-/// FIXME.
+/// Point-wised restricted image.
-
-# include <mln/core/internal/image_primary.hh>
+# include <mln/pw/internal/image_base.hh>
# include <mln/core/concept/function.hh>
# include <mln/value/set.hh>
-# include <mln/metal/unqualif.hh>
-# include <mln/metal/not_equal.hh>
namespace mln
@@ -48,19 +45,24 @@ namespace mln
namespace pw { template <typename F, typename S> class image; }
+ // Properties
- /// Construct an image from a function and a site set.
- /// image = function | site_set.
- template <typename F, typename S>
- pw::image<F,S>
- operator | (const Function_v2v<F>& f, const Site_Set<S>& ps);
+ namespace trait
+ {
+ template <typename F, typename S>
+ struct image_< pw::image<F,S> >
+ : pw_image_<F,S, pw::image<F,S> >
+ {
+ };
+
+ } // end of namespace mln::traits.
namespace internal
{
- /// Data structure for mln::pw::image
+ /// Data structure for mln::pw::internal::image
template <typename F, typename S>
struct data< mln::pw::image<F,S> >
{
@@ -72,127 +74,52 @@ namespace mln
} // end of namespace mln::internal
-
- namespace trait
- {
-
- // FIXME: the result type should *not* be qualified
-
- template <typename F, typename S>
- struct image_< pw::image<F,S> > : default_image_< mln_result(F),
- pw::image<F,S> >
- {
- private:
- typedef typename F::mutable_result mutable_result;
- typedef mlc_not_equal(mutable_result, void) is_mutable;
-
- public:
- // misc
- typedef trait::image::category::primary category;
- typedef trait::image::speed::fast speed;
- typedef trait::image::size::regular size;
-
- // value
- typedef trait::image::vw_io::none vw_io;
- typedef trait::image::vw_set::none vw_set;
- typedef trait::image::value_access::computed value_access;
- typedef trait::image::value_storage::disrupted value_storage;
- typedef trait::image::value_browsing::site_wise_only value_browsing;
- typedef trait::image::value_alignment::irrelevant value_alignment;
- typedef mlc_if(is_mutable,
- trait::image::value_io::read_write,
- trait::image::value_io::read_only) value_io;
-
- // site / domain
- typedef mlc_if(is_mutable,
- trait::image::pw_io::read_write,
- trait::image::pw_io::read) pw_io;
- typedef /* FIXME: depends on S */ undef localization;
- typedef /* FIXME: depends on S */ undef dimension;
-
- // extended domain
- typedef trait::image::ext_domain::none ext_domain;
- typedef trait::image::ext_value::irrelevant ext_value;
- typedef trait::image::ext_io::irrelevant ext_io;
- };
-
- } // end of namespace mln::trait
+ /// Construct an image from a function and a site set.
+ /// image = function | site_set.
+ template <typename F, typename S>
+ pw::image<F,S>
+ operator | (const Function_v2v<F>& f, const Site_Set<S>& ps);
namespace pw
{
- /// FIXME
- ///
+ /// A generic point-wise image implementation.
+ /// Parameter \p F is a function restricting the domain.
+ /// Parameter \p S is the domain type.
template <typename F, typename S>
class image :
- public internal::image_primary<mln_result(F), S, image<F,S> >
+ public pw::internal::image_base< F, S, image<F,S> >
{
- typedef typename F::mutable_result mutable_result;
- typedef mlc_not_equal(mutable_result, void) is_mutable;
+ typedef pw::internal::image_base< F, S, image<F,S> > super_;
public:
-
/// Skeleton.
typedef image< tag::function_<F>, tag::pset_<S> > skeleton;
- /// Function associated type.
- typedef F function_t;
-
- /// Value associated type.
- typedef mln_result(F) value;
-
- /// Return type of read-only access.
- typedef mln_result(F) rvalue;
-
- /// Return type of read-write access.
- typedef mlc_if(is_mutable, mutable_result, mln_result(F)) lvalue;
-
/// Constructor without argument.
image();
/// Constructor.
image(const Function_v2v<F>& f, const Site_Set<S>& ps);
- /// Initialize an empty image.
- void init_(const Function_v2v<F>& f, const Site_Set<S>& ps);
-
- /// Give the definition domain.
- const S& domain() const;
-
- /// Return the function which computes a site value.
- F function() const;
-
- /// Read-only access of pixel value at point site \p p.
- rvalue operator()(const mln_psite(S)& p) const;
-
- /// Read-write access returns either a temporary value (copy) or
- /// a reference in the case of a mutable function (container).
- lvalue operator()(const mln_psite(S)& p);
};
} // end of namespace mln::pw
+ /// Init_
-# ifndef MLN_INCLUDE_ONLY
+ template <typename F, typename S, typename E, typename J>
+ void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model);
- // init_
- template <typename F, typename S>
- void init_(tag::function_t, F& f, const pw::image<F,S>& model)
- {
- f = model.function();
- }
+# ifndef MLN_INCLUDE_ONLY
- template <typename F1, typename F2, typename S>
- void init_(tag::function_t, F1& f, const pw::image<F2,S>& model)
- {
- init_(tag::function, f, model.function());
- }
+ /// Init_
- template <typename F, typename S, typename J>
- void init_(tag::image_t, pw::image<F,S>& target, const J& model)
+ template <typename F, typename S, typename E, typename J>
+ void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model)
{
F f;
init_(tag::function, f, exact(model));
@@ -201,6 +128,7 @@ namespace mln
target.init_(f, s);
}
+
// Operator.
template <typename F, typename S>
@@ -212,7 +140,8 @@ namespace mln
return tmp;
}
- // internal::data< pw::image<F,S> >
+
+ // data< pw::image >
namespace internal
{
@@ -221,11 +150,13 @@ namespace mln
inline
data< mln::pw::image<F,S> >::data(const F& f, const S& ps)
: f_(f),
- pset_(ps)
+ pset_(ps)
{
}
- }
+ } // end of namespace mln::internal
+
+
// pw::image<F,S>
@@ -242,51 +173,9 @@ namespace mln
inline
image<F,S>::image(const Function_v2v<F>& f, const Site_Set<S>& ps)
{
- this->data_ = new internal::data< pw::image<F,S> >(exact(f), exact(ps));
+ this->data_ = new mln::internal::data< image<F,S> >(exact(f), exact(ps));
}
- template <typename F, typename S>
- inline
- void
- image<F,S>::init_(const Function_v2v<F>& f, const Site_Set<S>& ps)
- {
- this->data_ = new internal::data< image<F,S> >(exact(f), exact(ps));
- }
-
- template <typename F, typename S>
- inline
- const S&
- image<F,S>::domain() const
- {
- return this->data_->pset_;
- }
-
- template <typename F, typename S>
- inline
- F
- image<F,S>:: function() const
- {
- return this->data_->f_;
- }
-
-
- template <typename F, typename S>
- inline
- typename image<F,S>::rvalue
- image<F,S>::operator()(const mln_psite(S)& p) const
- {
- mln_precondition(this->data_->pset_.has(p));
- return this->data_->f_(p);
- }
-
- template <typename F, typename S>
- inline
- typename image<F,S>::lvalue
- image<F,S>::operator()(const mln_psite(S)& p)
- {
- mln_precondition(this->data_->pset_.has(p));
- return this->data_->f_(p);
- }
} // end of namespace mln::pw
diff --git a/milena/mln/pw/internal/image_base.hh b/milena/mln/pw/internal/image_base.hh
new file mode 100644
index 0000000..2770612
--- /dev/null
+++ b/milena/mln/pw/internal/image_base.hh
@@ -0,0 +1,257 @@
+// 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_PW_INTERNAL_IMAGE_BASE_HH
+# define MLN_PW_INTERNAL_IMAGE_BASE_HH
+
+/// \file mln/pw/internal/image_base.hh
+///
+/// Definition of the common base class for all point-wise images.
+
+# include <mln/core/internal/image_primary.hh>
+# include <mln/metal/unqualif.hh>
+# include <mln/metal/not_equal.hh>
+# include <mln/value/set.hh>
+
+
+namespace mln
+{
+
+
+ // Forward declaration.
+ namespace pw
+ {
+
+ namespace internal
+ {
+
+ template <typename F, typename S, typename E>
+ struct image_base;
+
+ } // end of namespace mln::pw::internal
+
+ } // end of namespace mln::pw
+
+ namespace trait
+ {
+
+ // FIXME: the result type should *not* be qualified
+
+ template <typename F, typename S, typename E>
+ struct pw_image_
+ : default_image_<mln_result(F),E>
+ {
+ private:
+ typedef typename F::mutable_result mutable_result;
+ typedef mlc_not_equal(mutable_result, void) is_mutable;
+
+ public:
+ // misc
+ typedef trait::image::category::primary category;
+ typedef trait::image::speed::fast speed;
+ typedef trait::image::size::regular size;
+
+ // value
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::value_storage::disrupted value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_alignment::irrelevant value_alignment;
+ typedef mlc_if(is_mutable,
+ trait::image::value_io::read_write,
+ trait::image::value_io::read_only) value_io;
+
+ // site / domain
+ typedef mlc_if(is_mutable,
+ trait::image::pw_io::read_write,
+ trait::image::pw_io::read) pw_io;
+ typedef /* FIXME: depends on S */ undef localization;
+ typedef /* FIXME: depends on S */ undef dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::none ext_domain;
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace pw
+ {
+
+ namespace internal
+ {
+
+ /// A base class for point-wise images.
+ /// Parameter \p F is the image value type.
+ /// Parameter \p S is the image site set type.
+ template <typename F, typename S, typename E>
+ struct image_base
+ : public mln::internal::image_primary<mln_result(F), S, E >
+ {
+ typedef typename F::mutable_result mutable_result;
+ typedef mlc_not_equal(mutable_result, void) is_mutable;
+
+ public:
+ /// Function associated type.
+ typedef F function_t;
+
+ /// Value associated type.
+ typedef mln_result(F) value;
+
+ /// Return type of read-only access.
+ typedef mln_result(F) rvalue;
+
+ /// Return type of read-write access.
+ typedef mlc_if(is_mutable, mutable_result, mln_result(F)) lvalue;
+
+ /// Initialize an empty image.
+ void init_(const Function_v2v<F>& f, const Site_Set<S>& ps);
+
+ /// Give the definition domain.
+ const S& domain() const;
+
+ /// Return the function which computes a site value.
+ F function() const;
+
+ /// Read-only access of pixel value at point site \p p.
+ rvalue operator()(const mln_psite(S)& p) const;
+
+ /// Read-write access returns either a temporary value (copy) or
+ /// a reference in the case of a mutable function (container).
+ lvalue operator()(const mln_psite(S)& p);
+
+ protected:
+ image_base();
+ image_base(const Function_v2v<F>& f, const Site_Set<S>& ps);
+ };
+
+ } // end of namespace mln::pw::internal
+
+ } // end of namespace mln::pw
+
+
+ // init_
+
+ template <typename F, typename S, typename E>
+ void init_(tag::function_t, F& f, const pw::internal::image_base<F,S,E>& model);
+
+ template <typename F1, typename F2, typename S, typename E>
+ void init_(tag::function_t, F1& f, const pw::internal::image_base<F2,S,E>& model);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // init_
+
+ template <typename F, typename S, typename E>
+ void init_(tag::function_t, F& f, const pw::internal::image_base<F,S,E>& model)
+ {
+ f = model.function();
+ }
+
+ template <typename F1, typename F2, typename S, typename E>
+ void init_(tag::function_t, F1& f, const pw::internal::image_base<F2,S,E>& model)
+ {
+ init_(tag::function, f, model.function());
+ }
+
+
+ namespace pw
+ {
+
+ namespace internal
+ {
+
+ template <typename F, typename S, typename E>
+ inline
+ image_base<F,S,E>::image_base()
+ {
+ }
+
+ template <typename F, typename S, typename E>
+ inline
+ image_base<F,S,E>::image_base(const Function_v2v<F>& f, const Site_Set<S>& ps)
+ {
+ this->data_ = new mln::internal::data<E>(exact(f), exact(ps));
+ }
+
+ template <typename F, typename S, typename E>
+ inline
+ void
+ image_base<F,S,E>::init_(const Function_v2v<F>& f, const Site_Set<S>& ps)
+ {
+ this->data_ = new mln::internal::data<E>(exact(f), exact(ps));
+ }
+
+ template <typename F, typename S, typename E>
+ inline
+ const S&
+ image_base<F,S,E>::domain() const
+ {
+ return this->data_->pset_;
+ }
+
+ template <typename F, typename S, typename E>
+ inline
+ F
+ image_base<F,S,E>:: function() const
+ {
+ return this->data_->f_;
+ }
+
+
+ template <typename F, typename S, typename E>
+ inline
+ typename image_base<F,S,E>::rvalue
+ image_base<F,S,E>::operator()(const mln_psite(S)& p) const
+ {
+ mln_precondition(this->data_->pset_.has(p));
+ return this->data_->f_(p);
+ }
+
+ template <typename F, typename S, typename E>
+ inline
+ typename image_base<F,S,E>::lvalue
+ image_base<F,S,E>::operator()(const mln_psite(S)& p)
+ {
+ mln_precondition(this->data_->pset_.has(p));
+ return this->data_->f_(p);
+ }
+
+ } // end of namespace mln::pw::internal
+
+ } // end of namespace mln::pw
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_PW_INTERNAL_IMAGE_BASE_HH
diff --git a/milena/mln/tag/skeleton.hh b/milena/mln/tag/skeleton.hh
index 36f8581..a90bd05 100644
--- a/milena/mln/tag/skeleton.hh
+++ b/milena/mln/tag/skeleton.hh
@@ -1,5 +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
@@ -29,11 +29,10 @@
#ifndef MLN_TAG_SKELETON_HH
# define MLN_TAG_SKELETON_HH
-/*! \file mln/tag/skeleton.hh
- *
- * \brief Definition of tags used in the skeleton types associated to
- * image types.
- */
+/// \file mln/tag/skeleton.hh
+///
+/// Definition of tags used in the skeleton types associated to
+/// image types.
namespace mln
@@ -46,6 +45,7 @@ namespace mln
template <typename D> struct data_ { typedef D param; };
template <typename E> struct ext_ { typedef E param; };
template <typename F> struct function_ { typedef F param; };
+ template <typename G> struct graph_ { typedef G param; };
template <typename I> struct image_ { typedef I param; };
template <typename N> struct neighb_ { typedef N param; };
template <typename P> struct psite_ { typedef P param; };
diff --git a/milena/mln/trait/ch_value.hh b/milena/mln/trait/ch_value.hh
index cff3a59..e02bf04 100644
--- a/milena/mln/trait/ch_value.hh
+++ b/milena/mln/trait/ch_value.hh
@@ -1,5 +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
@@ -50,6 +50,8 @@ namespace mln
namespace algebra { template <unsigned n, typename T> class vec; }
template <typename G, typename F> class p_edges;
template <typename G, typename F> class p_vertices;
+ template <typename P, typename V, typename G> class vertex_image;
+ template <typename P, typename V, typename G> class edge_image;
namespace pw { template <typename F, typename S> class image; }
@@ -165,7 +167,8 @@ namespace mln
typedef typename image_from_grid< grid, V >::ret ret;
};
- // line_graph image
+
+ // Graph image based on p_edges
template < typename F,
typename G, typename FP,
typename V >
@@ -174,15 +177,36 @@ namespace mln
typedef pw::image< mln_ch_function_value(F, V), p_edges<G, FP> > ret;
};
- // graph image
+ // Graph image based on p_vertices
template < typename F,
typename G, typename FP,
typename V >
struct ch_value_< pw::image< tag::function_<F>, tag::pset_<p_vertices<G, FP> > >, V >
+
{
typedef pw::image< mln_ch_function_value(F, V), p_vertices<G, FP> > ret;
};
+ // Vertex Image
+ template < typename P, typename V1, typename G, typename V2>
+ struct ch_value_< vertex_image< tag::psite_<P>,
+ tag::value_<V1>,
+ tag::graph_<G> >,
+ V2 >
+ {
+ typedef vertex_image< P, V2, G > ret;
+ };
+
+ // Edge Image
+ template < typename P, typename V1, typename G, typename V2>
+ struct ch_value_< edge_image< tag::psite_<P>,
+ tag::value_<V1>,
+ tag::graph_<G> >,
+ V2 >
+ {
+ typedef edge_image< P, V2, G > ret;
+ };
+
template < template <class, class> class M, typename T, typename S,
typename V >
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index 10e900f..c93e0f9 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -202,6 +202,10 @@ namespace mln
/// Return the edge whose id is \a e.
edge_t edge(unsigned e) const;
+
+ /// Return the list of all edges.
+ const std::vector<util::ord_pair<unsigned> >& edges() const;
+
/// Return the number of edges in the graph.
size_t e_nmax() const;
@@ -420,6 +424,13 @@ namespace mln
}
inline
+ const std::vector<util::ord_pair<unsigned> >&
+ graph::edges() const
+ {
+ return this->data_->edges_;
+ }
+
+ inline
graph::edge_t
graph::edge(unsigned e) const
{
diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am
index b8c3abc..cdd52f6 100644
--- a/milena/tests/core/image/Makefile.am
+++ b/milena/tests/core/image/Makefile.am
@@ -7,6 +7,7 @@ check_PROGRAMS = \
cast_image \
complex_image \
decorated_image \
+ edge_image \
flat_image \
hexa \
graph_image \
@@ -24,7 +25,8 @@ check_PROGRAMS = \
sub_image \
t_image \
tr_image \
- unproject_image
+ unproject_image \
+ vertex_image
## bgraph_image \
## mono_obased_rle_image \
@@ -66,6 +68,8 @@ t_image_SOURCES = t_image.cc
tr_image_SOURCES = tr_image.cc
unproject_image_SOURCES = unproject_image.cc
##value_enc_image_SOURCES = value_enc_image.cc
+vertex_image_SOURCES = vertex_image.cc
+edge_image_SOURCES = edge_image.cc
# Tests depending on the FreeImagePlus library.
if FREEIMAGEPLUS
diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/edge_image.cc
similarity index 73%
copy from milena/tests/core/image/graph_image.cc
copy to milena/tests/core/image/edge_image.cc
index e8a71f2..7ee2f98 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/edge_image.cc
@@ -1,4 +1,4 @@
-// Copyright(C) 2007, 2008 EPITA Research and Development Laboratory(LRDE)
+// 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
@@ -25,27 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/image/graph_image.cc
+/// \file tests/core/image/edge_image.cc
///
-/// Tests on mln::graph_image.
+/// Tests on mln::edge_image.
#include <vector>
-#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_window.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
-#include <mln/core/concept/function.hh>
-#include <mln/core/neighb.hh>
-#include <mln/core/var.hh>
+#include <mln/core/image/edge_image.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/accu/bbox.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/util/site_pair.hh>
#include <mln/debug/draw_graph.hh>
-#include <mln/debug/println.hh>
/* The graph is as follows:
@@ -63,17 +59,17 @@
// Expected neighbors for forward and backward iteration.
// -1 is an invalid id.
-static unsigned expected_fwd_nb[5][3] = { { 1, -1, -1 },
- { 0, 2, 3 },
- { 1, 4, -1 },
- { 1, 4, -1 },
- { 3, 2, -1 } };
+static unsigned expected_fwd_nb[5][3] = { { 1, 2, -1 },
+ { 0, 2, 4 },
+ { 0, 1, 3 },
+ { 2, 4, -1 },
+ { 1, 3, -1 } };
-static unsigned expected_bkd_nb[5][3] = { { 1, -1, -1 },
- { 3, 2, 0 },
- { 4, 1, -1 },
- { 4, 1, -1 },
- { 2, 3, -1 } };
+static unsigned expected_bkd_nb[5][3] = { { 2, 1, -1 },
+ { 4, 2, 0 },
+ { 3, 1, 0 },
+ { 4, 2, -1 },
+ { 3, 1, -1 } };
int main()
@@ -85,15 +81,15 @@ int main()
`--------*/
// Points associated to vertices.
- typedef fun::i2v::array<point2d> fsite_t;
+ typedef util::site_pair<point2d> site_t;
+ typedef fun::i2v::array<site_t> fsite_t;
fsite_t sites(5);
- sites(0) = point2d(0,0); // Point associated to vertex 0.
- sites(1) = point2d(2,2); // Point associated to vertex 1.
- sites(2) = point2d(0,4); // Point associated to vertex 2.
- sites(3) = point2d(4,3); // Point associated to vertex 3.
- sites(4) = point2d(4,4); // Point associated to vertex 4.
+ sites(0) = site_t(point2d(0,0),point2d(2,2)); // Site associated to edge 0.
+ sites(1) = site_t(point2d(2,2),point2d(0,4)); // Site associated to edge 1.
+ sites(2) = site_t(point2d(2,2),point2d(4,3)); // Site associated to edge 2.
+ sites(3) = site_t(point2d(4,3),point2d(4,4)); // Site associated to edge 3.
+ sites(4) = site_t(point2d(4,4),point2d(0,4)); // Site associated to edge 4.
- // Edges.
util::graph g;
// Populate the graph with vertices.
@@ -108,25 +104,18 @@ int main()
//g.print_debug(std::cout);
- /*----------------------.
- | Graph image support. |
- `----------------------*/
-
- typedef p_vertices<util::graph, fsite_t> S;
- S pv(g, sites);
-
/*-------------.
| Graph image. |
`-------------*/
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pv.nsites());
+ viota_t iota(g.v_nmax());
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- // Create graph image.
- mln_const_VAR(ima, (iota | pv));
+ typedef edge_image<site_t,unsigned> ima_t;
+ ima_t ima(g, sites, iota);
{
// FIXME: Move this part to a special test case.
@@ -135,7 +124,10 @@ int main()
accu::bbox<point2d> a;
mln_piter_(ima_t) p(ima.domain());
for_all(p)
- a.take(p);
+ {
+ a.take(p.first());
+ a.take(p.second());
+ }
box2d bbox = a.to_result();
mln_assertion(bbox == make::box2d(5, 5));
@@ -161,7 +153,7 @@ int main()
// We use the value 9 in debug::graph to represent edges to distinguish it
// from vertices holding a value of 1.
- debug::draw_graph(ima_rep, pv, 1, 9);
+ debug::draw_graph(ima_rep, ima.domain(), 1, 9);
}
/*------------.
@@ -174,7 +166,7 @@ int main()
for_all(p)
mln_assertion(ima(p) == i++);
- typedef graph_elt_window<util::graph, fsite_t> win_t;
+ typedef ima_t::win_t win_t;
win_t win;
{
@@ -205,11 +197,11 @@ int main()
}
}
- typedef graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
- neighb_t neigh;
+ typedef ima_t::nbh_t nbh_t;
+ nbh_t neigh;
{
// Neighborhood - Forward iteration
- mln_niter_(neighb_t) n(neigh, p);
+ mln_niter_(nbh_t) n(neigh, p);
for_all(p)
{
@@ -224,7 +216,7 @@ int main()
{
// Neighborhood - Backward iteration
- mln_bkd_niter_(neighb_t) n(neigh, p);
+ mln_bkd_niter_(nbh_t) n(neigh, p);
for_all(p)
{
i = 0;
diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/graph_image.cc
index e8a71f2..4902fc0 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/graph_image.cc
@@ -174,7 +174,7 @@ int main()
for_all(p)
mln_assertion(ima(p) == i++);
- typedef graph_elt_window<util::graph, fsite_t> win_t;
+ typedef graph_elt_window<util::graph,S> win_t;
win_t win;
{
@@ -205,7 +205,7 @@ int main()
}
}
- typedef graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
+ typedef graph_elt_neighborhood<util::graph,S> neighb_t;
neighb_t neigh;
{
// Neighborhood - Forward iteration
diff --git a/milena/tests/core/image/line_graph_image.cc b/milena/tests/core/image/line_graph_image.cc
index fe660f5..2c11e73 100644
--- a/milena/tests/core/image/line_graph_image.cc
+++ b/milena/tests/core/image/line_graph_image.cc
@@ -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
@@ -25,16 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/image/graph_image.cc
+/// \file tests/core/image/line_graph_image.cc
///
-/// Tests on mln::graph_image.
+/// Tests on mln::line_graph_image.
#include <mln/core/alias/point2d.hh>
/// Required for line graph images.
#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_window.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/neighb.hh>
#include <mln/core/var.hh>
#include <mln/pw/all.hh>
@@ -57,17 +59,17 @@
// Expected neighbors for forward and backward iteration.
-static unsigned expected_fwd_nbh[5][3] = { { 1, 2, -1 },
- { 0, 2, 4 },
- { 0, 1, 3 },
- { 2, 4, -1 },
- { 1, 3, -1 } };
+static unsigned expected_fwd_nbh[5][3] = { { 1, -1, -1 },
+ { 0, 2, 3 },
+ { 1, 4, -1 },
+ { 1, 4, -1 },
+ { 3, 2, -1 } };
-static unsigned expected_bkd_nbh[5][3] = { { 2, 1, -1 },
- { 4, 2, 0 },
- { 3, 1, 0 },
- { 4, 2, -1 },
- { 3, 1, -1 } };
+static unsigned expected_bkd_nbh[5][3] = { { 1, 0, -1 },
+ { 3, 2, 0 },
+ { 4, 1, -1 },
+ { 4, 1, -1 },
+ { 2, 3, -1 } };
int main()
@@ -99,25 +101,19 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
- /*---------------------------.
- | Line graph image support. |
- `---------------------------*/
-
- typedef p_edges<util::graph, fsite_t> S;
- S pe(g, sites);
-
/*-------------------.
| Line graph image. |
`-------------------*/
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pe.nsites());
- for(unsigned i = 0; i < iota.size(); ++i)
+ viota_t iota(g.v_nmax());
+ for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
// Create line graph image.
- mln_const_VAR(ima,(iota | pe));
+ typedef vertex_image<point2d,unsigned> ima_t;
+ ima_t ima(g, sites, iota);
/*------------.
| Iterators. |
@@ -132,7 +128,7 @@ int main()
for_all(p)
mln_assertion(ima(p) == i++);
- typedef line_graph_elt_window<util::graph, fsite_t> win_t;
+ typedef ima_t::win_t win_t;
win_t win;
{
@@ -164,7 +160,7 @@ int main()
}
- typedef line_graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
+ typedef ima_t::nbh_t neighb_t;
neighb_t neigh;
{
diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/vertex_image.cc
similarity index 84%
copy from milena/tests/core/image/graph_image.cc
copy to milena/tests/core/image/vertex_image.cc
index e8a71f2..3531420 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/vertex_image.cc
@@ -1,4 +1,4 @@
-// Copyright(C) 2007, 2008 EPITA Research and Development Laboratory(LRDE)
+// 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
@@ -25,18 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/image/graph_image.cc
+/// \file tests/core/image/vertex_image.cc
///
-/// Tests on mln::graph_image.
+/// Tests on mln::vertex_image.
#include <vector>
-#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_window.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
-#include <mln/core/concept/function.hh>
-#include <mln/core/neighb.hh>
-#include <mln/core/var.hh>
+#include <mln/core/image/vertex_image.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/accu/bbox.hh>
@@ -45,7 +41,6 @@
#include <mln/util/graph.hh>
#include <mln/debug/draw_graph.hh>
-#include <mln/debug/println.hh>
/* The graph is as follows:
@@ -108,25 +103,18 @@ int main()
//g.print_debug(std::cout);
- /*----------------------.
- | Graph image support. |
- `----------------------*/
-
- typedef p_vertices<util::graph, fsite_t> S;
- S pv(g, sites);
-
/*-------------.
| Graph image. |
`-------------*/
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pv.nsites());
+ viota_t iota(g.v_nmax());
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- // Create graph image.
- mln_const_VAR(ima, (iota | pv));
+ typedef vertex_image<point2d,unsigned> ima_t;
+ ima_t ima(g, sites, iota);
{
// FIXME: Move this part to a special test case.
@@ -161,7 +149,7 @@ int main()
// We use the value 9 in debug::graph to represent edges to distinguish it
// from vertices holding a value of 1.
- debug::draw_graph(ima_rep, pv, 1, 9);
+ debug::draw_graph(ima_rep, ima.domain(), 1, 9);
}
/*------------.
@@ -174,7 +162,7 @@ int main()
for_all(p)
mln_assertion(ima(p) == i++);
- typedef graph_elt_window<util::graph, fsite_t> win_t;
+ typedef ima_t::win_t win_t;
win_t win;
{
@@ -205,11 +193,11 @@ int main()
}
}
- typedef graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
- neighb_t neigh;
+ typedef ima_t::nbh_t nbh_t;
+ nbh_t neigh;
{
// Neighborhood - Forward iteration
- mln_niter_(neighb_t) n(neigh, p);
+ mln_niter_(nbh_t) n(neigh, p);
for_all(p)
{
@@ -224,7 +212,7 @@ int main()
{
// Neighborhood - Backward iteration
- mln_bkd_niter_(neighb_t) n(neigh, p);
+ mln_bkd_niter_(nbh_t) n(neigh, p);
for_all(p)
{
i = 0;
diff --git a/milena/tests/core/site_set/p_edges.cc b/milena/tests/core/site_set/p_edges.cc
index 42e0da0..281e70c 100644
--- a/milena/tests/core/site_set/p_edges.cc
+++ b/milena/tests/core/site_set/p_edges.cc
@@ -1,4 +1,4 @@
-// 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
@@ -38,7 +38,7 @@
// Function mapping an edge to a specific site.
template <typename G>
-struct my_fun
+struct my_fun : mln::Function< my_fun<G> >
{
typedef mln::point2d result;
diff --git a/milena/tests/morpho/artificial_line_graph_image_wst.cc b/milena/tests/morpho/artificial_line_graph_image_wst.cc
index 65a31e6..7574c9c 100644
--- a/milena/tests/morpho/artificial_line_graph_image_wst.cc
+++ b/milena/tests/morpho/artificial_line_graph_image_wst.cc
@@ -54,9 +54,7 @@
#include <mln/core/alias/neighb2d.hh>
/// Required for line graph images.
-#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/var.hh>
+#include <mln/core/image/edge_image.hh>
#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
@@ -117,20 +115,18 @@ int main()
`----------------*/
// Line graph image.
- typedef pw::image<fun::i2v::array<input_val_t>, p_edges<util::graph,
- fun::i2v::array< util::site_pair<point2d> > > > lg_ima_t;
+ typedef edge_image<util::site_pair<point2d>, input_val_t, util::graph> lg_ima_t;
lg_ima_t lg_ima = morpho::line_gradient(input);
/*------.
| WST. |
`------*/
- typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
+ typedef lg_ima_t::nbh_t nbh_t;
nbh_t nbh;
// Perform a Watershed Transform.
- typedef pw::image<fun::i2v::array<unsigned>, p_edges<util::graph,
- fun::i2v::array< util::site_pair<point2d> > > > wshed_t;
+ typedef edge_image<util::site_pair<point2d>, unsigned, util::graph> wshed_t;
unsigned nbasins;
wshed_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins);
mln_assertion(nbasins == 1155);
diff --git a/milena/tests/morpho/graph_image_morpho.cc b/milena/tests/morpho/graph_image_morpho.cc
index 04c18ad..35b3045 100644
--- a/milena/tests/morpho/graph_image_morpho.cc
+++ b/milena/tests/morpho/graph_image_morpho.cc
@@ -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
@@ -37,10 +38,8 @@
#include <mln/morpho/erosion.hh>
/// Required for graph images.
-#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/var.hh>
-#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
@@ -93,25 +92,18 @@ int main()
g.add_edge(4, 2);
- /*----------------------.
- | Graph image support. |
- `----------------------*/
-
- typedef p_vertices<util::graph, fsite_t> pv_t;
- pv_t pv(g, sites);
-
/*--------------.
| Graph image. |
`--------------*/
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pv.nsites());
+ viota_t iota(g.v_nmax());
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- // Create graph image.
- mln_const_VAR(ima, (iota | pv));
+ typedef vertex_image<point2d,unsigned,util::graph> ima_t;
+ ima_t ima(g, sites, iota);
/*-------------------------------------.
| Image representation/visualization. |
@@ -148,7 +140,8 @@ int main()
| Processing graph images. |
`--------------------------*/
- graph_elt_window<util::graph, fsite_t> win;
+
+ ima_t::win_t win;
mln_const_VAR(ima_dil, morpho::dilation(ima, win));
debug::draw_graph(ima_rep, ima_dil.domain(), pw::cst(9), pw::cst(2));
diff --git a/milena/tests/morpho/graph_image_wst.cc b/milena/tests/morpho/graph_image_wst.cc
index caecece..7eb1c24 100644
--- a/milena/tests/morpho/graph_image_wst.cc
+++ b/milena/tests/morpho/graph_image_wst.cc
@@ -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
@@ -33,10 +34,8 @@
#include <mln/core/alias/point2d.hh>
/// Required for graph images.
-#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/var.hh>
-#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
@@ -86,32 +85,24 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
-
- /*----------------------.
- | Graph image support. |
- `----------------------*/
-
- typedef p_vertices<util::graph, fsite_t> pv_t;
- pv_t pv(g, sites);
-
/*-------------.
| Graph image. |
`-------------*/
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pv.nsites());
+ viota_t iota(g.v_nmax());
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- // Create graph image.
- mln_const_VAR(ima, (iota | pv));
+ typedef vertex_image<point2d,unsigned,util::graph> ima_t;
+ ima_t ima(g,sites,iota);
/*------.
| WST. |
`------*/
- typedef graph_elt_neighborhood<util::graph, fsite_t> nbh_t;
+ typedef ima_t::nbh_t nbh_t;
nbh_t nbh;
unsigned nbasins;
diff --git a/milena/tests/morpho/lena_line_graph_image_wst1.cc b/milena/tests/morpho/lena_line_graph_image_wst1.cc
index 142bdad..72bd8bb 100644
--- a/milena/tests/morpho/lena_line_graph_image_wst1.cc
+++ b/milena/tests/morpho/lena_line_graph_image_wst1.cc
@@ -60,10 +60,8 @@
#include <mln/convert/to_window.hh>
/// Required for line graph images.
-#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/image/edge_image.hh>
#include <mln/core/var.hh>
-#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
@@ -146,24 +144,19 @@ int main()
}
// Line graph point set.
- typedef p_edges<util::graph, edge_sites_t> pe_t;
- pe_t pe(g, edge_sites);
-
- // Line graph image
- typedef pw::image<edge_values_t, pe_t> lg_ima_t;
- lg_ima_t lg_ima = (edge_values | pe);
+ typedef edge_image<util::site_pair<point2d>,int,util::graph> lg_ima_t;
+ lg_ima_t lg_ima(g, edge_sites, edge_values);
/*------.
| WST. |
`------*/
- typedef line_graph_elt_neighborhood<util::graph, edge_sites_t> nbh_t;
+ typedef lg_ima_t::nbh_t nbh_t;
nbh_t nbh;
// Perform a Watershed Transform.
int_u8 nbasins;
- typedef pw::image<fun::i2v::array<int_u8>, p_edges<util::graph,
- fun::i2v::array< util::site_pair<point2d> > > > wshed_t;
+ typedef edge_image<util::site_pair<point2d>,int_u8,util::graph> wshed_t;
wshed_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins);
mln_assertion(nbasins == 5);
diff --git a/milena/tests/morpho/lena_line_graph_image_wst2.cc b/milena/tests/morpho/lena_line_graph_image_wst2.cc
index 6922a83..c409346 100644
--- a/milena/tests/morpho/lena_line_graph_image_wst2.cc
+++ b/milena/tests/morpho/lena_line_graph_image_wst2.cc
@@ -56,10 +56,8 @@
#include <mln/core/alias/neighb2d.hh>
/// Required for line graph images.
-#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/image/edge_image.hh>
#include <mln/core/var.hh>
-#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
@@ -104,15 +102,14 @@ int main()
`----------------*/
// Line graph image.
- typedef pw::image<fun::i2v::array<input_val_t>, p_edges<util::graph,
- fun::i2v::array< util::site_pair<point2d> > > > lg_ima_t;
+ typedef edge_image<util::site_pair<point2d>,input_val_t,util::graph> lg_ima_t;
lg_ima_t lg_ima = morpho::line_gradient(input);
/*-----------------.
| Simplification. |
`-----------------*/
- typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
+ typedef lg_ima_t::nbh_t nbh_t;
nbh_t nbh;
lg_ima_t closed_lg_ima = morpho::closing::area_on_vertices(lg_ima, nbh, 20);
@@ -123,8 +120,7 @@ int main()
// Perform a Watershed Transform.
unsigned nbasins;
- typedef pw::image<fun::i2v::array<unsigned>, p_edges<util::graph,
- fun::i2v::array< util::site_pair<point2d> > > > wshed_t;
+ typedef edge_image<util::site_pair<point2d>,unsigned,util::graph> wshed_t;
wshed_t wshed = morpho::meyer_wst(closed_lg_ima, nbh, nbasins);
mln_assertion(nbasins == 46);
diff --git a/milena/tests/morpho/line_graph_image_morpho.cc b/milena/tests/morpho/line_graph_image_morpho.cc
index 2b32421..3a5becb 100644
--- a/milena/tests/morpho/line_graph_image_morpho.cc
+++ b/milena/tests/morpho/line_graph_image_morpho.cc
@@ -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
@@ -32,16 +33,17 @@
#include <mln/core/alias/point2d.hh>
/// Required for line graph images.
-#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_window.hh>
-#include <mln/core/var.hh>
-#include <mln/pw/all.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/fun/i2v/array.hh>
+#include <mln/util/line_graph.hh>
#include <mln/util/graph.hh>
+#include <mln/util/site_pair.hh>
#include <mln/morpho/erosion.hh>
#include <mln/morpho/dilation.hh>
+static const unsigned dil_ref[] = { 12, 14, 13, 14, 13 };
+static const unsigned ero_ref[] = { 11, 10, 10, 12, 11 };
int main()
{
@@ -67,17 +69,8 @@ int main()
// Graph.
util::graph g;
- // Points associated to vertices.
- typedef fun::i2v::array<point2d> fsite_t;
- fsite_t sites(5);
- sites(0) = point2d(0,0); // Point associated to vertex 0.
- sites(1) = point2d(2,2); // Point associated to vertex 1.
- sites(2) = point2d(0,4); // Point associated to vertex 2.
- sites(3) = point2d(4,3); // Point associated to vertex 3.
- sites(4) = point2d(4,4); // Point associated to vertex 4.
-
// Populate the graph with vertices.
- g.add_vertices(sites.size());
+ g.add_vertices(5);
// Populate the graph with edges.
g.add_edge(0, 1);
@@ -86,13 +79,19 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
+ /// Create the corresponding line graph.
+ /// Edges are now considered as vertices.
+ util::line_graph<util::graph> lg(g);
- /*---------------------------.
- | Line graph image support. |
- `---------------------------*/
-
- typedef p_edges<util::graph, fsite_t> pe_t;
- pe_t pe(g, sites);
+ // Points associated to the line graph vertices (edges in the graph).
+ typedef util::site_pair<point2d> P;
+ typedef fun::i2v::array<P> fsite_t;
+ fsite_t sites(5);
+ sites(0) = P(point2d(0,0), point2d(2,2)); // Site associated to vertex 0.
+ sites(1) = P(point2d(2,2), point2d(0,4)); // Site associated to vertex 1.
+ sites(2) = P(point2d(2,2), point2d(4,3)); // Site associated to vertex 2.
+ sites(3) = P(point2d(4,3), point2d(4,4)); // Site associated to vertex 3.
+ sites(4) = P(point2d(0,4), point2d(4,4)); // Site associated to vertex 4.
/*-------------------.
| Line graph image. |
@@ -100,30 +99,31 @@ int main()
// Line graph values.
typedef fun::i2v::array<unsigned> viota_t;
- viota_t iota(pe.nsites());
+ viota_t iota(lg.v_nmax());
for (unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
- // Create line graph image.
- mln_const_VAR(ima, (iota | pe));
+ typedef vertex_image<P,unsigned,util::line_graph<util::graph> > ima_t;
+ ima_t ima(lg, sites, iota);
/*-------------------------------.
| Processing line graph images. |
`-------------------------------*/
- line_graph_elt_window<util::graph, fsite_t> win;
+ ima_t::win_t win;
+ unsigned i = 0;
- mln_const_VAR(ima_dil, morpho::dilation(ima, win));
+ ima_t ima_dil = morpho::dilation(ima, win);
// Manual iteration over the domain of IMA_DIL.
- mln_piter_(ima_dil_t) p_dil(ima_dil.domain());
+ mln_piter_(ima_t) p_dil(ima_dil.domain());
for_all (p_dil)
- std::cout << "ima_dil (" << p_dil << ") = " << ima_dil(p_dil) << std::endl;
- std::cout << std::endl;
+ mln_assertion(dil_ref[i++] == ima_dil(p_dil));
- mln_const_VAR(ima_ero, morpho::erosion(ima, win));
+ ima_t ima_ero = morpho::erosion(ima, win);
// Manual iteration over the domain of IMA_ERO.
- mln_piter_(ima_ero_t) p_ero(ima_ero.domain());
+ mln_piter_(ima_t) p_ero(ima_ero.domain());
+ i = 0;
for_all (p_ero)
- std::cout << "ima_ero (" << p_ero << ") = " << ima_ero(p_ero) << std::endl;
+ mln_assertion(ero_ref[i++] == ima_ero(p_ero));
}
diff --git a/milena/tests/morpho/line_graph_image_wst.cc b/milena/tests/morpho/line_graph_image_wst.cc
index 73afbda..6df2052 100644
--- a/milena/tests/morpho/line_graph_image_wst.cc
+++ b/milena/tests/morpho/line_graph_image_wst.cc
@@ -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
@@ -32,16 +33,17 @@
#include <mln/core/alias/point2d.hh>
/// Required for line graph images.
-#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/var.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/pw/all.hh>
#include <mln/fun/i2v/array.hh>
#include <mln/util/graph.hh>
+#include <mln/util/line_graph.hh>
#include <mln/util/site_pair.hh>
-#include <mln/morpho/meyer_wst.hh>
+#include <mln/morpho/watershed/flooding.hh>
+static const unsigned ima_ref[] = { 0, 10, 5, 2, 4, 6, 0, 3, 5, 2 };
+static const unsigned ima_wst[] = { 2, 0, 1, 2, 2, 1, 1, 2, 0, 1 };
int main()
{
@@ -68,20 +70,8 @@ int main()
foward order. */
util::graph g;
- // Sites associated to vertices.
- typedef fun::i2v::array<point2d> fsite_t;
- fsite_t sites(8);
- sites(0) = point2d(0,0); // Point associated to vertex 0.
- sites(1) = point2d(0,1); // Point associated to vertex 1.
- sites(2) = point2d(0,2); // Point associated to vertex 2.
- sites(3) = point2d(0,3); // Point associated to vertex 3.
- sites(4) = point2d(1,0); // Point associated to vertex 4.
- sites(5) = point2d(1,1); // Point associated to vertex 5.
- sites(6) = point2d(1,2); // Point associated to vertex 6.
- sites(7) = point2d(1,3); // Point associated to vertex 7.
-
// Populate the graph with vertices.
- g.add_vertices(sites.size());
+ g.add_vertices(8);
// Populate the graph with edges.
g.add_edge(0, 1);
@@ -97,47 +87,56 @@ int main()
g.add_edge(5, 6);
g.add_edge(6, 7);
- // Associate edges to sites.
- typedef fun::i2v::array< util::site_pair<point2d> > edge_sites_t;
- edge_sites_t edge_sites(g.e_nmax());
- mln_edge_iter_(util::graph) e(g);
- for_all(e)
- edge_sites(e) = util::site_pair<point2d>(sites(e.v1()), sites(e.v2()));
+ util::line_graph<util::graph> lg(g);
- typedef p_edges<util::graph, edge_sites_t> pe_t;
- pe_t pe(g, edge_sites);
+ // Sites associated to vertices.
+ typedef util::site_pair<point2d> P;
+ typedef fun::i2v::array<P> fsite_t;
+ fsite_t sites(10);
+ sites(0) = P(point2d(0,0), point2d(0,1)); // Site associated to vertex 0.
+ sites(1) = P(point2d(0,1), point2d(0,2)); // Site associated to vertex 1.
+ sites(2) = P(point2d(0,2), point2d(0,3)); // Site associated to vertex 2.
+ sites(3) = P(point2d(0,0), point2d(1,0)); // Site associated to vertex 7.
+ sites(4) = P(point2d(0,1), point2d(1,1)); // Site associated to vertex 8.
+ sites(5) = P(point2d(0,2), point2d(1,2)); // Site associated to vertex 9.
+ sites(6) = P(point2d(0,3), point2d(1,3)); // Site associated to vertex 3.
+ sites(7) = P(point2d(1,0), point2d(1,1)); // Site associated to vertex 4.
+ sites(8) = P(point2d(1,1), point2d(1,2)); // Site associated to vertex 5.
+ sites(9) = P(point2d(1,2), point2d(1,3)); // Site associated to vertex 6.
// Edge values.
typedef fun::i2v::array<int> edge_values_t;
- edge_values_t edge_values(pe.nsites());
+ edge_values_t edge_values(10);
static const int values[] = { 0, 10, 5, 2, 4, 6, 0, 3, 5, 2 };
for (unsigned i = 0; i < edge_values.size(); ++i)
edge_values(i) = values[i];
- // Create line graph image.
- mln_const_VAR(ima,(edge_values | pe));
+ typedef vertex_image< P, int, util::line_graph<util::graph> > ima_t;
+ ima_t ima(lg, sites, edge_values);
/*------------.
| Iterators. |
`------------*/
+ unsigned i = 0;
+
// Manual iteration over the domain of IMA.
mln_piter_(ima_t) p(ima.domain());
for_all (p)
- std::cout << "ima (" << p << ") = " << ima(p) << std::endl;
- std::cout << std::endl;
+ mln_assertion(ima_ref[i++] == ima(p));
- typedef line_graph_elt_neighborhood<util::graph, edge_sites_t> nbh_t;
+ typedef ima_t::nbh_t nbh_t;
nbh_t nbh;
-
unsigned nbasins;
- mln_const_VAR(wshed, morpho::meyer_wst(ima, nbh, nbasins));
- std::cout << "nbasins = " << nbasins << std::endl;
+ typedef mln_ch_value_(ima_t,unsigned) wshed_t;
+ wshed_t wshed = morpho::watershed::flooding(ima, nbh, nbasins);
+ mln_assertion(nbasins == 2);
+ i = 0;
// Manual iteration over the domain of WSHED.
mln_piter_(wshed_t) pw(wshed.domain());
for_all (pw)
- std::cout << "wshed (" << pw << ") = " << wshed(pw) << std::endl;
+ mln_assertion(ima_wst[i++] == wshed(pw));
}
diff --git a/milena/tests/util/graph.cc b/milena/tests/util/graph.cc
index 60a609a..d832023 100644
--- a/milena/tests/util/graph.cc
+++ b/milena/tests/util/graph.cc
@@ -37,12 +37,7 @@ int main ()
util::graph g;
- g.add_vertex (); // 0
- g.add_vertex (); // 1
- g.add_vertex (); // 2
- g.add_vertex (); // 3
- g.add_vertex (); // 4
- g.add_vertex (); // 5
+ g.add_vertices(6);
g.add_edge (0, 1);
g.add_edge (0, 2);
g.add_edge (3, 4);
--
1.5.6.5
1
0