* mln/accu/all.hh,
* mln/accu/essential.hh,
* mln/accu/image/essential.hh,
* mln/accu/site_set/all.hh,
* mln/accu/site_set/essential.hh: update all and essential includes.
* mln/accu/site_set/rectangularity.hh: new accumulator.
* tests/accu/Makefile.am,
* tests/accu/site_set/Makefile.am,
* tests/accu/site_set/rectangularity.cc: add associated test.
---
milena/ChangeLog | 16 +++
milena/mln/accu/all.hh | 1 +
milena/mln/accu/essential.hh | 5 +-
milena/mln/accu/{ => image}/essential.hh | 25 +---
milena/mln/accu/{essential.hh => site_set/all.hh} | 26 +---
milena/mln/accu/{ => site_set}/essential.hh | 25 +---
milena/mln/accu/site_set/rectangularity.hh | 132 ++++++++++++++++++++
milena/tests/accu/Makefile.am | 4 +
milena/tests/accu/site_set/Makefile.am | 10 ++
.../accu/site_set/rectangularity.cc} | 54 +++++----
10 files changed, 218 insertions(+), 80 deletions(-)
copy milena/mln/accu/{ => image}/essential.hh (67%)
copy milena/mln/accu/{essential.hh => site_set/all.hh} (67%)
copy milena/mln/accu/{ => site_set}/essential.hh (67%)
create mode 100644 milena/mln/accu/site_set/rectangularity.hh
create mode 100644 milena/tests/accu/site_set/Makefile.am
copy milena/{mln/accu/essential.hh => tests/accu/site_set/rectangularity.cc} (63%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index be240e1..c68b693 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,21 @@
2009-03-19 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Add accu::site_set::rectangularity.
+
+ * mln/accu/all.hh,
+ * mln/accu/essential.hh,
+ * mln/accu/image/essential.hh,
+ * mln/accu/site_set/all.hh,
+ * mln/accu/site_set/essential.hh: update all and essential includes.
+
+ * mln/accu/site_set/rectangularity.hh: new accumulator.
+
+ * tests/accu/Makefile.am,
+ * tests/accu/site_set/Makefile.am,
+ * tests/accu/site_set/rectangularity.cc: add associated test.
+
+2009-03-19 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add accu::couple.
* mln/accu/internal/couple.hh: new class.
diff --git a/milena/mln/accu/all.hh b/milena/mln/accu/all.hh
index 5b4e761..0e4d72d 100644
--- a/milena/mln/accu/all.hh
+++ b/milena/mln/accu/all.hh
@@ -96,6 +96,7 @@ namespace mln
// Sub-directories
# include <mln/accu/image/all.hh>
+# include <mln/accu/site_set/all.hh>
#endif // ! MLN_ACCU_ALL_HH
diff --git a/milena/mln/accu/essential.hh b/milena/mln/accu/essential.hh
index e8c57cc..c69540d 100644
--- a/milena/mln/accu/essential.hh
+++ b/milena/mln/accu/essential.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 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,5 +46,8 @@
# include <mln/accu/rank.hh>
# include <mln/accu/sum.hh>
+# include <mln/accu/image/essential.hh>
+# include <mln/accu/site_set/essential.hh>
+
#endif // !MLN_ACCU_ESSENTIAL_HH_
diff --git a/milena/mln/accu/essential.hh b/milena/mln/accu/image/essential.hh
similarity index 67%
copy from milena/mln/accu/essential.hh
copy to milena/mln/accu/image/essential.hh
index e8c57cc..9a72225 100644
--- a/milena/mln/accu/essential.hh
+++ b/milena/mln/accu/image/essential.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 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,26 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_ESSENTIAL_HH_
-# define MLN_ACCU_ESSENTIAL_HH_
+#ifndef MLN_ACCU_IMAGE_ESSENTIAL_HH_
+# define MLN_ACCU_IMAGE_ESSENTIAL_HH_
-/// \file mln/accu/essential.hh
+/// \file mln/accu/image/essential.hh
///
-/// File that includes the most useful accumulator types.
+/// File that includes the most useful accumulator types working on images.
-# include <mln/accu/bbox.hh>
-# include <mln/accu/center.hh>
-# include <mln/accu/count.hh>
-# include <mln/accu/histo.hh>
-# include <mln/accu/max.hh>
-# include <mln/accu/max_h.hh>
-# include <mln/accu/mean.hh>
-# include <mln/accu/median_h.hh>
-# include <mln/accu/min.hh>
-# include <mln/accu/min_h.hh>
-# include <mln/accu/min_max.hh>
-# include <mln/accu/rank.hh>
-# include <mln/accu/sum.hh>
-#endif // !MLN_ACCU_ESSENTIAL_HH_
+#endif // !MLN_ACCU_IMAGE_ESSENTIAL_HH_
diff --git a/milena/mln/accu/essential.hh b/milena/mln/accu/site_set/all.hh
similarity index 67%
copy from milena/mln/accu/essential.hh
copy to milena/mln/accu/site_set/all.hh
index e8c57cc..03c8dae 100644
--- a/milena/mln/accu/essential.hh
+++ b/milena/mln/accu/site_set/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 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,26 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_ESSENTIAL_HH_
-# define MLN_ACCU_ESSENTIAL_HH_
+#ifndef MLN_ACCU_SITE_SET_ALL_HH_
+# define MLN_ACCU_SITE_SET_ALL_HH_
-/// \file mln/accu/essential.hh
+/// \file mln/accu/site_set/all.hh
///
-/// File that includes the most useful accumulator types.
+/// File that includes all accumulator types working on site sets.
-# include <mln/accu/bbox.hh>
-# include <mln/accu/center.hh>
-# include <mln/accu/count.hh>
-# include <mln/accu/histo.hh>
-# include <mln/accu/max.hh>
-# include <mln/accu/max_h.hh>
-# include <mln/accu/mean.hh>
-# include <mln/accu/median_h.hh>
-# include <mln/accu/min.hh>
-# include <mln/accu/min_h.hh>
-# include <mln/accu/min_max.hh>
-# include <mln/accu/rank.hh>
-# include <mln/accu/sum.hh>
+# include <mln/accu/site_set/rectangularity.hh>
-#endif // !MLN_ACCU_ESSENTIAL_HH_
+#endif // !MLN_ACCU_SITE_SET_ALL_HH_
diff --git a/milena/mln/accu/essential.hh b/milena/mln/accu/site_set/essential.hh
similarity index 67%
copy from milena/mln/accu/essential.hh
copy to milena/mln/accu/site_set/essential.hh
index e8c57cc..feb5a97 100644
--- a/milena/mln/accu/essential.hh
+++ b/milena/mln/accu/site_set/essential.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 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,26 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_ESSENTIAL_HH_
-# define MLN_ACCU_ESSENTIAL_HH_
+#ifndef MLN_ACCU_SITE_SET_ESSENTIAL_HH_
+# define MLN_ACCU_SITE_SET_ESSENTIAL_HH_
-/// \file mln/accu/essential.hh
+/// \file mln/accu/site_set/essential.hh
///
-/// File that includes the most useful accumulator types.
+/// File that includes the most useful accumulator types working on site sets.
-# include <mln/accu/bbox.hh>
-# include <mln/accu/center.hh>
-# include <mln/accu/count.hh>
-# include <mln/accu/histo.hh>
-# include <mln/accu/max.hh>
-# include <mln/accu/max_h.hh>
-# include <mln/accu/mean.hh>
-# include <mln/accu/median_h.hh>
-# include <mln/accu/min.hh>
-# include <mln/accu/min_h.hh>
-# include <mln/accu/min_max.hh>
-# include <mln/accu/rank.hh>
-# include <mln/accu/sum.hh>
-#endif // !MLN_ACCU_ESSENTIAL_HH_
+#endif // !MLN_ACCU_SITE_SET_ESSENTIAL_HH_
diff --git a/milena/mln/accu/site_set/rectangularity.hh
b/milena/mln/accu/site_set/rectangularity.hh
new file mode 100644
index 0000000..fef5b21
--- /dev/null
+++ b/milena/mln/accu/site_set/rectangularity.hh
@@ -0,0 +1,132 @@
+// Copyright (C) 2009 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_SITE_SET_RECTANGULARITY_HH
+# define MLN_ACCU_SITE_SET_RECTANGULARITY_HH
+
+/// \file mln/accu/site_set/rectangularity.hh
+///
+/// Compute the rectangularity of a site set.
+
+# include <mln/accu/internal/couple.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/accu/count.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace site_set
+ {
+
+ /// Compute the rectangularity of a site set.
+ template <typename P>
+ class rectangularity
+ : public accu::internal::couple<accu::bbox<P>,
+ accu::count<P>,
+ float,
+ rectangularity<P> >
+ {
+
+ public:
+
+ typedef accu::internal::couple<accu::bbox<P>,
+ accu::count<P>,
+ float,
+ rectangularity<P> > super_;
+
+ typedef accu::bbox<P> A1;
+ typedef accu::count<P> A2;
+
+ typedef float result;
+
+ /// Constructor
+ rectangularity();
+
+ /// Return the site set bounding box.
+ mln_result(A1) bbox() const;
+ /// Return the site set area.
+ mln_result(A2) area() const;
+
+ /// Return the rectangularity value.
+ result to_result() const;
+
+ protected:
+ using super_::a1_;
+ using super_::a2_;
+
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ rectangularity<P>::rectangularity()
+ {
+ }
+
+ template <typename P>
+ inline
+ mln_result(rectangularity<P>::A1)
+ rectangularity<P>::bbox() const
+ {
+ mln_precondition(a1_.is_valid());
+ return a1_.to_result();
+ }
+
+ template <typename P>
+ inline
+ mln_result(rectangularity<P>::A2)
+ rectangularity<P>::area() const
+ {
+ mln_precondition(a2_.is_valid());
+ return a2_.to_result();
+ }
+
+ template <typename P>
+ inline
+ mln_result(rectangularity<P>)
+ rectangularity<P>::to_result() const
+ {
+ mln_precondition(this->is_valid());
+ // Force division return type.
+ return static_cast<result>(a2_.to_result()) / a1_.to_result().nsites();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu::site_set
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+#endif // ! MLN_ACCU_SITE_SET_RECTANGULARITY_HH
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index fafbec1..7aca2bd 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -2,6 +2,10 @@
include $(top_srcdir)/milena/tests/tests.mk
+SUBDIRS = \
+ image \
+ site_set
+
check_PROGRAMS = \
all_accus \
bbox \
diff --git a/milena/tests/accu/site_set/Makefile.am
b/milena/tests/accu/site_set/Makefile.am
new file mode 100644
index 0000000..042cf00
--- /dev/null
+++ b/milena/tests/accu/site_set/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ rectangularity
+
+rectangularity_SOURCES = rectangularity.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/accu/essential.hh b/milena/tests/accu/site_set/rectangularity.cc
similarity index 63%
copy from milena/mln/accu/essential.hh
copy to milena/tests/accu/site_set/rectangularity.cc
index e8c57cc..22e1e3e 100644
--- a/milena/mln/accu/essential.hh
+++ b/milena/tests/accu/site_set/rectangularity.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 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
@@ -25,26 +25,36 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_ESSENTIAL_HH_
-# define MLN_ACCU_ESSENTIAL_HH_
-
-/// \file mln/accu/essential.hh
+/// \file tests/accu/site_set/rectangularity.hh
///
-/// File that includes the most useful accumulator types.
-
-# include <mln/accu/bbox.hh>
-# include <mln/accu/center.hh>
-# include <mln/accu/count.hh>
-# include <mln/accu/histo.hh>
-# include <mln/accu/max.hh>
-# include <mln/accu/max_h.hh>
-# include <mln/accu/mean.hh>
-# include <mln/accu/median_h.hh>
-# include <mln/accu/min.hh>
-# include <mln/accu/min_h.hh>
-# include <mln/accu/min_max.hh>
-# include <mln/accu/rank.hh>
-# include <mln/accu/sum.hh>
-
-#endif // !MLN_ACCU_ESSENTIAL_HH_
+/// Tests on mln::accu::site_set::rectangularity.
+
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/box2d.hh>
+
+#include <mln/accu/site_set/rectangularity.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::site_set::rectangularity<point2d> accu;
+ accu.take_as_init(point2d(0,0));
+ accu.take(point2d(0,1));
+ accu.take(point2d(1,0));
+ accu.take(point2d(1,1));
+
+ mln_assertion(accu.to_result() == 1);
+ }
+
+ {
+ accu::site_set::rectangularity<point2d> accu;
+ accu.take(point2d(0,0));
+ accu.take(point2d(1,1));
+ std::cout << accu << std::endl;
+ mln_assertion(accu.to_result() == 0.5f);
+ }
+}
--
1.5.6.5