https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix accu::histo_h and cleanup level::median.
* mln/level/median.hh (internal::median_tests): New.
(median_dir): Remove; useless, better replace by handling
win::line!
(impl::median): Rename as...
(impl::generic::median): ...this.
Update.
(impl::median_line): New.
(internal::mediant_dispatch): New.
(include): Update.
* mln/accu/transform_line.hh: New.
* mln/accu/all.hh: Update.
* tests/level/median_dir.cc: Remove.
There is no median_dir.hh file so having this test is dull!
* tests/level/median_hline2d.cc: Likewise.
* tests/level/median.cc: Merge tests from removed files.
* tests/level/Makefile.am: Update.
* mln/accu/histo.hh (init): Fix.
Forgetting to set sum_ to 0 leads to errors in median
filtering...
* mln/accu/median_h.hh: Upgrade file doc style.
* mln/canvas/browsing/dir_struct_elt_incr_update.hh:
Add some debug information; I think that this code is bugged...
* tests/accu/transform_snake.cc,
* tests/accu/transform_diagonal.cc,
* tests/accu/transform_directional.cc
(ref): Remove unused object.
* tests/accu/median_h.cc: Upgrade file doc style.
* tests/accu/transform_line.cc: New.
* tests/accu/Makefile.am: Update.
mln/accu/all.hh | 1
mln/accu/histo.hh | 6
mln/accu/median_h.hh | 3
mln/accu/transform_line.hh | 245 ++++++++++++++++++++++
mln/canvas/browsing/dir_struct_elt_incr_update.hh | 19 +
mln/level/median.hh | 198 +++++++----------
tests/accu/Makefile.am | 2
tests/accu/median_h.cc | 12 -
tests/accu/transform_diagonal.cc | 8
tests/accu/transform_directional.cc | 4
tests/accu/transform_line.cc | 51 ++++
tests/accu/transform_snake.cc | 5
tests/level/Makefile.am | 4
tests/level/median.cc | 31 +-
14 files changed, 436 insertions(+), 153 deletions(-)
Index: mln/level/median.hh
--- mln/level/median.hh (revision 3139)
+++ mln/level/median.hh (working copy)
@@ -41,10 +41,11 @@
# include <mln/win/shift.hh>
# include <mln/win/diff.hh>
+# include <mln/win/line.hh>
# include <mln/canvas/browsing/snake_fwd.hh>
-# include <mln/canvas/browsing/dir_struct_elt_incr_update.hh>
# include <mln/accu/median_h.hh>
+# include <mln/accu/transform_line.hh>
namespace mln
@@ -62,36 +63,33 @@
*
* \pre \p input and \p output have to be initialized.
*/
- template <typename I, typename W, typename O>
- void median(const Image<I>& input, const Window<W>& win,
- Image<O>& output);
+ template <typename I, typename W>
+ mln_concrete(I)
+ median(const Image<I>& input, const Window<W>& win);
- /*! Compute in \p output the median filter of image \p input in
- * the direction \p dir with strength \p length.
- *
- * \param[in] input The image to be filtered.
- * \param[in] dir The filtering direction.
- * \param[in] length The filtering strength.
- * \param[out] output The output image.
- *
- * \pre \p input and \p output have to be initialized.
- * \pre \p dir is between 0 and less than the image dimension.
- * \pre \p length has to be odd.
- */
- template <typename I, typename O>
- void median_dir(const Image<I>& input, unsigned dir, unsigned length,
- Image<O>& output);
+# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+ template <typename I, typename W>
+ void
+ median_tests(const Image<I>& input, const Window<W>& win)
+ {
+ mln_precondition(exact(input).is_valid());
+ // mln_precondition(exact(win).is_valid());
+ (void) input;
+ (void) win;
+ }
+
+ } // end of namespace level::internal
-# ifndef MLN_INCLUDE_ONLY
namespace impl
{
-
// Functors.
@@ -184,140 +182,108 @@
- template <typename I_, typename O>
- struct median_dir_t
+ namespace generic
{
- typedef I_ I;
- enum { dim = I::site::dim };
- // i/o
- const I& input;
- const unsigned dir;
- const unsigned length;
- O& output;
-
- // aux data
- mln_psite(I) p;
- accu::median_h<mln_value(I)> med;
-
- // ctor
+ template <typename I, typename W>
inline
- median_dir_t(const I& input, unsigned dir, unsigned length, O& output)
- : // i/o
- input(input),
- dir(dir),
- length(length),
- output(exact(output)),
- // aux data
- p(),
- med()
+ mln_concrete(I)
+ median(const Image<I>& input, const Window<W>& win)
{
- }
+ trace::entering("level::impl::generic::median");
- inline
- void init()
- {
- }
+ mlc_equal(mln_trait_image_quant(I),
+ trait::image::quant::low)::check();
+ internal::median_tests(input, win);
- inline
- void init_line()
- {
- med.init();
- }
+ extension::adjust(input, win);
- inline
- void add_point(mln_psite(I) pt)
- {
- med.take(input(pt));
- }
+ typedef mln_concrete(I) O;
+ O output;
+ initialize(output, input);
+ median_t<I,W,O> f(exact(input), exact(win), output);
+ canvas::browsing::snake_fwd(f);
- inline
- void remove_point(mln_psite(I) pu)
- {
- med.untake(input(pu));
+ trace::exiting("level::impl::generic::median");
+ return output;
}
- inline
- void next()
- {
- if (output.has(p))
- output(p) = med.to_result();
- }
+ } // end of namespace mln::level::impl::generic
+
+ template <typename I,
+ typename M, unsigned i, typename C>
inline
- void final()
+ mln_concrete(I)
+ median_line(const Image<I>& input, const win::line<M,i,C>&
win)
{
+ trace::entering("level::impl::median_line");
+
+ mlc_equal(mln_trait_image_quant(I),
+ trait::image::quant::low)::check();
+ internal::median_tests(input, win);
+
+ accu::median_h<mln_value(I)> a;
+ mln_concrete(I) output = accu::transform_line(a, input, win.length(), i);
+
+ trace::exiting("level::impl::median_line");
+ return output;
}
- }; // end of median_dir_t
+
+ } // end of namespace mln::level::impl
- template <typename I, typename O>
+ namespace internal
+ {
+
+ template <typename I, typename W>
inline
- void median_dir_(const Image<I>& input, unsigned dir, unsigned length,
O& output)
+ mln_concrete(I)
+ median_dispatch_wrt_win(const Image<I>& input, const Window<W>&
win)
{
- median_dir_t<I,O> f(exact(input), dir, length, output);
- canvas::browsing::dir_struct_elt_incr_update(f);
+ return impl::generic::median(input, win);
}
-
- template <typename I, typename W, typename O>
+ template <typename I,
+ typename M, unsigned i, typename C>
inline
- void median_(const Image<I>& input, const Window<W>& win,
O& output)
+ mln_concrete(I)
+ median_dispatch_wrt_win(const Image<I>& input, const
win::line<M,i,C>& win)
{
- // FIXME: resize border!
- median_t<I,W,O> f(exact(input), exact(win), output);
- canvas::browsing::snake_fwd(f);
+ return impl::median_line(input, win);
}
-# ifdef MLN_CORE_WIN_LINE_HH
- template <typename I, typename M, unsigned i, typename C, typename O>
+ template <typename I, typename W>
inline
- void median_(const Image<I>& input, const win::line<M,i,C>&
win, O& output)
+ mln_concrete(I)
+ median_dispatch(const Image<I>& input, const Window<W>& win)
{
- median_dir(input, i, win.length(), output); // FIXME: Make 1 explicit!
+ return median_dispatch_wrt_win(input, exact(win));
}
-# endif // ! MLN_CORE_WIN_LINE_HH
-
- } // end of namespace mln::level::impl
+ } // end of namespace level::internal
- // Facades.
+ // Facade.
- template <typename I, typename W, typename O>
- void median(const Image<I>& input, const Window<W>& win,
- Image<O>& output)
+ template <typename I, typename W>
+ mln_concrete(I)
+ median(const Image<I>& input, const Window<W>& win)
{
trace::entering("level::median");
- mln_assertion(exact(output).domain() == exact(input).domain());
- impl::median_(exact(input), exact(win), exact(output));
-
- trace::exiting("level::median");
- }
-
- template <typename I, typename O>
- void median_dir(const Image<I>& input, unsigned dir, unsigned length,
- Image<O>& output)
- {
- trace::entering("level::median_dir");
-
- mlc_is(mln_trait_image_value_io(O), trait::image::value_io::read_write)::check();
- mlc_is(mln_trait_image_localization(I),
- trait::image::localization::basic_grid)::check();
- mlc_converts_to(mln_value(I), mln_value(O))::check();
-
- mln_precondition(exact(output).domain() == exact(input).domain());
- typedef mln_psite(I) P;
- mln_precondition(dir < P::dim);
- mln_precondition(length % 2 == 1);
+ mlc_equal(mln_trait_image_quant(I),
+ trait::image::quant::low)::check();
- impl::median_dir_(exact(input), dir, length, exact(output));
+ internal::median_tests(input, win);
+ mln_concrete(I) output;
+ output = internal::median_dispatch(input, win);
- trace::exiting("level::median_dir");
+ trace::exiting("level::median");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/transform_line.hh
--- mln/accu/transform_line.hh (revision 0)
+++ mln/accu/transform_line.hh (revision 0)
@@ -0,0 +1,245 @@
+// 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_TRANSFORM_LINE_HH
+# define MLN_ACCU_TRANSFORM_LINE_HH
+
+/// \file mln/accu/transform_line.hh
+///
+/// Run an accumulator over a line (in a particular direction).
+///
+/// \todo Import code from sandox/geraud/browsing/fwd.cc to handle the
+/// case of no-domain-extension.
+///
+/// \todo Specialize for fastest images.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/extension/adjust.hh>
+
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ template <typename A, typename I>
+ mln_ch_value(I, mln_result(A))
+ transform_line(const Accumulator<A>& a,
+ const Image<I>& input,
+ unsigned length, unsigned dir);
+
+ template <typename A, typename I>
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform_line(const Meta_Accumulator<A>& a,
+ const Image<I>& input,
+ unsigned length, unsigned dir);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename A, typename I>
+ void transform_line_tests(const Accumulator<A>& a_, const
Image<I>& input_)
+ {
+ A a = exact(a_);
+ const I& input = exact(input_);
+
+ mln_precondition(input.is_valid());
+ mln_psite(I)* p;
+ mln_precondition(sizeof(a.take(input(*p)), 0) == sizeof(int));
+
+ (void) p;
+ (void) a;
+ (void) input;
+ }
+
+ } // end of namespace mln::accu::internal
+
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_line(const Accumulator<A>& a_,
+ const Image<I>& input_,
+ unsigned length, unsigned dir)
+ {
+ trace::entering("accu::impl::transform_line");
+
+ const I& input = exact(input_);
+ A a = exact(a_);
+
+ internal::transform_line_tests(a, input);
+
+ mln_ch_value(I, mln_result(A)) output;
+ initialize(output, input);
+
+ typedef mln_psite(I) P;
+ const P
+ pmin = input.domain().pmin(),
+ pmax = input.domain().pmax();
+ const def::coord
+ pmax_dir = pmax[dir],
+ pmin_dir = pmin[dir];
+
+ P p = pmin, // Starting point.
+ qt, qu;
+ def::coord& p_dir = p [dir];
+ def::coord& qt_dir = qt[dir];
+ def::coord& qu_dir = qu[dir];
+
+ do
+ {
+
+ // Start the run.
+ // ---------------
+
+ qt = p;
+ qt_dir = p_dir - length / 2;
+ qu = qt;
+ a.init();
+
+ for (unsigned i = 0; i < length; ++i)
+ {
+ if (input.has(qt))
+ a.take(input(qt));
+ qt_dir++;
+ }
+ if (input.has(p))
+ output(p) = a.to_result();
+
+ // Browse the run.
+ // ---------------
+
+ while (p_dir < pmax_dir)
+ {
+ ++p_dir;
+ if (input.has(qt))
+ a.take(input(qt));
+ if (input.has(qu))
+ a.untake(input(qu));
+ if (input.has(p))
+ output(p) = a.to_result();
+ qt_dir++;
+ qu_dir++;
+ }
+
+ p_dir = pmin_dir;
+
+
+ // Go to the next run.
+ // -------------------
+
+ for (int c = P::dim - 1; c >= 0; --c)
+ {
+ if (c == int(dir))
+ continue;
+ if (p[c] != pmax[c])
+ {
+ ++p[c];
+ break;
+ }
+ p[c] = pmin[c];
+ }
+
+ } while (p != pmin);
+
+ trace::exiting("accu::impl::transform_line");
+ return output;
+ }
+
+ } // end of namespace mln::accu::impl::generic
+
+ } // end of namespace mln::accu::impl
+
+
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_result(A))
+ transform_line(const Accumulator<A>& a,
+ const Image<I>& input,
+ unsigned length, unsigned dir)
+ {
+ trace::entering("accu::transform_line");
+
+ internal::transform_line_tests(a, input);
+
+ extension::adjust(input, length);
+ mln_ch_value(I, mln_result(A)) output;
+ output = impl::generic::transform_line(a, input, length, dir);
+
+ trace::exiting("accu::transform_line");
+ return output;
+ }
+
+
+ template <typename A, typename I>
+ inline
+ mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
+ transform_line(const Meta_Accumulator<A>& a,
+ const Image<I>& input,
+ unsigned length, unsigned dir)
+ {
+ trace::entering("accu::transform_line");
+
+ typedef mln_accu_with(A, mln_value(I)) A_;
+ A_ a_ = accu::unmeta(exact(a), mln_value(I)());
+
+ internal::transform_line_tests(a_, input);
+
+ extension::adjust(input, length);
+ mln_ch_value(I, mln_result(A_)) output;
+ output = impl::generic::transform_line(a_, input, length, dir);
+
+ trace::exiting("accu::transform_line");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_TRANSFORM_LINE_HH
Index: mln/accu/all.hh
--- mln/accu/all.hh (revision 3139)
+++ mln/accu/all.hh (working copy)
@@ -89,6 +89,7 @@
# include <mln/accu/transform_directional.hh>
# include <mln/accu/transform_diagonal.hh>
+# include <mln/accu/transform_line.hh>
# include <mln/accu/transform_snake.hh>
Index: mln/accu/histo.hh
--- mln/accu/histo.hh (revision 3139)
+++ mln/accu/histo.hh (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
@@ -34,7 +35,6 @@
///
/// \todo Use histo::data instead of std::vector!
-
# include <vector>
# include <algorithm>
@@ -44,6 +44,7 @@
# include <mln/value/set.hh>
# include <mln/histo/data.hh>
+
namespace mln
{
@@ -161,6 +162,7 @@
histo<V>::init()
{
h_.clear();
+ sum_ = 0;
}
template <typename V>
Index: mln/accu/median_h.hh
--- mln/accu/median_h.hh (revision 3139)
+++ mln/accu/median_h.hh (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
Index: mln/canvas/browsing/dir_struct_elt_incr_update.hh
--- mln/canvas/browsing/dir_struct_elt_incr_update.hh (revision 3139)
+++ mln/canvas/browsing/dir_struct_elt_incr_update.hh (working copy)
@@ -137,34 +137,53 @@
f.init_line();
// initialization (before first point of the line)
+ std::cout << "init" << std::endl;
for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
if (f.input.has(pt))
+ {
+ std::cout << '+' << pt << ' ';
f.add_point(pt);
+ }
// left columns (just take new points)
+ std::cout << "left" << std::endl;
for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
{
if (f.input.has(pt))
+ {
+ std::cout << '+' << pt << ' ';
f.add_point(pt);
+ }
f.next();
}
// middle columns (both take and untake)
+ std::cout << "middle" << std::endl;
cu = pmin_dir;
for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
{
if (f.input.has(pt))
+ {
+ std::cout << '+' << pt << ' ';
f.add_point(pt);
+ }
if (f.input.has(pu))
+ {
+ std::cout << '-' << pu << ' ';
f.remove_point(pu);
+ }
f.next();
}
// right columns (now just untake old points)
+ std::cout << "right" << std::endl;
for (; p_dir <= pmax_dir; ++cu, ++p_dir)
{
if (f.input.has(pu))
+ {
+ std::cout << '-' << pu << ' ';
f.remove_point(pu);
+ }
f.next();
}
Index: tests/level/median.cc
--- tests/level/median.cc (revision 3139)
+++ tests/level/median.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
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/median.cc
- *
- * \brief Test on mln::level::median.
- */
+/// \file tests/level/median.cc
+///
+/// Test on mln::level::median.
#include <mln/core/image/image2d.hh>
#include <mln/win/rectangle2d.hh>
@@ -47,13 +47,20 @@
using namespace mln;
using value::int_u8;
- win::rectangle2d rect(5, 5);
- border::thickness = 6;
-
image2d<int_u8> lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<int_u8> out(lena.domain());
-
- level::median(lena, rect, out);
- io::pgm::save(out, "out.pgm");
+ {
+ win::rectangle2d rect(51, 51);
+ image2d<int_u8> out = level::median(lena, rect);
+ io::pgm::save(out, "out_rect.pgm");
+ }
+ {
+ win::rectangle2d rect(1, 51);
+ win::hline2d line(51);
+ image2d<int_u8>
+ ref = level::median(lena, rect),
+ out = level::median(lena, line);
+ mln_assertion(out == ref);
+ io::pgm::save(out, "out_line.pgm");
+ }
}
Index: tests/level/Makefile.am
--- tests/level/Makefile.am (revision 3139)
+++ tests/level/Makefile.am (working copy)
@@ -13,9 +13,7 @@
convert \
median \
median_ \
- median_dir \
median_fast \
- median_hline2d \
saturate \
sort_psites \
stretch \
@@ -31,9 +29,7 @@
convert_SOURCES = convert.cc
median_SOURCES = median.cc
median__SOURCES = median_.cc
-median_dir_SOURCES = median_dir.cc
median_fast_SOURCES = median_fast.cc
-median_hline2d_SOURCES = median_hline2d.cc
saturate_SOURCES = saturate.cc
sort_psites_SOURCES = sort_psites.cc
stretch_SOURCES = stretch.cc
Index: tests/accu/transform_snake.cc
--- tests/accu/transform_snake.cc (revision 3139)
+++ tests/accu/transform_snake.cc (working copy)
@@ -44,9 +44,6 @@
image2d<int> ima(4, 5);
win::rectangle2d rec(3, 3);
- image2d<unsigned>
- out = accu::transform_snake(accu::meta::count(), ima, rec),
- ref(ima.domain());
-
+ image2d<unsigned> out = accu::transform_snake(accu::meta::count(), ima, rec);
mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
}
Index: tests/accu/median_h.cc
--- tests/accu/median_h.cc (revision 3139)
+++ tests/accu/median_h.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
@@ -25,16 +26,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/accu/median_h.cc
- *
- * \brief Tests on mln::accu::median_h.
- */
+/// \file tests/accu/median_h.cc
+///
+/// Tests on mln::accu::median_h.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/accu/median_h.hh>
+
int main()
{
using namespace mln;
@@ -66,4 +67,5 @@
mln_assertion(med.to_result() == 7u);
}
+
}
Index: tests/accu/transform_diagonal.cc
--- tests/accu/transform_diagonal.cc (revision 3139)
+++ tests/accu/transform_diagonal.cc (working copy)
@@ -44,17 +44,13 @@
{
win::diag2d w(3);
- image2d<unsigned>
- out = accu::transform_diagonal(accu::meta::count(), ima, w),
- ref(ima.domain());
+ image2d<unsigned> out = accu::transform_diagonal(accu::meta::count(), ima, w);
mln_assertion(out == (pw::cst(w.size()) | ima.domain()));
}
{
win::backdiag2d w(3);
- image2d<unsigned>
- out = accu::transform_diagonal(accu::meta::count(), ima, w),
- ref(ima.domain());
+ image2d<unsigned> out = accu::transform_diagonal(accu::meta::count(), ima, w);
mln_assertion(out == (pw::cst(w.size()) | ima.domain()));
}
Index: tests/accu/transform_line.cc
--- tests/accu/transform_line.cc (revision 0)
+++ tests/accu/transform_line.cc (revision 0)
@@ -0,0 +1,51 @@
+// 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/accu/transform_line.cc
+///
+/// Tests on mln::accu::transform_line.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/accu/transform_line.hh>
+#include <mln/accu/count.hh>
+#include <mln/pw/all.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<unsigned> ima(4, 5);
+ unsigned len = 3;
+ for (unsigned dir = 0; dir < 2; ++dir)
+ {
+ image2d<unsigned> out = accu::transform_line(accu::meta::count(), ima, len,
dir);
+ mln_assertion(out == (pw::cst(3) | ima.domain()));
+ }
+
+}
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 3139)
+++ tests/accu/Makefile.am (working copy)
@@ -22,6 +22,7 @@
transform \
transform_diagonal \
transform_directional \
+ transform_line \
transform_snake \
tuple
@@ -44,6 +45,7 @@
transform_SOURCES = transform.cc
transform_diagonal_SOURCES = transform_diagonal.cc
transform_directional_SOURCES = transform_directional.cc
+transform_line_SOURCES = transform_line.cc
transform_snake_SOURCES = transform_snake.cc
tuple_SOURCES = tuple.cc
Index: tests/accu/transform_directional.cc
--- tests/accu/transform_directional.cc (revision 3139)
+++ tests/accu/transform_directional.cc (working copy)
@@ -46,9 +46,7 @@
for (unsigned dir = 0; dir < 2; ++dir)
{
- image2d<unsigned>
- out = accu::transform_directional(accu::meta::count(), ima, rec, dir),
- ref(ima.domain());
+ image2d<unsigned> out = accu::transform_directional(accu::meta::count(), ima,
rec, dir);
mln_assertion(out == (pw::cst(rec.size()) | ima.domain()));
}
}