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
May 2009
- 11 participants
- 312 discussions
26 May '09
---
swilena/ChangeLog | 4 ++++
swilena/box2d.i | 23 ++++++++++++++++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 391d3e3..917269e 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,9 @@
2009-05-26 Roland Levillain <roland(a)lrde.epita.fr>
+ * box2d.i: Add a ctor taking two `int's as argument.
+
+2009-05-26 Roland Levillain <roland(a)lrde.epita.fr>
+
* python/sps-local.in (PYTHONPATH): Fix paths.
2009-05-14 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/swilena/box2d.i b/swilena/box2d.i
index 00e91e1..e24f016 100644
--- a/swilena/box2d.i
+++ b/swilena/box2d.i
@@ -1,5 +1,5 @@
// -*- C++ -*-
-// 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
@@ -42,8 +42,11 @@
%include "mln/core/site_set/box.hh";
%include "mln/core/alias/box2d.hh";
-// Swig tries to wrap everything by default; prevent it from wrapping
-// invalid methods (1D and 3D ctors for a box2d).
+/* Swig tries to wrap everything by default; prevent it from wrapping
+ invalid methods (1D and 3D ctors for an mln::box2d). Moreover, as
+ Python does not automatically convert `int's to `short's, we cannot
+ use the ctor taking two `mln::def::coord's (i.e. `short's)
+ either. */
/* FIXME: Can't we simplify these directives, i.e. use `point2d'
directly? Maybe we could use mln_coord()? */
%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> >
@@ -51,11 +54,22 @@
%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> >
::box(typename mln::point<mln::grid::square, mln::def::coord>::coord,
+ typename mln::point<mln::grid::square, mln::def::coord>::coord);
+
+%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> >
+::box(typename mln::point<mln::grid::square, mln::def::coord>::coord,
typename mln::point<mln::grid::square, mln::def::coord>::coord,
typename mln::point<mln::grid::square, mln::def::coord>::coord);
-%extend mln::box
+%extend mln::box< mln::point<mln::grid::square, mln::def::coord> >
{
+ // Provide a ctor creating an `mln::box2d' from two `int's.
+ mln::box< mln::point< mln::grid::square, mln::def::coord> > (int nrows,
+ int ncols)
+ {
+ return new mln::box<mln::point2d>(nrows, ncols);
+ }
+
unsigned nrows() const
{
// FIXME: This is the exact content of box_impl_<2, C, E>::nrows.
@@ -69,5 +83,4 @@
}
}
-
%template(box2d) mln::box< mln::point<mln::grid::square, mln::def::coord> >;
--
1.6.1.2
1
0
26 May '09
---
swilena/ChangeLog | 4 ++++
swilena/python/sps-local.in | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index 398b9ab..391d3e3 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-26 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * python/sps-local.in (PYTHONPATH): Fix paths.
+
2009-05-14 Roland Levillain <roland(a)lrde.epita.fr>
Improve Swilena.
diff --git a/swilena/python/sps-local.in b/swilena/python/sps-local.in
index 04126aa..91b7d77 100644
--- a/swilena/python/sps-local.in
+++ b/swilena/python/sps-local.in
@@ -1,6 +1,6 @@
# -*- sh -*-
# sps local version, for use from non installed distributions.
-PYTHONPATH='@abs_builddir@/python:@abs_srcdir@/python':"$PYTHONPATH" \
+PYTHONPATH='@abs_builddir@:@abs_srcdir@':"$PYTHONPATH" \
DYLD_LIBRARY_PATH='.libs:@abs_top_builddir@/src/.libs' \
exec @PYTHON@ -i @abs_srcdir@/sps.py "$@"
--
1.6.1.2
1
0
26 May '09
* mln/core/site_set/box_piter.hh
(mln::box_fwd_piter_(const mln::box<P>& b)): Here.
---
milena/ChangeLog | 7 +++++++
milena/mln/core/site_set/box_piter.hh | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 772c204..e8366b8 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-26 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Use fully qualified type names to help Swig.
+
+ * mln/core/site_set/box_piter.hh
+ (mln::box_fwd_piter_(const mln::box<P>& b)): Here.
+
2009-05-26 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Move propagation and filtering attributes routines from sandbox.
diff --git a/milena/mln/core/site_set/box_piter.hh b/milena/mln/core/site_set/box_piter.hh
index f312d8f..66242d1 100644
--- a/milena/mln/core/site_set/box_piter.hh
+++ b/milena/mln/core/site_set/box_piter.hh
@@ -66,7 +66,7 @@ namespace mln
///
/// \param[in] b A box.
///
- box_fwd_piter_(const box<P>& b);
+ box_fwd_piter_(const mln::box<P>& b);
/// Test the iterator validity.
bool is_valid_() const;
@@ -147,7 +147,7 @@ namespace mln
template <typename P>
inline
- box_fwd_piter_<P>::box_fwd_piter_(const box<P>& b)
+ box_fwd_piter_<P>::box_fwd_piter_(const mln::box<P>& b)
{
this->change_target(b);
}
--
1.6.1.2
1
0
---
scribo/tests/unit_test/.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 scribo/tests/unit_test/.gitignore
diff --git a/scribo/tests/unit_test/.gitignore b/scribo/tests/unit_test/.gitignore
new file mode 100644
index 0000000..d67e8d6
--- /dev/null
+++ b/scribo/tests/unit_test/.gitignore
@@ -0,0 +1 @@
+/scribo_*.cc
--
1.6.1.2
1
0
---
ChangeLog | 6 +-
milena/ChangeLog | 125 ++++++++++++++++++++-------------------------
milena/sandbox/ChangeLog | 63 ++++++++++++++---------
scribo/ChangeLog | 18 +++---
4 files changed, 107 insertions(+), 105 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f7ada5f..28f856d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,14 @@
2009-05-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
- * configure.ac: configure milena/tests/core/image/dmorph.
+ * configure.ac: Configure milena/tests/core/image/dmorph.
2009-05-22 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Configure scribo directory and generate unit tests.
- * configure.ac: configure scribo directory.
+ * configure.ac: Configure scribo directory.
- * bootstrap: generate unit tests for scribo.
+ * bootstrap: Generate unit tests for scribo.
2009-05-15 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8d18e3c..772c204 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -101,7 +101,7 @@
routine.
* tests/transformation/rotate.cc: fix wrong reference result.
-
+
* tests/util/Makefile.am: remove a non existing test.
2009-05-18 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -144,21 +144,6 @@
* mln/core/internal/image_domain_morpher.hh: Upgrade doc style.
* tests/core/image/p2p_image.cc: Move echo.
-2009-05-19 Etienne FOLIO <folio(a)lrde.epita.fr>
-
- HSV type, HSL <-> HSV conversions, and tests.
- * sandbox/folio/mln/fun/v2v/hsl_to_hsv.hh: New algorithms.
- * sandbox/folio/mln/fun/v2v/rgb_to_hsv.hh: float -> float01_<n>.
- * sandbox/folio/mln/histo/compute_histo_3d.hh: Some corrections.
- * sandbox/folio/mln/value/hsv.hh: HSV value type.
- * sandbox/folio/test/histo/plot_lena.cc: New test.
- * sandbox/folio/test/histo/plot_lena_3d.cc: New test.
- * sandbox/folio/test/histo/plot_lena_rgb.cc: New test.
- * sandbox/folio/test/histo/projected.cc: New test.
- * sandbox/folio/test/histo/projected3d.cc: New test.
- * sandbox/folio/test/value/circular.cc: test.
- * sandbox/folio/test/value/hsv.cc: test.
-
2009-05-19 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Extend plot I/O with load() function.
@@ -166,7 +151,7 @@
* mln/io/plot/all.hh: New file including plot/ files.
* mln/io/plot/load.hh: New draft for plot loading, nonfunctional.
* mln/io/plot/save.hh: Update delimiter to simple whitespace.
- * mln/labeling/compute.hh: Allow accumulator array to be
+ * mln/labeling/compute.hh: Allow accumulator array to be
passed as an argument.
2009-05-18 Roland Levillain <roland(a)lrde.epita.fr>
@@ -862,23 +847,23 @@
2009-05-06 Frederic Bour <bour(a)lrde.epita.fr>
Correct typo errors, rename storage_ to state, update thrubin morpher.
- * mln/core/concept/meta_function.hh: Add mln_fun_withbin for binary
+ * mln/core/concept/meta_function.hh: Add mln_fun_withbin for binary
metafunction.
- * mln/core/image/thrubin_morpher.hh: Correct implementation of
+ * mln/core/image/thrubin_morpher.hh: Correct implementation of
thrubin_morpher.hh.
- * mln/core/image/thru_morpher.hh: Typos correction.
- * mln/fun/binary.hh,
- * mln/fun/binary_param.hh: Renamed storage_get to state.
- * mln/fun/math/inf.hh,
- * mln/fun/math/sup.hh: Correct bug when working on two different
+ * mln/core/image/thru_morpher.hh: Typos correction.
+ * mln/fun/binary.hh,
+ * mln/fun/binary_param.hh: Renamed storage_get to state.
+ * mln/fun/math/inf.hh,
+ * mln/fun/math/sup.hh: Correct bug when working on two different
types.
- * mln/fun/spe/binary.hh,
- * mln/fun/spe/unary.hh,
- * mln/fun/unary.hh,
- * mln/fun/unary_param.hh: Renamed storage_get to state.
- * mln/trait/next/solve_proxy.hh: Added one inclusion to prevent
+ * mln/fun/spe/binary.hh,
+ * mln/fun/spe/unary.hh,
+ * mln/fun/unary.hh,
+ * mln/fun/unary_param.hh: Renamed storage_get to state.
+ * mln/trait/next/solve_proxy.hh: Added one inclusion to prevent
errors.
- * sandbox/fred/tests/thru.cc: Added test for thrubin.
+ * sandbox/fred/tests/thru.cc: Added test for thrubin.
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -913,27 +898,29 @@
2009-05-05 Frederic Bour <bour(a)lrde.epita.fr>
- Tidy source code of new functions, renamed trait::fun to trait::function.
- * mln/core/image/thru_morpher.hh,
- * mln/core/image/thrubin_morpher.hh,
- * mln/fun/accu_result.hh,
- * mln/fun/binary.hh: tidied.
- * mln/fun/component/comp.hh: Splitted into multiples files:
- * mln/fun/component/comp_count.hh: New,
- * mln/fun/component/ithcomp.hh: New,
- * mln/fun/component/scomp.hh: New. Static i'th component extraction.
- * mln/fun/math/cos.hh,
- * mln/fun/math/inf.hh,
- * mln/fun/math/sup.hh,
- * mln/fun/point/col.hh,
- * mln/fun/point/row.hh,
- * mln/fun/point/sli.hh,
- * mln/fun/spe/binary.hh,
- * mln/fun/spe/unary.hh,
- * mln/fun/unary.hh: tidied.
- * mln/trait/fun.hh: Removed. Renamed to:
- * mln/trait/functions.hh: New.
- * sandbox/fred/tests/fun.cc: Small update.
+ Tidy source code of new functions, renamed trait::fun to
+ trait::function.
+
+ * mln/core/image/thru_morpher.hh,
+ * mln/core/image/thrubin_morpher.hh,
+ * mln/fun/accu_result.hh,
+ * mln/fun/binary.hh: tidied.
+ * mln/fun/component/comp.hh: Splitted into multiples files:
+ * mln/fun/component/comp_count.hh: New,
+ * mln/fun/component/ithcomp.hh: New,
+ * mln/fun/component/scomp.hh: New. Static i'th component extraction.
+ * mln/fun/math/cos.hh,
+ * mln/fun/math/inf.hh,
+ * mln/fun/math/sup.hh,
+ * mln/fun/point/col.hh,
+ * mln/fun/point/row.hh,
+ * mln/fun/point/sli.hh,
+ * mln/fun/spe/binary.hh,
+ * mln/fun/spe/unary.hh,
+ * mln/fun/unary.hh: tidied.
+ * mln/trait/fun.hh: Removed. Renamed to:
+ * mln/trait/functions.hh: New.
+ * sandbox/fred/tests/fun.cc: Small update.
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -1192,17 +1179,17 @@
2009-04-29 Frederic Bour <bour(a)lrde.epita.fr>
Modification to parametrized functions, functions tutorial WIP.
- * mln/fun/binary.hh,
- * mln/fun/unary.hh: Modified parameters system. Now distinguish
+ * mln/fun/binary.hh,
+ * mln/fun/unary.hh: Modified parameters system. Now distinguish
Exact type from Flag type.
- * mln/fun/binary_param.hh: New.
- * mln/fun/from_accu.hh: Updated to latest functions syntax.
- * mln/fun/unary.hh: Modified parameters system.
- * mln/fun/unary_param.hh: New.
- * sandbox/fred/functions.html,
- * sandbox/fred/functions.mkdown: New. Tutorial
- * sandbox/fred/tests/Makefile: Added one test.
- * sandbox/fred/tests/wip.cc: New.
+ * mln/fun/binary_param.hh: New.
+ * mln/fun/from_accu.hh: Updated to latest functions syntax.
+ * mln/fun/unary.hh: Modified parameters system.
+ * mln/fun/unary_param.hh: New.
+ * sandbox/fred/functions.html,
+ * sandbox/fred/functions.mkdown: New. Tutorial
+ * sandbox/fred/tests/Makefile: Added one test.
+ * sandbox/fred/tests/wip.cc: New.
2009-04-29 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -2211,15 +2198,15 @@
2009-04-06 Frederic Bour <bour(a)lrde.epita.fr>
Clean new fun implementation.
- * sandbox/fred/mln/fun/binary.hh,
- * sandbox/fred/mln/fun/compose.hh,
- * sandbox/fred/mln/fun/composition.hh,
- * sandbox/fred/mln/fun/spe/binary.hh,
- * sandbox/fred/mln/fun/spe/unary.hh,
- * sandbox/fred/mln/fun/unary.hh: Clean and update to make use of
+ * sandbox/fred/mln/fun/binary.hh,
+ * sandbox/fred/mln/fun/compose.hh,
+ * sandbox/fred/mln/fun/composition.hh,
+ * sandbox/fred/mln/fun/spe/binary.hh,
+ * sandbox/fred/mln/fun/spe/unary.hh,
+ * sandbox/fred/mln/fun/unary.hh: Clean and update to make use of
param.hh.
- * sandbox/fred/mln/fun/param.hh: New.
- * sandbox/fred/mln/trait/fun.hh: Add support for parameter storage.
+ * sandbox/fred/mln/fun/param.hh: New.
+ * sandbox/fred/mln/trait/fun.hh: Add support for parameter storage.
2009-04-06 Edwin Carlinet <carlinet(a)lrde.epita.fr>
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 799eee1..4a9c521 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -24,7 +24,7 @@
Change processing chain, now filter before normalization.
* fabien/igr/Makefile: Add filter target.
* fabien/igr/filter.cc: New tool for filtering input.
- * fabien/igr/fixed_seg/main.cc: Update closing to
+ * fabien/igr/fixed_seg/main.cc: Update closing to
closing::sum
* fabien/igr/point_filtering/main.cc: Minor update.
@@ -34,6 +34,21 @@
* fabien/igr/point_filtering/Makefile: New target all.
* fabien/igr/point_filtering/main.cc: Load plots and compute filtering.
+2009-05-19 Etienne FOLIO <folio(a)lrde.epita.fr>
+
+ HSV type, HSL <-> HSV conversions, and tests.
+ * folio/mln/fun/v2v/hsl_to_hsv.hh: New algorithms.
+ * folio/mln/fun/v2v/rgb_to_hsv.hh: float -> float01_<n>.
+ * folio/mln/histo/compute_histo_3d.hh: Some corrections.
+ * folio/mln/value/hsv.hh: HSV value type.
+ * folio/test/histo/plot_lena.cc: New test.
+ * folio/test/histo/plot_lena_3d.cc: New test.
+ * folio/test/histo/plot_lena_rgb.cc: New test.
+ * folio/test/histo/projected.cc: New test.
+ * folio/test/histo/projected3d.cc: New test.
+ * folio/test/value/circular.cc: test.
+ * folio/test/value/hsv.cc: test.
+
2009-05-18 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move Scribo from sandbox to the root directory.
@@ -143,7 +158,7 @@
* milena/sandbox/scribo/text/grouping/internal/update_link_array.hh,
* milena/sandbox/scribo/text/recognition.hh,
* milena/sandbox/scribo/util/all.hh,
- * milena/sandbox/scribo/util/text.hh: move ...
+ * milena/sandbox/scribo/util/text.hh: Move ...
* scribo/Doxyfile,
* scribo/Doxyfile_tex,
@@ -306,32 +321,32 @@
inim: Improve boxes algorithm.
Because of recent changes in scribo, the current work won't compile
with the last SVN revision. However, it used to compile with r3697.
- * boxes.cc: Fix a couple of bugs.
+ * inim/2010/boxes/boxes.cc: Fix a couple of bugs.
2009-05-15 Etienne FOLIO <folio(a)lrde.epita.fr>
Small cleanup.
- * README: Howto.
- * configure: Cleaned.
- * morpho.cc: Cleaned.
+ * inim/2010/morpho/README: Howto.
+ * inim/2010/morpho/configure: Cleaned.
+ * inim/2010/morpho/morpho.cc: Cleaned.
2009-05-15 Etienne FOLIO <folio(a)lrde.epita.fr>
Move a script.
- * run.sh: New moved file.
- * treat.sh: Remove moved file.
+ * inim/2010/morpho/run.sh: New moved file.
+ * inim/2010/morpho/treat.sh: Remove moved file.
2009-05-15 Etienne FOLIO <folio(a)lrde.epita.fr>
Big cleanup.
- * Makefile: Remove. Not needed.
- * README: New explainations.
- * configure: To build the Makefile.
- * dilation-n.hh: New algorithm.
- * erosion-n.hh: New algorithm.
- * main_dilation-n.cc: New test file.
- * morpho.cc: Cleanup in here.
- * treat.sh: Adaptation.
+ * inim/2010/morpho/Makefile: Remove. Not needed.
+ * inim/2010/morpho/README: New explainations.
+ * inim/2010/morpho/configure: To build the Makefile.
+ * inim/2010/morpho/dilation-n.hh: New algorithm.
+ * inim/2010/morpho/erosion-n.hh: New algorithm.
+ * inim/2010/morpho/main_dilation-n.cc: New test file.
+ * inim/2010/morpho/morpho.cc: Cleanup in here.
+ * inim/2010/morpho/treat.sh: Adaptation.
2009-05-15 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
@@ -346,11 +361,11 @@
* inim/2010/blur/Makefile: Add -DNDEBUG.
* inim/2010/blur/README: Add information about results.
* inim/2010/blur/cuttor.hxx: Call to gaussian_directional_2d.
- Add compile time errors.
- * inim/2010/blur/vect_it.hh: Change file included from
- vect_it to vect_it_OLD.
- * inim/2010/blur/vect_it_OLD.hxx: Try fixing the problem of
- backward search.
+ Add compile time errors.
+ * inim/2010/blur/vect_it.hh: Change file included from
+ vect_it to vect_it_OLD.
+ * inim/2010/blur/vect_it_OLD.hxx: Try fixing the problem of
+ backward search.
2009-05-15 Florent DHalluin <d-halluin(a)lrde.epita.fr>
@@ -398,11 +413,11 @@
Inim fix bugs related to word croping.
* edwin/inim/inim.cc: Add height closing to avoid word to be cropped.
* edwin/mln/morpho/tree/filter.hh: Add generic filter to
- replace filtered components by a user value instead of
- predefined values.
+ replace filtered components by a user value instead of
+ predefined values.
* edwin/rush/exo2/test.cc: Minor fixes.
* edwin/rush/exo2/wst_from_tree.cc: Test corrected sharpness
- with wst.
+ with wst.
* inim/2011/fredwin: New.
2009-05-15 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 82c4648..e4b5756 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,19 +1,19 @@
2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
- Add missing Makefile.am in Scribo.
+ Add missing Makefile.am in Scribo.
- * Makefile.am,
- * src/Makefile.am,
- * src/binarization/Makefile.am,
- * tests/Makefile.am,
- * tests/preprocessing/Makefile.am,
- * tests/unit_test/Makefile.am: new.
+ * Makefile.am,
+ * src/Makefile.am,
+ * src/binarization/Makefile.am,
+ * tests/Makefile.am,
+ * tests/preprocessing/Makefile.am,
+ * tests/unit_test/Makefile.am: new.
2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
- Add a script to generate unit tests for scribo.
+ Add a script to generate unit tests for scribo.
- * tests/unit_test/build_unit_test.sh: new.
+ * tests/unit_test/build_unit_test.sh: new.
$Rev$
--
1.6.1.2
1
0
On 26/05/09 20:03, Roland Levillain wrote:
> Vincent Ordy<ordy(a)lrde.epita.fr> writes:
>> inim: Improve boxes algorithm.
>> Because of recent changes in scribo, the current work won't compile
>> with the last SVN revision. However, it used to compile with r3697.
>
> Ce n'est pas le genre d'information qui doit figurer dans un ChangeLog.
> Ce fichier décrit ce qui se passe dans la distribution des fichiers, pas
> dans le dépôt.
Noté.
>> * boxes.cc: Fix a couple of bugs.
>
> Mauvais chemin.
>
> Attention aux bugs de svn-wrapper : il faut faire `svn commit' depuis le
> répertoire qui contient le ChangeLog où seront inscrits les changements
> (en l'occurrence milena/sandbox/).
Arf, c'est de ma faute, je n'y ai pas prêté attention à ce moment.
--
Warren Seine
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-05-16 Vincent Ordy <ordy(a)lrde.epita.fr>
inim: Improve boxes algorithm.
Because of recent changes in scribo, the current work won't compile
with the last SVN revision. However, it used to compile with r3697.
* boxes.cc: Fix a couple of bugs.
---
boxes.cc | 156 ++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 85 insertions(+), 71 deletions(-)
Index: trunk/milena/sandbox/inim/2010/boxes/boxes.cc
===================================================================
--- trunk/milena/sandbox/inim/2010/boxes/boxes.cc (revision 3848)
+++ trunk/milena/sandbox/inim/2010/boxes/boxes.cc (revision 3849)
@@ -38,16 +38,13 @@
#include <scribo/debug/save_linked_textbboxes_image.hh>
#include <scribo/text/grouping/group_from_double_link.hh>
#include <scribo/filter/small_components.hh>
-
#include <scribo/debug/save_textbboxes_image.hh>
#include <scribo/make/debug_filename.hh>
#include <mln/logical/not.hh>
#include <mln/io/dump/save.hh>
-
#include <mln/io/pgm/save.hh>
#include <mln/fun/v2v/wrap.hh>
-
#include <mln/math/abs.hh>
int usage(const char *name)
@@ -61,103 +58,127 @@
typedef image2d<value::label_16> scribo_image;
-template< typename T >
-double vec_y_norm(const T& t)
-{
- return mln::math::abs(t[1] / t[0]);
-}
template< typename T >
-double bboxes_y_mean(const T& bboxes)
+double
+bboxes_height_mean(const T& bboxes)
{
double mean = 0.;
+ unsigned count = 0;
for (unsigned i = 1; i < bboxes.nelements(); i++)
{
mln_VAR(s, bboxes[i].pmax() - bboxes[i].pmin());
- mean += (s[1] / s[0]);
+ if (s[1] < 10 || s[1] > 300)
+ continue;
+
+ mean += s[1];
+ count++;
}
- mean /= static_cast<double>(bboxes.nelements());
+ mean /= static_cast<double>(count);
return mean;
}
+
+template <typename I>
+scribo::util::text<I>
+group_from_line_array(const scribo::util::text<I>& text,
+ mln::util::array<unsigned>& array)
+{
+ /// Accumulator array
+ mln::util::array< accu::bbox<mln_site(I)> > tboxes;
+ tboxes.resize(text.bboxes().nelements());
+
+ /// Adding bounding boxes to accumulator
+ for (unsigned label = 0; label < array.size(); ++label)
+ for (unsigned i = label; i < array.size(); i++)
+ {
+ if (label != array[i])
+ continue;
+
+ tboxes[label].take(text.bbox(i));
+ }
+
+ fun::i2v::array<unsigned> f;
+ convert::from_to(array, f);
+
+ /// Finding valid bounding boxes
+ mln::util::array< box<mln_site(I)> > bresult;
+ bresult.append(box<mln_site(I)>());
+ for_all_components(i, tboxes)
+ if (tboxes[i].is_valid())
+ bresult.append(tboxes[i]);
+
+ /// Labelizing (FIXME)
+ mln_value(I) new_nbboxes;
+ I new_lbl = labeling::relabel(text.label_image(),
+ text.nbboxes(),
+ mln::make::relabelfun(f, text.nbboxes(),
+ new_nbboxes));
+
+ scribo::util::text<I> result(bresult, new_lbl, new_nbboxes);
+ return result;
+}
+
+
int main(int argc, char* argv[])
{
if (argc != 3)
return usage(argv[0]);
- scribo::make::internal::debug_filename_prefix = "extract_text_double_link";
+ std::cout << "# Line detection algorithm (boxes)" << std::endl << std::endl;
- std::cout << "Debug 1" << std::endl;
+ scribo::make::internal::debug_filename_prefix = "extract_text_double_link";
+ /// Loading image
image2d<bool> input;
io::pbm::load(input, argv[1]);
-
- std::cout << "Debug 2" << std::endl;
-
logical::not_inplace(input);
- std::cout << "Debug 3" << std::endl;
-
+ /// Extract boxes
value::label_16 nbboxes;
scribo::util::text<image2d<value::label_16> >
text = text::extract_bboxes(input, c8(), nbboxes);
-
- std::cout << "Debug 4" << std::endl;
-
text = filter::small_components(text,4);
- std::cout << "Debug 5" << std::endl;
-
+ /// Grouping components
mln::util::array<unsigned>
left_link = text::grouping::group_with_single_left_link(text, 30),
right_link = text::grouping::group_with_single_right_link(text, 30);
- std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
-
+ std::cout << "* Before validation: " << nbboxes << " boxes" << std::endl;
- std::cout << "Debug 6" << std::endl;
scribo::debug::save_linked_textbboxes_image(input,
text, left_link, right_link,
- literal::red, literal::cyan, literal::yellow,
+ literal::red,
+ literal::cyan,
+ literal::yellow,
literal::green,
scribo::make::debug_filename("links.ppm"));
- std::cout << "Debug 7" << std::endl;
-
- // Validation.
+ // Validation
scribo::util::text< scribo_image > grouped_text
= text::grouping::group_from_double_link(text, left_link, right_link);
- std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
-
- io::dump::save(grouped_text.label_image(), argv[2]);
+ std::cout << "* After validation: " << grouped_text.bboxes().nelements()
+ << " boxes" << std::endl;
+ /// Save grouped text image
io::pgm::save(level::transform(grouped_text.label_image(),
fun::v2v::wrap<value::int_u8>()),
- "tmp.pgm");
-
- std::cout << "Debug 8" << std::endl;
-
-
-
-
-
-
+ "words.pgm");
mln_VAR(b, grouped_text.bboxes());
- std::cout << "Bounding boxes: " << std::endl << b << std::endl;
-
mln_VAR(m, grouped_text.mass_centers());
- std::cout << "Mass centers: " << std::endl << m << std::endl;
- // Mean of the y components of the bounding boxes
- double mean = bboxes_y_mean(b);
- std::cout << "Mean: " << mean << std::endl;
+ // Word height mean
+ double word_height_mean = bboxes_height_mean(b);
+ std::cout << "* Word height mean: " << word_height_mean << std::endl;
+
mln::util::array< unsigned > lines(m.size());
@@ -172,36 +193,29 @@
if (i == j)
continue;
- double y_norm_diff = vec_y_norm(m[j] - m[i]);
-// std::cout << "y_norm_diff: " << y_norm_diff << std::endl;
- if (y_norm_diff > 1000)
- {
- std::cout << "(" << i << "," << j << ")" << std::endl;
- continue;
- }
- if (y_norm_diff < mean * 2)
- {
+ double component_y_diff = mln::math::abs(m[j][0] - m[i][0]);
+
+ if (component_y_diff < 0.3 * word_height_mean)
lines[j] = lines[i];
-// std::cout << "Associating " << i << " to " << j << std::endl;
- }
}
- std::cout << "Lines: " << std::endl << lines << std::endl;
-
-// scribo::util::text< scribo_image > grouped_lines
-// = text::grouping::group_from_single_link(text, lines);
-
-
-
-
-
-
+ scribo::util::text< scribo_image > grouped_lines
+ = group_from_line_array(grouped_text, lines);
+ std::cout << "* Line number: " << grouped_lines.bboxes().nelements()
+ << std::endl;
scribo::debug::save_textbboxes_image(input, grouped_text.bboxes(),
literal::red,
scribo::make::debug_filename("boxes.ppm"));
- std::cout << "Debug 9" << std::endl;
-}
+ /// Does not seem to work (FIXME)
+ io::pgm::save(level::transform(grouped_lines.label_image(),
+ fun::l2l::wrap<value::int_u8>()),
+ "fixme.ppm");
+ /// Alternative save
+ scribo::debug::save_textbboxes_image(input, grouped_lines.bboxes(),
+ literal::red,
+ argv[2]);
+}
2
1
milena r3875: Move propagation and filtering attributes routines from sandbox
by Edwin Carlinet 26 May '09
by Edwin Carlinet 26 May '09
26 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-26 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Move propagation and filtering attributes routines from sandbox.
* mln/morpho/tree/filter: New.
* mln/morpho/tree/propagate_if.hh: New.
* mln/morpho/tree/propagate_node.hh: New.
* mln/morpho/tree/propagate_representative.hh: New.
* sandbox/edwin/mln/morpho/tree/filter/all.hh: Remove.
* sandbox/edwin/mln/morpho/tree/filter/direct.hh: Remove.
* sandbox/edwin/mln/morpho/tree/filter/max.hh: Remove.
* sandbox/edwin/mln/morpho/tree/filter/min.hh: Remove.
* sandbox/edwin/mln/morpho/tree/filter/subtractive.hh: Remove.
* sandbox/edwin/mln/morpho/tree/filter: Remove.
* sandbox/edwin/mln/morpho/tree/propagate_if.hh: Remove.
* sandbox/edwin/mln/morpho/tree/propagate_node.hh: Remove.
* sandbox/edwin/mln/morpho/tree/propagate_representative.hh: Remove.
---
trunk/milena/headers.mk | 10
trunk/milena/mln/morpho/tree/filter/all.hh | 66 +++
trunk/milena/mln/morpho/tree/filter/direct.hh | 91 ++++
trunk/milena/mln/morpho/tree/filter/max.hh | 110 +++++
trunk/milena/mln/morpho/tree/filter/min.hh | 100 ++++
trunk/milena/mln/morpho/tree/filter/subtractive.hh | 97 ++++
trunk/milena/mln/morpho/tree/propagate_if.hh | 326 +++++++++++++++
trunk/milena/mln/morpho/tree/propagate_node.hh | 209 +++++++++
trunk/milena/mln/morpho/tree/propagate_representative.hh | 76 +++
9 files changed, 1084 insertions(+), 1 deletion(-)
Index: trunk/milena/headers.mk
===================================================================
--- trunk/milena/headers.mk (revision 3874)
+++ trunk/milena/headers.mk (revision 3875)
@@ -261,6 +261,8 @@
mln/core/image/complex_window_piter.hh \
mln/core/image/complex_windows.hh \
mln/core/image/decorated_image.hh \
+mln/core/image/dmorph/all.hh \
+mln/core/image/dmorph/transformed_image.hh \
mln/core/image/edge_image.hh \
mln/core/image/essential.hh \
mln/core/image/extended.hh \
@@ -398,6 +400,8 @@
mln/core/site_set/p_run_piter.hh \
mln/core/site_set/p_set.hh \
mln/core/site_set/p_set_of.hh \
+mln/core/site_set/p_transformed.hh \
+mln/core/site_set/p_transformed_piter.hh \
mln/core/site_set/p_vaccess.hh \
mln/core/site_set/p_vertices.hh \
mln/core/site_set/p_vertices_psite.hh \
@@ -664,6 +668,8 @@
mln/io/pgm/all.hh \
mln/io/pgm/load.hh \
mln/io/pgm/save.hh \
+mln/io/plot/all.hh \
+mln/io/plot/load.hh \
mln/io/plot/save.hh \
mln/io/pnm/all.hh \
mln/io/pnm/load_header.hh \
@@ -677,7 +683,6 @@
mln/io/ppm/save.hh \
mln/io/tiff/all.hh \
mln/io/tiff/load.hh \
-mln/io/tiff/save.hh \
mln/io/txt/all.hh \
mln/io/txt/save.hh \
mln/labeling/all.hh \
@@ -934,6 +939,8 @@
mln/morpho/reconstruction/all.hh \
mln/morpho/reconstruction/by_dilation/all.hh \
mln/morpho/reconstruction/by_dilation/union_find.hh \
+mln/morpho/reconstruction/by_erosion/all.hh \
+mln/morpho/reconstruction/by_erosion/union_find.hh \
mln/morpho/skeleton_constrained.hh \
mln/morpho/thickening.hh \
mln/morpho/thick_miss.hh \
@@ -1245,6 +1252,7 @@
mln/value/stack.hh \
mln/value/super_value.hh \
mln/value/viter.hh \
+mln/version.hh \
mln/win/all.hh \
mln/win/backdiag2d.hh \
mln/win/ball.hh \
Index: trunk/milena/mln/morpho/tree/propagate_representative.hh
===================================================================
--- trunk/milena/mln/morpho/tree/propagate_representative.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/propagate_representative.hh (revision 3875)
@@ -0,0 +1,76 @@
+// 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_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_
+
+/// \file mln/morpho/tree/propagate_representative.hh
+///
+/// Component tree routines.
+
+namespace mln{
+ namespace morpho {
+ namespace tree {
+
+ /**
+ ** Propagate the representative node's value to
+ ** non-representative points of the component.
+ **
+ ** @param t Component tree.
+ ** @param f_ Value image.
+ */
+ template <typename T, typename F>
+ void
+ propagate_representative(const T& t, Image<F>& f_);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F>
+ inline
+ void
+ propagate_representative(const T& t, Image<F>& f_)
+ {
+ F a = exact(f_);
+ mln_up_site_piter(T) p(t);
+ for_all(p)
+ if (! t.is_a_node(p))
+ {
+ mln_assertion(t.is_a_node(t.parent(p)));
+ a(p) = a(t.parent(p));
+ }
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ }
+ }
+}
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_ */
Property changes on: trunk/milena/mln/morpho/tree/propagate_representative.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/mln/morpho/tree/filter/min.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/min.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/min.hh (revision 3875)
@@ -0,0 +1,100 @@
+// 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_MORPHO_TREE_FILTER_MIN_HH_
+# define MLN_MORPHO_TREE_FILTER_MIN_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+
+/**
+** @file mln/morpho/tree/filter/min.hh
+**
+** @brief Filtering with min strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+
+ /**
+ ** Min pruning strategy. A node is removed iif its parent is
+ ** removed or if it does not verify the predicate \p pred_.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::min");
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)) || !pred(n))
+ {
+ f(n) = f(tree.parent(n));
+ mark(n) = true;
+ }
+
+ trace::exiting("mln::morpho::tree::filter::min");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_MIN_HH_ */
Index: trunk/milena/mln/morpho/tree/filter/max.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/max.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/max.hh (revision 3875)
@@ -0,0 +1,110 @@
+// 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_MORPHO_TREE_FILTER_MAX_HH_
+# define MLN_MORPHO_TREE_FILTER_MAX_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+/**
+** @file mln/morpho/tree/filter/max.hh
+**
+** @brief Filtering with max strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Max pruning strategy. A node is removed iif all of its
+ ** children are removed or if it does not verify the predicate
+ ** \p pred_.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::max");
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, true);
+
+ {
+ mln_up_node_piter(T) n(tree);
+ for_all(n)
+ if (!mark(n))
+ mark(tree.parent(n)) = false;
+ else if (pred(n))
+ {
+ mark(tree.parent(n)) = false;
+ mark(n) = false;
+ }
+ }
+
+ {
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(n))
+ f(n) = f(tree.parent(n));
+ }
+
+ trace::exiting("mln::morpho::tree::filter::max");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_MAX_HH_ */
Index: trunk/milena/mln/morpho/tree/filter/all.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/all.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/all.hh (revision 3875)
@@ -0,0 +1,66 @@
+// 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_MORPHO_TREE_FILTER_ALL_HH_
+# define MLN_MORPHO_TREE_FILTER_ALL_HH_
+
+/**
+** @file mln/morpho/tree/filter.hh
+**
+** Methods to handle component tree filtering strategies with
+** non-increasing attribute. Nevertheless, it works on increasing
+** predicate as well. In this case, all strategies have the same
+** result but min filter or direct filter should be used in term
+** of performance. If a predicate test is too slow, then consider
+** the min filter that minimizes calls to predicate function.
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ /// Namespace for attribute filtering.
+ namespace filter {
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+// Pruning strategies.
+# include <mln/morpho/tree/filter/min.hh>
+# include <mln/morpho/tree/filter/max.hh>
+
+// Non-pruning stategies.
+# include <mln/morpho/tree/filter/direct.hh>
+# include <mln/morpho/tree/filter/subtractive.hh>
+
+
+
+#endif /* !MLN_MORPHO_TREE_FILTER_ALL_HH_ */
Index: trunk/milena/mln/morpho/tree/filter/direct.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/direct.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/direct.hh (revision 3875)
@@ -0,0 +1,91 @@
+// 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_MORPHO_TREE_FILTER_DIRECT_HH_
+# define MLN_MORPHO_TREE_FILTER_DIRECT_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+/**
+** @file mln/morpho/tree/filter/direct.hh
+**
+** @brief Filtering with direct strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Direct non-pruning strategy. A node is removed if it does
+ ** not verify the predicate. The sub-components remain intact.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::direct");
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (!pred(n))
+ f(n) = f(tree.parent(n));
+
+ trace::exiting("mln::morpho::tree::filter::direct");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_DIRECT_HH_ */
Index: trunk/milena/mln/morpho/tree/filter/subtractive.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/subtractive.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/subtractive.hh (revision 3875)
@@ -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.
+
+#ifndef MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_
+# define MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/ops.hh>
+
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/propagate_if.hh>
+
+/**
+** @file mln/morpho/tree/filter/subtractive.hh
+**
+** @brief Filtering with subtractive strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Subtractive pruning strategy. The node is removed if it
+ ** does not verify the predicate. The sub-components values
+ ** are set to the value of the removed component.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::subtractive");
+
+ morpho::tree::propagate_if(tree, f, morpho::tree::desc_propagation (), !pred);
+
+ mln_up_node_piter(T) n(tree);
+ for_all(n)
+ if (!pred(n))
+ f(n) = f(tree.parent(n));
+
+ trace::exiting("mln::morpho::tree::filter::subtractive");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_ */
Property changes on: trunk/milena/mln/morpho/tree/filter
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/mln/morpho/tree/propagate_node.hh
===================================================================
--- trunk/milena/mln/morpho/tree/propagate_node.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/propagate_node.hh (revision 3875)
@@ -0,0 +1,209 @@
+// 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_MORPHO_TREE_PROPAGATE_NODE_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_NODE_HH_
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/macros.hh>
+# include <mln/morpho/tree/data.hh>
+
+/// \file mln/morpho/tree/propagate_node.hh
+///
+/// Functions to propagate node in the tree.
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ /**
+ ** Propagate a value \p v from a node \p n to its descendants.
+ **
+ ** @param n[in] Node to propagate.
+ ** @param t[in] Component tree used for propagation.
+ ** @param a_[in] Attribute image where values are propagated.
+ ** @param v[in] Value to propagate.
+ ** @param nb_leaves[out] Optional. Store the number of leaves in
+ ** the component.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ const mln_value(A)& v,
+ unsigned* nb_leaves = 0);
+
+ /**
+ ** Propagate the node's value to its descendants.
+ **
+ ** @param n[in] Node to propagate.
+ ** @param t[in] Component tree used for propagation.
+ ** @param a_[in] Attribute image where values are propagated.
+ ** @param nb_leaves[out] Optional. Store the number of leaves in
+ ** the component.
+ */
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_descendants(mln_psite(A)& n,
+ const T& t,
+ Image<A>& a_,
+ unsigned* nb_leaves = 0);
+
+
+ /**
+ ** Propagate a value \p v from a node \p n to its ancestors.
+ **
+ ** @param n Node to propagate.
+ ** @param t Component tree used for propagation.
+ ** @param a_ Attribute image where values are propagated.
+ ** @param v Value to propagate.
+ */
+ template <typename T, typename A>
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ const mln_value(A)& v);
+
+ /**
+ ** Propagate the node's value to its ancestors.
+ **
+ ** @param n Node to propagate.
+ ** @param t Component tree used for propagation.
+ ** @param a_ Attribute image where values are propagated.
+ */
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_);
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ /* Descendants propagation */
+
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ const mln_value(A)& v,
+ unsigned* nb_leaves = 0)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+ mln_precondition(a.domain().has(n));
+
+
+ if (!t.is_a_node(n)) // Get the representant.
+ n = t.parent(n);
+ mln_assertion(t.is_a_node(n));
+
+ typename T::preorder_piter pp(t, n);
+
+ pp.start(); // We don't set n to v.
+
+ if (nb_leaves)
+ *nb_leaves += t.is_a_leaf(pp);
+
+ for (pp.next(); pp.is_valid(); pp.next())
+ {
+ a(pp) = v;
+ if (nb_leaves && t.is_a_leaf(pp))
+ ++(*nb_leaves);
+ }
+ }
+
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_descendants(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ unsigned* nb_leaves = 0)
+
+ {
+ A& a = exact(a_);
+ propagate_node_to_descendants(n, t, a, a(n), nb_leaves);
+ }
+
+
+ /* Ancestors propagation */
+
+ template <typename T, typename A>
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_,
+ const mln_value(A)& v)
+ {
+ A& a = exact(a_);
+ mln_precondition(a.is_valid());
+ mln_precondition(a.domain() == t.f().domain());
+ mln_precondition(a.domain().has(n));
+
+ if (!t.is_a_node(n)) // Get the representant.
+ n = t.parent(n);
+ mln_assertion(t.is_a_node(n));
+
+ if (t.is_root(n))
+ return;
+
+ do {
+ n = t.parent(n);
+ a(n) = v;
+ } while (!t.is_root(n));
+
+ }
+
+ template <typename T, typename A>
+ inline
+ void
+ propagate_node_to_ancestors(mln_psite(A) n,
+ const T& t,
+ Image<A>& a_)
+ {
+ A& a = exact(a_);
+ propagate_node_to_ancestors(n, t, a, a(n));
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_NODE_HH_ */
Property changes on: trunk/milena/mln/morpho/tree/propagate_node.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/mln/morpho/tree/propagate_if.hh
===================================================================
--- trunk/milena/mln/morpho/tree/propagate_if.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/propagate_if.hh (revision 3875)
@@ -0,0 +1,326 @@
+// 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_MORPHO_TREE_PROPAGATE_IF_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_IF_HH_
+
+/**
+** @file mln/morpho/tree/propagate_if.hh
+**
+** @brief Routines to handle propagation with predicate.
+**
+*/
+
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/propagate_node.hh>
+
+# include <mln/data/fill.hh>
+# include <mln/pw/all.hh>
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ template <typename WP>
+ struct way_of_propagation : Object< WP > { protected: way_of_propagation() {}; };
+ struct desc_propagation : way_of_propagation <desc_propagation> {};
+ struct asc_propagation : way_of_propagation <asc_propagation> {};
+
+ /**
+ ** Propagate nodes checking the predicate \p pred in the way
+ ** defined by \p way_of_propagation.
+ **
+ ** @param tree Component tree used for propagation.
+ ** @param a_ Attributed image where values are propagated.
+ ** @param way_of_propagation Propagate node in acsendant or
+ ** descendant way.
+ ** @param pred Predicate that node must check to be propagated.
+ ** @param v Value to be propagated. (By default \p v is the value
+ ** at the node being propagated).
+ */
+ template <typename T, typename A, typename P2B, typename WP>
+ inline
+ void
+ propagate_if(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>&,
+ const Function_p2b<P2B>& pred,
+ const mln_value(A)& v);
+
+ template <typename T, typename A, typename P2B>
+ inline
+ void
+ propagate_if(const T& tree,
+ Image<A>& a_,
+ const desc_propagation&,
+ const Function_p2b<P2B>& pred);
+
+ /**
+ ** Propagate nodes having the value v in the way
+ ** defined by \p way_of_propagation.
+ **
+ ** @param tree Component tree used for propagation.
+ ** @param a_ Attributed image where values are propagated.
+ ** @param way_of_propagation Propagate node in acsendant or
+ ** descendant way.
+ ** @param v Value that node must have to be propagated.
+ ** @param v_prop Value to propagate (By default it is the value
+ ** at the node being propagated).
+ */
+ template <typename T, typename A, typename WP>
+ inline
+ void
+ propagate_if_value(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>&,
+ const mln_value(A)& v,
+ const mln_value(A)& v_prop);
+
+ template <typename T, typename A, typename WP>
+ inline
+ void
+ propagate_if_value(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>&,
+ const mln_value(A)& v);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+ template <typename T, typename A, typename P2B>
+ bool check_propagate_if(const T& t,
+ const A& a,
+ const asc_propagation& prop,
+ const P2B& pred,
+ const mln_value(A)& v)
+ {
+ (void) prop;
+ mln_node_piter(T) n(t);
+ for_all(n)
+ if (pred(n) && a(t.parent(n)) != v)
+ return false;
+ return true;
+ }
+
+ template <typename T, typename A, typename P2B>
+ bool check_propagate_if(const T& t,
+ const A& a,
+ const desc_propagation& prop,
+ const P2B& pred,
+ const mln_value(A)& v)
+ {
+ (void) prop;
+ mln_node_piter(T) n(t);
+ for_all(n)
+ if (a(n) != v && pred(t.parent(n)))
+ return false;
+ return true;
+ }
+
+ template <typename T, typename A, typename P2B>
+ bool check_propagate_if(const T& t,
+ const A& a,
+ const desc_propagation& prop,
+ const P2B& pred)
+ {
+ (void) prop;
+ mln_node_piter(T) n(t);
+ for_all(n)
+ if (a(n) != a(t.parent(n)) && pred(t.parent(n)))
+ return false;
+ return true;
+ }
+
+ template <typename T, typename A, typename P2B>
+ inline
+ void
+ propagate_if(const T& tree,
+ A& a,
+ const desc_propagation& prop,
+ const P2B& pred,
+ const mln_value(A)& v)
+ {
+ (void) prop;
+
+ mln_precondition(a.is_valid());
+ mln_precondition(tree.f().domain() == a.domain());
+
+ mln_ch_value(typename T::function, bool) mark;
+ initialize(mark, tree.f());
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)))
+ {
+ a(n) = v;
+ mark(n) = true;
+ }
+ else if (pred(n))
+ mark(n) = true;
+ mln_postcondition(check_propagate_if(tree, a, prop, pred, v));
+ }
+
+ template <typename T, typename A, typename P2B>
+ inline
+ void
+ propagate_if(const T& tree,
+ A& a,
+ const desc_propagation& prop,
+ const P2B& pred)
+ {
+ (void) prop;
+
+ mln_precondition(a.is_valid());
+ mln_precondition(tree.f().domain() == a.domain());
+
+ mln_ch_value(typename T::function, bool) mark;
+ initialize(mark, tree.f());
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)))
+ {
+ a(n) = a(tree.parent(n));
+ mark(n) = true;
+ }
+ else if (pred(n))
+ mark(n) = true;
+ mln_postcondition(check_propagate_if(tree, a, prop, pred));
+ }
+
+
+ template <typename T, typename A, typename P2B>
+ inline
+ void
+ propagate_if(const T& tree,
+ A& a,
+ const asc_propagation& prop,
+ const P2B& pred,
+ const mln_value(A)& v)
+ {
+ (void) prop;
+
+ mln_precondition(a.is_valid());
+ mln_precondition(tree.f().domain() == a.domain());
+
+ mln_ch_value(typename T::function, bool) mark;
+ initialize(mark, tree.f());
+ mln::data::fill(mark, false);
+
+ mln_up_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(n))
+ {
+ a(n) = v;
+ mark(tree.parent(n)) = true;
+ }
+ else if (pred(n))
+ mark(tree.parent(n)) = true;
+
+ mln_postcondition(check_propagate_if(tree, a, prop, pred, v));
+ }
+
+ } // end of namespace mln::morpho::tree::internal
+
+
+ /* Facades */
+
+ template <typename T, typename A, typename WP>
+ inline
+ void
+ propagate_if_value(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>& prop_,
+ const mln_value(A)& v,
+ const mln_value(A)& v_prop)
+ {
+ A& a = exact(a_);
+ const WP& prop = exact(prop_);
+
+ internal::propagate_if(tree, a, prop, pw::value(a) == pw::cst(v), v_prop);
+ }
+
+
+ template <typename T, typename A, typename WP>
+ inline
+ void
+ propagate_if_value(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>& prop_,
+ const mln_value(A)& v)
+ {
+ A& a = exact(a_);
+ const WP& prop = exact(prop_);
+
+ internal::propagate_if(tree, a, prop, pw::value(a) == pw::cst(v), v);
+ }
+
+ template <typename T, typename A, typename P2B, typename WP>
+ inline
+ void
+ propagate_if(const T& tree,
+ Image<A>& a_,
+ const way_of_propagation<WP>& prop_,
+ const Function_p2b<P2B>& pred_,
+ const mln_value(A)& v)
+ {
+ A& a = exact(a_);
+ const WP& prop = exact(prop_);
+ const P2B& pred = exact(pred_);
+
+ internal::propagate_if(tree, a, prop, pred, v);
+ }
+
+ template <typename T, typename A, typename P2B>
+ inline
+ void
+ propagate_if(const T& tree,
+ Image<A>& a_,
+ const desc_propagation& prop,
+ const Function_p2b<P2B>& pred_)
+ {
+ A& a = exact(a_);
+ const P2B& pred = exact(pred_);
+
+ internal::propagate_if(tree, a, prop, pred);
+ }
+
+#endif /* !MLN_INCLUDE_ONLY */
+
+
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_IF_HH_ */
Property changes on: trunk/milena/mln/morpho/tree/propagate_if.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_representative.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh (deleted)
===================================================================
1
0
milena r3874: Add getters to base and current level to height attribute
by Edwin Carlinet 26 May '09
by Edwin Carlinet 26 May '09
26 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-26 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add getters to base and current level to height attribute.
* mln/morpho/attribute/height.hh: Add base and current level getters.
---
height.hh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
Index: trunk/milena/mln/morpho/attribute/height.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/height.hh (revision 3873)
+++ trunk/milena/mln/morpho/attribute/height.hh (revision 3874)
@@ -104,6 +104,10 @@
/// Get the value of the accumulator.
unsigned to_result() const;
+ /// Get base & current level of the accumulator.
+ unsigned base_level() const;
+ unsigned current_level() const;
+
protected:
/// The reference level in the component.
@@ -209,6 +213,23 @@
template <typename I>
inline
+ unsigned
+ height<I>::base_level() const
+ {
+ return ref_;
+ }
+
+ template <typename I>
+ inline
+ unsigned
+ height<I>::current_level() const
+ {
+ return cur_;
+ }
+
+
+ template <typename I>
+ inline
bool
height<I>::is_valid() const
{
1
0
26 May '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-05-26 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Check guard and separate attribute filters into their own file.
* edwin/mln/morpho/tree/filter.hh,
* edwin/mln/morpho/tree/filter/all.hh,
* edwin/mln/morpho/tree/filter/direct.hh,
* edwin/mln/morpho/tree/filter/max.hh,
* edwin/mln/morpho/tree/filter/min.hh,
* edwin/mln/morpho/tree/filter/subtractive.hh,
* edwin/mln/morpho/tree/filter:
Attribute filtering routines.
* edwin/mln/morpho/tree/propagate_representative.hh,
* edwin/mln/morpho/tree/propagate_if.hh,
* edwin/mln/morpho/tree/propagate_node.hh:
Basic propagation routines.
* edwin/rush/exo2/wst_from_tree.cc,
* edwin/tests/sharp.cc:
Fix WST on the reconstructed by erosion image.
---
mln/morpho/tree/filter.hh | 148 ----------------------------
mln/morpho/tree/filter/all.hh | 66 ++++++++++++
mln/morpho/tree/filter/direct.hh | 91 +++++++++++++++++
mln/morpho/tree/filter/max.hh | 110 ++++++++++++++++++++
mln/morpho/tree/filter/min.hh | 100 ++++++++++++++++++
mln/morpho/tree/filter/subtractive.hh | 97 ++++++++++++++++++
mln/morpho/tree/propagate.hh | 63 ++++++++---
mln/morpho/tree/propagate_if.hh | 5
mln/morpho/tree/propagate_node.hh | 4
mln/morpho/tree/propagate_representative.hh | 76 ++++++++++++++
rush/exo2/wst_from_tree.cc | 32 +++---
tests/sharp.cc | 147 +++++++++------------------
12 files changed, 663 insertions(+), 276 deletions(-)
Index: trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc
===================================================================
--- trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc (revision 3872)
+++ trunk/milena/sandbox/edwin/rush/exo2/wst_from_tree.cc (revision 3873)
@@ -47,6 +47,7 @@
#include "color_labeling_mean.hh"
/* WST */
+#include <mln/morpho/reconstruction/by_erosion/union_find.hh>
#include <mln/morpho/watershed/all.hh>
#include <mln/morpho/elementary/dilation.hh>
@@ -181,7 +182,6 @@
I input = color_internal_gradient(input_);
io::pgm::save(input, "gradient.pgm");
-
/***************************/
/* Component tree creation */
/***************************/
@@ -206,29 +206,37 @@
// Component filtering
- // this should use a filter from morpho/tree/filter with the predicate on the height of the parent
- // so use function composition but ...
+ // this should use a filter from morpho/tree/filter with the
+ // predicate on the height of the parent so use function
+ // composition but ...
+ // fixme : wrong height value !
mymin(t, a, pw::value(h_img) > pw::cst(lambda_h));
}
/************************************************/
/* Retrieve Components (Maximising the criteria)*/
/************************************************/
- A component_img;
- {
p_array< mln_psite_(A) > obj_array;
- I output = level::stretch(int_u8(), a); //adapt to 0-255
- io::pgm::save(output, "components.pgm");
+ {
+ //I output = level::stretch(int_u8(), a); //adapt to 0-255
+ //io::pgm::save(output, "components.pgm");
obj_array = morpho::tree::get_components(t, a);
std::cout << obj_array.nsites() << std::endl;
- component_img = morpho::tree::propagate_components(a, t, obj_array, 1.1);
+ }
- // debug
- //I output = level::stretch(int_u8(), component_img); //adapt to 0-255
- //io::pgm::save(output, "components.pgm");
+ I reconstructed;
+ {
+ I marker = set_value_to_components(t, obj_array, (int_u8) 0, (int_u8) 255);
+ set_value_to_components(t, input, obj_array, (int_u8) 0);
+
+ io::pgm::save(marker, "marker.pgm");
+
+ // input is the mask.
+ reconstructed = morpho::reconstruction::by_erosion::union_find(marker, input, c4());
+ io::pgm::save(reconstructed, "reconstructed.pgm");
}
@@ -237,7 +245,7 @@
/************************************************/
typedef image2d<int_u16> WST;
int_u16 n_basins = 0;
- WST wst = morpho::watershed::flooding(component_img, c4(), n_basins);
+ WST wst = morpho::watershed::flooding(reconstructed, c4(), n_basins);
if (!output_ || output_ == 1)
{
Index: trunk/milena/sandbox/edwin/tests/sharp.cc
===================================================================
--- trunk/milena/sandbox/edwin/tests/sharp.cc (revision 3872)
+++ trunk/milena/sandbox/edwin/tests/sharp.cc (revision 3873)
@@ -17,11 +17,12 @@
#include <mln/morpho/tree/propagate.hh>
/* Attributes */
-#include <mln/morpho/attribute/sharpness.hh>
+#include <mln/morpho/attribute/mysharpness.hh>
/* io */
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
/* data & pw */
#include <mln/core/concept/function.hh>
@@ -36,6 +37,7 @@
/* label */
#include <mln/labeling/blobs.hh>
#include <mln/value/label_16.hh>
+#include <mln/labeling/colorize.hh>
/* trace */
#include <mln/trace/quiet.hh>
@@ -67,41 +69,6 @@
namespace mln
{
- // Distance, stored on pixels, of neighboring colors.
-
- value::int_u8 dist_mean(const value::rgb8& c1, const value::rgb8& c2)
- {
- 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;
- }
-
- template <typename N>
- image2d<value::int_u8>
- dist_on_pixels(const image2d<value::rgb8>& input, const N& nbh)
- {
- using value::int_u8;
- image2d<int_u8> output(input.domain());
-
- mln_piter(box2d) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- int_u8 d = 0u;
- for_all(n) if (input.domain().has(n))
- {
- int_u8 d_ = dist_mean(input(p), input(n));
- if (d_ > d)
- d = d_;
- }
- output(p) = 255 - d;
- }
- return output;
- }
template <typename P2V>
struct height_wrapper_ : Function_p2v< height_wrapper_<P2V> >
@@ -161,6 +128,27 @@
return card_wrapper_<P2V>(f);
}
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ mymin(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)) || !pred(tree.parent(n)))
+ {
+ f(n) = 0.0;
+ mark(n) = true;
+ }
+ }
+
}
@@ -231,48 +219,24 @@
if (mydebug)
dsp("Image sharp attribute", timer);
- // TODO: l'attribut devrait favoriser les composantes plus larges
- // dans son calcul. Ainsi au lieu de faire un sharpness, on aurait
- // un ratio sharpness / hauteur de composante (reprendre l'idee du
- // log utilise pour INIM).
- typedef morpho::attribute::sharpness<I> sharp_t;
typedef mln_ch_value_(I, double) A;
- typedef mln_ch_value_(I, sharp_t) B;
-
- B a_img;
- A a = morpho::tree::compute_attribute_image(sharp_t (), tree, &a_img);
- // Note: then we work on nodes (component representant so we don't
- // need to propagate the representant value to the component sites.
-
-
- /***********************************/
- /* Components Filtering */
- /***********************************/
-
- // So we compute card attribute and we filter big components
- // FIXME: some attributes are compositions of attributes, here
- // sharpness can give area so, it would be fine if we could give an
- // optional extra argument to compute_attribute where the
- // accumulators image will be stored.
-
- if (card)
+ A a;
{
- if (mydebug)
- dsp("Image card attribute", timer);
+ typedef morpho::attribute::volume<I> v_attr;
+ typedef mln_ch_value_(I, unsigned) H;
+ typedef mln_ch_value_(I, v_attr) V;
+ H h_img;
+ V v_img;
- a = duplicate((fun::p2v::ternary(card_wrapper(pw::value(a_img)) > pw::cst(card),
- pw::value(a),
- pw::cst(0.0))) | a.domain());
- }
+ a = morpho::attribute::mysharpness(tree, &h_img, &v_img);
+ // Component filtering
if (height)
- {
- if (mydebug)
- dsp("Image height attribute", timer);
- a = duplicate((fun::p2v::ternary(height_wrapper(pw::value(a_img)) > pw::cst(height),
- pw::value(a),
- pw::cst(0.0))) | a.domain());
+ mymin(tree, a, pw::value(h_img) > pw::cst(height));
+
+ if (card)
+ morpho::tree::filter::filter(tree, a, card_wrapper(pw::value(v_img)) > pw::cst(card), 0.0);
}
/************************************************/
@@ -302,14 +266,6 @@
obj_array = morpho::tree::get_components(tree, a);
}
-
- /* Print them */
-// if (mydebug) {
-// mln_fwd_piter_(p_array< mln_psite_(I) >) c(obj_array);
-// for_all(c)
-// std::cout << c;
-// }
-
/***********************************/
/* Use components in output image */
/***********************************/
@@ -328,27 +284,28 @@
// labeling
typedef mln_ch_value_(I, bool) M;
-
M mask = morpho::tree::set_value_to_components(tree, obj_array, true, false);
- //typedef mln_ch_value_(I, value::label<16>) L;
- //value::label<16> nlabel;
- //L label = labeling::blobs(mask, c4(), nlabel);
- //io::pgm::save(label, "label.pgm");
-
+ {
+ typedef mln_ch_value_(I, value::label<16>) L;
+ typedef mln_ch_value_(I, value::rgb<8>) O;
+ value::label<16> nlabel;
+ L label = labeling::blobs(mask, c4(), nlabel);
+ O output = labeling::colorize(value::rgb8(), label, nlabel);
+ io::ppm::save(output, "label.pgm");
+ }
if (mydebug) {
dsp("Finish", timer);
}
-
-
-// /* Now store output image */
- I out;
- initialize(out, input);
- data::fill(out, 0);
- data::paste(input | pw::value(mask), out);
- io::pgm::save(out, "output.pgm");
-
+ /* Now store output image */
+// {
+// I out;
+// initialize(out, input);
+// data::fill(out, 255);
+// data::paste(input | pw::value(mask), out);
+// io::pgm::save(out, "output.pgm");
+// }
}
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/propagate.hh (revision 3872)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/propagate.hh (revision 3873)
@@ -33,6 +33,7 @@
/// Functions to propagate a node value in the tree.
# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/propagate_representative.hh>
# include <mln/morpho/tree/propagate_node.hh>
namespace mln {
@@ -40,21 +41,6 @@
namespace tree {
- /// Propagate the representative point's value to
- /// non-representative node points.
- template <typename T, typename A>
- void
- propagate_representative(const T& t, Image<A>& a_)
- {
- A a = exact(a_);
- mln_up_site_piter(T) p(t);
- for_all(p)
- if (! t.is_a_node(p))
- {
- mln_assertion(t.is_a_node(t.parent(p)));
- a(p) = a(t.parent(p));
- }
- }
/**
** For each component in the list \p component_list, it
@@ -105,16 +91,55 @@
initialize(out, tree.f());
mln::data::fill(out, null);
- mln_piter(p_array< mln_psite(T) >) p(component_list);
- for_all(p)
{
+ mln_piter(p_array< mln_psite(T) >) n(component_list);
+ for_all(n)
+ out(n) = value;
+ }
+
+ {
+ mln_dn_site_piter(T) p(tree);
+ for_all(p)
+ if (out(tree.parent(p)) == value)
out(p) = value;
- morpho::tree::propagate_node_to_descendants(p, tree, out);
}
- morpho::tree::propagate_representative(tree, out);
return out;
}
+ template <typename T, typename F>
+ inline
+ void
+ set_value_to_components(const T& tree,
+ Image<F>& f_,
+ const p_array< mln_psite(T) >& component_list,
+ const mln_value(F)& value)
+ {
+ F& f = exact(f_);
+
+ mln_ch_value(typename T::function, bool) mark;
+ initialize(mark, tree.f());
+ mln::data::fill(mark, false);
+
+ {
+ mln_piter(p_array< mln_psite(T) >) n(component_list);
+ for_all(n)
+ {
+ mark(n) = true;
+ f(n) = value;
+ }
+ }
+
+ {
+ mln_dn_site_piter(T) p(tree);
+ for_all(p)
+ if (mark(tree.parent(p)))
+ {
+ mark(p) = true;
+ f(p) = value;
+ }
+ }
+ }
+
} // end of namespace mln::morpho::tree
} // end of namespace mln::morpho
} // end of namespace mln
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_representative.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_representative.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_representative.hh (revision 3873)
@@ -0,0 +1,76 @@
+// 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_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_
+# define MLN_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_
+
+/// \file mln/morpho/tree/propagate_representative.hh
+///
+/// Component tree routines.
+
+namespace mln{
+ namespace morpho {
+ namespace tree {
+
+ /**
+ ** Propagate the representative node's value to
+ ** non-representative points of the component.
+ **
+ ** @param t Component tree.
+ ** @param f_ Value image.
+ */
+ template <typename T, typename F>
+ void
+ propagate_representative(const T& t, Image<F>& f_);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F>
+ inline
+ void
+ propagate_representative(const T& t, Image<F>& f_)
+ {
+ F a = exact(f_);
+ mln_up_site_piter(T) p(t);
+ for_all(p)
+ if (! t.is_a_node(p))
+ {
+ mln_assertion(t.is_a_node(t.parent(p)));
+ a(p) = a(t.parent(p));
+ }
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ }
+ }
+}
+
+#endif /* !MLN_MORPHO_TREE_PROPAGATE_REPRESENTATIVE_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter.hh (revision 3872)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter.hh (revision 3873)
@@ -56,59 +56,7 @@
filter(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_, const mln_value(F)& v);
- template <typename T, typename F, typename P2B>
- inline
- void
- min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
-
-
- template <typename T, typename F, typename P2B>
- inline
- void
- max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
-
- template <typename T, typename F, typename P2B>
- inline
- void
- direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
-
- template <typename T, typename F, typename P2B>
- inline
- void
- subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
-
-
# ifndef MLN_INCLUDE_ONLY
- namespace internal
- {
-
- template <typename P2B>
- struct not_pred_ : Function_p2b< not_pred_<P2B> >
- {
- not_pred_(const Function_p2b<P2B>& f) :
- f_ (exact(f))
- {
- }
-
- template <typename P>
- bool operator() (const P& p) const
- {
- return !(f_(p));
- }
-
- private:
- const P2B& f_;
- };
-
- template <typename P2B>
- inline
- not_pred_<P2B>
- not_pred(const Function_p2b<P2B>& f)
- {
- return not_pred_<P2B>(f);
- }
-
- }
template <typename T, typename F, typename P2B>
inline
@@ -118,31 +66,8 @@
F& f = exact(f_);
const P2B& pred = exact(pred_);
- //FIXME precondition
- mln_ch_value(F, bool) mark;
- initialize(mark, f);
- mln::data::fill(mark, false);
-
- mln_dn_node_piter(T) n(tree);
- for_all(n)
- if (mark(tree.parent(n)) || !pred(n))
- {
- f(n) = v;
- mark(n) = true;
- }
- //FIXME postcondition
- }
-
-
- template <typename T, typename F, typename P2B>
- inline
- void
- min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
- {
- F& f = exact(f_);
- const P2B& pred = exact(pred_);
+ trace::entering("mln::morpho::tree::filter::filter");
- //FIXME precondition
mln_ch_value(F, bool) mark;
initialize(mark, f);
mln::data::fill(mark, false);
@@ -151,78 +76,11 @@
for_all(n)
if (mark(tree.parent(n)) || !pred(n))
{
- f(n) = f(tree.parent(n));
+ f(n) = v;
mark(n) = true;
}
- //FIXME postcondition
- }
-
- template <typename T, typename F, typename P2B>
- inline
- void
- max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
- {
- F& f = exact(f_);
- const P2B& pred = exact(pred_);
- //FIXME precondition
- mln_ch_value(F, bool) mark;
- initialize(mark, f);
- mln::data::fill(mark, true);
-
- {
- mln_up_node_piter(T) n(tree);
- for_all(n)
- if (!mark(n))
- mark(tree.parent(n)) = false;
- else if (pred(n))
- {
- mark(tree.parent(n)) = false;
- mark(n) = false;
- }
- }
-
- {
- mln_dn_node_piter(T) n(tree);
- for_all(n)
- if (mark(n))
- f(n) = f(tree.parent(n));
- }
- }
-
- template <typename T, typename F, typename P2B>
- inline
- void
- direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
- {
- F& f = exact(f_);
- const P2B& pred = exact(pred_);
-
- //FIXME precondition
- mln_dn_node_piter(T) n(tree);
- for_all(n)
- if (!pred(n))
- f(n) = f(tree.parent(n));
- //FIXME postcondition
- }
-
- template <typename T, typename F, typename P2B>
- inline
- void
- subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
- {
- F& f = exact(f_);
- const P2B& pred = exact(pred_);
-
- //FIXME precondition
-
- morpho::tree::propagate_if(tree, f, morpho::tree::desc_propagation (), internal::not_pred(pred));
-
- mln_up_node_piter(T) n(tree);
- for_all(n)
- if (!pred(n))
- f(n) = f(tree.parent(n));
- //FIXME postcondition
+ trace::exiting("mln::morpho::tree::filter::filter");
}
# endif /* !MLN_INCLUDE_ONLY */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter/min.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter/min.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter/min.hh (revision 3873)
@@ -0,0 +1,100 @@
+// 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_MORPHO_TREE_FILTER_MIN_HH_
+# define MLN_MORPHO_TREE_FILTER_MIN_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+
+/**
+** @file mln/morpho/tree/filter/min.hh
+**
+** @brief Filtering with min strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+
+ /**
+ ** Min pruning strategy. A node is removed iif its parent is
+ ** removed or if it does not verify the predicate \p pred_.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::min");
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)) || !pred(n))
+ {
+ f(n) = f(tree.parent(n));
+ mark(n) = true;
+ }
+
+ trace::exiting("mln::morpho::tree::filter::min");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_MIN_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter/max.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter/max.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter/max.hh (revision 3873)
@@ -0,0 +1,110 @@
+// 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_MORPHO_TREE_FILTER_MAX_HH_
+# define MLN_MORPHO_TREE_FILTER_MAX_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+/**
+** @file mln/morpho/tree/filter/max.hh
+**
+** @brief Filtering with max strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Max pruning strategy. A node is removed iif all of its
+ ** children are removed or if it does not verify the predicate
+ ** \p pred_.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::max");
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, true);
+
+ {
+ mln_up_node_piter(T) n(tree);
+ for_all(n)
+ if (!mark(n))
+ mark(tree.parent(n)) = false;
+ else if (pred(n))
+ {
+ mark(tree.parent(n)) = false;
+ mark(n) = false;
+ }
+ }
+
+ {
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(n))
+ f(n) = f(tree.parent(n));
+ }
+
+ trace::exiting("mln::morpho::tree::filter::max");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_MAX_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter/all.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter/all.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter/all.hh (revision 3873)
@@ -0,0 +1,66 @@
+// 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_MORPHO_TREE_FILTER_ALL_HH_
+# define MLN_MORPHO_TREE_FILTER_ALL_HH_
+
+/**
+** @file mln/morpho/tree/filter.hh
+**
+** Methods to handle component tree filtering strategies with
+** non-increasing attribute. Nevertheless, it works on increasing
+** predicate as well. In this case, all strategies have the same
+** result but min filter or direct filter should be used in term
+** of performance. If a predicate test is too slow, then consider
+** the min filter that minimizes calls to predicate function.
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ /// Namespace for attribute filtering.
+ namespace filter {
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+// Pruning strategies.
+# include <mln/morpho/tree/filter/min.hh>
+# include <mln/morpho/tree/filter/max.hh>
+
+// Non-pruning stategies.
+# include <mln/morpho/tree/filter/direct.hh>
+# include <mln/morpho/tree/filter/subtractive.hh>
+
+
+
+#endif /* !MLN_MORPHO_TREE_FILTER_ALL_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter/direct.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter/direct.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter/direct.hh (revision 3873)
@@ -0,0 +1,91 @@
+// 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_MORPHO_TREE_FILTER_DIRECT_HH_
+# define MLN_MORPHO_TREE_FILTER_DIRECT_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+
+/**
+** @file mln/morpho/tree/filter/direct.hh
+**
+** @brief Filtering with direct strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Direct non-pruning strategy. A node is removed if it does
+ ** not verify the predicate. The sub-components remain intact.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::direct");
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (!pred(n))
+ f(n) = f(tree.parent(n));
+
+ trace::exiting("mln::morpho::tree::filter::direct");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_DIRECT_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/filter/subtractive.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/filter/subtractive.hh (revision 0)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/filter/subtractive.hh (revision 3873)
@@ -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.
+
+#ifndef MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_
+# define MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_
+
+# include <mln/core/concept/function.hh>
+# include <mln/fun/ops.hh>
+
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/propagate_if.hh>
+
+/**
+** @file mln/morpho/tree/filter/subtractive.hh
+**
+** @brief Filtering with subtractive strategy.
+**
+**
+*/
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+ /**
+ ** Subtractive pruning strategy. The node is removed if it
+ ** does not verify the predicate. The sub-components values
+ ** are set to the value of the removed component.
+ **
+ ** @param[in] tree Component tree.
+ ** @param[out] f_ Image to filter.
+ ** @param[in] pred_ Filtering criterion.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::subtractive");
+
+ morpho::tree::propagate_if(tree, f, morpho::tree::desc_propagation (), !pred);
+
+ mln_up_node_piter(T) n(tree);
+ for_all(n)
+ if (!pred(n))
+ f(n) = f(tree.parent(n));
+
+ trace::exiting("mln::morpho::tree::filter::subtractive");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+#endif /* !MLN_MORPHO_TREE_FILTER_SUBTRACTIVE_HH_ */
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh (revision 3872)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh (revision 3873)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -78,7 +78,7 @@
/**
- ** Propagate a value \v from a node \n to its ancestors.
+ ** Propagate a value \p v from a node \p n to its ancestors.
**
** @param n Node to propagate.
** @param t Component tree used for propagation.
Index: trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh
===================================================================
--- trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh (revision 3872)
+++ trunk/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh (revision 3873)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -32,8 +32,7 @@
/**
** @file mln/morpho/tree/propagate_if.hh
**
-** @brief Methods to handle propagation startegies
-** in component trees.
+** @brief Routines to handle propagation with predicate.
**
*/
1
0