milena r3443: Add take_as_init specialization to compute_attribute_image

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-02-28 Edwin Carlinet <carlinet@lrde.epita.fr> Add take_as_init specialization to compute_attribute_image. * mln/canvas/morpho/attribute_filter.hh, * mln/morpho/tree/compute_attribute_image.hh Add take_as_init specialization. * tests/canvas/morpho/Makefile.am, * tests/morpho/Makefile.am: Correct Makefile rules. * tests/morpho/tree/compute_attribute_image.cc: Test file for compute_attribute_image. --- mln/canvas/morpho/attribute_filter.hh | 5 +-- mln/morpho/tree/compute_attribute_image.hh | 41 ++++++++++++++++++++++++++- tests/canvas/morpho/Makefile.am | 4 +- tests/morpho/Makefile.am | 12 ------- tests/morpho/tree/compute_attribute_image.cc | 10 ++---- 5 files changed, 49 insertions(+), 23 deletions(-) Index: trunk/milena/tests/morpho/tree/compute_attribute_image.cc =================================================================== --- trunk/milena/tests/morpho/tree/compute_attribute_image.cc (revision 3442) +++ trunk/milena/tests/morpho/tree/compute_attribute_image.cc (revision 3443) @@ -40,8 +40,8 @@ #include <mln/morpho/tree/data.hh> #include <mln/morpho/tree/compute_attribute_image.hh> -#include <mln/accu/count.hh> -#include <mln/accu/volume.hh> +#include <mln/morpho/attribute/card.hh> +#include <mln/morpho/attribute/volume.hh> int main() @@ -63,16 +63,14 @@ morpho::tree::data<I,S> t(f, s, c4()); debug::println(t.parent_image()); - typedef util::pix<I> Px; - { - accu::count<Px> a; + morpho::attribute::card<I> a; image2d<unsigned> area = morpho::tree::compute_attribute_image(a, t); debug::println(area); } { - accu::volume<I> v; + morpho::attribute::volume<I> v; image2d<unsigned> volume = morpho::tree::compute_attribute_image(v, t); debug::println(volume); } Index: trunk/milena/tests/morpho/Makefile.am =================================================================== --- trunk/milena/tests/morpho/Makefile.am (revision 3442) +++ trunk/milena/tests/morpho/Makefile.am (revision 3443) @@ -10,10 +10,6 @@ check_PROGRAMS = \ artificial_line_graph_image_wst \ - closing_algebraic \ - closing_area \ - closing_height \ - closing_volume \ combined \ complex_image_morpho \ complex_image_wst \ @@ -46,14 +42,6 @@ # FIXME: Have erosion and dilation perform symmetric tests. erosion_SOURCES = erosion.cc -opening_area_SOURCES = opening_area.cc -closing_algebraic_SOURCES = closing_algebraic.cc -closing_area_SOURCES = closing_area.cc -closing_height_SOURCES = closing_height.cc -opening_height_SOURCES = opening_height.cc -closing_volume_SOURCES = closing_volume.cc -opening_volume_SOURCES = opening_volume.cc - contrast_SOURCES = contrast.cc general_SOURCES = general.cc gradient_SOURCES = gradient.cc Index: trunk/milena/tests/canvas/morpho/Makefile.am =================================================================== --- trunk/milena/tests/canvas/morpho/Makefile.am (revision 3442) +++ trunk/milena/tests/canvas/morpho/Makefile.am (revision 3443) @@ -2,6 +2,6 @@ include $(top_srcdir)/milena/tests/tests.mk -check_PROGRAMS=connected_filter +check_PROGRAMS=attribute_filter -connected_filter_SOURCES=connected_filter.cc +attribute_filter_SOURCES=attribute_filter.cc Index: trunk/milena/mln/morpho/tree/compute_attribute_image.hh =================================================================== --- trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3442) +++ trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3443) @@ -72,6 +72,45 @@ # ifndef MLN_INCLUDE_ONLY + // Take_as_init specialization + + + template <typename A, typename I, typename P> + void take_as_init (trait::accumulator::when_pix::use_none, A& accu, + const I& input, const P& p) + { + (void)input; + (void)p; + accu.take_as_init(); + } + + template <typename A, typename I, typename P> + void take_as_init (trait::accumulator::when_pix::use_pix, A& accu, + const I& input, const P& p) + { + accu.take_as_init(make::pix(input, p)); + } + + template <typename A, typename I, typename P> + void take_as_init (trait::accumulator::when_pix::use_v, A& accu, + const I& input, const P& p) + { + accu.take_as_init(input(p)); + } + + template <typename A, typename I, typename P> + void take_as_init (trait::accumulator::when_pix::use_p, A& accu, + const I& input, const P& p) + { + accu.take_as_init(p); + } + + + template <typename A, typename I, typename P> + void take_as_init (A& accu, const I& input, const P& p) + { + take_as_init (mln_trait_accumulator_when_pix(A)(), accu, input, p); + } // Facade. @@ -99,7 +138,7 @@ // Initialize every attribute with the corresponding pixel. mln_piter(I) p(t.f().domain()); for_all(p) - acc(p).take_as_init(make::pix(t.f(), p)); + take_as_init(acc(p), t.f(), p); } { mln_fwd_piter(T) p(t.domain()); Index: trunk/milena/mln/canvas/morpho/attribute_filter.hh =================================================================== --- trunk/milena/mln/canvas/morpho/attribute_filter.hh (revision 3442) +++ trunk/milena/mln/canvas/morpho/attribute_filter.hh (revision 3443) @@ -87,7 +87,8 @@ const I& input, const P& p) { (void)input; - accu.take_as_init (p); + (void)p; + accu.take_as_init (); } template <typename A, typename I, typename P> @@ -101,7 +102,7 @@ void take_as_init (trait::accumulator::when_pix::use_v, A& accu, const I& input, const P& p) { - accu.take_as_init (make::pix(input, p)); + accu.take_as_init (input(p)); } template <typename A, typename I>
participants (1)
-
Edwin Carlinet