https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Update median"".
* tests/level/median_.cc: New.
* mln/level/median.hh: .
* mln/win/rectangle2d.hh: .
mln/level/median.hh | 15 ++++++------
mln/win/rectangle2d.hh | 9 ++++---
tests/level/median_.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 10 deletions(-)
Index: tests/level/median_.cc
--- tests/level/median_.cc (revision 0)
+++ tests/level/median_.cc (revision 0)
@@ -0,0 +1,59 @@
+// 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/level/median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ 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::impl::median_(lena, rect, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: mln/level/median.hh
--- mln/level/median.hh (revision 2346)
+++ mln/level/median.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -98,7 +98,7 @@
struct median_t
{
typedef mln_psite(I) P;
- typedef mln_dpsite(I) D;
+ typedef mln_dpsite(P) D;
// i/o
@@ -108,10 +108,10 @@
// aux data
- accu::median_h<mln_vset(I)> med;
+ accu::median_h<mln_value(I)> med;
P p;
window<D> win_fp, win_fm, win_bp, win_bm, win_dp, win_dm;
- mln_qiter(W) q_fp, q_fm, q_bp, q_bm, q_dp, q_dm;
+ mln_qiter(window<D>) q_fp, q_fm, q_bp, q_bm, q_dp, q_dm;
// ctor
@@ -123,7 +123,7 @@
win(exact(win_)),
output(exact(output_)),
// aux data
- med(input.values_eligible()),
+ med(),
p(),
win_fp(set::diff(win, geom::shift(win, left))),
win_fm(set::diff(geom::shift(win, left), win)),
@@ -196,7 +196,7 @@
// aux data
mln_psite(I) p;
- accu::median_h<mln_vset(I)> med;
+ accu::median_h<mln_value(I)> med;
// ctor
inline
@@ -304,7 +304,8 @@
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_support(I), trait::image::support::aligned)::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());
Index: mln/win/rectangle2d.hh
--- mln/win/rectangle2d.hh (revision 2346)
+++ mln/win/rectangle2d.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/internal/window_base.hh>
# include <mln/core/internal/dpoints_base.hh>
# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/def/coord.hh>
namespace mln
@@ -131,9 +132,11 @@
width_(width)
{
mln_precondition(height % 2 == 1 && width % 2 == 1);
- const int drow = height / 2, dcol = width / 2;
- for (int row = - drow; row <= drow; ++row)
- for (int col = - dcol; col <= dcol; ++col)
+ const def::coord drow = (def::coord) (height / 2);
+ const def::coord dcol = (def::coord) (width / 2);
+
+ for (def::coord row = (def::coord) -drow; row <= drow; ++row)
+ for (def::coord col = (def::coord) -dcol; col <= dcol; ++col)
this->insert(dpoint2d(row, col));
}