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
December 2007
- 11 participants
- 54 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add tests for mln/accu.
* tests/accu/bbox.cc: New.
* tests/accu/compute.cc: New.
* tests/accu/count.cc: New.
* tests/accu/histo.cc: New.
* tests/accu/max.cc: New.
* tests/accu/max_h.cc: New.
* tests/accu/mean.cc: New.
* tests/accu/median.cc: New.
* tests/accu/min_h.cc: New.
* tests/accu/min_max.cc: New.
* tests/accu/pair.cc: New.
---
bbox.cc | 50 +++++++++++++++++++++++++++++++++++++++++++
compute.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++
count.cc | 54 +++++++++++++++++++++++++++++++++++++++++++++++
histo.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
max.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
max_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
mean.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
median.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
min_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
min_max.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pair.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 691 insertions(+)
Index: trunk/milena/tests/accu/pair.cc
===================================================================
--- trunk/milena/tests/accu/pair.cc (revision 0)
+++ trunk/milena/tests/accu/pair.cc (revision 1580)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 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
+// 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/mean.cc
+ *
+ * \brief Tests on mln::accu::mean.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/mean.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::pair_<accu::mean<int>, accu::max<int> > mean;
+
+ mean.take(10);
+ mean.take(9);
+ mean.take(8);
+ mean.take(7);
+ mean.take(6);
+ mean.take(5);
+ mean.take(4);
+ mean.take(3);
+ mean.take(2);
+ mean.take(1);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 5);
+ }
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(8);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 6);
+ }
+}
Index: trunk/milena/tests/accu/compute.cc
===================================================================
--- trunk/milena/tests/accu/compute.cc (revision 0)
+++ trunk/milena/tests/accu/compute.cc (revision 1580)
@@ -0,0 +1,55 @@
+// Copyright (C) 2007 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
+// 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/compute.cc
+ *
+ * \brief Tests on mln::accu::compute.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/compute.hh>
+#include <mln/level/compute.hh>
+
+#include <mln/accu/min.hh>
+
+int main()
+{
+ using namespace mln;
+ using typename value::int_u8;
+
+ // FIXME : make this test compile
+// int_u8 vs[3][3] = { {9,8,7},
+// {6,5,4},
+// {3,2,1} };
+
+// image2d<int_u8> ima = make::image2d(vs);
+// int a = accu::compute<accu::min>(ima);
+
+// std::cout << a << std::endl;
+}
Index: trunk/milena/tests/accu/max_h.cc
===================================================================
--- trunk/milena/tests/accu/max_h.cc (revision 0)
+++ trunk/milena/tests/accu/max_h.cc (revision 1580)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 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
+// 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/max_h.cc
+ *
+ * \brief Tests on mln::accu::max_h.
+ */
+
+#include <mln/value/int_u8.hh>
+#include <mln/accu/max_h.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::max_h< set<int_u8> > a;
+
+ a.take(1);
+ a.take(1);
+ a.take(1);
+
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ mln_assertion(a.to_result() == 234);
+}
Index: trunk/milena/tests/accu/median.cc
===================================================================
--- trunk/milena/tests/accu/median.cc (revision 0)
+++ trunk/milena/tests/accu/median.cc (revision 1580)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 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
+// 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/median.cc
+ *
+ * \brief Tests on mln::accu::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/median.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::median< value::set<value::int_u8> > med;
+
+ med.take(10);
+ med.take(9);
+ med.take(8);
+ med.take(7);
+ med.take(6);
+ med.take(5);
+ med.take(4);
+ med.take(3);
+ med.take(2);
+ med.take(1);
+ med.take(0);
+
+ mln_assertion(med.to_result() == 5);
+ }
+
+ {
+ accu::median< value::set<value::int_u8> > med;
+
+ med.take(10);
+ med.take(7);
+ med.take(0);
+
+ mln_assertion(med.to_result() == 7);
+ }
+}
Index: trunk/milena/tests/accu/mean.cc
===================================================================
--- trunk/milena/tests/accu/mean.cc (revision 0)
+++ trunk/milena/tests/accu/mean.cc (revision 1580)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 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
+// 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/mean.cc
+ *
+ * \brief Tests on mln::accu::mean.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/mean.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(9);
+ mean.take(8);
+ mean.take(7);
+ mean.take(6);
+ mean.take(5);
+ mean.take(4);
+ mean.take(3);
+ mean.take(2);
+ mean.take(1);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 5);
+ }
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(8);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 6);
+ }
+}
Index: trunk/milena/tests/accu/max.cc
===================================================================
--- trunk/milena/tests/accu/max.cc (revision 0)
+++ trunk/milena/tests/accu/max.cc (revision 1580)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 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
+// 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/max.cc
+ *
+ * \brief Tests on mln::accu::max.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+
+#include <mln/accu/nil.hh>
+#include <mln/accu/max.hh>
+#include <mln/accu/p.hh>
+#include <mln/accu/v.hh>
+#include <mln/accu/compute.hh>
+
+#include <mln/level/compute.hh>
+
+
+int main()
+{
+ using namespace mln;
+ image2d<int> ima(3, 3);
+ debug::iota(ima);
+ mln_assertion(level::compute< accu::max >(ima) == 9);
+ mln_assertion(level::compute< accu::max_<int> >(ima) == 9);
+
+ accu::compute< accu::nil >(ima); // No-op.
+
+ // FIXME : what's the difference between
+ // accu::compute< accu::max >(ima);
+
+ mln_assertion( accu::compute< accu::val<accu::max> >(ima) == 9);
+
+// std::cout << accu::compute< accu::max >(ima)
+// << std::endl;
+}
Index: trunk/milena/tests/accu/histo.cc
===================================================================
--- trunk/milena/tests/accu/histo.cc (revision 0)
+++ trunk/milena/tests/accu/histo.cc (revision 1580)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 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
+// 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/histo.cc
+ *
+ * \brief Tests on mln::accu::histo.
+ */
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/histo.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::histo< set<int_u8> > a;
+
+ a.take(1);
+ a.take(1);
+ a.take(1);
+
+
+ a.take(2);
+ a.take(2);
+ a.take(2);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+
+ mln_assertion(a[1] == 3);
+ mln_assertion(a[2] == 3);
+ mln_assertion(a[234] == 6);
+
+ a.untake(234);
+ mln_assertion(a[234] == 5);
+
+ // Abort
+ // a.untake(235);
+}
Index: trunk/milena/tests/accu/min_max.cc
===================================================================
--- trunk/milena/tests/accu/min_max.cc (revision 0)
+++ trunk/milena/tests/accu/min_max.cc (revision 1580)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 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
+// 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/min_max.cc
+ *
+ * \brief Tests on mln::accu::min_max.
+ */
+
+// FIXME : This test doesn't compile without this include.
+#include <mln/value/builtin/integers.hh>
+
+#include <mln/accu/min_max.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mln_accu_with_(accu::min_max, int) accu;
+
+ accu.take(7);
+
+ mln_assertion(accu.to_result().first == 7);
+ mln_assertion(accu.to_result().second == 7);
+ }
+
+ {
+ mln_accu_with_(accu::min_max, int) accu;
+
+ accu.take(10);
+ accu.take(9);
+ accu.take(8);
+ accu.take(7);
+ accu.take(6);
+ accu.take(5);
+ accu.take(4);
+ accu.take(3);
+ accu.take(2);
+ accu.take(1);
+ accu.take(0);
+
+ mln_assertion(accu.to_result().first == 0);
+ mln_assertion(accu.to_result().second == 10);
+ }
+}
Index: trunk/milena/tests/accu/count.cc
===================================================================
--- trunk/milena/tests/accu/count.cc (revision 0)
+++ trunk/milena/tests/accu/count.cc (revision 1580)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 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
+// 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/count.cc
+ *
+ * \brief Tests on mln::accu::count.
+ */
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/count.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::count_<value::int_u8> accu;
+ mln_assertion(accu.to_result() == 0);
+ }
+
+ {
+ accu::count_<value::int_u8> accu;
+ for (int i = 0; i < 200; i++)
+ accu.take(i);
+ mln_assertion(accu.to_result() == 200);
+ }
+
+}
Index: trunk/milena/tests/accu/min_h.cc
===================================================================
--- trunk/milena/tests/accu/min_h.cc (revision 0)
+++ trunk/milena/tests/accu/min_h.cc (revision 1580)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 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
+// 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/min_h.cc
+ *
+ * \brief Tests on mln::accu::min_h.
+ */
+
+#include <mln/value/int_u8.hh>
+#include <mln/accu/min_h.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::min_h< set<int_u8> > a;
+
+ a.take(42);
+ a.take(42);
+ a.take(42);
+
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ mln_assertion(a.to_result() == 42);
+}
Index: trunk/milena/tests/accu/bbox.cc
===================================================================
--- trunk/milena/tests/accu/bbox.cc (revision 0)
+++ trunk/milena/tests/accu/bbox.cc (revision 1580)
@@ -0,0 +1,50 @@
+// Copyright (C) 2007 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
+// 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/nil.cc
+ *
+ * \brief Tests on mln::accu::nil.
+ */
+
+
+#include <mln/core/point2d.hh>
+#include <mln/core/box2d.hh>
+
+#include <mln/accu/bbox.hh>
+
+int main()
+{
+ using namespace mln;
+ accu::bbox<point2d> accu;
+
+ accu.take_as_init(make::point2d(0,0));
+ accu.take(make::point2d(0,5));
+ accu.take(make::point2d(5,0));
+ accu.take(make::point2d(5,5));
+
+ mln_assertion(accu.to_result() == make::box2d(0,0,5,5));
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Review the mln/geom directory.
* mln/geom/bbox.hh: Active a precondition.
* mln/geom/chamfer.hh: Add documentation.
---
bbox.hh | 3 ++-
chamfer.hh | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
Index: trunk/milena/mln/geom/bbox.hh
===================================================================
--- trunk/milena/mln/geom/bbox.hh (revision 1578)
+++ trunk/milena/mln/geom/bbox.hh (revision 1579)
@@ -35,6 +35,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/core/concept/point_set.hh>
# include <mln/core/concept/box.hh>
# include <mln/core/concept/window.hh>
# include <mln/core/concept/weighted_window.hh>
@@ -125,7 +126,7 @@
{
mln_precondition(exact(pset).npoints() != 0);
box_<mln_point(S)> tmp = impl::bbox_(exact(pset));
- // FIXME: mln_postcondition(tmp <= pset.bbox());
+ mln_postcondition(tmp <= exact(pset).bbox());
return tmp;
}
Index: trunk/milena/mln/geom/chamfer.hh
===================================================================
--- trunk/milena/mln/geom/chamfer.hh (revision 1578)
+++ trunk/milena/mln/geom/chamfer.hh (revision 1579)
@@ -47,7 +47,7 @@
namespace geom
{
-
+ /// Apply chamfer algorithm to a binary image.
template <typename I, typename W>
mln_ch_value( I, unsigned )
chamfer(const Image<I>& input_, const W& w_win_,
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix warnings in io.
* mln/io/abort.hh: Fix a compile error.
* mln/io/pnm/save_header.hh: Fix a 'unused parameter.' warning.
---
abort.hh | 2 +-
pnm/save_header.hh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: trunk/milena/mln/io/abort.hh
===================================================================
--- trunk/milena/mln/io/abort.hh (revision 1577)
+++ trunk/milena/mln/io/abort.hh (revision 1578)
@@ -45,7 +45,7 @@
namespace internal
{
/// The way to abort when an error occur in io processing.
- void abort()
+ void abort();
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/io/pnm/save_header.hh
===================================================================
--- trunk/milena/mln/io/pnm/save_header.hh (revision 1577)
+++ trunk/milena/mln/io/pnm/save_header.hh (revision 1578)
@@ -64,7 +64,7 @@
}
inline
- void save_max_val(bool&, std::ofstream& file)
+ void save_max_val(bool&, std::ofstream&)
{
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-03 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Creation of rle_image and test.
* mln/core/internal/run_image.hh: Factorize compression code.
* mln/core/p_runs.hh: Fix and add size_mem().
* mln/core/rle_encode.hh: Rewrite algo and add feature for taking
zero into account or not.
* mln/core/rle_image.hh: Add traits and Fixes.
* mln/core/runs_psite.hh: Fix and remove a FIXME.
* mln/level/transform.hh: Fix call of transform.
* mln/util/lazy_set.hh: Fix and add Doc.
* tests/core/Makefile.am: Add test.
* tests/core/rle_image.cc: New.
---
mln/core/internal/run_image.hh | 28 ++++++++++-----
mln/core/p_runs.hh | 15 +++++++-
mln/core/rle_encode.hh | 47 ++++++++++++-------------
mln/core/rle_image.hh | 54 ++++++++++++++++++++++++-----
mln/core/runs_psite.hh | 6 +--
mln/level/transform.hh | 2 -
mln/util/lazy_set.hh | 4 +-
tests/core/Makefile.am | 2 +
tests/core/rle_image.cc | 75 +++++++++++++++++++++++++++++++++++++++++
9 files changed, 183 insertions(+), 50 deletions(-)
Index: trunk/milena/tests/core/rle_image.cc
===================================================================
--- trunk/milena/tests/core/rle_image.cc (revision 0)
+++ trunk/milena/tests/core/rle_image.cc (revision 1577)
@@ -0,0 +1,75 @@
+// Copyright (C) 2007 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
+// 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/labeling/blobs.cc
+ *
+ * \brief Test on mln::labeling::blobs.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/pw/all.hh>
+#include <mln/core/neighb2d.hh>
+
+#include <mln/labeling/blobs.hh>
+#include <mln/level/transform.hh>
+#include <mln/level/paste.hh>
+#include <mln/level/compare.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/core/rle_encode.hh>
+
+struct fold_t : public mln::Function_v2v< fold_t >
+{
+ typedef mln::value::int_u8 result;
+ result operator()(unsigned i) const { return i == 0 ? 0 : (i - 1) % 255 + 1; }
+};
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../../img/tiny.pgm");
+ image2d<int_u8> cmp(lena.domain());
+
+ unsigned n;
+ image2d<unsigned> labels = labeling::blobs((pw::value(lena) > pw::cst(172u)) | lena.domain(),
+ c4(), n);
+ std::cout << n << std::endl;
+
+ rle_image<point2d, int_u8> rle = rle_encode(level::transform(labels, fold_t()));
+
+ level::fill(cmp, literal::zero);
+ level::paste(rle, cmp);
+
+ mln_assertion(cmp == level::transform(labels, fold_t()));
+}
Index: trunk/milena/tests/core/Makefile.am
===================================================================
--- trunk/milena/tests/core/Makefile.am (revision 1576)
+++ trunk/milena/tests/core/Makefile.am (revision 1577)
@@ -8,6 +8,7 @@
exact \
initialize \
p_runs \
+ rle_image \
t_image
category_SOURCES = category.cc
@@ -15,6 +16,7 @@
exact_SOURCES = exact.cc
initialize_SOURCES = initialize.cc
p_runs_SOURCES = p_runs.cc
+rle_image_SOURCES = rle_image.cc
t_image_SOURCES = t_image.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/core/internal/run_image.hh
===================================================================
--- trunk/milena/mln/core/internal/run_image.hh (revision 1576)
+++ trunk/milena/mln/core/internal/run_image.hh (revision 1577)
@@ -33,10 +33,9 @@
* \brief Definition of mln::internal::run_image_ class for internal use only
*/
-# include <mln/core/internal/image_base.hh>
-# include <mln/core/internal/run_pset.hh>
-# include <mln/core/internal/run_psite.hh>
-# include <mln/value/set.hh>
+# include <mln/core/internal/image_primary.hh>
+# include <mln/core/p_runs.hh>
+# include <mln/core/runs_psite.hh>
namespace mln
{
@@ -46,22 +45,35 @@
/*! \brief Factorization class for run_image.
*
+ * Parameter \c T is the type of the image value.
* Parameter \c P is the type of the image point.
* Parameter \c E is the Exact type of the image.
*/
- template <typename P, typename E>
- class run_image_ : public internal::image_primary_< internal::run_pset_<P>, E >
+ template <typename T, typename P, typename E>
+ class run_image_ : public internal::image_primary_< p_runs_<P>, E >
{
protected:
run_image_();
+
+ public:
+ float compression() const;
};
# ifndef MLN_INCLUDE_ONLY
- template <typename P, typename E>
+ template <typename T, typename P, typename E>
+ inline
+ run_image_<T, P, E>::run_image_()
+ {
+ }
+
+ template <typename T, typename P, typename E>
inline
- run_image_<P, E>::run_image_()
+ float
+ run_image_<T, P, E>::compression() const
{
+ return float(exact(this)->data_->size_mem()) /
+ float (sizeof(T) * exact(this)->data_->domain_->bbox().npoints());
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/rle_image.hh
===================================================================
--- trunk/milena/mln/core/rle_image.hh (revision 1576)
+++ trunk/milena/mln/core/rle_image.hh (revision 1577)
@@ -34,8 +34,8 @@
*/
# include <mln/core/internal/run_image.hh>
-# include <mln/core/internal/run_pset.hh>
-# include <mln/core/internal/run_psite.hh>
+# include <mln/core/p_runs.hh>
+# include <mln/core/runs_psite.hh>
# include <mln/value/set.hh>
# include <vector>
@@ -58,12 +58,37 @@
std::vector<T> values_;
/// domain of the image
- run_pset_<P> domain_;
+ p_runs_<P> domain_;
+
+ /// Return the size of the data in memory.
+ unsigned size_mem() const;
};
} // end of namespace mln::internal
+ namespace trait
+ {
+
+ template <typename P, typename T>
+ struct image_< rle_image<P,T> > : default_image_< T, rle_image<P,T> >
+ {
+ typedef trait::image::category::primary category;
+
+ typedef trait::image::access::browsing access;
+ // FIXME: Put the right dimension.
+ typedef trait::image::space::two_d space;
+ typedef trait::image::size::regular size;
+ typedef trait::image::support::aligned support;
+
+ typedef trait::image::border::none border;
+ typedef trait::image::data::linear data;
+ typedef trait::image::io::read_only io;
+ typedef trait::image::speed::slow speed;
+ };
+
+ } // end of namespace mln::trait
+
/*! \brief RLE image.
*
@@ -73,15 +98,15 @@
* This image is not point wise accessible.
*/
template <typename P, typename T>
- class rle_image : public internal::run_image_< P, rle_image<P, T> >
+ class rle_image : public internal::run_image_< T, P, rle_image<P, T> >
{
public:
typedef T value;
typedef T& lvalue;
typedef const T rvalue;
- typedef internal::run_psite<P> psite;
+ typedef runs_psite<P> psite;
typedef mln::value::set<T> vset;
- typedef internal::run_pset_<P> pset;
+ typedef p_runs_<P> pset;
/// Skeleton.
@@ -91,7 +116,7 @@
rle_image();
/// Add a new range to the image.
- void insert(const P& p, unsigned len, T value);
+ void insert(const p_run<P>& pr, T value);
/// Read-only access to the image value located at point \p p.
rvalue operator() (const psite& site) const;
@@ -124,12 +149,21 @@
{
}
+ template <typename P, typename T>
+ inline
+ unsigned
+ data_< rle_image<P,T> >::size_mem() const
+ {
+ return sizeof(T) * values_.size() + domain_.size_mem();
+ }
+
} // end of namespace mln::internal
template <typename P, typename T>
inline
rle_image<P, T>::rle_image()
{
+ this->data_ = new internal::data_< rle_image<P,T> >();
}
template <typename P, typename T>
@@ -151,11 +185,13 @@
template <typename P, typename T>
inline
void
- rle_image<P, T>::insert(const P& p, unsigned len, T value)
+ rle_image<P, T>::insert(const p_run<P>& pr, T value)
{
if (!this->has_data())
this->data_ = new internal::data_< rle_image<P,T> >();
- this->data_->domain_.insert(p, len);
+ mln_assertion(this->data_->values_.size() == 0 ||
+ pr.first() > this->data_->domain_[this->data_->domain_.nruns() - 1].first());
+ this->data_->domain_.insert(pr);
this->data_->values_.push_back(value);
}
Index: trunk/milena/mln/core/runs_psite.hh
===================================================================
--- trunk/milena/mln/core/runs_psite.hh (revision 1576)
+++ trunk/milena/mln/core/runs_psite.hh (revision 1577)
@@ -89,7 +89,7 @@
protected:
/// Start of the psite range.
- P p_; // FIXME: Rename as p_ (like everywhere else!)
+ P p_;
/// Position in the psite range.
unsigned range_index_;
@@ -106,11 +106,11 @@
runs_psite<P>::runs_psite(const p_runs_<P>& pr, const P& p)
{
unsigned i = 0;
- while (i < pr.nruns() && p < pr[i].first())
+ while (i < pr.nruns() && p >= pr[i].first())
++i;
mln_assertion(i != 0);
- range_index_ = p[P::dim - 1] - pr[i].first()[P::dim - 1];
+ range_index_ = p[P::dim - 1] - pr[i - 1].first()[P::dim - 1];
mln_assertion(pr[i - 1].npoints() > range_index_);
Index: trunk/milena/mln/core/rle_encode.hh
===================================================================
--- trunk/milena/mln/core/rle_encode.hh (revision 1576)
+++ trunk/milena/mln/core/rle_encode.hh (revision 1577)
@@ -33,8 +33,7 @@
* \brief Definintion of function which encodes an image in rle_image.
*/
-# include <mln/core/sparse_image.hh>
-# include <vector>
+# include <mln/core/rle_image.hh>
namespace mln
{
@@ -48,7 +47,7 @@
*/
template <typename I>
rle_image<mln_point(I), mln_value(I)>
- rle_encode(const Image<I>& input);
+ rle_encode(const Image<I>& input, bool ignore_zero = true);
# ifndef MLN_INCLUDE_ONLY
/*!
@@ -59,10 +58,10 @@
bool
on_the_same_line(const P& p1, const P& p2)
{
- unsigned dim = P::dim;
+ const unsigned dim = P::dim;
bool same_line = true;
- for (int n = dim - 1; same_line and n > 0; --n)
+ for (unsigned n = 0; same_line && n < dim - 1; ++n)
same_line = (p1[n] == p2[n]);
return same_line;
}
@@ -70,38 +69,36 @@
template <typename I>
inline
rle_image<mln_point(I), mln_value(I)>
- rle_encode(const Image<I>& input)
+ rle_encode(const Image<I>& input, bool ignore_zero)
{
+ typedef mln_point(I) P;
+
rle_image<mln_point(I), mln_value(I)> output;
+ const I& ima = exact(input);
mln_piter(I) p (exact(input).domain());
- unsigned len = 1;
- /// range point start
+ unsigned len = 0;
mln_point(I) rstart;
- /// range value
mln_value(I) rvalue;
- p.start();
- if (!p.is_valid())
- return output;
-
- rstart = p;
- rvalue = exact(input)(p);
- p.next_();
- while (p.is_valid())
+ for_all(p)
+ if (!ignore_zero || ima(p) != literal::zero || len)
+ {
+ if (len == 0)
{
- if (rvalue == exact(input)(p) and
- on_the_same_line(rstart, mln_point(I)(p)))
+ ++len;
+ rstart = p;
+ rvalue = ima(p);
+ }
+ else
+ if (rvalue == ima(p)
+ && on_the_same_line(rstart, mln_point(I)(p)))
++len;
else
{
- output.insert(rstart, len, rvalue);
- len = 1;
- rstart = p;
- rvalue = exact(input)(p);
+ output.insert(p_run<P>(rstart, len), rvalue);
+ len = 0;
}
- p.next_();
}
- output.insert(rstart, len, rvalue);
return output;
}
Index: trunk/milena/mln/core/p_runs.hh
===================================================================
--- trunk/milena/mln/core/p_runs.hh (revision 1576)
+++ trunk/milena/mln/core/p_runs.hh (revision 1577)
@@ -90,6 +90,9 @@
/// Return the i-th run of the list of runs
const p_run<P>& operator[](unsigned i) const;
+ /// Return the size of the data in memory.
+ unsigned size_mem() const;
+
// /// Return the container of the pset (internal use only).
// const container& con() const;
@@ -162,7 +165,7 @@
break;
if (equal)
mln_assertion(prec->first()[P::dim - 1] + (signed)prec->length()
- < pr.first()[P::dim - 1]);
+ <= pr.first()[P::dim - 1]);
}
if (iter != con_.vect().end())
@@ -173,7 +176,7 @@
break;
if (equal)
mln_assertion(pr.first()[P::dim - 1] + (signed)pr.length()
- < iter->first()[P::dim - 1]);
+ <= iter->first()[P::dim - 1]);
}
con_.insert(pr);
@@ -217,6 +220,14 @@
return con_[i];
}
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::size_mem() const
+ {
+ return nruns() * 2 * (sizeof(P) + sizeof(unsigned));
+ }
+
// template <typename P>
// const typename p_runs_<P>::container&
// p_runs_<P>::con() const
Index: trunk/milena/mln/level/transform.hh
===================================================================
--- trunk/milena/mln/level/transform.hh (revision 1576)
+++ trunk/milena/mln/level/transform.hh (revision 1577)
@@ -129,7 +129,7 @@
mln_precondition(exact(input).has_data());
mln_ch_value(I, mln_result(F)) output;
initialize(output, input);
- transform_(input, f, output);
+ transform(input, f, output);
trace::exiting("level::transform");
return output;
Index: trunk/milena/mln/util/lazy_set.hh
===================================================================
--- trunk/milena/mln/util/lazy_set.hh (revision 1576)
+++ trunk/milena/mln/util/lazy_set.hh (revision 1577)
@@ -171,7 +171,7 @@
/*! \brief Update \a v_ from \a s_.
*
- * FIXME: explain.
+ * Make the vector contains the same element than the sorted set..
*/
void update_() const;
@@ -233,7 +233,7 @@
const E&
lazy_set_<E>::element(unsigned i) const
{
- assert(i < v_.size());
+ assert(i < s_.size());
if (needs_update_)
update_();
return v_[i];
1
0