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
November 2008
- 14 participants
- 266 discussions
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix previous patch.
* mln/morpho/erosion.spe.hh: Remove old code.
---
erosion.spe.hh | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2783)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2784)
@@ -1095,13 +1095,9 @@
{
}
- template <typename V>
- void neutral(const V&) { return mln_max(V); }
- void neutral(const bool&) { return true; }
-
void init()
{
- extension::adjust_fill(input, win, neutral(mln_value(I)()));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
1
0
milena r2783: Add accumulator template parameter to all versions of erosion
by Matthieu Garrigues 04 Nov '08
by Matthieu Garrigues 04 Nov '08
04 Nov '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
* mln/morpho/erosion.spe.hh: Add accumulator template parameter to all
versions of erosion.
---
erosion.spe.hh | 146 +++++++++++++++++++++++++++++++++------------------------
1 file changed, 85 insertions(+), 61 deletions(-)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2782)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2783)
@@ -305,17 +305,17 @@
return output;
}
- template <typename I, typename W>
+ template <typename I, typename W, typename A>
struct erosion_arbitrary_2d_fastest_functor
{
- typedef erosion_arbitrary_2d_fastest_functor<I,W> self;
+ typedef erosion_arbitrary_2d_fastest_functor<I,W,A> self;
typedef void (self::*move_fun)();
typedef mln_deduce(I, psite, delta) dpsite;
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
@@ -346,7 +346,7 @@
erosion_arbitrary_2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
win_left_fwd(win::shift(win, mln::left) - win),
win_right_fwd(win - win::shift(win, mln::left)),
@@ -398,50 +398,50 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
- min.init();
+ accu.init();
p = input.domain().pmin() - dps[0];
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = input.domain().pmin();
}
void right()
{
for_all(q_l_fwd)
- min.untake(q_l_fwd.val());
+ accu.untake(q_l_fwd.val());
for_all(q_r_fwd)
- min.take(q_r_fwd.val());
- output(p) = min;
+ accu.take(q_r_fwd.val());
+ output(p) = accu;
}
void left()
{
for_all(q_r_bkd)
- min.untake(q_r_bkd.val());
+ accu.untake(q_r_bkd.val());
for_all(q_l_bkd)
- min.take(q_l_bkd.val());
- output(p) = min;
+ accu.take(q_l_bkd.val());
+ output(p) = accu;
}
void down()
{
for_all(q_top_down)
- min.untake(q_top_down.val());
+ accu.untake(q_top_down.val());
for_all(q_bot_down)
- min.take(q_bot_down.val());
- output(p) = min;
+ accu.take(q_bot_down.val());
+ output(p) = accu;
}
void up()
{
for_all(q_bot_up)
- min.untake(q_bot_up.val());
+ accu.untake(q_bot_up.val());
for_all(q_top_up)
- min.take(q_top_up.val());
- output(p) = min;
+ accu.take(q_top_up.val());
+ output(p) = accu;
}
};
@@ -453,7 +453,11 @@
{
trace::entering("morpho::impl:erosion_arbitrary_2d_fastest");
- typedef erosion_arbitrary_2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_arbitrary_2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::snake_generic(f);
@@ -555,7 +559,7 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
accu.init();
p = input.domain().pmin() - dps[0];
@@ -802,7 +806,7 @@
// Diagonal2d non fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_diagonal2d_functor
{
typedef I_ I;
@@ -811,7 +815,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -824,7 +828,7 @@
erosion_diagonal2d_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
@@ -835,27 +839,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(input(q_l));
+ accu.untake(input(q_l));
for_all(q_r)
- min.take(input(q_r));
- output(p) = min;
+ accu.take(input(q_r));
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(-1, 1);
mln_qiter(W) q(win, p);
for_all(q)
- min.take(input(q));
+ accu.take(input(q));
p = p + dpsite(-1, 1);
}
@@ -873,7 +877,11 @@
{
trace::entering("morpho::impl:erosion_diagonal2d");
- typedef erosion_diagonal2d_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_diagonal2d_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::diagonal2d(f);
@@ -884,7 +892,7 @@
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_backdiagonal2d_functor
{
typedef I_ I;
@@ -893,7 +901,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -906,7 +914,7 @@
erosion_backdiagonal2d_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
@@ -917,27 +925,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(input(q_l));
+ accu.untake(input(q_l));
for_all(q_r)
- min.take(input(q_r));
- output(p) = min;
+ accu.take(input(q_r));
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(1, 1);
mln_qiter(W) q(win, p);
for_all(q)
- min.take(input(q));
+ accu.take(input(q));
p = p + dpsite(1, 1);
}
@@ -954,7 +962,11 @@
{
trace::entering("morpho::impl:erosion_backdiagonal2d");
- typedef erosion_backdiagonal2d_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_backdiagonal2d_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::backdiagonal2d(f);
@@ -966,7 +978,7 @@
// Diagonal2d fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_diagonal2d_fastest_functor
{
typedef I_ I;
@@ -975,7 +987,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -988,7 +1000,7 @@
erosion_diagonal2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(1, -1)) - win),
win_right(win - win::shift(win, dpsite(1, -1))),
@@ -999,27 +1011,27 @@
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(q_l.val());
+ accu.untake(q_l.val());
for_all(q_r)
- min.take(q_r.val());
- output(p) = min;
+ accu.take(q_r.val());
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(-1, 1);
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = p + dpsite(-1, 1);
}
@@ -1036,7 +1048,11 @@
{
trace::entering("morpho::impl:erosion_diagonal2d_fastest");
- typedef erosion_diagonal2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_diagonal2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::diagonal2d(f);
@@ -1048,7 +1064,7 @@
// Backdiagonal2d fastest.
- template <typename I_, typename W>
+ template <typename I_, typename W, typename A>
struct erosion_backdiagonal2d_fastest_functor
{
typedef I_ I;
@@ -1057,7 +1073,7 @@
const I& input;
const W& win;
mln_concrete(I) output;
- accu::min_h<mln_value(I)> min;
+ A accu;
mln_psite(I) p;
enum { dim = I::site::dim };
@@ -1070,7 +1086,7 @@
erosion_backdiagonal2d_fastest_functor(const I& input, const W& win)
: input(input),
win(win),
- min(),
+ accu(),
dir(dir),
win_left(win::shift(win, dpsite(-1, -1)) - win),
win_right(win - win::shift(win, dpsite(-1, -1))),
@@ -1079,29 +1095,33 @@
{
}
+ template <typename V>
+ void neutral(const V&) { return mln_max(V); }
+ void neutral(const bool&) { return true; }
+
void init()
{
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, neutral(mln_value(I)()));
initialize(output, input);
}
void next()
{
for_all(q_l)
- min.untake(q_l.val());
+ accu.untake(q_l.val());
for_all(q_r)
- min.take(q_r.val());
- output(p) = min;
+ accu.take(q_r.val());
+ output(p) = accu;
}
void init_diag()
{
- min.init();
+ accu.init();
p = p - dpsite(1, 1);
mln_qixter(const I, W) q(input, win, p);
for_all(q)
- min.take(q.val());
+ accu.take(q.val());
p = p + dpsite(1, 1);
}
@@ -1118,7 +1138,11 @@
{
trace::entering("morpho::impl:erosion_backdiagonal2d_fastest");
- typedef erosion_backdiagonal2d_fastest_functor<I, W> F;
+ typedef mlc_is(mln_trait_image_kind(I),
+ trait::image::kind::binary) is_binary;
+ typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A;
+
+ typedef erosion_backdiagonal2d_fastest_functor<I, W, A> F;
F f(exact(input), exact(win));
canvas::browsing::backdiagonal2d(f);
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix sanity check.
* tests/all_headers.cc: Fill with every all.hh headers.
* mln/core/image/all.hh: Fix inclusions.
mln/core/image/all.hh | 113 ++++++++++++++++++++++++--------------------------
tests/all_headers.cc | 91 ++++++++++++++++++++++------------------
2 files changed, 106 insertions(+), 98 deletions(-)
Index: tests/all_headers.cc
--- tests/all_headers.cc (revision 2781)
+++ tests/all_headers.cc (working copy)
@@ -30,61 +30,70 @@
* \brief Tests with all headers. (check norris tests)
*/
-
-#include <mln/test/all.hh>
-#include <mln/convert/all.hh>
-#include <mln/estim/all.hh>
-//#include <mln/debug/all.hh>
-#include <mln/histo/all.hh>
-#include <mln/pw/all.hh>
-#include <mln/geom/all.hh>
-#include <mln/core/trait/all.hh>
-#include <mln/fun/i2v/all.hh>
-#include <mln/fun/p2b/all.hh>
+#include <mln/util/all.hh>
#include <mln/fun/p2v/all.hh>
-#include <mln/fun/v2v/all.hh>
#include <mln/fun/x2x/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/i2v/all.hh>
#include <mln/fun/all.hh>
-#include <mln/math/all.hh>
-#include <mln/set/all.hh>
-#include <mln/draw/all.hh>
-#include <mln/metal/math/all.hh>
-#include <mln/metal/all.hh>
-#include <mln/morpho/all.hh>
+#include <mln/fun/x2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/extension/all.hh>
+#include <mln/histo/all.hh>
+#include <mln/trait/op/all.hh>
+#include <mln/trait/all.hh>
+#include <mln/trait/value/all.hh>
+#include <mln/win/all.hh>
+#include <mln/core/routine/all.hh>
+#include <mln/core/trait/all.hh>
+#include <mln/core/def/all.hh>
+#include <mln/core/internal/check/image_all.hh>
+#include <mln/core/image/all.hh>
+#include <mln/core/site_set/all.hh>
+#include <mln/io/pbm/all.hh>
#include <mln/io/pfm/all.hh>
#include <mln/io/pgm/all.hh>
+#include <mln/io/all.hh>
#include <mln/io/fits/all.hh>
-#include <mln/io/ppm/all.hh>
-#include <mln/io/pbm/all.hh>
#include <mln/io/pnm/all.hh>
-#include <mln/io/all.hh>
-#include <mln/level/naive/all.hh>
-#include <mln/level/approx/all.hh>
-#include <mln/level/all.hh>
-#include <mln/arith/all.hh>
-#include <mln/linear/all.hh>
-#include <mln/logical/all.hh>
+#include <mln/io/ppm/all.hh>
+#include <mln/make/all.hh>
#include <mln/canvas/morpho/all.hh>
-#include <mln/canvas/browsing/all.hh>
#include <mln/canvas/all.hh>
+#include <mln/canvas/browsing/all.hh>
+#include <mln/estim/all.hh>
+#include <mln/arith/all.hh>
+#include <mln/display/all.hh>
+#include <mln/test/all.hh>
+#include <mln/border/all.hh>
+#include <mln/trace/all.hh>
+#include <mln/debug/all.hh>
+#include <mln/morpho/elementary/all.hh>
+#include <mln/morpho/all.hh>
#include <mln/accu/all.hh>
+#include <mln/pw/all.hh>
+#include <mln/linear/all.hh>
+#include <mln/metal/all.hh>
+#include <mln/metal/math/all.hh>
+#include <mln/set/all.hh>
+#include <mln/convert/impl/all.hh>
+#include <mln/convert/all.hh>
+#include <mln/geom/all.hh>
+#include <mln/literal/all.hh>
+#include <mln/level/approx/all.hh>
+#include <mln/level/all.hh>
+#include <mln/level/naive/all.hh>
+#include <mln/math/all.hh>
#include <mln/norm/all.hh>
-#include <mln/value/internal/all.hh>
-#include <mln/value/concept/all.hh>
+#include <mln/logical/all.hh>
+#include <mln/draw/all.hh>
#include <mln/value/builtin/all.hh>
#include <mln/value/all.hh>
-//#include <mln/make/all.hh>
-#include <mln/border/all.hh>
-#include <mln/labeling/all.hh>
-#include <mln/util/all.hh>
-#include <mln/trait/value/all.hh>
-#include <mln/trait/op/all.hh>
-#include <mln/trait/all.hh>
+#include <mln/value/internal/all.hh>
+#include <mln/value/concept/all.hh>
#include <mln/tag/all.hh>
-#include <mln/trace/all.hh>
-#include <mln/literal/all.hh>
-#include <mln/display/all.hh>
-#include <mln/win/all.hh>
+#include <mln/labeling/all.hh>
+
int main ()
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 2781)
+++ mln/core/image/all.hh (working copy)
@@ -36,63 +36,62 @@
*/
-# include <bgraph_image.hh>
-# include <bgraph_psite.hh>
-# include <cast_image.hh>
-# include <ch_piter.hh>
-# include <complex_image.hh>
-# include <complex_neighborhood_piter.hh>
-# include <complex_neighborhoods.hh>
-# include <complex_window_piter.hh>
-# include <complex_windows.hh>
-# include <decorated_image.hh>
-# include <extended.hh>
-# include <extension_fun.hh>
-# include <extension_ima.hh>
-# include <extension_val.hh>
-# include <fi_adaptor.hh>
-# include <flat_image.hh>
-# include <graph_elt_neighborhood.hh>
-# include <graph_elt_window.hh>
-# include <graph_image.hh>
-# include <graph_neighborhood_piter.hh>
-# include <graph_window_piter.hh>
-# include <hexa.hh>
-# include <hexa_piter.hh>
-# include <image1d.hh>
-# include <image2d.hh>
-# include <image2d_h.hh>
-# include <image3d.hh>
-# include <image_if.hh>
-# include <interpolated.hh>
-# include <lazy_image.hh>
-# include <line_graph_elt_neighborhood.hh>
-# include <line_graph_elt_window.hh>
-# include <line_graph_image.hh>
-# include <line_graph_neighborhood_piter.hh>
-# include <line_graph_psite.hh>
-# include <line_graph_window_piter.hh>
-# include <mono_obased_rle_encode.hh>
-# include <mono_obased_rle_image.hh>
-# include <mono_rle_encode.hh>
-# include <mono_rle_image.hh>
-# include <obased_rle_encode.hh>
-# include <obased_rle_image.hh>
-# include <plain.hh>
-# include <rle_encode.hh>
-# include <rle_image.hh>
-# include <safe.hh>
-# include <sparse_encode.hh>
-# include <sparse_image.hh>
-# include <status.txt
-# include <sub_image.hh>
-# include <sub_image_if.hh>
-# include <t_image.hh>
-# include <translate_image.hh>
-# include <tr_image.hh>
-# include <tr_mesh.hh>
-# include <value_enc_image.hh>
-# include <value_encode.hh>
+# include <mln/core/image/bgraph_image.hh>
+# include <mln/core/image/bgraph_psite.hh>
+# include <mln/core/image/cast_image.hh>
+# include <mln/core/image/ch_piter.hh>
+# include <mln/core/image/complex_image.hh>
+# include <mln/core/image/complex_neighborhood_piter.hh>
+# include <mln/core/image/complex_neighborhoods.hh>
+# include <mln/core/image/complex_window_piter.hh>
+# include <mln/core/image/complex_windows.hh>
+# include <mln/core/image/decorated_image.hh>
+# include <mln/core/image/extended.hh>
+# include <mln/core/image/extension_fun.hh>
+# include <mln/core/image/extension_ima.hh>
+# include <mln/core/image/extension_val.hh>
+# include <mln/core/image/flat_image.hh>
+# include <mln/core/image/graph_elt_neighborhood.hh>
+# include <mln/core/image/graph_elt_window.hh>
+# include <mln/core/image/graph_image.hh>
+# include <mln/core/image/graph_neighborhood_piter.hh>
+# include <mln/core/image/graph_window_piter.hh>
+# include <mln/core/image/hexa.hh>
+# include <mln/core/image/hexa_piter.hh>
+# include <mln/core/image/image1d.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image2d_h.hh>
+# include <mln/core/image/image3d.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/image/interpolated.hh>
+# include <mln/core/image/lazy_image.hh>
+# include <mln/core/image/line_graph_elt_neighborhood.hh>
+# include <mln/core/image/line_graph_elt_window.hh>
+# include <mln/core/image/line_graph_image.hh>
+# include <mln/core/image/line_graph_neighborhood_piter.hh>
+# include <mln/core/image/line_graph_psite.hh>
+# include <mln/core/image/line_graph_window_piter.hh>
+# include <mln/core/image/mono_obased_rle_encode.hh>
+# include <mln/core/image/mono_obased_rle_image.hh>
+# include <mln/core/image/mono_rle_encode.hh>
+# include <mln/core/image/mono_rle_image.hh>
+# include <mln/core/image/obased_rle_encode.hh>
+# include <mln/core/image/obased_rle_image.hh>
+# include <mln/core/image/plain.hh>
+# include <mln/core/image/rle_encode.hh>
+# include <mln/core/image/rle_image.hh>
+# include <mln/core/image/safe.hh>
+# include <mln/core/image/sparse_encode.hh>
+# include <mln/core/image/sparse_image.hh>
+# include <mln/core/image/sub_image.hh>
+# include <mln/core/image/sub_image_if.hh>
+# include <mln/core/image/t_image.hh>
+# include <mln/core/image/translate_image.hh>
+# include <mln/core/image/tr_image.hh>
+# include <mln/core/image/tr_mesh.hh>
+# include <mln/core/image/value_enc_image.hh>
+# include <mln/core/image/value_encode.hh>
+//# include <mln/core/image/fi_adaptor.hh>
#endif // ! MLN_CORE_IMAGE_ALL_HH
Index: mln/util/tree_to_image.hh
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update the transform routine.
* tests/level/transform_full.cc: Update tests.
* mln/level/transform.spe.hh,
* mln/level/transform.hh: Update, output is now directly returned.
* mln/level/stretch.hh: Update.
mln/level/stretch.hh | 2
mln/level/transform.hh | 47 ++----
mln/level/transform.spe.hh | 296 ++++++++++++++++++------------------------
tests/level/transform_full.cc | 4
4 files changed, 147 insertions(+), 202 deletions(-)
Index: tests/level/transform_full.cc
--- tests/level/transform_full.cc (revision 2780)
+++ tests/level/transform_full.cc (working copy)
@@ -76,9 +76,9 @@
{
const I& ref = exact(ref_);
- I out (ref.domain());
+ mln_ch_value(I, mln_result_(mysqrt)) out;
{
- level::transform(ref, mysqrt(), out);
+ out = level::transform(ref, mysqrt());
mln_piter(I) p (ref.domain ());
for_all(p)
mln_assertion ((mln_value(I))(ref(p) % 42) == out(p) );
Index: mln/level/transform.spe.hh
--- mln/level/transform.spe.hh (revision 2780)
+++ mln/level/transform.spe.hh (working copy)
@@ -74,27 +74,29 @@
namespace generic
{
- template <typename I, typename F, typename O>
- void transform(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_);
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input_,
+ const Function_v2v<F>& f_);
}
-
- template <typename I, typename F, typename O>
- void transform_lowq(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_lowq");
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
- mlc_is(mln_trait_image_pw_io(O),
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
value::lut_vec<mln_vset(I), mln_result(F)>
@@ -105,21 +107,26 @@
output(p) = lut(input(p));
trace::exiting("level::impl::transform_lowq");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_taken(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_taken(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_taken");
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
- mlc_is(mln_trait_image_pw_io(O),
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
value::lut_vec<mln_vset(I), mln_result(F)>
@@ -130,47 +137,56 @@
output(p) = lut(input(p));
trace::exiting("level::impl::transform_taken");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_singleton(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_singleton(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_singleton");
const I& input = exact(input_);
const F& f = exact(f_);
- level::internal::transform_tests(input_, f_, output_);
- mln_precondition((mlc_is(mln_trait_image_pw_io(O),
- trait::image::pw_io::read_write)::value ||
- mlc_is(mln_trait_image_vw_io(O),
- trait::image::vw_io::read_write)::value));
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+
+ level::internal::transform_tests(input_, f_, output);
mln_result(F) val = f(input.val());
- fill_with_value(output_, val);
+ fill_with_value(output, val);
trace::exiting("level::impl::transform_singleton");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_fast(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_fast(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_fast");
+ typedef mln_ch_value(I, mln_result(F)) O;
+
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+
level::internal::transform_tests(input, f, output);
mln_pixter(const I) pi(input);
mln_pixter(O) po(output);
-
po.start();
for_all(pi)
{
@@ -179,20 +195,26 @@
}
trace::exiting("level::impl::transform_fast");
+
+ return output;
}
- template <typename I, typename F, typename O>
- void transform_fast_lowq(const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_fast_lowq(const Image<I>& input_,
+ const Function_v2v<F>& f_)
{
trace::entering("level::impl::transform_fast_lowq");
+ typedef mln_ch_value(I, mln_result(F)) O;
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
+
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
level::internal::transform_tests(input, f, output);
@@ -210,6 +232,8 @@
}
trace::exiting("level::impl::transform_fast_lowq");
+
+ return output;
}
@@ -220,208 +244,144 @@
{
/// Deal with image not updated
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::undef,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::undef,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::generic::transform(input, f, output);
+ return impl::generic::transform(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::any,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::generic::transform(input, f, output);
+ return impl::generic::transform(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::uni,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::uni,
mln::trait::image::quant::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::transform_taken(input, f, output);
+ return impl::transform_taken(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::vw_set::none,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::vw_set::any,
mln::trait::image::quant::low,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- impl::transform_lowq(input, f, output);
+ return impl::transform_lowq(input, f);
}
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::some,
- mln::trait::image::ext_domain::some,
- const Image<I>& input_,
- const Function_v2v<F>& f,
- Image<O>& output_)
- {
- const I& input = exact(input_);
- O& output = exact(output_);
-
- if (input.domain() == output.domain())
- transform_fast(input, f, output);
- else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f, output);
- }
-
- template <typename I, typename F, typename O>
+ /// FIXME check that is right
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::direct,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::any,
mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::none,
- mln::trait::image::ext_domain::none,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_fast(input, f, output);
- }
-
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(mln::trait::image::quant::low,
- mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::some,
- mln::trait::image::ext_domain::some,
- const Image<I>& input_,
- const Function_v2v<F>& f,
- Image<O>& output_)
- {
- const I& input = exact(input_);
- O& output = exact(output_);
-
- if (input.domain() == output.domain())
- transform_fast_lowq(input, f, output);
- else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
- mln_trait_image_quant(I)(),
- input, f, output);
+ return transform_fast(input, f);
}
- template <typename I, typename F, typename O>
+ /// FIXME check that is right
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::low,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::low,
mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::none,
- mln::trait::image::ext_domain::none,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_fast_lowq(input, f, output);
+ return transform_fast_lowq(input, f);
}
- template <typename I, typename F, typename O>
+
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::quant::any,
- mln::trait::image::value_access::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::quant::any,
mln::trait::image::value_access::any,
- mln::trait::image::ext_domain::any,
- mln::trait::image::ext_domain::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f, output);
+ input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::any,
- mln::trait::image::value_storage::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::any,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f, output);
+ input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::singleton,
- mln::trait::image::value_storage::any,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::singleton,
const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
+ const Function_v2v<F>& f)
{
- transform_singleton(input, f, output);
+ return transform_singleton(input, f);
}
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform_dispatch_(mln::trait::image::value_storage::one_block,
- mln::trait::image::value_storage::one_block,
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(mln::trait::image::value_storage::one_block,
const Image<I>& input_,
- const Function_v2v<F>& f_,
- Image<O>& output_)
+ const Function_v2v<F>& f_)
{
const I& input = exact(input_);
- O& output = exact(output_);
-
- /// Check basic properties
+ /// Check alignement property
if (mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value &&
- mlc_is(mln_trait_image_value_alignement(O),
trait::image::value_alignement::with_grid)::value)
- {
- transform_dispatch_(mln_trait_image_quant(I)(),
+ return transform_dispatch_(mln_trait_image_quant(I)(),
mln_trait_image_value_access(I)(),
- mln_trait_image_value_access(O)(),
- mln_trait_image_ext_domain(I)(),
- mln_trait_image_ext_domain(O)(),
- input, f_, output);
- }
+ input, f_);
else
- transform_dispatch_(mln_trait_image_vw_set(I)(),
+ return transform_dispatch_(mln_trait_image_vw_set(I)(),
mln_trait_image_quant(I)(),
- input, f_, output);
+ input, f_);
}
- template <typename I, typename F, typename O>
- inline
- void transform_dispatch_(const Image<I>& input,
- const Function_v2v<F>& f,
- Image<O>& output)
- {
- transform_dispatch_(mln_trait_image_value_storage(I)(),
- mln_trait_image_value_storage(O)(),
- input, f, output);
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform_dispatch_(const Image<I>& input,
+ const Function_v2v<F>& f)
+ {
+ return transform_dispatch_(mln_trait_image_value_storage(I)(),
+ input, f);
}
}
Index: mln/level/transform.hh
--- mln/level/transform.hh (revision 2780)
+++ mln/level/transform.hh (working copy)
@@ -93,11 +93,10 @@
(void) output;
// Properties check
- // FIXME: Re-activate!
-// mln_precondition((mlc_is(mln_trait_image_pw_io(O),
-// trait::image::pw_io::read_write)::value ||
-// mlc_is(mln_trait_image_vw_io(O),
-// trait::image::vw_io::read_write)::value));
+ mln_precondition((mlc_is(mln_trait_image_pw_io(O),
+ trait::image::pw_io::read_write)::value ||
+ mlc_is(mln_trait_image_vw_io(O),
+ trait::image::vw_io::read_write)::value));
// FIXME Convert test
mlc_converts_to(mln_result(F), mln_value(O))::check();
@@ -118,29 +117,31 @@
{
// Generic implementation.
- template <typename I, typename F, typename O>
+ template <typename I, typename F>
inline
- void transform(const Image<I>& input_, const Function_v2v<F>& f_,
- Image<O>& output_)
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input_, const Function_v2v<F>& f_)
{
trace::entering("level::impl::generic::transform");
-
const I& input = exact(input_);
const F& f = exact(f_);
- O& output = exact(output_);
- level::internal::transform_tests(input, f, output);
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
- mlc_is(mln_trait_image_pw_io(O),
+ level::internal::transform_tests(input, f, output);
+ mlc_is(mln_trait_image_pw_io(mln_ch_value(I, mln_result(F))),
trait::image::pw_io::read_write)::check();
mln_piter(I) p(input.domain());
for_all(p)
output(p) = f(input(p));
-
trace::exiting("level::impl::generic::transform");
+
+ return output;
}
} // end of namespace mln::level::impl::generic
@@ -150,21 +151,6 @@
// Facade.
- template <typename I, typename F, typename O>
- inline
- void transform(const Image<I>& input, const Function_v2v<F>& f,
- Image<O>& output)
- {
- trace::entering("level::transform");
-
- mln_precondition(exact(output).domain() >= exact(input).domain());
- impl::internal::transform_dispatch_(exact(input), exact(f), exact(output));
-
- trace::exiting("level::transform");
- }
-
-
-
template <typename I, typename F>
inline
mln_ch_value(I, mln_result(F))
@@ -172,12 +158,11 @@
{
trace::entering("level::transform");
- mln_precondition(exact(input).has_data());
mln_ch_value(I, mln_result(F)) output;
- initialize(output, input);
- transform(input, f, output);
+ output = impl::internal::transform_dispatch_(exact(input), exact(f));
trace::exiting("level::transform");
+
return output;
}
Index: mln/level/stretch.hh
--- mln/level/stretch.hh (revision 2780)
+++ mln/level/stretch.hh (working copy)
@@ -81,7 +81,7 @@
float a = (M - m) / (max - min);
float b = (m * max - M * min) / (max - min);
fun::v2v::linear<float, float, int> f(a, b);
- level::transform(input, f, output);
+ output = level::transform(input, f);
}
trace::exiting("level::impl::stretch");
}
1
0
04 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make convolution return the straightforward type.
* mln/core/concept/object.hh: Add metal include.
* mln/metal/is_not_a.hh: New.
* mln/metal/all.hh: Update.
* mln/metal/is_a.hh (U): Rename as...
(M): ...this; more appropriate.
* mln/linear/ch_convolve.hh: New.
* mln/linear/convolve.hh: Fix return type.
* mln/linear/lap.hh: Update.
* mln/accu/convolve.hh: Add check.
* tests/linear/convolve.cc: Update.
* tests/linear/lap.cc: Update.
mln/accu/convolve.hh | 3 -
mln/core/concept/object.hh | 1
mln/linear/ch_convolve.hh | 92 +++++++++++++++++++++++++++++++++++++++++++++
mln/linear/convolve.hh | 33 +++++++---------
mln/linear/lap.hh | 77 +++++++++++++++++++++++--------------
mln/metal/all.hh | 13 +++---
mln/metal/is_a.hh | 26 ++++++------
mln/metal/is_not_a.hh | 28 +++++--------
tests/linear/convolve.cc | 12 ++---
tests/linear/lap.cc | 11 +++--
10 files changed, 204 insertions(+), 92 deletions(-)
Index: tests/linear/convolve.cc
--- tests/linear/convolve.cc (revision 2779)
+++ tests/linear/convolve.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -61,11 +62,8 @@
.04, .04, .04, .04, .04,
.04, .04, .04, .04, .04 };
w_window2d_float w = make::w_window2d(ws);
+ image2d<float> tmp = linear::convolve(lena, w);
-// image2d<float> tmp = linear::convolve(lena, w);
-// image2d<int_u8> out = level::transform(tmp, math::round<int_u8>());
-
- image2d<int_u8> out = linear::convolve(lena, w);
-
- io::pgm::save(out, "out.pgm");
+ io::pgm::save(level::transform(tmp, math::round<int_u8>()),
+ "out.pgm");
}
Index: tests/linear/lap.cc
--- tests/linear/lap.cc (revision 2779)
+++ tests/linear/lap.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -33,9 +34,11 @@
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
#include <mln/border/thickness.hh>
#include <mln/linear/lap.hh>
+#include <mln/level/stretch.hh>
#include "tests/data.hh"
@@ -47,8 +50,8 @@
border::thickness = 1;
- image2d<int_u8> lena;
+ image2d<int_u8> lena, out;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<int> tmp(lena.domain());
- linear::lap_4(lena, tmp);
+ level::stretch(linear::lap_4(lena), out);
+ io::pgm::save(out, "out.pgm");
}
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 2779)
+++ mln/core/concept/object.hh (working copy)
@@ -45,6 +45,7 @@
// metal
# include <mln/metal/is_a.hh>
+# include <mln/metal/is_not_a.hh>
# include <mln/metal/is.hh>
# include <mln/metal/is_not.hh>
# include <mln/metal/equal.hh>
Index: mln/metal/is_not_a.hh
--- mln/metal/is_not_a.hh (revision 2778)
+++ mln/metal/is_not_a.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_METAL_IS_NOT_HH
-# define MLN_METAL_IS_NOT_HH
+#ifndef MLN_METAL_IS_NOT_A_HH
+# define MLN_METAL_IS_NOT_A_HH
-/*! \file mln/metal/is_not.hh
- *
- * \brief Definition of a type that means "is not".
- */
+/// \file mln/metal/is_not_a.hh
+///
+/// Definition of a type that means "is not a".
-# include <mln/metal/is.hh>
+# include <mln/metal/is_a.hh>
-# define mlc_is_not(T, U) mln::metal::is_not< T, U >
+# define mlc_is_not_a(T, M) mln::metal::is_not_a< T, M >
@@ -46,12 +45,9 @@
namespace metal
{
- /*! \brief "is_not" check.
- *
- * FIXME: Doc!
- */
- template <typename T, typename U>
- struct is_not : not_< is<T, U> >::eval
+ /// "is_not_a" static Boolean expression.
+ template <typename T, template <class> class M>
+ struct is_not_a : not_< is_a<T, M> >::eval
{
};
@@ -60,4 +56,4 @@
} // end of namespace mln
-#endif // ! MLN_METAL_IS_NOT_HH
+#endif // ! MLN_METAL_IS_NOT_A_HH
Property changes on: mln/metal/is_not_a.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 2779)
+++ mln/metal/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,10 @@
#ifndef MLN_METAL_ALL_HH
# define MLN_METAL_ALL_HH
-/*! \file mln/metal/all.hh
- *
- * \brief File that includes all meta-programming tools.
- */
+/// \file mln/metal/all.hh
+///
+/// File that includes all meta-programming tools.
+
namespace mln
{
@@ -61,7 +62,9 @@
# include <mln/metal/converts_to.hh>
# include <mln/metal/is.hh>
+# include <mln/metal/is_not.hh>
# include <mln/metal/is_a.hh>
+# include <mln/metal/is_not_a.hh>
# include <mln/metal/goes_to.hh>
# include <mln/metal/const.hh>
Index: mln/metal/is_a.hh
--- mln/metal/is_a.hh (revision 2779)
+++ mln/metal/is_a.hh (working copy)
@@ -37,14 +37,14 @@
/// \brief Expand to a "metalic" boolean expression stating whether \a
-/// T is a subclass of \a U or not.
+/// T is a subclass of \a M or not.
///
-/// In the current implementation, \a U must be template class with
+/// In the current implementation, \a M must be template class with
/// exactly one, non template parameter.
///
/// This macro is the recommended user interface of the "is_a"
/// facility.
-# define mlc_is_a(T, U) mln::metal::is_a<T, U>
+# define mlc_is_a(T, M) mln::metal::is_a<T, M>
@@ -72,12 +72,12 @@
static T* ptr();
};
- template <typename T, template <class> class U>
+ template <typename T, template <class> class M>
struct helper_is_a_
{
template<class V>
- static yes_ selector(U<V>*);
+ static yes_ selector(M<V>*);
static no_ selector(...);
};
@@ -89,22 +89,22 @@
*
* FIXME: Doc!
*/
- template <typename T, template <class> class U>
- struct is_a : bool_<( sizeof( internal::helper_is_a_< T, U >::selector(internal::make_< T >::ptr()) )
+ template <typename T, template <class> class M>
+ struct is_a : bool_<( sizeof( internal::helper_is_a_< T, M >::selector(internal::make_< T >::ptr()) )
==
sizeof( internal::yes_ ) )>
{};
- template <typename T, template <class> class U>
- struct is_a< const T, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< const T, M > : is_a< T, M >::eval
{};
- template <typename T, template <class> class U>
- struct is_a< T&, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< T&, M > : is_a< T, M >::eval
{};
- template <typename T, template <class> class U>
- struct is_a< const T&, U > : is_a< T, U >::eval
+ template <typename T, template <class> class M>
+ struct is_a< const T&, M > : is_a< T, M >::eval
{};
Index: mln/linear/ch_convolve.hh
--- mln/linear/ch_convolve.hh (revision 0)
+++ mln/linear/ch_convolve.hh (revision 0)
@@ -0,0 +1,92 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LINEAR_CH_CONVOLVE_HH
+# define MLN_LINEAR_CH_CONVOLVE_HH
+
+/// \file mln/linear/ch_convolve.hh
+///
+/// Define convolution return type.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/trait/ch_value.hh>
+# include <mln/value/ops.hh>
+
+
+/// Define the result of the convolution of an image with type \p I
+/// with a weighted window of type \p W or weights of type \p W.
+# define mln_ch_convolve(I, W) \
+ typename mln::linear::ch_convolve<I, W>::ret
+
+
+namespace mln
+{
+
+ namespace linear
+ {
+
+ namespace internal
+ {
+
+ template <bool b, /* = true, i.e., W is a Weighted_Window */
+ typename I, typename W>
+ struct ch_convolve_helper
+ {
+ typedef mln_sum_x(mln_value(I), mln_weight(W)) V;
+ typedef mln_ch_value(I, V) ret;
+ };
+
+ template <typename I, typename W>
+ struct ch_convolve_helper<false, I, W>
+ {
+ typedef mln_sum_x(mln_value(I), W) V;
+ typedef mln_ch_value(I, V) ret;
+ };
+
+ } // end of namespace mln::linear::internal
+
+
+ template <typename I, typename W>
+ struct ch_convolve
+ : private mlc_and( mlc_is_a(I, Image),
+ mlc_is_not_a(W, Window) )::check_t
+ {
+ protected:
+ enum { is_w_win = mlc_is_a(W, Weighted_Window)::value };
+ typedef internal::ch_convolve_helper<is_w_win, I, W> helper;
+ public:
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::linear
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LINEAR_CH_CONVOLVE_HH
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 2779)
+++ mln/linear/convolve.hh (working copy)
@@ -29,18 +29,15 @@
#ifndef MLN_LINEAR_CONVOLVE_HH
# define MLN_LINEAR_CONVOLVE_HH
-/*! \file mln/linear/convolve.hh
- *
- * \brief Convolution.
- *
- * \todo Introduce an accumulator.
- */
+/// \file mln/linear/convolve.hh
+///
+/// Convolution.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/weighted_window.hh>
-# include <mln/extension/adjust_duplicate.hh>
+# include <mln/linear/ch_convolve.hh>
# include <mln/accu/convolve.hh>
-
+# include <mln/extension/adjust_duplicate.hh>
namespace mln
@@ -60,7 +57,7 @@
* \pre output.domain = input.domain
*/
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input, const Weighted_Window<W>& w_win);
@@ -95,7 +92,7 @@
{
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input_,
const Weighted_Window<W>& w_win_)
{
@@ -107,7 +104,7 @@
extension::adjust_duplicate(input, w_win);
- typedef mln_concrete(I) O;
+ typedef mln_ch_convolve(I, W) O;
O output;
initialize(output, input);
@@ -132,7 +129,7 @@
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_fastest(const Image<I>& input_,
const Weighted_Window<W>& w_win_)
{
@@ -144,7 +141,7 @@
extension::adjust_duplicate(input, w_win);
- typedef mln_concrete(I) O;
+ typedef mln_ch_convolve(I, W) O;
O output;
initialize(output, input);
mln_pixter(O) p_out(output);
@@ -176,7 +173,7 @@
{
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(trait::image::speed::any,
const Image<I>& input,
const Weighted_Window<W>& w_win)
@@ -185,7 +182,7 @@
}
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(trait::image::speed::fastest,
const Image<I>& input,
const Weighted_Window<W>& w_win)
@@ -194,7 +191,7 @@
}
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve_dispatch(const Image<I>& input,
const Weighted_Window<W>& w_win)
{
@@ -208,14 +205,14 @@
// Facade.
template <typename I, typename W>
- mln_concrete(I)
+ mln_ch_convolve(I, W)
convolve(const Image<I>& input, const Weighted_Window<W>& w_win)
{
trace::entering("linear::convolve");
internal::convolve_tests(input, w_win);
- mln_concrete(I) output;
+ mln_ch_convolve(I, W) output;
output = internal::convolve_dispatch(mln_trait_image_speed(I)(),
input, w_win);
Index: mln/linear/lap.hh
--- mln/linear/lap.hh (revision 2779)
+++ mln/linear/lap.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -46,65 +47,85 @@
// FIXME: Doc!
- template <typename I, typename O>
- void lap_4(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_8(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_x(const Image<I>& input, Image<O>& output);
-
- template <typename I, typename O>
- void lap_o(const Image<I>& input, Image<O>& output);
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_4(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_8(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_x(const Image<I>& input);
+
+ template <typename I>
+ mln_ch_convolve(I, int)
+ lap_o(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
// Laplacian operators (Cf. Sonka et al., p. 81)
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_4(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_4(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_4");
+ mln_precondition(exact(input).has_data());
int ws[] = { 0, 1, 0,
1, -4, 1,
0, 1, 0 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_4");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_8(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_8(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_8");
+ mln_precondition(exact(input).has_data());
int ws[] = { 1, 1, 1,
1, -8, 1,
1, 1, 1 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_8");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_x(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_x(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_x");
+ mln_precondition(exact(input).has_data());
int ws[] = { +2, -1, +2,
-1, -4, -1,
+2, -1, +2 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_x");
+ return output;
}
- template <typename I, typename O>
+ template <typename I>
inline
- void lap_o(const Image<I>& input, Image<O>& output)
+ mln_ch_convolve(I, int)
+ lap_o(const Image<I>& input)
{
- mln_precondition(exact(output).domain() == exact(input).domain());
+ trace::entering("linear::lap_o");
+ mln_precondition(exact(input).has_data());
int ws[] = { -1, +2, -1,
+2, -4, +2,
-1, +2, -1 };
- convolve(input, make::w_window2d(ws), output);
+ mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
+ trace::exiting("linear::lap_o");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/convolve.hh
--- mln/accu/convolve.hh (revision 2779)
+++ mln/accu/convolve.hh (working copy)
@@ -52,7 +52,8 @@
*/
template <typename T1, typename T2,
typename R = mln_sum_x(T1, T2)>
- struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >
+ struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >,
+ private metal::converts_to< mln_sum_x(T1, T2), R >::check_t
{
typedef std::pair<T1,T2> argument;
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Fix Sanity.
* tests/all_headers.cc: Make this test pass.
* mln/core/site_set/p_graph.hh: Fix wrong use of graph.
* mln/core/image/translate_image.hh: Make it compile.
* mln/core/image/all.hh: Complete headers inclusion.
* mln/util/tree.hh,
* mln/core/concept/window.hh: Gcc 4.3 fix.
* mln/core/site_set/p_centered.hh: Update.
* mln/core/window.hh: Update.
* mln/win/multiple_size.hh: Update.
* mln/win/multiple.hh: Update.
* mln/core/internal/image_value_morpher.hh: Add FIXME doxygen.
* mln/linear/local/convolve.hh: Fix namespace.
* mln/value/stack.hh: Make proper inheritens.
* mln/border/equalize.hh: Make it compile.
* mln/set/all.hh: Fix inclusion.
* mln/io/fits/load.hh: Add FIXME dependency.
* mln/draw/graph.hh: Move...
* mln/debug/graph.hh: ...here.
* mln/debug/all.hh: Update.
* mln/draw/all.hh: Update.
mln/border/equalize.hh | 5 +-
mln/core/concept/window.hh | 2 -
mln/core/image/all.hh | 58 ++++++++++++++++++++++++++++++-
mln/core/image/translate_image.hh | 14 +++----
mln/core/internal/image_value_morpher.hh | 1
mln/core/site_set/p_centered.hh | 2 -
mln/core/site_set/p_graph.hh | 4 +-
mln/debug/all.hh | 1
mln/debug/graph.hh | 36 ++++++++-----------
mln/draw/all.hh | 1
mln/io/fits/load.hh | 2 +
mln/linear/local/convolve.hh | 2 -
mln/set/all.hh | 2 -
mln/util/tree.hh | 6 +--
mln/value/stack.hh | 6 ++-
mln/win/multiple.hh | 4 +-
mln/win/multiple_size.hh | 4 +-
tests/all_headers.cc | 28 +++++++-------
18 files changed, 117 insertions(+), 61 deletions(-)
Index: tests/all_headers.cc
--- tests/all_headers.cc (revision 2778)
+++ tests/all_headers.cc (working copy)
@@ -32,32 +32,32 @@
#include <mln/test/all.hh>
-//#include <mln/convert/all.hh>
+#include <mln/convert/all.hh>
#include <mln/estim/all.hh>
-#include <mln/debug/all.hh>
+//#include <mln/debug/all.hh>
#include <mln/histo/all.hh>
#include <mln/pw/all.hh>
#include <mln/geom/all.hh>
#include <mln/core/trait/all.hh>
-//#include <mln/fun/i2v/all.hh>
-//#include <mln/fun/p2b/all.hh>
-//#include <mln/fun/p2v/all.hh>
-//#include <mln/fun/v2v/all.hh>
-//#include <mln/fun/x2x/all.hh>
-//#include <mln/fun/all.hh>
+#include <mln/fun/i2v/all.hh>
+#include <mln/fun/p2b/all.hh>
+#include <mln/fun/p2v/all.hh>
+#include <mln/fun/v2v/all.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/fun/all.hh>
#include <mln/math/all.hh>
-//#include <mln/set/all.hh>
+#include <mln/set/all.hh>
#include <mln/draw/all.hh>
#include <mln/metal/math/all.hh>
#include <mln/metal/all.hh>
#include <mln/morpho/all.hh>
#include <mln/io/pfm/all.hh>
#include <mln/io/pgm/all.hh>
-//#include <mln/io/fits/all.hh>
+#include <mln/io/fits/all.hh>
#include <mln/io/ppm/all.hh>
#include <mln/io/pbm/all.hh>
#include <mln/io/pnm/all.hh>
-//#include <mln/io/all.hh>
+#include <mln/io/all.hh>
#include <mln/level/naive/all.hh>
#include <mln/level/approx/all.hh>
#include <mln/level/all.hh>
@@ -70,16 +70,16 @@
#include <mln/accu/all.hh>
#include <mln/norm/all.hh>
#include <mln/value/internal/all.hh>
-#include <mln/value/all.hh>
#include <mln/value/concept/all.hh>
#include <mln/value/builtin/all.hh>
-#include <mln/make/all.hh>
+#include <mln/value/all.hh>
+//#include <mln/make/all.hh>
#include <mln/border/all.hh>
#include <mln/labeling/all.hh>
#include <mln/util/all.hh>
-#include <mln/trait/all.hh>
#include <mln/trait/value/all.hh>
#include <mln/trait/op/all.hh>
+#include <mln/trait/all.hh>
#include <mln/tag/all.hh>
#include <mln/trace/all.hh>
#include <mln/literal/all.hh>
Index: mln/debug/graph.hh
--- mln/debug/graph.hh (revision 2778)
+++ mln/debug/graph.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_DRAW_GRAPH_HH
-# define MLN_DRAW_GRAPH_HH
+#ifndef MLN_DEBUG_DRAW_GRAPH_HH
+# define MLN_DEBUG_DRAW_GRAPH_HH
-/// \file mln/draw/graph.hh
+/// \file mln/debug/draw_graph.hh
/// \brief Draw an (classical) image from a mln::graph_image.
# include <mln/pw/image.hh>
@@ -40,12 +40,8 @@
namespace mln
{
- namespace draw
+ namespace debug
{
- /* FIXME: `draw::graph' is not a good name. These functions do not
- actually _draw_ the graph/graph_image; it *converts* it to a
- printable image. These functions should be put elsewhere
- (e.g., in debug::). */
/*! \brief Draw an image \p ima from a mln::p_graph \p pg, with
* value \p vertex_v for vertices, value \p edge_v for edges and 0 for
@@ -61,7 +57,7 @@
*/
template <typename I, typename P>
void
- graph(Image<I>& ima, const p_graph<P>& pg,
+ draw_graph(Image<I>& ima, const p_graph<P>& pg,
mln_value(I) vertex_v, mln_value(I) edge_v);
/*! \brief Draw an image \p ima from a mln::graph_image \p gi.
@@ -78,7 +74,7 @@
// constructed from `int'! We should remove this last argument.
template <typename I, typename P, typename V>
void
- graph(Image<I>& ima, const graph_image<P, V>& gi,
+ draw_graph(Image<I>& ima, const graph_image<P, V>& gi,
mln_value(I) edge_v = 1);
# ifndef MLN_INCLUDE_ONLY
@@ -89,12 +85,12 @@
template <typename I, typename P>
inline
void
- graph(Image<I>& ima, const p_graph<P>& pg,
+ draw_graph(Image<I>& ima, const p_graph<P>& pg,
mln_value(I) vertex_v, mln_value(I) edge_v)
{
- // Draw the background.
+ // Debug the background.
level::fill(ima, 0);
- // Draw the lines (edges).
+ // Debug the lines (edges).
for (unsigned l = 0; l < pg.nedges(); ++l)
line (exact(ima),
// FIXME: Too low-level. See similar remarks
@@ -102,7 +98,7 @@
pg.gr_->vertex_data(pg.gr_->edge(l).v1()),
pg.gr_->vertex_data(pg.gr_->edge(l).v2()),
edge_v);
- // Draw the points (vertices).
+ // Debug the points (vertices).
for (unsigned p = 0; p < pg.nsites(); ++p)
exact(ima)(pg.gr_->vertex_data(p)) = vertex_v;
}
@@ -110,23 +106,23 @@
template <typename I, typename P, typename V>
inline
void
- graph(Image<I>& ima, const graph_image<P, V>& gi,
+ draw_graph(Image<I>& ima, const graph_image<P, V>& gi,
mln_value(I) edge_v)
{
- // Draw the background.
+ // Debug the background.
level::fill(ima, 0);
- // Draw the lines (edges).
+ // Debug the lines (edges).
for (unsigned l = 0; l < gi.domain().nedges(); ++l)
line (exact(ima), gi.vertex1(l), gi.vertex2(l), edge_v);
- // Draw the points (vertices).
+ // Debug the points (vertices).
for (unsigned p = 0; p < gi.domain().nvertices(); ++p)
exact(ima)(gi.domain().point_from_id(p)) = gi.vertex_values()[p];
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::draw
+ } // end of namespace mln::debug
} // end of namespace mln
-#endif // MLN_GRAPH_PSITE_HH
+#endif // MLN_DEBUG_DRAW_GRAPH_HH
Property changes on: mln/debug/graph.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/debug/all.hh
--- mln/debug/all.hh (revision 2778)
+++ mln/debug/all.hh (working copy)
@@ -50,6 +50,7 @@
# include <mln/debug/iota.hh>
# include <mln/debug/println.hh>
# include <mln/debug/println_with_border.hh>
+# include <mln/debug/graph.hh>
#endif // ! MLN_DEBUG_ALL_HH
Index: mln/core/site_set/p_centered.hh
--- mln/core/site_set/p_centered.hh (revision 2778)
+++ mln/core/site_set/p_centered.hh (working copy)
@@ -253,7 +253,7 @@
{
this->change_target(s);
q_.center_at(s.center());
- q_.change_target(s.window());
+ q_.change_target(s.window_());
}
template <typename W>
Index: mln/core/site_set/p_graph.hh
--- mln/core/site_set/p_graph.hh (revision 2778)
+++ mln/core/site_set/p_graph.hh (working copy)
@@ -70,7 +70,7 @@
typedef p_graph<P> self_;
typedef internal::site_set_base_< P, self_ > super_;
- typedef util::graph<P> graph;
+ typedef util::graph graph;
/// \brief Construct a graph psite set from a graph of points.
///
@@ -201,7 +201,7 @@
inline
p_graph<P>::p_graph(const graph& gr)
// Create a deep, managed copy of GR.
- : gr_ (new util::graph<P>(gr))
+ : gr_ (new util::graph(gr))
{
}
Index: mln/core/image/translate_image.hh
--- mln/core/image/translate_image.hh (revision 2778)
+++ mln/core/image/translate_image.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/internal/image_identity.hh>
# include <mln/core/alias/box2d.hh>
+//FIXME: Fix this image morpher.
namespace mln
{
@@ -76,13 +77,11 @@
{
typedef trait::image::category::domain_morpher category;
- typedef mln_trait_image_access(I) access;
- typedef mln_trait_image_space(I) space;
+ typedef mln_trait_image_value_access(I) access;
+ typedef mln_trait_image_localization(I) space;
typedef mln_trait_image_size(I) size;
- typedef mln_trait_image_support(I) support;
- typedef mln_trait_image_border(I) border;
- typedef mln_trait_image_io_from_(I) io;
- typedef mln_trait_image_data_from_(I) data;
+ //typedef mln_trait_image_io_from_(I) io;
+ //typedef mln_trait_image_data_from_(I) data;
};
@@ -100,8 +99,7 @@
struct translate_image : public mln::internal::image_identity< I, mln_pset(I), translate_image<I> >
{
- typedef mln::internal::image_morpher< I, mln_pset(I), translate_image<I> > super_;
- typedef line_piter_<mln_psite(I)> line_piter;
+ typedef mln::internal::image_morpher< I, mln_value(I), mln_pset(I), translate_image<I> > super_;
/// Return type of read-write access.
typedef mln_morpher_lvalue(I) lvalue;
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 2778)
+++ mln/core/image/all.hh (working copy)
@@ -36,7 +36,63 @@
*/
-// FIXME: Complete...
+# include <bgraph_image.hh>
+# include <bgraph_psite.hh>
+# include <cast_image.hh>
+# include <ch_piter.hh>
+# include <complex_image.hh>
+# include <complex_neighborhood_piter.hh>
+# include <complex_neighborhoods.hh>
+# include <complex_window_piter.hh>
+# include <complex_windows.hh>
+# include <decorated_image.hh>
+# include <extended.hh>
+# include <extension_fun.hh>
+# include <extension_ima.hh>
+# include <extension_val.hh>
+# include <fi_adaptor.hh>
+# include <flat_image.hh>
+# include <graph_elt_neighborhood.hh>
+# include <graph_elt_window.hh>
+# include <graph_image.hh>
+# include <graph_neighborhood_piter.hh>
+# include <graph_window_piter.hh>
+# include <hexa.hh>
+# include <hexa_piter.hh>
+# include <image1d.hh>
+# include <image2d.hh>
+# include <image2d_h.hh>
+# include <image3d.hh>
+# include <image_if.hh>
+# include <interpolated.hh>
+# include <lazy_image.hh>
+# include <line_graph_elt_neighborhood.hh>
+# include <line_graph_elt_window.hh>
+# include <line_graph_image.hh>
+# include <line_graph_neighborhood_piter.hh>
+# include <line_graph_psite.hh>
+# include <line_graph_window_piter.hh>
+# include <mono_obased_rle_encode.hh>
+# include <mono_obased_rle_image.hh>
+# include <mono_rle_encode.hh>
+# include <mono_rle_image.hh>
+# include <obased_rle_encode.hh>
+# include <obased_rle_image.hh>
+# include <plain.hh>
+# include <rle_encode.hh>
+# include <rle_image.hh>
+# include <safe.hh>
+# include <sparse_encode.hh>
+# include <sparse_image.hh>
+# include <status.txt
+# include <sub_image.hh>
+# include <sub_image_if.hh>
+# include <t_image.hh>
+# include <translate_image.hh>
+# include <tr_image.hh>
+# include <tr_mesh.hh>
+# include <value_enc_image.hh>
+# include <value_encode.hh>
#endif // ! MLN_CORE_IMAGE_ALL_HH
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2778)
+++ mln/core/concept/window.hh (working copy)
@@ -277,7 +277,7 @@
for (unsigned w = 0; w < nw; ++w)
{
ostr << " #" << w << ':';
- win.window(w).print(ostr);
+ win.window_(w).print(ostr);
}
ostr << " ]";
}
Index: mln/core/window.hh
Index: mln/core/internal/image_value_morpher.hh
--- mln/core/internal/image_value_morpher.hh (revision 2778)
+++ mln/core/internal/image_value_morpher.hh (working copy)
@@ -45,6 +45,7 @@
namespace internal
{
+ //FIXME: Fix doxygen.
/*! A base class for image morphers w.r.t. value.
* Parameter \p S is a point set type.
Index: mln/draw/all.hh
--- mln/draw/all.hh (revision 2778)
+++ mln/draw/all.hh (working copy)
@@ -43,7 +43,6 @@
}
# include <mln/draw/box.hh>
-# include <mln/draw/graph.hh>
# include <mln/draw/label.hh>
# include <mln/draw/line.hh>
# include <mln/draw/plot.hh>
Index: mln/linear/local/convolve.hh
--- mln/linear/local/convolve.hh (revision 2778)
+++ mln/linear/local/convolve.hh (working copy)
@@ -127,7 +127,7 @@
const W& w_win,
R& result)
{
- const P& p = internal::force_exact<P>(p_);
+ const P& p = mln::internal::force_exact<P>(p_);
mln_precondition(p.ima().border() >= w_win.delta());
R tmp = 0;
Index: mln/value/stack.hh
--- mln/value/stack.hh (revision 2778)
+++ mln/value/stack.hh (working copy)
@@ -109,7 +109,7 @@
// here.
typedef trait::image::category::value_morpher category;
- typedef trait::image::value::vectorial value;
+ typedef trait::image::nature::vectorial nature;
/* FIXME: Setting the speed trait of a stack_image to `fast' is
a bad approximation.
@@ -146,7 +146,9 @@
*/
template <unsigned n, typename I>
struct stack_image
- : public mln::internal::image_value_morpher< I, stack_image<n,I> >
+ : public mln::internal::image_value_morpher< I,
+ algebra::vec<n, mln_value(I)>,
+ stack_image<n,I> >
{
/// Point_Site associated type.
typedef mln_psite(I) psite;
Index: mln/border/equalize.hh
--- mln/border/equalize.hh (revision 2778)
+++ mln/border/equalize.hh (working copy)
@@ -116,8 +116,9 @@
{
trace::entering("border::equalize");
- mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
- mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
+ //FIXME: check border
+ //mlc_is(mln_trait_image_border(I), trait::image::border::some)::check();
+ //mlc_is(mln_trait_image_border(J), trait::image::border::some)::check();
const I& ima1 = exact(ima1_);
const J& ima2 = exact(ima2_);
mln_precondition(ima1.has_data() && ima2.has_data());
Index: mln/set/all.hh
--- mln/set/all.hh (revision 2778)
+++ mln/set/all.hh (working copy)
@@ -46,6 +46,6 @@
# include <mln/set/inter.hh>
# include <mln/set/is_subset_of.hh>
# include <mln/set/sym_diff.hh>
-# include <mln/set/union.hh>
+# include <mln/set/uni.hh>
#endif // ! MLN_SET_ALL_HH
Index: mln/win/multiple_size.hh
--- mln/win/multiple_size.hh (revision 2778)
+++ mln/win/multiple_size.hh (working copy)
@@ -101,7 +101,7 @@
void set_window(unsigned i, const W& win);
- const W& window(unsigned i) const;
+ const W& window_(unsigned i) const;
unsigned nwindows() const;
@@ -200,7 +200,7 @@
template <typename W, typename F>
inline
const W&
- multiple_size<W,F>::window(unsigned i) const
+ multiple_size<W,F>::window_(unsigned i) const
{
mln_precondition(i < win_.nelements());
return win_[i];
Index: mln/win/multiple.hh
--- mln/win/multiple.hh (revision 2778)
+++ mln/win/multiple.hh (working copy)
@@ -103,7 +103,7 @@
void set_window(unsigned i, const W& win);
- const W& window(unsigned i) const;
+ const W& window_(unsigned i) const;
unsigned nwindows() const;
@@ -206,7 +206,7 @@
template <typename W, typename F>
inline
const W&
- multiple<W,F>::window(unsigned i) const
+ multiple<W,F>::window_(unsigned i) const
{
mln_precondition(i < win_.nelements());
return win_[i];
Index: mln/io/fits/load.hh
--- mln/io/fits/load.hh (revision 2778)
+++ mln/io/fits/load.hh (working copy)
@@ -43,6 +43,8 @@
# include <mln/core/image/image2d.hh>
# include <mln/value/int_u8.hh>
+
+//FIXME: Add fitsio dependency
# include <fitsio.h>
namespace mln
Index: mln/util/tree.hh
--- mln/util/tree.hh (revision 2778)
+++ mln/util/tree.hh (working copy)
@@ -269,7 +269,7 @@
*
* \return The tree of the current branch.
*/
- tree<T>& tree();
+ tree<T>& util_tree();
private:
/// The tree of this branch.
@@ -554,8 +554,8 @@
template <typename T>
inline
- util::tree<T>&
- branch<T>::tree()
+ mln::util::tree<T>&
+ branch<T>::util_tree()
{
return tree_;
}
1
0
03 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
INIM: Move classif work in the inim directory.
* classif: Move ...
* inim/classif: ... Here.
* inim/classif/Makefile: Update relative include directory.
* inim/classif/proj.hh: Trailing update.
Makefile | 6 +++---
proj.hh | 5 ++---
2 files changed, 5 insertions(+), 6 deletions(-)
Index: inim/classif/proj.hh
--- inim/classif/proj.hh (revision 2777)
+++ inim/classif/proj.hh (working copy)
@@ -58,11 +58,10 @@
K mean, const char * fn)
{
- //accu::mean<unsigned, unsigned long, value::int_u8> mean_accu;
- accu::maj_h<value::int_u8> max_1;
+ accu::max<value::int_u8> max_1;
image2d<value::int_u8> hproj = proj(histo, max_1);
- accu::maj_h<value::int_u8> max_2;
+ accu::max<value::int_u8> max_2;
image2d<value::int_u8> proj_class = proj(ws, max_2);
//std::cout << histo;
Index: inim/classif/Makefile
--- inim/classif/Makefile (revision 2777)
+++ inim/classif/Makefile (working copy)
@@ -1,18 +1,18 @@
DISP=xv
# ICCVG
-ICCVG_INCLUDES=-I../..
+ICCVG_INCLUDES=-I../../..
ICCVG_SRC=iccvg04.cc
ICCVG=iccvg
ICCVG_DBG=iccvg_dbg
-IMG?=../../img/lena.ppm
+IMG?=..//../img/lena.ppm
DIV?=4
LAMBDA?=10
# V2
-V2_INCLUDES=-I../..
+V2_INCLUDES=-I../../..
V2_SRC=v2.cc max_tree.hh
V2=v2
V2_DBG=v2_dbg
1
0
03 Nov '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Create doc/benchmark/morpho, add bench for erosion.
* doc/benchmark/morpho/erosion.cc: New, bench several specialization
of erosion.
* doc/benchmark/morpho: New.
* tests/morpho/erosion.cc: Make it a real test, not a
benchmark. Remove output and timer.
---
doc/benchmark/morpho/erosion.cc | 292 ++++++++++++++++++++++++++++++++++++++++
tests/morpho/erosion.cc | 94 ------------
2 files changed, 295 insertions(+), 91 deletions(-)
Index: branches/cleanup-2008/milena/tests/morpho/erosion.cc
===================================================================
--- branches/cleanup-2008/milena/tests/morpho/erosion.cc (revision 2775)
+++ branches/cleanup-2008/milena/tests/morpho/erosion.cc (revision 2776)
@@ -42,31 +42,12 @@
#include <mln/morpho/erosion.hh>
#include "tests/data.hh"
-#include "tests/timer.hh"
-
int main()
{
using namespace mln;
using value::int_u8;
-// unsigned
-// l_oct = 11, L_oct = 6 * l_oct + 1,
-// l_rec = 29, L_rec = 2 * l_rec + 1;
-
- // l_
- // oct rec err
- // 0 0 3
- // 0 1 5
- // 1 2 15
- // 1 3 9
- // 2 5 11
- // 3 8 9
- // 5 13 15
- // 8 21 11
- // 11 29 1
- // 25 66 15
-
border::thickness = 20;
image2d<int_u8> lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
@@ -79,214 +60,145 @@
win::octagon2d oct(6 * 3 + 1);
image2d<int_u8> out;
image2d<int_u8> ref;
-// trace::quiet = false;
- timer t;
// Rectangle
- std::cout << "-------------------------- Rectangle: " << std::endl;
-
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, rec);
- std::cout << "generic on rectangle2d: " << t << std::endl;
}
{
- t.start();
out = morpho::erosion(lena, rec);
- std::cout << "dispach on rectangle2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, rec);
- std::cout << "erosion_arbitrary_2d_fastest on rectangle2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d(lena, rec);
- std::cout << "erosion_arbitrary_2d on rectangle2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
//Hline
-
- std::cout << "-------------------------- Hline2d: " << std::endl;
-
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, hline);
- std::cout << "generic on hline2d: " << t << std::endl;
}
{
- t.start();
out = morpho::erosion(lena, hline);
- std::cout << "dispach on hline2d : " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, hline);
- std::cout << "erosion_arbitrary_2d_fastest on hline2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d(lena, hline);
- std::cout << "erosion_arbitrary_2d on hline2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
- std::cout << "-------------------------- Vline2d: "<< std::endl;
-
//Vline
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, vline);
- std::cout << "generic on vline2d: " << t << std::endl;
}
{
- t.start();
out = morpho::erosion(lena, vline);
- std::cout << "dispach on vline2d : " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, vline);
- std::cout << "erosion_arbitrary_2d_fastest on vline2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d(lena, vline);
- std::cout << "erosion_arbitrary_2d on vline2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
//Diag2d
- std::cout << "-------------------------- Diag2d: "<< std::endl;
+
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, diag2d);
- std::cout << "generic on diag2d: " << t << std::endl;
}
{
- t.start();
out = morpho::erosion(lena, diag2d);
- std::cout << "dispach on diag2d : " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, diag2d);
- std::cout << "erosion_arbitrary_2d_fastest on diag2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d(lena, diag2d);
- std::cout << "erosion_arbitrary_2d on diag2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
//Backdiag2d
- std::cout << "-------------------------- Backdiag2d: "<< std::endl;
+
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, backdiag2d);
- std::cout << "generic on backdiag2d: " << t << std::endl;
}
{
- t.start();
out = morpho::erosion(lena, backdiag2d);
- std::cout << "dispach on backdiag2d : " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d_fastest(lena, backdiag2d);
- std::cout << "erosion_arbitrary_2d_fastest on backdiag2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
{
- t.start();
out = morpho::impl::erosion_arbitrary_2d(lena, backdiag2d);
- std::cout << "erosion_arbitrary_2d on backdiag2d: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
- std::cout << "-------------------------- Octagon: " << std::endl;
+
// Octagon
{
- t.start();
ref = morpho::impl::generic::erosion_on_function(lena, oct);
- std::cout << "generic on octagon: " << t << std::endl;
io::pgm::save(ref, "out_oct_ref.pgm");
}
{
- t.start();
out = morpho::erosion(lena, oct);
- std::cout << "dispach on octagon: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
- std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
}
Index: branches/cleanup-2008/milena/doc/benchmark/morpho/erosion.cc
===================================================================
--- branches/cleanup-2008/milena/doc/benchmark/morpho/erosion.cc (revision 0)
+++ branches/cleanup-2008/milena/doc/benchmark/morpho/erosion.cc (revision 2776)
@@ -0,0 +1,292 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/morpho/erosion.cc
+ *
+ * \brief Test on mln::morpho::erosion.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/all.hh>
+
+#include <mln/debug/iota.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/morpho/erosion.hh>
+
+#include "tests/data.hh"
+#include "tests/timer.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// unsigned
+// l_oct = 11, L_oct = 6 * l_oct + 1,
+// l_rec = 29, L_rec = 2 * l_rec + 1;
+
+ // l_
+ // oct rec err
+ // 0 0 3
+ // 0 1 5
+ // 1 2 15
+ // 1 3 9
+ // 2 5 11
+ // 3 8 9
+ // 5 13 15
+ // 8 21 11
+ // 11 29 1
+ // 25 66 15
+
+ border::thickness = 20;
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+
+ win::rectangle2d rec(21, 21);
+ win::hline2d hline(31);
+ win::vline2d vline(31);
+ win::diag2d diag2d(31);
+ win::backdiag2d backdiag2d(31);
+ win::octagon2d oct(6 * 3 + 1);
+ image2d<int_u8> out;
+ image2d<int_u8> ref;
+// trace::quiet = false;
+ timer t;
+
+
+ // Rectangle
+ std::cout << "-------------------------- Rectangle: " << std::endl;
+
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, rec);
+ std::cout << "generic on rectangle2d: " << t << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, rec);
+ std::cout << "dispach on rectangle2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d_fastest(lena, rec);
+ std::cout << "erosion_arbitrary_2d_fastest on rectangle2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d(lena, rec);
+ std::cout << "erosion_arbitrary_2d on rectangle2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ //Hline
+
+ std::cout << "-------------------------- Hline2d: " << std::endl;
+
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, hline);
+ std::cout << "generic on hline2d: " << t << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, hline);
+ std::cout << "dispach on hline2d : " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d_fastest(lena, hline);
+ std::cout << "erosion_arbitrary_2d_fastest on hline2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d(lena, hline);
+ std::cout << "erosion_arbitrary_2d on hline2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ std::cout << "-------------------------- Vline2d: "<< std::endl;
+
+ //Vline
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, vline);
+ std::cout << "generic on vline2d: " << t << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, vline);
+ std::cout << "dispach on vline2d : " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d_fastest(lena, vline);
+ std::cout << "erosion_arbitrary_2d_fastest on vline2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d(lena, vline);
+ std::cout << "erosion_arbitrary_2d on vline2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ //Diag2d
+ std::cout << "-------------------------- Diag2d: "<< std::endl;
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, diag2d);
+ std::cout << "generic on diag2d: " << t << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, diag2d);
+ std::cout << "dispach on diag2d : " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d_fastest(lena, diag2d);
+ std::cout << "erosion_arbitrary_2d_fastest on diag2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d(lena, diag2d);
+ std::cout << "erosion_arbitrary_2d on diag2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ //Backdiag2d
+ std::cout << "-------------------------- Backdiag2d: "<< std::endl;
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, backdiag2d);
+ std::cout << "generic on backdiag2d: " << t << std::endl;
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, backdiag2d);
+ std::cout << "dispach on backdiag2d : " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d_fastest(lena, backdiag2d);
+ std::cout << "erosion_arbitrary_2d_fastest on backdiag2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+
+ {
+ t.start();
+ out = morpho::impl::erosion_arbitrary_2d(lena, backdiag2d);
+ std::cout << "erosion_arbitrary_2d on backdiag2d: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+ std::cout << "-------------------------- Octagon: " << std::endl;
+
+ // Octagon
+ {
+ t.start();
+ ref = morpho::impl::generic::erosion_on_function(lena, oct);
+ std::cout << "generic on octagon: " << t << std::endl;
+ io::pgm::save(ref, "out_oct_ref.pgm");
+ }
+
+ {
+ t.start();
+ out = morpho::erosion(lena, oct);
+ std::cout << "dispach on octagon: " << t << std::endl;
+ bool test = out == ref;
+ mln_assertion(test);
+ std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
+ }
+
+}
1
0
cleanup-2008 2775: Make linear::convolve work properly with heterogenous types.
by Thierry Geraud 03 Nov '08
by Thierry Geraud 03 Nov '08
03 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make linear::convolve work properly with heterogenous types.
* tests/core/routine/primary.cc: New.
* tests/core/routine/Makefile.am: Update.
* tests/border/duplicate.cc: Layout.
* mln/core/routine/primary.hh: Complete.
* mln/core/internal/image_morpher.hh
(unmorph_): New overload from const target.
* mln/accu/convolve.hh: New.
* mln/accu/all.hh: Update.
(todo): New.
* mln/border/duplicate.hh: Fix.
* mln/extension/adjust_duplicate.hh: New.
* mln/linear/convolve.hh: Update.
mln/accu/all.hh | 7 +
mln/accu/convolve.hh | 148 +++++++++++++++++++++++++++++++++++++
mln/border/duplicate.hh | 140 ++++++++++++++++++++++-------------
mln/core/internal/image_morpher.hh | 16 +++-
mln/core/routine/primary.hh | 49 +++++++++++-
mln/extension/adjust_duplicate.hh | 112 ++++++++++++----------------
mln/linear/convolve.hh | 24 +++---
tests/border/duplicate.cc | 2
tests/core/routine/Makefile.am | 4 -
tests/core/routine/primary.cc | 46 +++++++++++
10 files changed, 420 insertions(+), 128 deletions(-)
Index: tests/core/routine/primary.cc
--- tests/core/routine/primary.cc (revision 0)
+++ tests/core/routine/primary.cc (revision 0)
@@ -0,0 +1,46 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/routine/primary.cc
+///
+/// Tests on mln::primary.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/sub_image.hh>
+#include <mln/core/routine/primary.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima(1, 1);
+ box2d b = ima.domain();
+
+ mln_assertion(primary((ima | b) | b).id_() == ima.id_());
+}
Index: tests/core/routine/Makefile.am
--- tests/core/routine/Makefile.am (revision 2774)
+++ tests/core/routine/Makefile.am (working copy)
@@ -6,11 +6,13 @@
clone \
exact \
extend \
- initialize
+ initialize \
+ primary
clone_SOURCES = clone.cc
exact_SOURCES = exact.cc
extend_SOURCES = extend.cc
initialize_SOURCES = initialize.cc
+primary_SOURCES = primary.cc
TESTS = $(check_PROGRAMS)
Index: tests/border/duplicate.cc
--- tests/border/duplicate.cc (revision 2774)
+++ tests/border/duplicate.cc (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -70,6 +71,5 @@
mln_assertion(ima.element(22) == 8);
mln_assertion(ima.element(23) == 9);
mln_assertion(ima.element(24) == 9);
-
}
Index: mln/core/routine/primary.hh
--- mln/core/routine/primary.hh (revision 2774)
+++ mln/core/routine/primary.hh (working copy)
@@ -42,9 +42,17 @@
namespace mln
{
+ // Forward declaration.
+ namespace internal
+ {
+ template <typename I> struct primary_type;
+ }
+
+
/// FIXME: Doc!
template <typename I>
- void primary(const Image<I>& ima);
+ const typename internal::primary_type<I>::ret&
+ primary(const Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
@@ -60,7 +68,8 @@
template <typename I, typename C>
struct primary_type_helper
{
- typedef typename primary_type<mln_delegatee(I)>::ret ret;
+ typedef typename I::delegatee D;
+ typedef typename primary_type<D>::ret ret;
};
template <typename I>
@@ -79,6 +88,37 @@
// Routine.
+ template <typename I>
+ const typename internal::primary_type<I>::ret&
+ primary_(const Image<I>& input); // Forward declaration.
+
+ template <typename I>
+ inline
+ const typename internal::primary_type<I>::ret&
+ primary_(trait::image::category::primary,
+ const Image<I>& input)
+ {
+ return exact(input);
+ }
+
+ template <typename I>
+ inline
+ const typename internal::primary_type<I>::ret&
+ primary_(trait::image::category::morpher,
+ const Image<I>& input)
+ {
+ return primary_(exact(input).unmorph_());
+ }
+
+ template <typename I>
+ inline
+ const typename internal::primary_type<I>::ret&
+ primary_(const Image<I>& input)
+ {
+ return primary_(mln_trait_image_category(I)(),
+ input);
+ }
+
} // end of namespace mln::internal
@@ -87,8 +127,11 @@
template <typename I>
inline
- void primary(const Image<I>&)
+ const typename internal::primary_type<I>::ret&
+ primary(const Image<I>& input)
{
+ mln_precondition(exact(input).has_data());
+ return internal::primary_(input);
}
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 2774)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -65,9 +65,12 @@
I* delegatee_();
- /// Give the morphed image.
+ /// Give the morphed image (mutable version).
I& unmorph_();
+ /// Give the morphed image (const version).
+ mlc_const(I)& unmorph_() const;
+
/* \brief Test if this image has been initialized; default impl.
*
@@ -154,6 +157,17 @@
template <typename I, typename T, typename S, typename E>
inline
+ mlc_const(I)&
+ image_morpher<I, T, S, E>::unmorph_() const
+ {
+ mlc_const(I)* ptr = delegatee_();
+ mln_assertion(ptr != 0);
+ return *ptr;
+ }
+
+
+ template <typename I, typename T, typename S, typename E>
+ inline
image_morpher<I, T, S, E>::operator I() const
{
mln_precondition(exact(this)->has_data());
Index: mln/linear/convolve.hh
--- mln/linear/convolve.hh (revision 2774)
+++ mln/linear/convolve.hh (working copy)
@@ -38,8 +38,8 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/weighted_window.hh>
-# include <mln/border/resize.hh>
-# include <mln/border/duplicate.hh>
+# include <mln/extension/adjust_duplicate.hh>
+# include <mln/accu/convolve.hh>
@@ -105,21 +105,23 @@
const W& w_win = exact(w_win_);
internal::convolve_tests(input, w_win);
- // extension::adjust_duplicate(input, w_win);
+ extension::adjust_duplicate(input, w_win);
typedef mln_concrete(I) O;
O output;
initialize(output, input);
+ accu::convolve<mln_value(I), mln_weight(W)> a;
+
mln_piter(I) p(input.domain());
mln_qiter(W) q(w_win, p);
for_all(p)
{
- mln_value(O) v = literal::zero;
+ a.init();
for_all(q) if (input.has(q))
- v += input(q) * q.w();
- output(p) = v;
+ a.take(input(q), q.w());
+ output(p) = a.to_result();
}
trace::exiting("linear::impl::generic::convolve");
@@ -140,23 +142,25 @@
const W& w_win = exact(w_win_);
internal::convolve_tests(input, w_win);
- // extension::adjust_duplicate(input, w_win);
+ extension::adjust_duplicate(input, w_win);
typedef mln_concrete(I) O;
O output;
initialize(output, input);
mln_pixter(O) p_out(output);
+ accu::convolve<mln_value(I), mln_weight(W)> a;
+
mln_pixter(const I) p(input);
mln_qixter(const I, W) q(p, w_win);
for_all_2(p, p_out)
{
- mln_value(O) v = literal::zero;
+ a.init();
unsigned i = 0;
for_all(q)
- v += w_win.w(i++) * q.val();
- p_out.val() = v;
+ a.take(q.val(), w_win.w(i++));
+ p_out.val() = a.to_result();
}
trace::exiting("linear::impl::convolve_fastest");
Index: mln/accu/all.hh
--- mln/accu/all.hh (revision 2774)
+++ mln/accu/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -35,6 +36,8 @@
* \todo Update accumulators s.a. count so that they are like min_/min.
*
* \todo Propagate those updates to mln/estim/.
+ *
+ * \todo Update the include list...
*/
@@ -46,6 +49,7 @@
{
/// Implementation namespace of accumulator namespace.
namespace impl {}
+
/// Internal namespace of accumulators.
namespace internal {}
}
@@ -55,6 +59,7 @@
# include <mln/accu/bbox.hh>
# include <mln/accu/count.hh>
+# include <mln/accu/convolve.hh>
# include <mln/accu/histo.hh>
# include <mln/accu/max.hh>
# include <mln/accu/mean.hh>
Index: mln/accu/convolve.hh
--- mln/accu/convolve.hh (revision 0)
+++ mln/accu/convolve.hh (revision 0)
@@ -0,0 +1,148 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ACCU_CONVOLVE_HH
+# define MLN_ACCU_CONVOLVE_HH
+
+/*! \file mln/accu/convolve.hh
+ *
+ * \brief Define an accumulator that computes a convolution.
+ */
+
+# include <mln/accu/internal/base.hh>
+# include <mln/value/ops.hh>
+# include <mln/literal/zero.hh>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /*! \brief Generic convolution accumulator class.
+ *
+ * Parameters \c T1 and \c T2 are the type of values to be
+ * convolved. Parameter \c R is the result type.
+ */
+ template <typename T1, typename T2,
+ typename R = mln_sum_x(T1, T2)>
+ struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >
+ {
+ typedef std::pair<T1,T2> argument;
+
+ convolve();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take(const argument& t);
+ void take(const T1& t1, const T2& t2);
+ void take(const convolve<T1,T2,R>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ R to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ typedef mln_sum_x(T1, T2) S;
+ S s_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T1, typename T2, typename R>
+ inline
+ convolve<T1,T2,R>::convolve()
+ {
+ init();
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ void
+ convolve<T1,T2,R>::init()
+ {
+ static S zero = literal::zero;
+ s_ = zero;
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ void
+ convolve<T1,T2,R>::take(const argument& t)
+ {
+ s_ += t.first * t.second;
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ void
+ convolve<T1,T2,R>::take(const T1& t1, const T2& t2)
+ {
+ s_ += t1 * t2;
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ void
+ convolve<T1,T2,R>::take(const convolve<T1,T2,R>& other)
+ {
+ s_ += other.s_;
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ R
+ convolve<T1,T2,R>::to_result() const
+ {
+ return s_;
+ }
+
+ template <typename T1, typename T2, typename R>
+ inline
+ bool
+ convolve<T1,T2,R>::is_valid() const
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_CONVOLVE_HH
Index: mln/border/duplicate.hh
--- mln/border/duplicate.hh (revision 2774)
+++ mln/border/duplicate.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -34,8 +35,9 @@
*/
# include <mln/core/concept/image.hh>
-# include <mln/level/memset_.hh>
-# include <mln/core/pixel.hh>
+# include <mln/core/routine/primary.hh>
+# include <mln/core/box_runstart_piter.hh>
+# include <mln/border/get.hh>
namespace mln
@@ -64,37 +66,37 @@
template <typename I>
inline
- void duplicate_1d_(const I& ima)
+ void duplicate_1D(I& ima)
{
- trace::entering("border::impl::duplicate_1d_");
+ trace::entering("border::impl::duplicate_1D");
typedef mln_psite(I) P;
- typename I::line_piter pl(ima.domain());
- unsigned len_c = exact(ima).bbox().len(P::dim - 1);
+ mln_box_runstart_piter(I) pl(ima.domain());
+ unsigned len_c = ima.bbox().len(P::dim - 1);
unsigned border = ima.border ();
for (unsigned i = 0; i < border; ++i)
- const_cast<I&>(ima)[i] = ima[border];
+ ima.element(i) = ima.element(border);
unsigned st = border + len_c - 1;
for (unsigned i = st + 1; i < ima.nelements (); ++i)
- const_cast<I&>(ima)[i] = ima[st];
+ ima.element(i) = ima.element(st);
- trace::exiting("border::impl::duplicate_1d_");
+ trace::exiting("border::impl::duplicate_1D");
}
template <typename I>
inline
- void duplicate_2d_(const I& ima)
+ void duplicate_2D(I& ima)
{
- trace::entering("border::impl::duplicate_2d_");
+ trace::entering("border::impl::duplicate_2D");
typedef mln_psite(I) P;
- typename I::line_piter pl(ima.domain());
+ mln_box_runstart_piter(I) pl(ima.domain());
unsigned border = ima.border ();
unsigned border_2x = 2 * ima.border ();
- unsigned len_c = exact(ima).bbox().len(1);
- unsigned len_r = exact(ima).bbox().len(0);
+ unsigned len_c = ima.bbox().len(1);
+ unsigned len_r = ima.bbox().len(0);
unsigned real_len_c = len_c + border_2x;
unsigned st;
@@ -103,43 +105,42 @@
{
st = ima.index_of_point (pl);
for (unsigned i = 1; i <= border; ++i)
- const_cast<I&>(ima)[st - i] = ima[st];
+ ima.element(st - i) = ima.element(st);
st = st + len_c - 1;
for (unsigned i = 1; i <= border; ++i)
- const_cast<I&>(ima)[st + i] = ima[st];
+ ima.element(st + i) = ima.element(st);
}
// Duplicate n first * border line
st = real_len_c * border;
for (unsigned k = 0; k < border; ++k)
for (unsigned i = 0; i < real_len_c; ++i)
- const_cast<I&>(ima)[k * real_len_c + i] = ima[st + i];
+ ima.element(k * real_len_c + i) = ima.element(st + i);
// Duplicate n last * border line
st = real_len_c * (border + len_r - 1);
for (unsigned k = 1; k <= border; ++k)
for (unsigned i = st; i < st + real_len_c; ++i)
- const_cast<I&>(ima)[k * real_len_c + i] = ima[i];
+ ima.element(k * real_len_c + i) = ima.element(i);
- trace::exiting("border::impl::duplicate_2d_");
+ trace::exiting("border::impl::duplicate_2D");
}
template <typename I>
inline
- void duplicate_3d_(const Image<I>& ima_)
+ void duplicate_3D(I& ima)
{
- trace::entering("border::impl::duplicate_3d_");
+ trace::entering("border::impl::duplicate_3D");
- const I& ima = exact(ima_);
mln_precondition(ima.has_data());
typedef mln_psite(I) P;
- typename I::line_piter pl(ima.domain());
+ mln_box_runstart_piter(I) pl(ima.domain());
unsigned border = ima.border ();
unsigned border_2x = 2 * ima.border ();
- unsigned len_c = exact(ima).bbox().len(P::dim - 1);
- unsigned len_r = exact(ima).bbox().len(1);
- unsigned len_s = exact(ima).bbox().len(0);
+ unsigned len_c = ima.bbox().len(P::dim - 1);
+ unsigned len_r = ima.bbox().len(1);
+ unsigned len_s = ima.bbox().len(0);
unsigned real_len_c = len_c + border_2x;
unsigned real_len_r = len_r + border_2x;
unsigned face = real_len_c * real_len_r;
@@ -155,10 +156,10 @@
{
st = ima.index_of_point (pl);
for (unsigned i = 1; i <= border; ++i)
- const_cast<I&>(ima)[st - i] = ima[st];
+ ima.element(st - i) = ima.element(st);
st = st + len_c - 1;
for (unsigned i = 1; i <= border; ++i)
- const_cast<I&>(ima)[st + i] = ima[st];
+ ima.element(st + i) = ima.element(st);
pl.next ();
}
@@ -166,57 +167,96 @@
st = border * face + k * face + border * real_len_c ;
for (unsigned j = 1; j <= border; ++j)
for (unsigned i = 0; i < real_len_c; ++i)
- const_cast<I&>(ima)[st - j * real_len_c + i] = ima[st + i];
+ ima.element(st - j * real_len_c + i) = ima.element(st + i);
// Duplicate n last * border line
st = border * face + k * face + (len_r + border - 1) * real_len_c ;
for (unsigned j = 1; j <= border; ++j)
for (unsigned i = 0; i < real_len_c; ++i)
- const_cast<I&>(ima)[st + j * real_len_c + i] = ima[st + i];
+ ima.element(st + j * real_len_c + i) = ima.element(st + i);
}
// Duplicate n first * border face
st = border * face;
for (unsigned k = 0; k < border; ++k)
for (unsigned i = 0; i < face; ++i)
- const_cast<I&>(ima)[k * face + i] = ima[st + i];
+ ima.element(k * face + i) = ima.element(st + i);
// Duplicate n last * border face
st = (len_s + border - 1) * face;
for (unsigned k = 1; k <= border; ++k)
for (unsigned i = 0; i < face; ++i)
- const_cast<I&>(ima)[st + k * face + i] = ima[st + i];
+ ima.element(st + k * face + i) = ima.element(st + i);
- trace::exiting("border::impl::duplicate_3d_");
+ trace::exiting("border::impl::duplicate_3D");
}
} // end of namespace mln::border::impl
- // Facade.
+ namespace internal
+ {
template <typename I>
- inline
- void duplicate(const Image<I>& ima_)
+ void duplicate_dispatch_on(metal::int_<1>, I& ima)
{
- trace::entering("border::duplicate");
+ impl::duplicate_1D(ima);
+ }
- const I& ima = exact(ima_);
- mln_precondition(ima.has_data());
+ template <typename I>
+ void duplicate_dispatch_on(metal::int_<2>, I& ima)
+ {
+ impl::duplicate_2D(ima);
+ }
- mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
+ template <typename I>
+ void duplicate_dispatch_on(metal::int_<3>, I& ima)
+ {
+ impl::duplicate_3D(ima);
+ }
- typedef mln_psite(I) P;
+ template <typename I>
+ void duplicate_dispatch_on(trait::image::speed::fastest,
+ const Image<I>& ima)
+ {
+ typedef mln_site(I) P;
+ duplicate_dispatch_on(metal::int_<P::dim>(),
+ const_cast<I&>(exact(ima)));
+ }
- if (!ima.border ())
- return;
+ template <typename I>
+ void duplicate_dispatch_on(trait::image::speed::any,
+ const Image<I>& ima)
+ {
+ // No-op.
+ }
+
+ template <typename I>
+ void duplicate_dispatch_on(const Image<I>& ima)
+ {
+ duplicate_dispatch_on(mln_trait_image_speed(I)(),
+ ima);
+ }
+
+ template <typename I>
+ void duplicate_dispatch(const Image<I>& ima)
+ {
+ duplicate_dispatch_on(primary(ima));
+ }
+
+ } // end of namespace mln::border::internal
+
+
+ // Facade.
+
+ template <typename I>
+ void duplicate(const Image<I>& ima)
+ {
+ trace::entering("border::duplicate");
+ mln_precondition(exact(ima).has_data());
- if (P::dim == 1)
- impl::duplicate_1d_(ima);
- if (P::dim == 2)
- impl::duplicate_2d_(ima);
- if (P::dim == 3)
- impl::duplicate_3d_(ima);
+ if (border::get(ima) != 0)
+ internal::duplicate_dispatch(ima);
trace::exiting("border::duplicate");
}
Index: mln/extension/adjust_duplicate.hh
--- mln/extension/adjust_duplicate.hh (revision 2769)
+++ mln/extension/adjust_duplicate.hh (working copy)
@@ -25,18 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_EXTENSION_ADJUST_FILL_HH
-# define MLN_CORE_EXTENSION_ADJUST_FILL_HH
+#ifndef MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH
+# define MLN_CORE_EXTENSION_ADJUST_DUPLICATE_HH
-/*! \file mln/extension/adjust_fill.hh
+/*! \file mln/extension/adjust_duplicate.hh
*
- * \brief Adjust then fill the domain extension.
+ * \brief Adjust the size of the domain extension then duplicate the
+ * image inner boundary.
*
* \todo Fix doc.
*/
# include <mln/border/adjust.hh>
-# include <mln/extension/fill.hh>
+# include <mln/border/duplicate.hh>
# include <mln/geom/delta.hh>
@@ -46,63 +47,56 @@
namespace extension
{
- /*! Fill the domain extension of image \p ima with the
- * single value \p v.
+ /*! Fill the domain extension of image \p ima by duplicating the
+ * image inner boundary.
*
* \param[in,out] ima The image whose domain extension is to be filled.
- * \param[in] val The value to assign.
*
* \pre \p ima has to be initialized.
- *
- * \todo Optimize with memset if possible.
*/
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Window<W>& win,
- const mln_value(I)& val);
+ void adjust_duplicate(const Image<I>& ima,
+ const Window<W>& win);
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Weighted_Window<W>& wwin,
- const mln_value(I)& val);
+ void adjust_duplicate(const Image<I>& ima,
+ const Weighted_Window<W>& wwin);
template <typename I, typename N>
- void adjust_fill(const Image<I>& ima,
- const Neighborhood<N>& nbh,
- const mln_value(I)& val);
+ void adjust_duplicate(const Image<I>& ima,
+ const Neighborhood<N>& nbh);
template <typename I>
- void adjust_fill(const Image<I>& ima,
- unsigned delta,
- const mln_value(I)& val);
+ void adjust_duplicate(const Image<I>& ima,
+ unsigned delta);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
- template <typename I, typename V>
- void do_adjust_fill(const I& ima,
- unsigned delta,
- const V& val)
+ template <typename I>
+ void do_adjust_duplicate(const I& ima,
+ unsigned delta)
{
mln_precondition(exact(ima).has_data());
// mln_precondition(exact(win_like).is_valid());
border::adjust(ima, delta);
- extension::fill(ima, val);
+ border::duplicate(ima);
}
- template <typename I, typename W, typename V>
- void do_adjust_fill(const I& ima,
- const W& win_like,
- const V& val)
+ template <typename I, typename W>
+ void do_adjust_duplicate(const I& ima,
+ const W& win_like)
{
mln_precondition(exact(ima).has_data());
// mln_precondition(exact(win_like).is_valid());
border::adjust(ima, geom::delta(win_like));
- extension::fill(ima, val);
+ border::duplicate(ima);
}
} // end of namespace mln::extension::impl
@@ -111,43 +105,39 @@
// Facades.
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Window<W>& win,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, win, val);
- trace::exiting("extension::adjust_fill");
+ void adjust_duplicate(const Image<I>& ima,
+ const Window<W>& win)
+ {
+ trace::entering("extension::adjust_duplicate");
+ impl::do_adjust_duplicate(ima, win);
+ trace::exiting("extension::adjust_duplicate");
}
template <typename I, typename W>
- void adjust_fill(const Image<I>& ima,
- const Weighted_Window<W>& wwin,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, wwin, val);
- trace::exiting("extension::adjust_fill");
+ void adjust_duplicate(const Image<I>& ima,
+ const Weighted_Window<W>& wwin)
+ {
+ trace::entering("extension::adjust_duplicate");
+ impl::do_adjust_duplicate(ima, wwin);
+ trace::exiting("extension::adjust_duplicate");
}
template <typename I, typename N>
- void adjust_fill(const Image<I>& ima,
- const Neighborhood<N>& nbh,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, nbh, val);
- trace::exiting("extension::adjust_fill");
+ void adjust_duplicate(const Image<I>& ima,
+ const Neighborhood<N>& nbh)
+ {
+ trace::entering("extension::adjust_duplicate");
+ impl::do_adjust_duplicate(ima, nbh);
+ trace::exiting("extension::adjust_duplicate");
}
template <typename I>
- void adjust_fill(const Image<I>& ima,
- unsigned delta,
- const mln_value(I)& val)
- {
- trace::entering("extension::adjust_fill");
- impl::do_adjust_fill(ima, delta, val);
- trace::exiting("extension::adjust_fill");
+ void adjust_duplicate(const Image<I>& ima,
+ unsigned delta)
+ {
+ trace::entering("extension::adjust_duplicate");
+ impl::do_adjust_duplicate(ima, delta);
+ trace::exiting("extension::adjust_duplicate");
}
@@ -158,4 +148,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_EXTENSION_FILL_HH
+#endif // ! MLN_CORE_EXTENSION_DUPLICATE_HH
Property changes on: mln/extension/adjust_duplicate.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
INIM: Add a README file.
* ballas/color/README: New.
README | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
Index: ballas/color/README
--- ballas/color/README (revision 0)
+++ ballas/color/README (revision 0)
@@ -0,0 +1,83 @@
+-*- outline -*-
+
+* Fichiers sources:
+
+Les fichiers sources se trouvent dans milena/sandbox/ballas/color/.
+
+** Les méthodes de références:
+
+*** reference.cc:
+ Utilisation de la seconde dérivée de gaussienne.
+ Les passages par 0 sont mis en rouges.
+
+*** reference2.cc:
+ Utilisation d'un gradient puis d'un filtre de clôture de volumes.
+
+ Variante testée (non retenue):
+ - un filtre de clôture d'aires.
+
+** min_tree:
+
+Les approches développées avec le min tree essayent de prendre en compte
+la couleur de l'image initial.
+
+Ici, on "expand" l'image pour pouvoir stocker les points et les edges directement
+sur l'image. Puis sur chaque edge, on stocke la distance séparant les deux
+pixels voisins cet edge. On construit ensuite un min tree sur ces edges.
+Ce min tree est ensuite filtrer afin d'éviter la sur-segmentation
+
+
+*** min_tree_area.cc:
+ Dans cette version, un filtre d'aire est appliqué aux edges constituant
+le min tree. Si l'aire des edges d'une région du min tree est inférieure à un
+lambda donné, on fusionne la région avec sa région supérieure.
+
+*** min_tree_volume.cc
+ Dans cette version, un filtre de volume est appliqué aux edges constituant
+le min tree.
+
+*** min_tree_color.cc
+ Dans cette version, on filtre en fonction de la couleur moyenne.
+Si la distance entre la couleur moyenne constituant 2 régions est inférieure
+à un lambda donné, on fusionne les régions.
+
+
+* Organisation des répertoires:
+
+Les images de tests se trouve dans le répertoire ~ballas/pub/result/
+
+Chaque sous-répertoire contient des tests sur une image en particulier
+Cette image est stockée dans le répertoire sous le nom input.ppm.
+
+Chaque sous-répertoire contiennent des répertoires avec les résultats
+en fonction des méthodes utilisées:
+- ref1 contient les résultats de la méthode reference.cc
+- ref2 contient les résultats de la méthode reference2.cc
+- area contient les résultats de la méthode min_tree_area.cc
+- volume contient les résultats de la méthode min_tree_volume.cc
+- color contient les résultats de la méthode min_tree_color.cc
+
+Les résultats sont organisés de la manière suivante dans les répertoires
+area, volume et color.
+** edge.pgm:
+ Image affichant les edges calculés avant le passage de min tree.
+ Ces edges contiennent la distance entre les deux pixels voisins.
+ Les pixels sont noir par défaut dans cette image.
+** edge.ppm:
+ Image affichant les edges calcules après l'application du filtre sur le
+ min tree.
+ Ces edges contiennent la distance entre les deux pixels voisins.
+ Les pixels sont noir par défaut dans cette image.
+** full.ppm:
+ Superposition de l'image edge.ppm et de l'image de départ.
+** colorize.ppm:
+ Image contenant les pixels coloriés à partir des edges de l'image.
+ On utilise une dilatation pour colorier les pixels, ce qui altère la
+ forme des lettres.
+
+Les résultats sont organisés de la manière suivante dans les répertoires
+ref1 et ref2.
+** lambda_x.ppm:
+ x est le lambda utilisé pour le filtre.
+ Dans ref1, nous avons une image avec les contours, alors que dans ref2,
+ nous une image découpée en zones.
1
0