* icdar/2009/dibco/binarization.cc,
* icdar/2009/dibco/svg.1.binarization.cc,
* icdar/2009/dibco/svg.2.binarization.cc,
* icdar/2009/dibco/svg.3.binarization.cc,
* lazzara/igr/irm/wst_rag_hsl.cc: use vertex_image and edge_image
types.
---
milena/sandbox/ChangeLog | 11 +++
milena/sandbox/icdar/2009/dibco/binarization.cc | 19 +++--
.../sandbox/icdar/2009/dibco/svg.1.binarization.cc | 14 ++--
.../sandbox/icdar/2009/dibco/svg.2.binarization.cc | 7 +-
.../sandbox/icdar/2009/dibco/svg.3.binarization.cc | 40 +++++-----
milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc | 79 ++++++++-----------
6 files changed, 87 insertions(+), 83 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index fba221d..2501564 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,14 @@
+2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Update the use of graph image in sandbox.
+
+ * icdar/2009/dibco/binarization.cc,
+ * icdar/2009/dibco/svg.1.binarization.cc,
+ * icdar/2009/dibco/svg.2.binarization.cc,
+ * icdar/2009/dibco/svg.3.binarization.cc,
+ * lazzara/igr/irm/wst_rag_hsl.cc: use vertex_image and edge_image
+ types.
+
2009-04-25 Alex Hamelin <hamelin(a)lrde.epita.fr>
End of vector method, proved to be useless.
diff --git a/milena/sandbox/icdar/2009/dibco/binarization.cc
b/milena/sandbox/icdar/2009/dibco/binarization.cc
index c9fadbc..14f4495 100644
--- a/milena/sandbox/icdar/2009/dibco/binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/binarization.cc
@@ -7,6 +7,8 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/double_neighb2d.hh>
+#include <mln/core/image/vertex_image.hh>
+
#include <mln/pw/all.hh>
#include <mln/core/image/image_if.hh>
#include <mln/core/site_set/p_queue.hh>
@@ -17,7 +19,7 @@
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/make/p_vertices_with_mass_centers.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -500,11 +502,12 @@ namespace mln
L& nlabels)
{
trace::entering("labeling__quasi_regional_minima");
-
+
+ (void) nlabels;
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
-
+
typedef mln_psite(I) P;
p_array<P> s = level::sort_psites_increasing(input);
@@ -694,8 +697,6 @@ int main(int argc, char *argv[])
// ----------------------------- R A G --------------------------------
- util::graph& gr = rag_data.first();
-
fun::i2v::array<int_u8> f_med;
convert::from_to(basin_med, f_med);
@@ -707,12 +708,12 @@ int main(int argc, char *argv[])
}
p_vertices<util::graph, fun::i2v::array<point2d> >
- pv = make::common_pvertices(ws, nbasins, rag_data.first());
-
- mln_VAR( med, f_med | pv );
+ pv = make::p_vertices_with_mass_centers(ws, nbasins, rag_data.first());
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
threshold = 25; // FIXME
diff --git a/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
b/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
index 2111a08..119c64b 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.1.binarization.cc
@@ -12,9 +12,10 @@
#include <mln/data/fill.hh>
+#include <mln/core/image/edge_image.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -103,7 +104,7 @@ namespace mln
}
template <typename FVV, typename G, typename V2P, typename E2P, typename FVE>
- pw::image<fun::i2v::array<mln_result(FVE)>,p_edges<G,E2P> >
+ edge_image<mln_result(FVE),mln_result(E2P)>
edge_image(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
const p_edges<G,E2P>& pe,
const Function_vv2v<FVE>& edge_value_)
@@ -118,8 +119,8 @@ namespace mln
edge_values_t edge_values(pe.nsites());
// image on graph edges
- typedef pw::image<edge_values_t, p_edges<G,E2P> > ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
+ typedef mln::edge_image<mln_result(FVE),mln_result(E2P)> ima_e_t;
+ ima_e_t ima_e(pe, edge_values);
mln_piter(ima_e_t) e(ima_e.domain());
for_all(e)
@@ -365,7 +366,8 @@ int main(int argc, char *argv[])
p_vertices<util::graph, fun::i2v::array<point2d> >
pv = make::common_pvertices(wst, nbasins, rag_data.first());
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
int_u8
object = 255,
@@ -376,7 +378,7 @@ int main(int argc, char *argv[])
initialize(out, med);
data::fill(out, unknown);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
// Initialization.
diff --git a/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
b/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
index d50c428..20a0505 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.2.binarization.cc
@@ -15,9 +15,9 @@
#include <mln/core/routine/duplicate.hh>
#include <mln/data/fill.hh>
+#include <mln/core/image/vertex_image.hh>
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -630,7 +630,8 @@ int main(int argc, char *argv[])
p_vertices<util::graph, fun::i2v::array<point2d> >
pv = make::common_pvertices(ws, nbasins, rag_data.first());
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d, int_u8> med_t;
+ med_t med(pv, f_med);
int_u8
object = 255,
@@ -641,7 +642,7 @@ int main(int argc, char *argv[])
initialize(out, med);
data::fill(out, unknown);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
// Initialization.
diff --git a/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
b/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
index 8af311f..86214c6 100644
--- a/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
+++ b/milena/sandbox/icdar/2009/dibco/svg.3.binarization.cc
@@ -7,6 +7,9 @@
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/double_neighb2d.hh>
+#include <mln/core/image/vertex_image.hh>
+#include <mln/core/image/edge_image.hh>
+
#include <mln/pw/all.hh>
#include <mln/core/image/image_if.hh>
#include <mln/core/site_set/p_queue.hh>
@@ -17,7 +20,6 @@
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/site_set/p_vertices.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/io/essential.hh>
#include <mln/value/int_u8.hh>
@@ -113,10 +115,10 @@ namespace mln
}
template <typename FVV, typename G, typename V2P, typename E2P, typename FVE>
- pw::image<fun::i2v::array<mln_result(FVE)>,p_edges<G,E2P> >
- edge_image(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
- const p_edges<G,E2P>& pe,
- const Function_vv2v<FVE>& edge_value_)
+ edge_image<mln_result(E2P), mln_result(FVE), G>
+ edgeimage(const pw::image<FVV,p_vertices<G,V2P> >& vertex_image,
+ const p_edges<G,E2P>& pe,
+ const Function_vv2v<FVE>& edge_value_)
{
trace::entering("edge_image");
@@ -128,8 +130,8 @@ namespace mln
edge_values_t edge_values(pe.nsites());
// image on graph edges
- typedef pw::image<edge_values_t, p_edges<G,E2P> > ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
+ typedef edge_image<mln_result(E2P), mln_result(FVE), G> ima_e_t;
+ ima_e_t ima_e(pe, edge_values);
mln_piter(ima_e_t) e(ima_e.domain());
for_all(e)
@@ -165,12 +167,12 @@ namespace mln
template <typename A, typename G, typename F, typename I, typename W>
- pw::image<fun::i2v::array<mln_value(I)>, p_vertices<G,F> >
- vertex_image(const Accumulator<A>& accu,
- const p_vertices<G,F>& pv,
- const Image<I>& input_,
- const Image<W>& wst_,
- const mln_value(W)& nbasins)
+ vertex_image<mln_result(F), mln_value(I), G>
+ verteximage(const Accumulator<A>& accu,
+ const p_vertices<G,F>& pv,
+ const Image<I>& input_,
+ const Image<W>& wst_,
+ const mln_value(W)& nbasins)
{
trace::entering("vertex_image");
@@ -185,9 +187,8 @@ namespace mln
convert::from_to(labeling::compute(accu, input, wst, nbasins),
vertex_values);
- pw::image<fun::i2v::array<mln_value(I)>,
- p_vertices<util::graph, fun::i2v::array<mln_site(I)> > >
- ima_vertex = vertex_values | pv;
+ vertex_image<mln_result(F), mln_value(I), G>
+ ima_vertex(pv, vertex_values);
trace::exiting("vertex_image");
return ima_vertex;
@@ -730,12 +731,13 @@ int main(int argc, char *argv[])
}
p_vertices<util::graph, fun::i2v::array<point2d> >
- pv = make::common_pvertices(ws, nbasins, rag_data.first());
+ pv = make::common_pvertices(ws, nbasins, gr);
- mln_VAR( med, f_med | pv );
+ typedef vertex_image<point2d,int_u8,util::graph> med_t;
+ med_t med(pv, f_med);
- typedef graph_elt_neighborhood<util::graph, F> N;
+ typedef med_t::nbh_t N;
N nbh;
threshold = 25; // FIXME
diff --git a/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
b/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
index 48cca5a..f08ca70 100644
--- a/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
+++ b/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
@@ -1,14 +1,13 @@
#include <mln/essential/2d.hh>
+#include <mln/core/image/edge_image.hh>
+
#include <mln/core/alias/dpoint2d.hh>
#include <mln/core/alias/vec3d.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/accu/center.hh>
#include <mln/accu/compute.hh>
-#include <mln/canvas/morpho/algebraic_union_find.hh>
-
#include <mln/debug/draw_graph.hh>
#include <mln/draw/box.hh>
@@ -34,6 +33,9 @@
#include <mln/value/hsl.hh>
#include <mln/make/region_adjacency_graph.hh>
+#include <mln/make/edge_image.hh>
+#include <mln/make/vertex_image.hh>
+#include <mln/make/p_vertices_with_mass_centers.hh>
// Given a color image and a wshed image, computes the component graph.
@@ -58,45 +60,39 @@ namespace mln
};
- value::int_u8 dist(const value::rgb8& c1, const value::rgb8& c2)
+ struct dist : Function_vv2v<dist>
{
- unsigned d = 0;
- d += (math::diff_abs(c1.red(), c2.red()) + 2) / 3;
- d += (math::diff_abs(c1.green(), c2.green()) + 2) / 3;
- d += (math::diff_abs(c1.blue(), c2.blue()) + 2) / 3;
- if (d > 255)
- d = 255;
- return d;
- }
+ typedef value::int_u8 result;
+
+ value::int_u8 operator()(const value::rgb8& c1, const value::rgb8& c2) const
+ {
+ unsigned d = 0;
+ d += (math::diff_abs(c1.red(), c2.red()) + 2) / 3;
+ d += (math::diff_abs(c1.green(), c2.green()) + 2) / 3;
+ d += (math::diff_abs(c1.blue(), c2.blue()) + 2) / 3;
+ if (d > 255u)
+ d = 255;
+ return d;
+ }
+
+ };
// ima_v, image on graph vertices; value = mean color per vertex (watershed basin)
template <typename I>
inline
- pw::image<fun::i2v::array<value::int_u8>,
- p_edges<util::graph, fun::i2v::array<mln_site(I)> > >
+ edge_image<mln_site(I),value::int_u8>
make_edge_graph_image(const I& ima_v, const util::graph& g)
{
// edge sites.
typedef fun::i2v::array<mln_site(I)> edge_site_t;
edge_site_t edge_site(g.e_nmax(), literal::origin);
- typedef p_edges<util::graph, edge_site_t > pe_t;
- pe_t pe(g, edge_site);
-
- // edge values
- typedef fun::i2v::array<value::int_u8> edge_values_t;
- edge_values_t edge_values(g.e_nmax());
// image on graph edges
- typedef pw::image<edge_values_t, pe_t> ima_e_t;
- ima_e_t ima_e = (edge_values | pe);
-
- mln_piter(ima_e_t) e(ima_e.domain());
- for_all(e) // in ima_e
- ima_e(e) = dist(ima_v.function()(e.element().v1()),
- ima_v.function()(e.element().v2()));
+ typedef edge_image<mln_site(I),value::int_u8> ima_e_t;
+ ima_e_t ima_e = make::edge_image(ima_v, edge_site, dist());
return ima_e;
}
@@ -123,30 +119,21 @@ namespace mln
}
template <typename I, typename J>
- pw::image<fun::i2v::array<mln_value(I)>,
- p_vertices<util::graph, fun::i2v::array<mln_site(I)> > >
+ vertex_image<mln_site(I), mln_value(I)>
make_vertex_graph_image(const util::graph& g, const I&input,
- const J& w, const mln_value(J)& nbasins)
+ const J& w, const mln_value(J)& nbasins)
{
- typedef util::array<mln_site(I)> vertex_sites_t;
- vertex_sites_t site_values;
- convert::from_to(labeling::compute(accu::center<mln_site(I)>(), w, nbasins),
- site_values);
-
- typedef fun::i2v::array<mln_site(J)> f_sites_t;
- f_sites_t sites;
- convert::from_to(site_values, sites);
-
- // p_vertices
- typedef p_vertices<util::graph, f_sites_t> S;
- S pv(g, sites);
-
+ /// Sites
+ typedef fun::i2v::array<mln_site(J)> vertex_sites_t;
+ typedef p_vertices<util::graph, vertex_sites_t> S;
+ S pv = make::p_vertices_with_mass_centers(w, nbasins, g);
+ /// Values
typedef fun::i2v::array<mln_value(I)> vertex_values_t;
vertex_values_t vertex_values;
convert::from_to(mean_color_values(input, w, nbasins), vertex_values);
- mln_VAR(ima_v, (vertex_values | pv));
+ vertex_image<mln_site(I), mln_value(I)> ima_v(pv, vertex_values);
return ima_v;
}
@@ -260,7 +247,7 @@ int main(int argc, char *argv[])
unsigned nbasins2;
fun::i2v::array<label_16> f;
{
- util::graph g = make::graph(vol, c4(), nbasins);
+ util::graph g = make::region_adjacency_graph(vol, c4(), nbasins);
mln_VAR(ima_v, make_vertex_graph_image(g, input, vol, nbasins));
mln_VAR(ima_e, make_edge_graph_image(ima_v, g));
@@ -302,7 +289,7 @@ int main(int argc, char *argv[])
// debug::println(vol);
vol2 = level::transform(vol, f);
// debug::println(vol2);
- util::graph g2 = make::graph(vol2, c4(), nbasins2);
+ util::graph g2 = make::region_adjacency_graph(vol2, c4(), nbasins2);
// Compute values distance on the HSL Image.
mln_VAR(ima_v2, make_vertex_graph_image(g2, input, vol2, nbasins2));
--
1.5.6.5