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
- 9625 discussions
* mln/fun/stat/mahalanobis.hh (var_1, mean): Rename as...
(var_1_, mean_): ...these.
Protect them.
(mean_t, mean): New typedef and method.
(operator()): Fix missing sqrt.
* tests/fun/stat/mahalanobis.cc: Augment.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/fun/stat/mahalanobis.hh | 24 +++++++++++++++++++-----
milena/tests/fun/stat/mahalanobis.cc | 17 ++++++++---------
3 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 9ac5049..702a0dc 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+ Fix fun stat mahalanobis.
+
+ * mln/fun/stat/mahalanobis.hh (var_1, mean): Rename as...
+ (var_1_, mean_): ...these.
+ Protect them.
+ (mean_t, mean): New typedef and method.
+ (operator()): Fix missing sqrt.
+ * tests/fun/stat/mahalanobis.cc: Augment.
+
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
Fix missing files and tests in world inter-pixel.
* mln/world/inter_pixel/all.hh: New.
diff --git a/milena/mln/fun/stat/mahalanobis.hh b/milena/mln/fun/stat/mahalanobis.hh
index 79eea0e..967ad29 100644
--- a/milena/mln/fun/stat/mahalanobis.hh
+++ b/milena/mln/fun/stat/mahalanobis.hh
@@ -32,6 +32,7 @@
///
/// Define the FIXME
+# include <cmath>
# include <mln/core/concept/function.hh>
# include <mln/algebra/vec.hh>
# include <mln/algebra/mat.hh>
@@ -59,8 +60,13 @@ namespace mln
float operator()(const V& v) const;
- algebra::mat<n,n,float> var_1;
- algebra::vec<n,float> mean;
+ typedef algebra::vec<n,float> mean_t;
+
+ mean_t mean() const;
+
+ protected:
+ algebra::mat<n,n,float> var_1_;
+ algebra::vec<n,float> mean_;
};
@@ -71,8 +77,8 @@ namespace mln
mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
const algebra::vec<V::dim,float>& mean)
{
- var_1 = var._1();
- mean = mean;
+ var_1_ = var._1();
+ mean_ = mean;
}
template <typename V>
@@ -80,7 +86,15 @@ namespace mln
float
mahalanobis<V>::operator()(const V& v) const
{
- return (v - mean).t() * var_1 * (v - mean);
+ return std::sqrt((v - mean_).t() * var_1_ * (v - mean_));
+ }
+
+ template <typename V>
+ inline
+ typename mahalanobis<V>::mean_t
+ mahalanobis<V>::mean() const
+ {
+ return mean_;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/fun/stat/mahalanobis.cc b/milena/tests/fun/stat/mahalanobis.cc
index 7df7af2..a2f1e00 100644
--- a/milena/tests/fun/stat/mahalanobis.cc
+++ b/milena/tests/fun/stat/mahalanobis.cc
@@ -60,15 +60,14 @@ int main()
for (int i = 0; i < n; ++i)
a.take(v[i]);
-// vec3f m = a.mean();
-// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
-// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
-// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-
fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+ mln_assertion(f(a.mean()) == 0.f);
-// algebra::mat<3,3,float> s_1 = a.variance()._1();
-// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
-// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
-// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+ float sum = 0.f;
+ for (int i = 0; i < n; ++i)
+ {
+ float f_ = f(v[i]);
+ sum += f_ * f_;
+ }
+ mln_assertion(std::abs(sum / n - 3.f) < 0.00002f);
}
--
1.6.1.2
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix missing files and tests in world inter-pixel.
* mln/world/inter_pixel/all.hh: New.
* mln/world/inter_pixel/dim2/all.hh: Fix copyright.
* mln/world/all.hh: New.
* mln/all.hh: Update.
* tests/world/inter_pixel/is_separator.cc: New.
* tests/world/inter_pixel/is_pixel.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
* tests/world/inter_pixel/separator_to_pixels.cc: New.
* mln/world/inter_pixel/make: Remove; useless.
* tests/world/inter_pixel/image2full.cc: Remove;
new stuff is...
* tests/world/inter_pixel/immerse.hh: ...this.
mln/all.hh | 1
mln/world/all.hh | 41 ++++++++++++++++++
mln/world/inter_pixel/all.hh | 47 ++++++++++++++++++++
mln/world/inter_pixel/dim2/all.hh | 6 +-
tests/world/inter_pixel/Makefile.am | 12 ++++-
tests/world/inter_pixel/is_pixel.cc | 46 ++++++++++++++++++++
tests/world/inter_pixel/is_separator.cc | 47 ++++++++++++++++++++
tests/world/inter_pixel/separator_to_pixels.cc | 56 +++++++++++++++++++++++++
8 files changed, 250 insertions(+), 6 deletions(-)
Index: mln/world/inter_pixel/all.hh
--- mln/world/inter_pixel/all.hh (revision 0)
+++ mln/world/inter_pixel/all.hh (revision 0)
@@ -0,0 +1,47 @@
+// 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_WORLD_INTER_PIXEL_ALL_HH
+# define MLN_WORLD_INTER_PIXEL_ALL_HH
+
+/// \file mln/world/inter_pixel/all.hh
+///
+/// File that includes all the inter-pixel routines.
+
+
+// Sub-directories.
+# include <mln/world/inter_pixel/dim2/all.hh>
+
+
+# include <mln/world/inter_pixel/compute.hh>
+# include <mln/world/inter_pixel/immerse.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+#endif // ! MLN_WORLD_INTER_PIXEL_ALL_HH
Index: mln/world/inter_pixel/dim2/all.hh
--- mln/world/inter_pixel/dim2/all.hh (revision 3770)
+++ mln/world/inter_pixel/dim2/all.hh (working copy)
@@ -1,4 +1,5 @@
-// 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
@@ -30,10 +31,9 @@
/// \file mln/world/inter_pixel/dim2/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel 2D routines.
-// Local directory.
# include <mln/world/inter_pixel/dim2/is_dot.hh>
# include <mln/world/inter_pixel/dim2/is_edge.hh>
# include <mln/world/inter_pixel/dim2/is_pixel.hh>
Index: mln/world/all.hh
--- mln/world/all.hh (revision 0)
+++ mln/world/all.hh (revision 0)
@@ -0,0 +1,41 @@
+// 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_WORLD_ALL_HH
+# define MLN_WORLD_ALL_HH
+
+/// \file mln/world/all.hh
+///
+/// File that includes all the world routines.
+
+
+// Sub-directories.
+# include <mln/world/binary_2d/all.hh>
+# include <mln/world/inter_pixel/all.hh>
+
+
+#endif // ! MLN_WORLD_ALL_HH
Index: mln/all.hh
--- mln/all.hh (revision 3770)
+++ mln/all.hh (working copy)
@@ -72,6 +72,7 @@
#include <mln/util/all.hh>
#include <mln/value/all.hh>
#include <mln/win/all.hh>
+#include <mln/world/all.hh>
#include <mln/essential/1d.hh>
#include <mln/essential/2d.hh>
Index: tests/world/inter_pixel/is_separator.cc
--- tests/world/inter_pixel/is_separator.cc (revision 0)
+++ tests/world/inter_pixel/is_separator.cc (revision 0)
@@ -0,0 +1,47 @@
+// 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.
+
+/// \file tests/world/inter_pixel/is_separator.cc
+///
+/// Tests on mln::world::inter_pixel::is_separator.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_separator.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d p00(0, 0), p01(0, 1), p10(1, 0), p11(1, 1);
+
+ mln_assertion(! is_separator()(p00));
+ mln_assertion( is_separator()(p01));
+ mln_assertion(! is_separator()(p11));
+ mln_assertion( is_separator()(p10));
+}
Property changes on: tests/world/inter_pixel/is_separator.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/world/inter_pixel/is_pixel.cc
--- tests/world/inter_pixel/is_pixel.cc (revision 0)
+++ tests/world/inter_pixel/is_pixel.cc (revision 0)
@@ -0,0 +1,46 @@
+// 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.
+
+/// \file tests/world/inter_pixel/is_pixel.cc
+///
+/// Tests on mln::world::inter_pixel::is_pixel.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d p00(0, 0), p01(0, 1), p11(1, 1);
+
+ mln_assertion( is_pixel()(p00));
+ mln_assertion(! is_pixel()(p01));
+ mln_assertion(! is_pixel()(p11));
+}
Index: tests/world/inter_pixel/Makefile.am
--- tests/world/inter_pixel/Makefile.am (revision 3770)
+++ tests/world/inter_pixel/Makefile.am (working copy)
@@ -6,10 +6,16 @@
dim2
check_PROGRAMS = \
- image2full \
- immerse
+ compute \
+ immerse \
+ is_pixel \
+ is_separator \
+ separator_to_pixels
-image2full_SOURCES = image2full.cc
+compute_SOURCES = compute.cc
immerse_SOURCES = immerse.cc
+is_pixel_SOURCES = is_pixel.cc
+is_separator_SOURCES = is_separator.cc
+separator_to_pixels_SOURCES = separator_to_pixels.cc
TESTS = $(check_PROGRAMS)
Index: tests/world/inter_pixel/separator_to_pixels.cc
--- tests/world/inter_pixel/separator_to_pixels.cc (revision 0)
+++ tests/world/inter_pixel/separator_to_pixels.cc (revision 0)
@@ -0,0 +1,56 @@
+// 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.
+
+/// \file tests/world/inter_pixel/separator_to_pixels.cc
+///
+/// Tests on mln::world::inter_pixel::separator_to_pixels.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+
+ point2d
+ p00(0, 0), p01(0, 1), p02(0, 2),
+ p10(1, 0),
+ p20(2, 0);
+
+ {
+ point2d p00_, p02_;
+ separator_to_pixels(p01, p00_, p02_);
+ mln_assertion(p00_ == p00 && p02_ == p02);
+ }
+ {
+ point2d p00_, p20_;
+ separator_to_pixels(p10, p00_, p20_);
+ mln_assertion(p00_ == p00 && p20_ == p20);
+ }
+}
1
0
07 May '09
* mln/world/inter_pixel/all.hh: New.
* mln/world/inter_pixel/dim2/all.hh: Fix copyright.
* mln/world/all.hh: New.
* mln/all.hh: Update.
* tests/world/inter_pixel/is_separator.cc: New.
* tests/world/inter_pixel/is_pixel.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
* tests/world/inter_pixel/separator_to_pixels.cc: New.
* mln/world/inter_pixel/make: Remove; useless.
* tests/world/inter_pixel/image2full.cc: Remove;
new stuff is...
* tests/world/inter_pixel/immerse.hh: ...this.
---
milena/ChangeLog | 17 +++++++
milena/mln/all.hh | 1 +
milena/mln/world/{inter_pixel/dim2 => }/all.hh | 20 ++++-----
milena/mln/world/inter_pixel/{dim2 => }/all.hh | 26 ++++++-----
milena/mln/world/inter_pixel/dim2/all.hh | 6 +-
milena/tests/world/inter_pixel/Makefile.am | 12 ++++-
.../inter_pixel/{image2full.cc => is_pixel.cc} | 34 ++++----------
.../world/inter_pixel/is_separator.cc} | 28 +++++++-----
.../{image2full.cc => separator_to_pixels.cc} | 48 +++++++++-----------
9 files changed, 102 insertions(+), 90 deletions(-)
copy milena/mln/world/{inter_pixel/dim2 => }/all.hh (71%)
copy milena/mln/world/inter_pixel/{dim2 => }/all.hh (69%)
copy milena/tests/world/inter_pixel/{image2full.cc => is_pixel.cc} (66%)
copy milena/{mln/world/inter_pixel/dim2/all.hh => tests/world/inter_pixel/is_separator.cc} (70%)
rename milena/tests/world/inter_pixel/{image2full.cc => separator_to_pixels.cc} (66%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10648a0..9ac5049 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,20 @@
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ Fix missing files and tests in world inter-pixel.
+
+ * mln/world/inter_pixel/all.hh: New.
+ * mln/world/inter_pixel/dim2/all.hh: Fix copyright.
+ * mln/world/all.hh: New.
+ * mln/all.hh: Update.
+ * tests/world/inter_pixel/is_separator.cc: New.
+ * tests/world/inter_pixel/is_pixel.cc: New.
+ * tests/world/inter_pixel/Makefile.am: Update.
+ * tests/world/inter_pixel/separator_to_pixels.cc: New.
+ * mln/world/inter_pixel/make: Remove; useless.
+ * tests/world/inter_pixel/image2full.cc: Remove;
+ new stuff is...
+ * tests/world/inter_pixel/immerse.hh: ...this.
+
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move object_id.hh to mln/util and add a missing operator<
diff --git a/milena/mln/all.hh b/milena/mln/all.hh
index cc4374b..7f77db4 100644
--- a/milena/mln/all.hh
+++ b/milena/mln/all.hh
@@ -72,6 +72,7 @@
#include <mln/util/all.hh>
#include <mln/value/all.hh>
#include <mln/win/all.hh>
+#include <mln/world/all.hh>
#include <mln/essential/1d.hh>
#include <mln/essential/2d.hh>
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/all.hh
similarity index 71%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/mln/world/all.hh
index 1c7131b..7154654 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/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,19 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#ifndef MLN_WORLD_ALL_HH
+# define MLN_WORLD_ALL_HH
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file mln/world/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the world routines.
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+// Sub-directories.
+# include <mln/world/binary_2d/all.hh>
+# include <mln/world/inter_pixel/all.hh>
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#endif // ! MLN_WORLD_ALL_HH
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/inter_pixel/all.hh
similarity index 69%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/mln/world/inter_pixel/all.hh
index 1c7131b..da3b105 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/inter_pixel/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,19 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_ALL_HH
+# define MLN_WORLD_INTER_PIXEL_ALL_HH
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file mln/world/inter_pixel/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel routines.
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+// Sub-directories.
+# include <mln/world/inter_pixel/dim2/all.hh>
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+# include <mln/world/inter_pixel/compute.hh>
+# include <mln/world/inter_pixel/immerse.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+#endif // ! MLN_WORLD_INTER_PIXEL_ALL_HH
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/mln/world/inter_pixel/dim2/all.hh
index 1c7131b..8696371 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/mln/world/inter_pixel/dim2/all.hh
@@ -1,4 +1,5 @@
-// 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
@@ -30,10 +31,9 @@
/// \file mln/world/inter_pixel/dim2/all.hh
///
-/// File that includes all the dim2 routines.
+/// File that includes all the inter-pixel 2D routines.
-// Local directory.
# include <mln/world/inter_pixel/dim2/is_dot.hh>
# include <mln/world/inter_pixel/dim2/is_edge.hh>
# include <mln/world/inter_pixel/dim2/is_pixel.hh>
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/world/inter_pixel/Makefile.am
index fdbcea2..89f7bf7 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -6,10 +6,16 @@ SUBDIRS = \
dim2
check_PROGRAMS = \
- image2full \
- immerse
+ compute \
+ immerse \
+ is_pixel \
+ is_separator \
+ separator_to_pixels
-image2full_SOURCES = image2full.cc
+compute_SOURCES = compute.cc
immerse_SOURCES = immerse.cc
+is_pixel_SOURCES = is_pixel.cc
+is_separator_SOURCES = is_separator.cc
+separator_to_pixels_SOURCES = separator_to_pixels.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/world/inter_pixel/image2full.cc b/milena/tests/world/inter_pixel/is_pixel.cc
similarity index 66%
copy from milena/tests/world/inter_pixel/image2full.cc
copy to milena/tests/world/inter_pixel/is_pixel.cc
index 06398a1..b783e80 100644
--- a/milena/tests/world/inter_pixel/image2full.cc
+++ b/milena/tests/world/inter_pixel/is_pixel.cc
@@ -25,36 +25,22 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/is_pixel.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::is_pixel.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_pixel.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
int main()
{
using namespace mln;
+ using namespace world::inter_pixel;
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
-
- ima_t ima_l = world::inter_pixel::image2full(ima);
-
- mln_assertion(ima_l == ref);
+ point2d p00(0, 0), p01(0, 1), p11(1, 1);
+ mln_assertion( is_pixel()(p00));
+ mln_assertion(! is_pixel()(p01));
+ mln_assertion(! is_pixel()(p11));
}
diff --git a/milena/mln/world/inter_pixel/dim2/all.hh b/milena/tests/world/inter_pixel/is_separator.cc
similarity index 70%
copy from milena/mln/world/inter_pixel/dim2/all.hh
copy to milena/tests/world/inter_pixel/is_separator.cc
index 1c7131b..7234acb 100644
--- a/milena/mln/world/inter_pixel/dim2/all.hh
+++ b/milena/tests/world/inter_pixel/is_separator.cc
@@ -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,19 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
-
-/// \file mln/world/inter_pixel/dim2/all.hh
+/// \file tests/world/inter_pixel/is_separator.cc
///
-/// File that includes all the dim2 routines.
+/// Tests on mln::world::inter_pixel::is_separator.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/is_separator.hh>
-// Local directory.
-# include <mln/world/inter_pixel/dim2/is_dot.hh>
-# include <mln/world/inter_pixel/dim2/is_edge.hh>
-# include <mln/world/inter_pixel/dim2/is_pixel.hh>
-# include <mln/world/inter_pixel/dim2/is_row_odd.hh>
+int main()
+{
+ using namespace mln;
+ using namespace world::inter_pixel;
+ point2d p00(0, 0), p01(0, 1), p10(1, 0), p11(1, 1);
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH
+ mln_assertion(! is_separator()(p00));
+ mln_assertion( is_separator()(p01));
+ mln_assertion(! is_separator()(p11));
+ mln_assertion( is_separator()(p10));
+}
diff --git a/milena/tests/world/inter_pixel/image2full.cc b/milena/tests/world/inter_pixel/separator_to_pixels.cc
similarity index 66%
rename from milena/tests/world/inter_pixel/image2full.cc
rename to milena/tests/world/inter_pixel/separator_to_pixels.cc
index 06398a1..fd77491 100644
--- a/milena/tests/world/inter_pixel/image2full.cc
+++ b/milena/tests/world/inter_pixel/separator_to_pixels.cc
@@ -25,36 +25,32 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/separator_to_pixels.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::separator_to_pixels.
+
+#include <mln/core/alias/point2d.hh>
+#include <mln/world/inter_pixel/separator_to_pixels.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
-#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
int main()
{
using namespace mln;
-
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
-
- ima_t ima_l = world::inter_pixel::image2full(ima);
-
- mln_assertion(ima_l == ref);
-
+ using namespace world::inter_pixel;
+
+ point2d
+ p00(0, 0), p01(0, 1), p02(0, 2),
+ p10(1, 0),
+ p20(2, 0);
+
+ {
+ point2d p00_, p02_;
+ separator_to_pixels(p01, p00_, p02_);
+ mln_assertion(p00_ == p00 && p02_ == p02);
+ }
+ {
+ point2d p00_, p20_;
+ separator_to_pixels(p10, p00_, p20_);
+ mln_assertion(p00_ == p00 && p20_ == p20);
+ }
}
--
1.6.1.2
1
0
07 May '09
* mln/core/concept/object_id.hh: move...
* mln/util/object_id.hh: ... here. Add a missing operator<.
* mln/util/graph_ids.hh: update include path.
---
milena/ChangeLog | 9 ++
milena/mln/core/concept/object_id.hh | 220 ----------------------------------
milena/mln/util/graph_ids.hh | 2 +-
milena/mln/util/object_id.hh | 213 ++++++++++++++++++++++++++++++++
4 files changed, 223 insertions(+), 221 deletions(-)
delete mode 100644 milena/mln/core/concept/object_id.hh
create mode 100644 milena/mln/util/object_id.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4430b6c..10648a0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move object_id.hh to mln/util and add a missing operator<
+
+ * mln/core/concept/object_id.hh: move...
+ * mln/util/object_id.hh: ... here. Add a missing operator<.
+
+ * mln/util/graph_ids.hh: update include path.
+
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move debug::colorize to labeling::colorize.
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
deleted file mode 100644
index e8102df..0000000
--- a/milena/mln/core/concept/object_id.hh
+++ /dev/null
@@ -1,220 +0,0 @@
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-
-#ifndef MLN_CORE_CONCEPT_OBJECT_ID_HH
-# define MLN_CORE_CONCEPT_OBJECT_ID_HH
-
-/// \file mln/core/concept/object_id.hh
-///
-/// Base class of an object id.
-
-
-# include <mln/core/concept/object.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/metal/abort.hh>
-
-namespace mln
-{
-
-
- /// Object category.
- template <typename E>
- struct Object_Id;
-
- template <>
- struct Object_Id<void>
- {
- };
-
-
-
- /// Base class of an object id.
- /// \tparam Tag the tag type
- /// \tparam Equiv the equivalent value.
- template <typename Tag, typename V>
- class object_id : public value::Integer< object_id<Tag, V> >
- {
- public:
- /// The underlying type id.
- typedef V value_t;
- typedef unsigned equiv;
- typedef V enc;
-
- /// Constructors
- /// @{
- object_id();
-
- template <typename V2>
- object_id(const V2& id);
-
- template <typename Tag2, typename V2>
- object_id(const object_id<Tag2,V2>& other);
- /// @}
-
- template <typename V2>
- object_id<Tag,V>& operator=(const V2& e);
-
- const V& value() const;
- V& value();
-
- operator unsigned() const;
-
- bool is_valid() const;
- void invalidate();
-
- unsigned to_equiv() const;
-
- protected:
- V id_;
- };
-
-
- template <typename Tag, typename V>
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-
- template <typename Tag, typename V, typename V2>
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::object_id()
- : id_(mln_max(V))
- {
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>::object_id(const V2& id)
- : id_(id)
- {
- mlc_converts_to(V2,V)::check();
- }
-
- template <typename Tag, typename V>
- template <typename Tag2, typename V2>
- inline
- object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
- {
- typedef object_id<Tag2,V2> id_t;
- mlc_abort(id_t)::check();
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>&
- object_id<Tag,V>::operator=(const V2& v)
- {
- mlc_converts_to(V2,V)::check();
-
- id_ = v;
- return *this;
- }
-
- template <typename Tag, typename V>
- inline
- V&
- object_id<Tag,V>::value()
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- const V&
- object_id<Tag,V>::value() const
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::operator unsigned() const
- {
- return id_;
- }
-
-
- template <typename Tag, typename V>
- inline
- bool
- object_id<Tag,V>::is_valid() const
- {
- return id_ != mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- void
- object_id<Tag,V>::invalidate()
- {
- id_ = mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- unsigned
- object_id<Tag,V>::to_equiv() const
- {
- return id_;
- }
-
-
-
-
- template <typename Tag, typename V>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
- {
- return lhs.value() == rhs.value();
- }
-
- template <typename Tag, typename V, typename V2>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs)
- {
- return lhs.value() == exact(rhs).to_equiv();
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
-} // end of namespace mln
-
-#endif // ! MLN_CORE_CONCEPT_OBJECT_ID_HH
-
diff --git a/milena/mln/util/graph_ids.hh b/milena/mln/util/graph_ids.hh
index df3e981..2f9eab5 100644
--- a/milena/mln/util/graph_ids.hh
+++ b/milena/mln/util/graph_ids.hh
@@ -33,7 +33,7 @@
///
/// Definition of graph element ids.
-# include <mln/core/concept/object_id.hh>
+# include <mln/util/object_id.hh>
namespace mln
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
new file mode 100644
index 0000000..b3ea879
--- /dev/null
+++ b/milena/mln/util/object_id.hh
@@ -0,0 +1,213 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_UTIL_OBJECT_ID_HH
+# define MLN_UTIL_OBJECT_ID_HH
+
+/// \file mln/core/concept/object_id.hh
+///
+/// Base class of an object id.
+
+
+# include <mln/core/concept/object.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/metal/abort.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ /// Base class of an object id.
+ /// \tparam Tag the tag type
+ /// \tparam Equiv the equivalent value.
+ template <typename Tag, typename V>
+ class object_id : public value::Integer< object_id<Tag, V> >
+ {
+ public:
+ /// The underlying type id.
+ typedef V value_t;
+ typedef unsigned equiv;
+ typedef V enc;
+
+ /// Constructors
+ /// @{
+ object_id();
+
+ template <typename V2>
+ object_id(const V2& id);
+
+ template <typename Tag2, typename V2>
+ object_id(const object_id<Tag2,V2>& other);
+ /// @}
+
+ template <typename V2>
+ object_id<Tag,V>& operator=(const V2& e);
+
+ const V& value() const;
+ V& value();
+
+ operator unsigned() const;
+
+ bool is_valid() const;
+ void invalidate();
+
+ unsigned to_equiv() const;
+
+ protected:
+ V id_;
+ };
+
+
+ template <typename Tag, typename V>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+ template <typename Tag, typename V, typename V2>
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::object_id()
+ : id_(mln_max(V))
+ {
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>::object_id(const V2& id)
+ : id_(id)
+ {
+ mlc_converts_to(V2,V)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename Tag2, typename V2>
+ inline
+ object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
+ {
+ typedef object_id<Tag2,V2> id_t;
+ mlc_abort(id_t)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>&
+ object_id<Tag,V>::operator=(const V2& v)
+ {
+ mlc_converts_to(V2,V)::check();
+
+ id_ = v;
+ return *this;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ V&
+ object_id<Tag,V>::value()
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ const V&
+ object_id<Tag,V>::value() const
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::operator unsigned() const
+ {
+ return id_;
+ }
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ object_id<Tag,V>::is_valid() const
+ {
+ return id_ != mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ void
+ object_id<Tag,V>::invalidate()
+ {
+ id_ = mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ unsigned
+ object_id<Tag,V>::to_equiv() const
+ {
+ return id_;
+ }
+
+
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() == rhs.value();
+ }
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() < rhs.value();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_OBJECT_ID_HH
+
--
1.5.6.5
1
0
[PATCH 09/31] Move object_id.hh to mln/util and add a missing operator<
by Roland Levillain 07 May '09
by Roland Levillain 07 May '09
07 May '09
* mln/core/concept/object_id.hh: move...
* mln/util/object_id.hh: ... here. Add a missing operator<.
* mln/util/graph_ids.hh: update include path.
---
milena/ChangeLog | 9 ++
milena/mln/core/concept/object_id.hh | 220 ----------------------------------
milena/mln/util/graph_ids.hh | 2 +-
milena/mln/util/object_id.hh | 213 ++++++++++++++++++++++++++++++++
4 files changed, 223 insertions(+), 221 deletions(-)
delete mode 100644 milena/mln/core/concept/object_id.hh
create mode 100644 milena/mln/util/object_id.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4430b6c..10648a0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move object_id.hh to mln/util and add a missing operator<
+
+ * mln/core/concept/object_id.hh: move...
+ * mln/util/object_id.hh: ... here. Add a missing operator<.
+
+ * mln/util/graph_ids.hh: update include path.
+
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Move debug::colorize to labeling::colorize.
diff --git a/milena/mln/core/concept/object_id.hh b/milena/mln/core/concept/object_id.hh
deleted file mode 100644
index e8102df..0000000
--- a/milena/mln/core/concept/object_id.hh
+++ /dev/null
@@ -1,220 +0,0 @@
-// 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.
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-
-#ifndef MLN_CORE_CONCEPT_OBJECT_ID_HH
-# define MLN_CORE_CONCEPT_OBJECT_ID_HH
-
-/// \file mln/core/concept/object_id.hh
-///
-/// Base class of an object id.
-
-
-# include <mln/core/concept/object.hh>
-# include <mln/value/concept/integer.hh>
-# include <mln/metal/abort.hh>
-
-namespace mln
-{
-
-
- /// Object category.
- template <typename E>
- struct Object_Id;
-
- template <>
- struct Object_Id<void>
- {
- };
-
-
-
- /// Base class of an object id.
- /// \tparam Tag the tag type
- /// \tparam Equiv the equivalent value.
- template <typename Tag, typename V>
- class object_id : public value::Integer< object_id<Tag, V> >
- {
- public:
- /// The underlying type id.
- typedef V value_t;
- typedef unsigned equiv;
- typedef V enc;
-
- /// Constructors
- /// @{
- object_id();
-
- template <typename V2>
- object_id(const V2& id);
-
- template <typename Tag2, typename V2>
- object_id(const object_id<Tag2,V2>& other);
- /// @}
-
- template <typename V2>
- object_id<Tag,V>& operator=(const V2& e);
-
- const V& value() const;
- V& value();
-
- operator unsigned() const;
-
- bool is_valid() const;
- void invalidate();
-
- unsigned to_equiv() const;
-
- protected:
- V id_;
- };
-
-
- template <typename Tag, typename V>
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
-
- template <typename Tag, typename V, typename V2>
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs);
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::object_id()
- : id_(mln_max(V))
- {
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>::object_id(const V2& id)
- : id_(id)
- {
- mlc_converts_to(V2,V)::check();
- }
-
- template <typename Tag, typename V>
- template <typename Tag2, typename V2>
- inline
- object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
- {
- typedef object_id<Tag2,V2> id_t;
- mlc_abort(id_t)::check();
- }
-
- template <typename Tag, typename V>
- template <typename V2>
- inline
- object_id<Tag,V>&
- object_id<Tag,V>::operator=(const V2& v)
- {
- mlc_converts_to(V2,V)::check();
-
- id_ = v;
- return *this;
- }
-
- template <typename Tag, typename V>
- inline
- V&
- object_id<Tag,V>::value()
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- const V&
- object_id<Tag,V>::value() const
- {
- return id_;
- }
-
- template <typename Tag, typename V>
- inline
- object_id<Tag,V>::operator unsigned() const
- {
- return id_;
- }
-
-
- template <typename Tag, typename V>
- inline
- bool
- object_id<Tag,V>::is_valid() const
- {
- return id_ != mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- void
- object_id<Tag,V>::invalidate()
- {
- id_ = mln_max(V);
- }
-
- template <typename Tag, typename V>
- inline
- unsigned
- object_id<Tag,V>::to_equiv() const
- {
- return id_;
- }
-
-
-
-
- template <typename Tag, typename V>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
- {
- return lhs.value() == rhs.value();
- }
-
- template <typename Tag, typename V, typename V2>
- inline
- bool
- operator==(const object_id<Tag,V>& lhs, const Value<V2>& rhs)
- {
- return lhs.value() == exact(rhs).to_equiv();
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
-} // end of namespace mln
-
-#endif // ! MLN_CORE_CONCEPT_OBJECT_ID_HH
-
diff --git a/milena/mln/util/graph_ids.hh b/milena/mln/util/graph_ids.hh
index df3e981..2f9eab5 100644
--- a/milena/mln/util/graph_ids.hh
+++ b/milena/mln/util/graph_ids.hh
@@ -33,7 +33,7 @@
///
/// Definition of graph element ids.
-# include <mln/core/concept/object_id.hh>
+# include <mln/util/object_id.hh>
namespace mln
diff --git a/milena/mln/util/object_id.hh b/milena/mln/util/object_id.hh
new file mode 100644
index 0000000..b3ea879
--- /dev/null
+++ b/milena/mln/util/object_id.hh
@@ -0,0 +1,213 @@
+// 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.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#ifndef MLN_UTIL_OBJECT_ID_HH
+# define MLN_UTIL_OBJECT_ID_HH
+
+/// \file mln/core/concept/object_id.hh
+///
+/// Base class of an object id.
+
+
+# include <mln/core/concept/object.hh>
+# include <mln/value/concept/integer.hh>
+# include <mln/metal/abort.hh>
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ /// Base class of an object id.
+ /// \tparam Tag the tag type
+ /// \tparam Equiv the equivalent value.
+ template <typename Tag, typename V>
+ class object_id : public value::Integer< object_id<Tag, V> >
+ {
+ public:
+ /// The underlying type id.
+ typedef V value_t;
+ typedef unsigned equiv;
+ typedef V enc;
+
+ /// Constructors
+ /// @{
+ object_id();
+
+ template <typename V2>
+ object_id(const V2& id);
+
+ template <typename Tag2, typename V2>
+ object_id(const object_id<Tag2,V2>& other);
+ /// @}
+
+ template <typename V2>
+ object_id<Tag,V>& operator=(const V2& e);
+
+ const V& value() const;
+ V& value();
+
+ operator unsigned() const;
+
+ bool is_valid() const;
+ void invalidate();
+
+ unsigned to_equiv() const;
+
+ protected:
+ V id_;
+ };
+
+
+ template <typename Tag, typename V>
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+ template <typename Tag, typename V, typename V2>
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::object_id()
+ : id_(mln_max(V))
+ {
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>::object_id(const V2& id)
+ : id_(id)
+ {
+ mlc_converts_to(V2,V)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename Tag2, typename V2>
+ inline
+ object_id<Tag,V>::object_id(const object_id<Tag2,V2>& id)
+ {
+ typedef object_id<Tag2,V2> id_t;
+ mlc_abort(id_t)::check();
+ }
+
+ template <typename Tag, typename V>
+ template <typename V2>
+ inline
+ object_id<Tag,V>&
+ object_id<Tag,V>::operator=(const V2& v)
+ {
+ mlc_converts_to(V2,V)::check();
+
+ id_ = v;
+ return *this;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ V&
+ object_id<Tag,V>::value()
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ const V&
+ object_id<Tag,V>::value() const
+ {
+ return id_;
+ }
+
+ template <typename Tag, typename V>
+ inline
+ object_id<Tag,V>::operator unsigned() const
+ {
+ return id_;
+ }
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ object_id<Tag,V>::is_valid() const
+ {
+ return id_ != mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ void
+ object_id<Tag,V>::invalidate()
+ {
+ id_ = mln_max(V);
+ }
+
+ template <typename Tag, typename V>
+ inline
+ unsigned
+ object_id<Tag,V>::to_equiv() const
+ {
+ return id_;
+ }
+
+
+
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator==(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() == rhs.value();
+ }
+
+ template <typename Tag, typename V>
+ inline
+ bool
+ operator<(const object_id<Tag,V>& lhs, const object_id<Tag,V>& rhs)
+ {
+ return lhs.value() < rhs.value();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_OBJECT_ID_HH
+
--
1.6.1.2
1
0
* mln/debug/colorize.hh: move...
* mln/labeling/colorize.hh: ... here.
* tests/labeling/Makefile.am,
* tests/labeling/colorize.cc: add a new test.
---
milena/ChangeLog | 10 +++++
milena/mln/{debug => labeling}/colorize.hh | 40 ++++++++++++++++---
milena/tests/labeling/Makefile.am | 2 +
milena/tests/labeling/colorize.cc | 56 ++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 7 deletions(-)
rename milena/mln/{debug => labeling}/colorize.hh (80%)
create mode 100644 milena/tests/labeling/colorize.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c69383e..4430b6c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move debug::colorize to labeling::colorize.
+
+ * mln/debug/colorize.hh: move...
+ * mln/labeling/colorize.hh: ... here.
+
+ * tests/labeling/Makefile.am,
+ * tests/labeling/colorize.cc: add a new test.
+
2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and new stuff.
diff --git a/milena/mln/debug/colorize.hh b/milena/mln/labeling/colorize.hh
similarity index 80%
rename from milena/mln/debug/colorize.hh
rename to milena/mln/labeling/colorize.hh
index 4f492bf..49b1f63 100644
--- a/milena/mln/debug/colorize.hh
+++ b/milena/mln/labeling/colorize.hh
@@ -29,7 +29,7 @@
#ifndef MLN_DEBUG_COLORIZE_HH
# define MLN_DEBUG_COLORIZE_HH
-/// \file mln/debug/colorize.hh
+/// \file mln/labeling/colorize.hh
///
/// Fill an image with successive values.
@@ -38,12 +38,14 @@
# include <mln/value/rgb8.hh>
# include <mln/literal/black.hh>
# include <mln/level/transform.hh>
+# include <mln/level/compute.hh>
+# include <mln/accu/max.hh>
namespace mln
{
- namespace debug
+ namespace labeling
{
namespace colorize_
@@ -58,8 +60,8 @@ namespace mln
/*!
* litera::black is used for component 0, e.g. the background.
* Min and max values for RGB values can be set through the global
- * variables mln::debug::colorize_::min_value and
- * mln::debug::colorize_::max_value.
+ * variables mln::labeling::colorize_::min_value and
+ * mln::labeling::colorize_::max_value.
*
* \param[in] value value type used in the returned image.
* \param[in] labeled_image A labeled image (\sa labeling::blobs).
@@ -72,6 +74,12 @@ namespace mln
const mln_value(L)& nlabels);
+ template <typename V, typename L>
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& labeled_image);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace colorize_
@@ -105,7 +113,7 @@ namespace mln
const Image<L>& input,
const mln_value(L)& nlabels)
{
- trace::entering("debug::colorize");
+ trace::entering("labeling::colorize");
mln_precondition(exact(input).is_valid());
// FIXME: check that V is a color type.
// FIXME: we want to be sure that this is a label.
@@ -132,13 +140,31 @@ namespace mln
mln_assertion(f.size() >= (label_count));
mln_ch_value(L, V) output = level::transform(input, f);
- trace::exiting("debug::colorize");
+ trace::exiting("labeling::colorize");
+ return output;
+ }
+
+ template <typename V, typename L>
+ inline
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& input)
+ {
+ trace::entering("labeling::colorize");
+ mln_precondition(exact(input).is_valid());
+
+ accu::max<mln_value(L)> accu;
+ mln_value(L) nlabels = level::compute(accu, input);
+
+ mln_ch_value(L,V) output = colorize(value, input, nlabels);
+
+ trace::exiting("labeling::colorize");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::debug
+ } // end of namespace mln::labeling
} // end of namespace mln
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 411674e..0dfb121 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
background \
blobs \
+ colorize \
compute \
fill_holes \
flat_zones \
@@ -20,6 +21,7 @@ check_PROGRAMS = \
background_SOURCES = background.cc
blobs_SOURCES = blobs.cc
+colorize_SOURCES = colorize.cc
compute_SOURCES = compute.cc
fill_holes_SOURCES = fill_holes.cc
flat_zones_SOURCES = flat_zones.cc
diff --git a/milena/tests/labeling/colorize.cc b/milena/tests/labeling/colorize.cc
new file mode 100644
index 0000000..e424473
--- /dev/null
+++ b/milena/tests/labeling/colorize.cc
@@ -0,0 +1,56 @@
+// 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.
+
+/// \file tests/labeling/colorize.cc
+///
+/// Test on mln::labeling::colorize.
+
+# include <mln/make/image.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/labeling/colorize.hh>
+# include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ value::int_u8 values[][2] = { { 3, 3 },
+ { 0, 0 } };
+
+ typedef value::rgb8 rgb_t;
+ value::rgb8 ref_data[][2] = { { rgb_t(89,92,86), rgb_t(89,92,86) },
+ { rgb_t(0,0,0), rgb_t(0,0,0) } };
+
+ image2d<value::int_u8> ima = make::image(values);
+ image2d<rgb_t> ref = make::image(ref_data);
+
+ image2d<value::rgb8> ima_color = labeling::colorize(value::rgb8(), ima);
+
+ mln_assertion(ref == ima_color);
+}
--
1.5.6.5
1
0
* mln/debug/colorize.hh: move...
* mln/labeling/colorize.hh: ... here.
* tests/labeling/Makefile.am,
* tests/labeling/colorize.cc: add a new test.
---
milena/ChangeLog | 10 +++++
milena/mln/{debug => labeling}/colorize.hh | 40 ++++++++++++++++---
milena/tests/labeling/Makefile.am | 2 +
milena/tests/labeling/colorize.cc | 56 ++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 7 deletions(-)
rename milena/mln/{debug => labeling}/colorize.hh (80%)
create mode 100644 milena/tests/labeling/colorize.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c69383e..4430b6c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-07 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Move debug::colorize to labeling::colorize.
+
+ * mln/debug/colorize.hh: move...
+ * mln/labeling/colorize.hh: ... here.
+
+ * tests/labeling/Makefile.am,
+ * tests/labeling/colorize.cc: add a new test.
+
2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and new stuff.
diff --git a/milena/mln/debug/colorize.hh b/milena/mln/labeling/colorize.hh
similarity index 80%
rename from milena/mln/debug/colorize.hh
rename to milena/mln/labeling/colorize.hh
index 4f492bf..49b1f63 100644
--- a/milena/mln/debug/colorize.hh
+++ b/milena/mln/labeling/colorize.hh
@@ -29,7 +29,7 @@
#ifndef MLN_DEBUG_COLORIZE_HH
# define MLN_DEBUG_COLORIZE_HH
-/// \file mln/debug/colorize.hh
+/// \file mln/labeling/colorize.hh
///
/// Fill an image with successive values.
@@ -38,12 +38,14 @@
# include <mln/value/rgb8.hh>
# include <mln/literal/black.hh>
# include <mln/level/transform.hh>
+# include <mln/level/compute.hh>
+# include <mln/accu/max.hh>
namespace mln
{
- namespace debug
+ namespace labeling
{
namespace colorize_
@@ -58,8 +60,8 @@ namespace mln
/*!
* litera::black is used for component 0, e.g. the background.
* Min and max values for RGB values can be set through the global
- * variables mln::debug::colorize_::min_value and
- * mln::debug::colorize_::max_value.
+ * variables mln::labeling::colorize_::min_value and
+ * mln::labeling::colorize_::max_value.
*
* \param[in] value value type used in the returned image.
* \param[in] labeled_image A labeled image (\sa labeling::blobs).
@@ -72,6 +74,12 @@ namespace mln
const mln_value(L)& nlabels);
+ template <typename V, typename L>
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& labeled_image);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace colorize_
@@ -105,7 +113,7 @@ namespace mln
const Image<L>& input,
const mln_value(L)& nlabels)
{
- trace::entering("debug::colorize");
+ trace::entering("labeling::colorize");
mln_precondition(exact(input).is_valid());
// FIXME: check that V is a color type.
// FIXME: we want to be sure that this is a label.
@@ -132,13 +140,31 @@ namespace mln
mln_assertion(f.size() >= (label_count));
mln_ch_value(L, V) output = level::transform(input, f);
- trace::exiting("debug::colorize");
+ trace::exiting("labeling::colorize");
+ return output;
+ }
+
+ template <typename V, typename L>
+ inline
+ mln_ch_value(L, V)
+ colorize(const V& value,
+ const Image<L>& input)
+ {
+ trace::entering("labeling::colorize");
+ mln_precondition(exact(input).is_valid());
+
+ accu::max<mln_value(L)> accu;
+ mln_value(L) nlabels = level::compute(accu, input);
+
+ mln_ch_value(L,V) output = colorize(value, input, nlabels);
+
+ trace::exiting("labeling::colorize");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::debug
+ } // end of namespace mln::labeling
} // end of namespace mln
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 411674e..0dfb121 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
background \
blobs \
+ colorize \
compute \
fill_holes \
flat_zones \
@@ -20,6 +21,7 @@ check_PROGRAMS = \
background_SOURCES = background.cc
blobs_SOURCES = blobs.cc
+colorize_SOURCES = colorize.cc
compute_SOURCES = compute.cc
fill_holes_SOURCES = fill_holes.cc
flat_zones_SOURCES = flat_zones.cc
diff --git a/milena/tests/labeling/colorize.cc b/milena/tests/labeling/colorize.cc
new file mode 100644
index 0000000..e424473
--- /dev/null
+++ b/milena/tests/labeling/colorize.cc
@@ -0,0 +1,56 @@
+// 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.
+
+/// \file tests/labeling/colorize.cc
+///
+/// Test on mln::labeling::colorize.
+
+# include <mln/make/image.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/labeling/colorize.hh>
+# include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ value::int_u8 values[][2] = { { 3, 3 },
+ { 0, 0 } };
+
+ typedef value::rgb8 rgb_t;
+ value::rgb8 ref_data[][2] = { { rgb_t(89,92,86), rgb_t(89,92,86) },
+ { rgb_t(0,0,0), rgb_t(0,0,0) } };
+
+ image2d<value::int_u8> ima = make::image(values);
+ image2d<rgb_t> ref = make::image(ref_data);
+
+ image2d<value::rgb8> ima_color = labeling::colorize(value::rgb8(), ima);
+
+ mln_assertion(ref == ima_color);
+}
--
1.6.1.2
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Several fixes and new stuff.
Starting revamping world inter-pixel.
* mln/world/inter_pixel/image2full.hh: Rename as...
* mln/world/inter_pixel/immerse.hh: ...this new file.
(image2full): Rename as...
(immerse): ...this.
Revamp.
* mln/world/inter_pixel/separator_to_pixels.hh: New.
* mln/world/inter_pixel/is_separator.hh: New.
* mln/world/inter_pixel/is_pixel.hh: New.
* mln/world/inter_pixel/compute.hh: New.
* mln/world/inter_pixel/make: New directory.
* mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
* mln/world/inter_pixel/display_edge.hh: Likewise.
* mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
* mln/core/point.hh (point): Fix warning.
Add static check.
* mln/core/internal/image_morpher.hh (unmorph): New typedef.
* mln/core/internal/pixel_impl.hh
(pixel_impl_): Fix compile errors with g++-3.4.
* mln/core/concept/gpoint.hh (operator*): New overload with scalar.
(trait): New corresponding trait.
* tests/world/inter_pixel/compute.cc: New.
* tests/world/inter_pixel/immerse.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
Fix missing code for operator less with builtins.
* mln/value/builtin/ops.hh:
(mln_internal_decl_op_less_): New.
(mln_internal_def_op_less_): New.
(mln_internal_builtins_op_less_): New.
Misc.
* mln/accu/stat/all.hh: New.
* mln/accu/all.hh: Update.
* mln/convert/to_fun.hh: Upgrade doc style.
* mln/data/paste_without_localization.hh: New.
* mln/data/paste.hh: New static check.
* mln/fun/c.hh: Likewise.
Fix ending guard.
Augmenting accumulators.
* mln/accu/stat/var.hh (mean_t): New typedef.
(to_result, mean): Fix null_ construction.
* tests/accu/stat: New directory.
* tests/accu/stat/Makefile.am: New.
* tests/accu/stat/var.cc: New.
* tests/accu/Makefile.am: Update.
Augmenting fun :-)
* mln/fun/access: New directory.
* mln/fun/access/all.hh: New.
* mln/fun/access/mean.hh: New.
* mln/fun/all.hh: Update.
* mln/fun/stat: New.
* mln/fun/stat/all.hh: New.
* mln/fun/stat/mahalanobis.hh: New.
* tests/fun/stat: New.
* tests/fun/stat/mahalanobis.cc: New.
* tests/fun/stat/Makefile.am: New.
* tests/fun/Makefile.am: Update.
mln/accu/all.hh | 1
mln/accu/stat/all.hh | 53 +++++++++++
mln/accu/stat/var.hh | 14 ++-
mln/convert/to_fun.hh | 10 +-
mln/core/concept/gpoint.hh | 32 ++++++-
mln/core/internal/image_morpher.hh | 4
mln/core/internal/pixel_impl.hh | 14 +--
mln/core/macros.hh | 10 ++
mln/core/point.hh | 11 +-
mln/data/paste.hh | 6 -
mln/data/paste_without_localization.hh | 93 ++++++++++++++++++++
mln/fun/access/all.hh | 52 +++++++++++
mln/fun/access/mean.hh | 91 +++++++++++++++++++
mln/fun/all.hh | 18 +--
mln/fun/c.hh | 14 +--
mln/fun/stat/all.hh | 54 +++++++++++
mln/fun/stat/mahalanobis.hh | 95 ++++++++++++++++++++
mln/value/builtin/ops.hh | 76 +++++++++++++++-
mln/world/inter_pixel/compute.hh | 99 +++++++++++++++++++++
mln/world/inter_pixel/display_edge.hh | 2
mln/world/inter_pixel/immerse.hh | 63 +++++++------
mln/world/inter_pixel/is_pixel.hh | 47 +++++++---
mln/world/inter_pixel/is_separator.hh | 91 +++++++++++++++++++
mln/world/inter_pixel/neighb2d.hh | 2
mln/world/inter_pixel/separator_to_pixels.hh | 123 +++++++++++++++++++++++++++
tests/accu/Makefile.am | 3
tests/accu/stat/Makefile.am | 10 ++
tests/accu/stat/var.cc | 73 ++++++++++++++++
tests/fun/Makefile.am | 10 +-
tests/fun/stat/Makefile.am | 10 ++
tests/fun/stat/mahalanobis.cc | 74 ++++++++++++++++
tests/world/inter_pixel/Makefile.am | 4
tests/world/inter_pixel/compute.cc | 87 +++++++++++++++++++
tests/world/inter_pixel/immerse.cc | 46 +++++-----
34 files changed, 1274 insertions(+), 118 deletions(-)
Index: mln/world/inter_pixel/immerse.hh
--- mln/world/inter_pixel/immerse.hh (revision 3759)
+++ mln/world/inter_pixel/immerse.hh (working copy)
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IMMERSE_HH
+# define MLN_WORLD_INTER_PIXEL_IMMERSE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/immerse.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Convert a classical image to an inter-pixel image.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/paste_without_localization.hh>
+# include <mln/geom/nsites.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
namespace mln
@@ -50,44 +47,48 @@
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
+ /// Convert an image to an inter-pixel image.
///
+ /// \param[in] input An image.
/// \return An inter-pixel image.
//
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I>
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+ template <typename I>
+ inline
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input_)
{
- trace::entering("world::inter_pixel::image2full");
+ trace::entering("world::inter_pixel::immerse");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_domain(I) b(2 * input.domain().pmin(),
+ 2 * input.domain().pmax());
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+ data::paste_without_localization(input, (output | is_pixel()).rw());
+ trace::exiting("world::inter_pixel::immerse");
+ return output | is_pixel();
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IMMERSE_HH
Property changes on: mln/world/inter_pixel/immerse.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/world/inter_pixel/neighb2d.hh
--- mln/world/inter_pixel/neighb2d.hh (revision 3767)
+++ mln/world/inter_pixel/neighb2d.hh (working copy)
@@ -101,4 +101,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
Index: mln/world/inter_pixel/separator_to_pixels.hh
--- mln/world/inter_pixel/separator_to_pixels.hh (revision 0)
+++ mln/world/inter_pixel/separator_to_pixels.hh (revision 0)
@@ -0,0 +1,123 @@
+// 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_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+# define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+
+/// \file mln/world/inter_pixel/separator_to_pixels.hh
+///
+/// FIXME: doc.
+///
+/// \todo Generalize to n-D.
+
+# include <mln/core/concept/gpoint.hh>
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename P>
+ void
+ separator_to_pixels(const Gpoint<P>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+ template <typename Ps, typename P>
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ inline
+ void
+ separator_to_pixels(const Gpoint<P>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const P& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ // FIXME: 2D only.
+ if (s.row() % 2)
+ {
+ // Horizontal edge.
+ p1 = point2d(s.row() - 1, s.col());
+ p2 = point2d(s.row() + 1, s.col());
+ }
+ else
+ {
+ // Vertical edge.
+ p1 = point2d(s.row(), s.col() - 1);
+ p2 = point2d(s.row(), s.col() + 1);
+ }
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+ template <typename Ps, typename P>
+ inline
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const Ps& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ separator_to_pixels(s.to_site(), p1, p2);
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
Index: mln/world/inter_pixel/display_edge.hh
--- mln/world/inter_pixel/display_edge.hh (revision 3767)
+++ mln/world/inter_pixel/display_edge.hh (working copy)
@@ -82,4 +82,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE
+#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
Index: mln/world/inter_pixel/is_separator.hh
--- mln/world/inter_pixel/is_separator.hh (revision 0)
+++ mln/world/inter_pixel/is_separator.hh (revision 0)
@@ -0,0 +1,91 @@
+// 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_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+# define MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+
+/// \file mln/world/inter_pixel/is_separator.hh
+///
+/// FIXME: doc.
+///
+/// \todo Make it work in n-D.
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ struct is_separator : public Function_p2b< is_separator >
+ {
+ typedef bool result;
+
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ return p.row() % 2 + p.col() % 2 == 1;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
Index: mln/world/inter_pixel/is_pixel.hh
--- mln/world/inter_pixel/is_pixel.hh (revision 3759)
+++ mln/world/inter_pixel/is_pixel.hh (working copy)
@@ -25,14 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
-# define MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
+# define MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
-/// \file mln/world/inter_pixel/dim2d/is_pixel.hh
+/// \file mln/world/inter_pixel/is_pixel.hh
///
-/// FIXME: insert comment.
+/// FIXME: doc.
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
-# include <mln/core/alias/point2d.hh>
namespace mln
{
@@ -43,29 +46,43 @@
namespace inter_pixel
{
- namespace dim2
- {
-
struct is_pixel : public Function_p2b< is_pixel >
{
typedef bool result;
- bool operator()(const point2d& p) const;
+
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
};
# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
inline
bool
- is_pixel::operator()(const point2d& p) const
+ is_pixel::operator()(const Gpoint<P>& p_) const
{
- return p.row() % 2 == 0 && p.col() % 2 == 0;
+ const P& p = exact(p_);
+ const unsigned n = P::dim;
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] % 2 == 1)
+ return false;
+ return true;
}
-# endif // ! MLN_INCLUDE_ONLY
-
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
- } // end of namespace mln::world::inter_pixel::dim2
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::world::inter_pixel
@@ -73,4 +90,4 @@
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
Property changes on: mln/world/inter_pixel/is_pixel.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/world/inter_pixel/compute.hh
--- mln/world/inter_pixel/compute.hh (revision 0)
+++ mln/world/inter_pixel/compute.hh (revision 0)
@@ -0,0 +1,99 @@
+// 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_WORLD_INTER_PIXEL_COMPUTE_HH
+# define MLN_WORLD_INTER_PIXEL_COMPUTE_HH
+
+/// \file mln/world/inter_pixel/compute.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename I, typename F>
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input, const Function_vv2v<F>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ inline
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input_, const Function_vv2v<F>& f_)
+ {
+ trace::entering("world::inter_pixel::compute");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
+
+ mln_precondition(input.is_valid());
+
+ typedef mln_unmorph(I) I_;
+ typedef mln_ch_value(I_, mln_result(F)) O_;
+ O_ output_;
+ initialize(output_, input.unmorph_());
+
+ typedef image_if<O_, is_separator> O;
+ O output(output_, is_separator());
+
+ mln_piter(O) e(output.domain());
+ for_all(e)
+ {
+ mln_site(I) p1, p2;
+ separator_to_pixels(e, p1, p2);
+ output(e) = f(input(p1), input(p2));
+ }
+
+ trace::exiting("world::inter_pixel::compute");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_COMPUTE_HH
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 3767)
+++ mln/core/macros.hh (working copy)
@@ -372,6 +372,16 @@
+// u
+
+/// Shortcuts to access the unmorph type associated to T.
+/// \{
+# define mln_unmorph(T) typename T::unmorph
+# define mln_unmorph_(T) T::unmorph
+/// \}
+
+
+
// v
/// Shortcuts to access the value type associated to T.
Index: mln/core/point.hh
--- mln/core/point.hh (revision 3767)
+++ mln/core/point.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 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
@@ -294,16 +294,17 @@
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
+ mlc_converts_to(C2, C)::check();
unsigned j = 0;
- //FIXME: to be improved.
+ //FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
- coord_[i] = v[j++];
+ coord_[i] = static_cast<C>(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
- coord_[i-j] = v[j];
+ coord_[i-j] = static_cast<C>(v[j]);
}
}
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 3767)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -64,6 +64,10 @@
I* delegatee_();
+
+ /// Unmorph image associated type.
+ typedef I unmorph;
+
/// Give the morphed image (mutable version).
I& unmorph_();
Index: mln/core/internal/pixel_impl.hh
--- mln/core/internal/pixel_impl.hh (revision 3767)
+++ mln/core/internal/pixel_impl.hh (working copy)
@@ -233,7 +233,7 @@
bool
pixel_impl_<I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -249,7 +249,7 @@
pixel_impl_<I, E>::val()
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -258,7 +258,7 @@
pixel_impl_<I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -267,7 +267,7 @@
pixel_impl_<I, E>::ima() const
{
// a const pixel, yet a mutable image
- return const_cast<I&>(image_);
+ return const_cast<I&>(this->image_);
}
template <typename I, typename E>
@@ -286,7 +286,7 @@
bool
pixel_impl_<const I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -302,7 +302,7 @@
pixel_impl_<const I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -310,7 +310,7 @@
const I&
pixel_impl_<const I, E>::ima() const
{
- return image_;
+ return this->image_;
}
template <typename I, typename E>
Index: mln/core/concept/gpoint.hh
--- mln/core/concept/gpoint.hh (revision 3767)
+++ mln/core/concept/gpoint.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
-# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
# include <mln/debug/format.hh>
@@ -74,6 +74,14 @@
typedef mln_delta(L) ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::times,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
+
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -200,7 +208,7 @@
- /// Substract a delta-point \p rhs to a grid point \p lhs.
+ /// Substract a delta-point \p dp to a grid point \p p.
///
/*! \param[in] p A grid point.
* \param[in] dp A delta-point.
@@ -217,6 +225,13 @@
operator-(const Gpoint<P>& p, const Gdpoint<D>& dp);
+ /// Multiply a point \p p by a scalar \p s.
+ //
+ template <typename P, typename S>
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s);
+
+
/// Print a grid point \p p into the output stream \p ostr.
/*! \param[in,out] ostr An output stream.
* \param[in] p A grid point.
@@ -380,6 +395,19 @@
return tmp;
}
+ template <typename P, typename S>
+ inline
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
+ {
+ int s_ = s.to_equiv();
+ const unsigned n = P::dim;
+ P tmp = exact(p);
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] *= s_;
+ return tmp;
+ }
+
template <typename P>
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>& p)
Index: mln/data/paste_without_localization.hh
--- mln/data/paste_without_localization.hh (revision 0)
+++ mln/data/paste_without_localization.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+# define MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+
+/// \file mln/data/paste_without_localization.hh
+///
+/// Paste the contents of an image into another one without taking
+/// into account the localization of sites.
+
+# include <mln/core/concept/image.hh>
+
+
+
+namespace mln
+{
+
+ namespace data
+ {
+
+ /// \brief Paste the contents of image \p input into the image \p
+ /// output without taking into account the localization of sites.
+ ///
+ /// \param[in] input The input image providing pixels values.
+ /// \param[in,out] output The image in which values are
+ /// assigned.
+ //
+ template <typename I, typename J>
+ void paste_without_localization(const Image<I>& input, Image<J>& output);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename J>
+ inline
+ void paste_without_localization(const Image<I>& input_, Image<J>& output_)
+ {
+ trace::entering("data::paste_without_localization");
+
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ mln_fwd_piter(I) pi(input.domain());
+ pi.start();
+ mln_fwd_piter(J) po(output.domain());
+ po.start();
+ while (pi.is_valid() && po.is_valid())
+ {
+ output(po) = input(pi);
+ pi.next();
+ po.next();
+ }
+
+ trace::exiting("data::paste_without_localization");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::data
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
Index: mln/data/paste.hh
--- mln/data/paste.hh (revision 3767)
+++ mln/data/paste.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 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
@@ -129,6 +129,8 @@
{
trace::entering("data::paste");
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
internal::paste_tests(input, output);
internal::paste_dispatch(input, output);
Index: mln/accu/all.hh
--- mln/accu/all.hh (revision 3767)
+++ mln/accu/all.hh (working copy)
@@ -99,6 +99,7 @@
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
+# include <mln/accu/stat/all.hh>
#endif // ! MLN_ACCU_ALL_HH
Index: mln/accu/stat/var.hh
--- mln/accu/stat/var.hh (revision 3767)
+++ mln/accu/stat/var.hh (working copy)
@@ -40,6 +40,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/util/pix.hh>
+
namespace mln
{
@@ -84,8 +85,13 @@
/// Get the number of items.
unsigned n_items() const;
+
+ /// Type equipment.
+ typedef algebra::vec<dim,float> mean_t;
+ // ...
+
/// Get the mean vector.
- algebra::vec<dim,float> mean() const;
+ mean_t mean() const;
/// Check whether this accu returns a valid result.
bool is_valid() const;
@@ -163,7 +169,7 @@
mln_result(var<T>)
var<T>::to_result() const
{
- static result null_(fun::i2v::all_to(0));
+ static result null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
@@ -192,10 +198,10 @@
template <typename T>
inline
- algebra::vec<dim,float>
+ typename var<T>::mean_t
var<T>::mean() const
{
- static algebra::vec<dim,float> null_(fun::i2v::all_to(0));
+ static algebra::vec<dim,float> null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
Index: mln/accu/stat/all.hh
--- mln/accu/stat/all.hh (revision 0)
+++ mln/accu/stat/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// 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_STAT_ALL_HH
+# define MLN_ACCU_STAT_ALL_HH
+
+/// \file mln/accu/stat/all.hh
+///
+/// File that includes all statistical accumulator types.
+
+
+namespace mln
+{
+ namespace accu
+ {
+
+ /// Namespace of statistical accumulators.
+ namespace stat {}
+
+ }
+}
+
+
+# include <mln/accu/stat/deviation.hh>
+# include <mln/accu/stat/var.hh>
+# include <mln/accu/stat/variance.hh>
+
+
+#endif // ! MLN_ACCU_STAT_ALL_HH
Index: mln/value/builtin/ops.hh
--- mln/value/builtin/ops.hh (revision 3767)
+++ mln/value/builtin/ops.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,11 +29,10 @@
#ifndef MLN_VALUE_BUILTIN_OPS_HH
# define MLN_VALUE_BUILTIN_OPS_HH
-/*! \file mln/value/builtin/ops.hh
- *
- * \brief Definitions of binary operators when lhs is a built-in and
- * rhs is an mln object.
- */
+/// \file mln/value/builtin/ops.hh
+///
+/// Definitions of binary operators when lhs is a built-in and
+/// rhs is an mln object.
# include <mln/value/scalar.hh>
# include <mln/trait/op/all.hh>
@@ -149,6 +149,7 @@
+
# define mln_internal_op_obj_builtins_(De, Symb, Name) \
\
mln_internal_##De##_op_obj_bi_(Symb, Name, signed char); \
@@ -317,6 +318,55 @@
+
+// Operator less (<) is a special case.
+
+# define mln_internal_decl_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs); \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_def_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs) \
+ { \
+ return exact(lhs) Symb value::scalar(rhs); \
+ } \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs) \
+ { \
+ return value::scalar(lhs) Symb exact(rhs); \
+ } \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_builtins_op_less_(De, Symb, Name) \
+ \
+ mln_internal_##De##_op_less_(Symb, Name, signed char); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned char); \
+ mln_internal_##De##_op_less_(Symb, Name, signed short); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned short); \
+ mln_internal_##De##_op_less_(Symb, Name, signed int); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned int); \
+ mln_internal_##De##_op_less_(Symb, Name, signed long); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned long); \
+ mln_internal_##De##_op_less_(Symb, Name, float); \
+ mln_internal_##De##_op_less_(Symb, Name, double); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
// FIXME: What about pointers, arrays, bool, etc.
// FIXME: Mod is not defined for float and double...
@@ -468,6 +518,12 @@
typedef mln_trait_op_less(O, mln::value::scalar_<B>) ret;
};
+ template <typename B, typename O>
+ struct set_binary_< op::less, mln::value::Built_In, B, mln::Object, O >
+ {
+ typedef mln_trait_op_less(mln::value::scalar_<B>, O) ret;
+ };
+
// 'Op+' is commutative so "o + b" => "o + scalar(b)".
@@ -548,6 +604,10 @@
mln_internal_builtins_opeq_obj_(decl, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(decl, <, less);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -583,6 +643,10 @@
mln_internal_builtins_opeq_obj_(def, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(def, <, less);
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/convert/to_fun.hh
--- mln/convert/to_fun.hh (revision 3767)
+++ mln/convert/to_fun.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,10 +29,9 @@
#ifndef MLN_CONVERT_TO_FUN_HH
# define MLN_CONVERT_TO_FUN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/convert/to_fun.hh
+///
+/// Conversions towards some mln::Function.
# include <mln/pw/value.hh>
# include <mln/fun/c.hh>
Index: mln/fun/c.hh
--- mln/fun/c.hh (revision 3767)
+++ mln/fun/c.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,11 +29,10 @@
#ifndef MLN_FUN_C_HH
# define MLN_FUN_C_HH
-/*! \file mln/fun/c.hh
- *
- * \brief Encapsulate a plain (C language-like) pointer to function
- * into a functor.
- */
+/// \file mln/fun/c.hh
+///
+/// Encapsulate a plain (C language-like) pointer to function
+/// into a functor.
# include <mln/fun/internal/selector.hh>
# include <mln/metal/unqualif.hh>
@@ -137,4 +137,4 @@
} // end of namespace mln
-#endif // ! MLN_FUN_P2B_C_HH
+#endif // ! MLN_FUN_C_HH
Index: mln/fun/access/all.hh
--- mln/fun/access/all.hh (revision 0)
+++ mln/fun/access/all.hh (revision 0)
@@ -0,0 +1,52 @@
+// 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_FUN_ACCESS_ALL_HH
+# define MLN_FUN_ACCESS_ALL_HH
+
+/// \file mln/fun/access/all.hh
+///
+/// File that includes all access functions.
+
+
+namespace mln
+{
+ namespace fun
+ {
+
+ /// Namespace for access functions.
+ namespace access
+ {}
+
+ }
+}
+
+
+# include <mln/fun/access/mean.hh>
+
+
+#endif // ! MLN_FUN_ACCESS_ALL_HH
Index: mln/fun/access/mean.hh
--- mln/fun/access/mean.hh (revision 0)
+++ mln/fun/access/mean.hh (revision 0)
@@ -0,0 +1,91 @@
+// 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 F 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_FUN_ACCESS_MEAN_HH
+# define MLN_FUN_ACCESS_MEAN_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace access
+ {
+
+ struct mean : unary<mean>
+ {
+ };
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct method_mean
+ {
+ typedef method_mean ret;
+
+ typedef typename T::mean_t result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return x.mean();
+ }
+ };
+
+ }
+
+ } // end of namespace mln::access
+
+ } // end of namespace mln
+
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename A>
+ struct set_unary_< fun::access::mean,
+ Accumulator, A > : fun::access::internal::method_mean<A>
+ {
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_ACCESS_MEAN_HH
Index: mln/fun/all.hh
--- mln/fun/all.hh (revision 3767)
+++ mln/fun/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/all.hh
+///
+/// File that includes all fun-related routines.
namespace mln
@@ -43,25 +43,25 @@
/// Internal namespace of functions.
namespace internal
- {
- }
- }
+ {}
}
+}
# include <mln/fun/c.hh>
# include <mln/fun/ops.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/fun/meta/all.hh>
# include <mln/fun/p2b/all.hh>
# include <mln/fun/p2v/all.hh>
+# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
# include <mln/fun/x2v/all.hh>
# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
#endif // ! MLN_FUN_ALL_HH
Index: mln/fun/stat/all.hh
--- mln/fun/stat/all.hh (revision 0)
+++ mln/fun/stat/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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_FUN_STAT_ALL_HH
+# define MLN_FUN_STAT_ALL_HH
+
+/// \file mln/fun/stat/all.hh
+///
+/// File that includes all statistical functions.
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ /// \brief Namespace of statistical functions.
+ ///
+ /// \ingroup modfun
+ namespace stat {}
+
+ }
+}
+
+
+# include <mln/fun/stat/mahalanobis.hh>
+
+
+#endif // ! MLN_FUN_STAT_ALL_HH
Index: mln/fun/stat/mahalanobis.hh
--- mln/fun/stat/mahalanobis.hh (revision 0)
+++ mln/fun/stat/mahalanobis.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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_FUN_STAT_MAHALANOBIS_HH
+# define MLN_FUN_STAT_MAHALANOBIS_HH
+
+/// \file mln/fun/stat/mahalanobis.hh
+///
+/// Define the FIXME
+
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace stat
+ {
+
+ template <typename V>
+ struct mahalanobis
+ : public Function_v2v< mahalanobis<V> >,
+ private metal::equal< V, algebra::vec<V::dim,float> >::check_t
+ {
+ enum { n = V::dim };
+ typedef float result;
+
+ mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean);
+
+ float operator()(const V& v) const;
+
+ algebra::mat<n,n,float> var_1;
+ algebra::vec<n,float> mean;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean)
+ {
+ var_1 = var._1();
+ mean = mean;
+ }
+
+ template <typename V>
+ inline
+ float
+ mahalanobis<V>::operator()(const V& v) const
+ {
+ return (v - mean).t() * var_1 * (v - mean);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::stat
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_X2V_NORM_MAHALANOBIS_HH
Index: tests/world/inter_pixel/compute.cc
--- tests/world/inter_pixel/compute.cc (revision 0)
+++ tests/world/inter_pixel/compute.cc (revision 0)
@@ -0,0 +1,87 @@
+// 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.
+
+/// \file tests/world/inter_pixel/compute.cc
+///
+/// Tests on mln::world::inter_pixel::compute.
+
+#include <cmath>
+
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/compute.hh>
+
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/debug/println.hh>
+
+
+
+struct d_t : mln::Function_vv2v<d_t>
+{
+ typedef int result;
+
+ int operator()(int i1, int i2) const
+ {
+ return std::abs(i2 - i1);
+ }
+}
+ d;
+
+
+
+int main()
+{
+ using namespace mln;
+
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
+
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
+
+ using namespace world::inter_pixel;
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
+
+
+ int refs[] = { 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1,
+ 0, 2, 0, 3, 0,
+ 7, 0, 4, 0, 3,
+ 0, 1, 0, 4, 0 };
+
+ mln_assertion(compute(imax, d) == (make::image2d(refs) | is_separator()));
+
+ mln_VAR(g, compute(imax, d));
+
+ unsigned n_basins;
+ debug::println(morpho::watershed::flooding(g, e2e(), n_basins));
+}
Index: tests/world/inter_pixel/immerse.cc
--- tests/world/inter_pixel/immerse.cc (revision 3759)
+++ tests/world/inter_pixel/immerse.cc (working copy)
@@ -25,36 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/world/inter_pixel/image2full.cc
+/// \file tests/world/inter_pixel/immerse.cc
///
-/// Tests on mln::world::inter_pixel::image2full
+/// Tests on mln::world::inter_pixel::immerse.
+#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
-#include <mln/make/image.hh>
-#include <mln/value/int_u8.hh>
#include <mln/level/compare.hh>
-#include <mln/world/inter_pixel/image2full.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+
int main()
{
using namespace mln;
- value::int_u8 vals[][3] = { { 3, 4, 5 },
- { 1, 3, 6 },
- { 8, 7, 3 } } ;
-
- value::int_u8 refs[][5] = { { 3, 0, 4, 0, 5 },
- { 0, 0, 0, 0, 0 },
- { 1, 0, 3, 0, 6 },
- { 0, 0, 0, 0, 0 },
- { 8, 0, 7, 0, 3 } };
-
- typedef image2d<value::int_u8> ima_t;
- ima_t ima = make::image(vals);
- ima_t ref = make::image(refs);
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
+
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
+
+ using namespace world::inter_pixel;
+
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
+
- ima_t ima_l = world::inter_pixel::image2full(ima);
+ int refs[] = { 3, 0, 4, 0, 5,
+ 0, 0, 0, 0, 0,
+ 1, 0, 3, 0, 6,
+ 0, 0, 0, 0, 0,
+ 8, 0, 7, 0, 3 };
- mln_assertion(ima_l == ref);
+ mln_assertion(imax == (make::image2d(refs) | is_pixel()));
+ mln_piter_(Ix) p(imax.domain());
+ for_all(p)
+ mln_assertion(is_pixel()(p));
}
Property changes on: tests/world/inter_pixel/immerse.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/world/inter_pixel/Makefile.am
--- tests/world/inter_pixel/Makefile.am (revision 3767)
+++ tests/world/inter_pixel/Makefile.am (working copy)
@@ -6,8 +6,10 @@
dim2
check_PROGRAMS = \
- image2full
+ image2full \
+ immerse
image2full_SOURCES = image2full.cc
+immerse_SOURCES = immerse.cc
TESTS = $(check_PROGRAMS)
Index: tests/accu/Makefile.am
--- tests/accu/Makefile.am (revision 3767)
+++ tests/accu/Makefile.am (working copy)
@@ -4,7 +4,8 @@
SUBDIRS = \
image \
- site_set
+ site_set \
+ stat
check_PROGRAMS = \
all_accus \
Index: tests/accu/stat/Makefile.am
--- tests/accu/stat/Makefile.am (revision 0)
+++ tests/accu/stat/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ var
+
+var_SOURCES = var.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/accu/stat/var.cc
--- tests/accu/stat/var.cc (revision 0)
+++ tests/accu/stat/var.cc (revision 0)
@@ -0,0 +1,73 @@
+// 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.
+
+/// \file tests/accu/stat/var.cc
+///
+/// Tests on mln::accu::stat::var.
+
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+
+
+float my_rand(int c)
+{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef algebra::vec<3,float> vec3f;
+
+ enum { n = 1000 };
+ vec3f v[n];
+
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+
+ mln_assertion(a.n_items() == n);
+
+ vec3f m = a.mean();
+ mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+ mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+ mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ algebra::mat<3,3,float> s_1 = a.variance()._1();
+ mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+ mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+ mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
Index: tests/fun/Makefile.am
--- tests/fun/Makefile.am (revision 3767)
+++ tests/fun/Makefile.am (working copy)
@@ -2,4 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+SUBDIRS = \
+ i2v \
+ p2b \
+ p2p \
+ p2v \
+ stat \
+ v2v \
+ vv2v \
+ x2x
Index: tests/fun/stat/mahalanobis.cc
--- tests/fun/stat/mahalanobis.cc (revision 0)
+++ tests/fun/stat/mahalanobis.cc (revision 0)
@@ -0,0 +1,74 @@
+// 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.
+
+/// \file tests/fun/stat/mahalanobis.cc
+///
+/// Tests on mln::fun::stat::mahalanobis.
+
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+#include <mln/fun/stat/mahalanobis.hh>
+
+
+float my_rand(int c)
+{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef algebra::vec<3,float> vec3f;
+
+ enum { n = 1000 };
+ vec3f v[n];
+
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+
+// vec3f m = a.mean();
+// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+
+// algebra::mat<3,3,float> s_1 = a.variance()._1();
+// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
Property changes on: tests/fun/stat/mahalanobis.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/fun/stat/Makefile.am
--- tests/fun/stat/Makefile.am (revision 0)
+++ tests/fun/stat/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ mahalanobis
+
+mahalanobis_SOURCES = mahalanobis.cc
+
+TESTS = $(check_PROGRAMS)
1
0
Starting revamping world inter-pixel.
* mln/world/inter_pixel/image2full.hh: Rename as...
* mln/world/inter_pixel/immerse.hh: ...this new file.
(image2full): Rename as...
(immerse): ...this.
Revamp.
* mln/world/inter_pixel/separator_to_pixels.hh: New.
* mln/world/inter_pixel/is_separator.hh: New.
* mln/world/inter_pixel/is_pixel.hh: New.
* mln/world/inter_pixel/compute.hh: New.
* mln/world/inter_pixel/make: New directory.
* mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
* mln/world/inter_pixel/display_edge.hh: Likewise.
* mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
* mln/core/point.hh (point): Fix warning.
Add static check.
* mln/core/internal/image_morpher.hh (unmorph): New typedef.
* mln/core/internal/pixel_impl.hh
(pixel_impl_): Fix compile errors with g++-3.4.
* mln/core/concept/gpoint.hh (operator*): New overload with scalar.
(trait): New corresponding trait.
* tests/world/inter_pixel/compute.cc: New.
* tests/world/inter_pixel/immerse.cc: New.
* tests/world/inter_pixel/Makefile.am: Update.
Fix missing code for operator less with builtins.
* mln/value/builtin/ops.hh:
(mln_internal_decl_op_less_): New.
(mln_internal_def_op_less_): New.
(mln_internal_builtins_op_less_): New.
Misc.
* mln/accu/stat/all.hh: New.
* mln/accu/all.hh: Update.
* mln/convert/to_fun.hh: Upgrade doc style.
* mln/data/paste_without_localization.hh: New.
* mln/data/paste.hh: New static check.
* mln/fun/c.hh: Likewise.
Fix ending guard.
Augmenting accumulators.
* mln/accu/stat/var.hh (mean_t): New typedef.
(to_result, mean): Fix null_ construction.
* tests/accu/stat: New directory.
* tests/accu/stat/Makefile.am: New.
* tests/accu/stat/var.cc: New.
* tests/accu/Makefile.am: Update.
Augmenting fun :-)
* mln/fun/access: New directory.
* mln/fun/access/all.hh: New.
* mln/fun/access/mean.hh: New.
* mln/fun/all.hh: Update.
* mln/fun/stat: New.
* mln/fun/stat/all.hh: New.
* mln/fun/stat/mahalanobis.hh: New.
* tests/fun/stat: New.
* tests/fun/stat/mahalanobis.cc: New.
* tests/fun/stat/Makefile.am: New.
* tests/fun/Makefile.am: Update.
---
milena/ChangeLog | 70 +++++++++++
milena/mln/accu/all.hh | 1 +
milena/mln/{fun => accu/stat}/all.hh | 42 +++-----
milena/mln/accu/stat/var.hh | 16 ++-
milena/mln/convert/to_fun.hh | 10 +-
milena/mln/core/concept/gpoint.hh | 32 +++++-
milena/mln/core/internal/image_morpher.hh | 4 +
milena/mln/core/internal/pixel_impl.hh | 14 +-
milena/mln/core/macros.hh | 10 ++
milena/mln/core/point.hh | 11 +-
milena/mln/data/paste.hh | 6 +-
.../paste_without_localization.hh} | 88 +++++++-------
milena/mln/fun/{ => access}/all.hh | 39 ++-----
.../mln/{convert/to_fun.hh => fun/access/mean.hh} | 80 ++++++++------
milena/mln/fun/all.hh | 18 ++--
milena/mln/fun/c.hh | 14 +-
milena/mln/fun/{ => stat}/all.hh | 39 ++----
.../{convert/to_fun.hh => fun/stat/mahalanobis.hh} | 80 ++++++++-----
milena/mln/value/builtin/ops.hh | 76 +++++++++++-
.../inter_pixel/{image2full.hh => compute.hh} | 74 +++++++------
milena/mln/world/inter_pixel/display_edge.hh | 2 +-
.../inter_pixel/{image2full.hh => immerse.hh} | 63 +++++-----
.../inter_pixel/{image2full.hh => is_pixel.hh} | 76 ++++++------
.../inter_pixel/{image2full.hh => is_separator.hh} | 72 ++++++------
milena/mln/world/inter_pixel/neighb2d.hh | 2 +-
.../mln/world/inter_pixel/separator_to_pixels.hh | 123 ++++++++++++++++++++
milena/tests/accu/Makefile.am | 3 +-
milena/tests/{fun => accu/stat}/Makefile.am | 7 +-
milena/{mln/fun/all.hh => tests/accu/stat/var.cc} | 66 ++++++-----
milena/tests/fun/Makefile.am | 10 ++-
.../{world/inter_pixel => fun/stat}/Makefile.am | 9 +-
.../fun/all.hh => tests/fun/stat/mahalanobis.cc} | 67 ++++++-----
milena/tests/world/inter_pixel/Makefile.am | 6 +-
.../world/inter_pixel/compute.cc} | 78 +++++++------
.../all.hh => tests/world/inter_pixel/immerse.cc} | 59 +++++-----
35 files changed, 850 insertions(+), 517 deletions(-)
copy milena/mln/{fun => accu/stat}/all.hh (63%)
copy milena/mln/{world/inter_pixel/image2full.hh => data/paste_without_localization.hh} (50%)
copy milena/mln/fun/{ => access}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/access/mean.hh} (56%)
copy milena/mln/fun/{ => stat}/all.hh (64%)
copy milena/mln/{convert/to_fun.hh => fun/stat/mahalanobis.hh} (52%)
copy milena/mln/world/inter_pixel/{image2full.hh => compute.hh} (56%)
copy milena/mln/world/inter_pixel/{image2full.hh => immerse.hh} (59%)
copy milena/mln/world/inter_pixel/{image2full.hh => is_pixel.hh} (56%)
rename milena/mln/world/inter_pixel/{image2full.hh => is_separator.hh} (56%)
create mode 100644 milena/mln/world/inter_pixel/separator_to_pixels.hh
copy milena/tests/{fun => accu/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/accu/stat/var.cc} (57%)
copy milena/tests/{world/inter_pixel => fun/stat}/Makefile.am (61%)
copy milena/{mln/fun/all.hh => tests/fun/stat/mahalanobis.cc} (55%)
copy milena/{mln/convert/to_fun.hh => tests/world/inter_pixel/compute.cc} (52%)
copy milena/{mln/fun/all.hh => tests/world/inter_pixel/immerse.cc} (61%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2583428..c69383e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,73 @@
+2009-05-07 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
+
+ Several fixes and new stuff.
+
+ Starting revamping world inter-pixel.
+
+ * mln/world/inter_pixel/image2full.hh: Rename as...
+ * mln/world/inter_pixel/immerse.hh: ...this new file.
+ (image2full): Rename as...
+ (immerse): ...this.
+ Revamp.
+ * mln/world/inter_pixel/separator_to_pixels.hh: New.
+ * mln/world/inter_pixel/is_separator.hh: New.
+ * mln/world/inter_pixel/is_pixel.hh: New.
+ * mln/world/inter_pixel/compute.hh: New.
+ * mln/world/inter_pixel/make: New directory.
+ * mln/world/inter_pixel/neighb2d.hh: Fix ending guard.
+ * mln/world/inter_pixel/display_edge.hh: Likewise.
+ * mln/core/macros.hh (mln_unmorph, mln_unmorph_): New.
+ * mln/core/point.hh (point): Fix warning.
+ Add static check.
+ * mln/core/internal/image_morpher.hh (unmorph): New typedef.
+ * mln/core/internal/pixel_impl.hh
+ (pixel_impl_): Fix compile errors with g++-3.4.
+ * mln/core/concept/gpoint.hh (operator*): New overload with scalar.
+ (trait): New corresponding trait.
+ * tests/world/inter_pixel/compute.cc: New.
+ * tests/world/inter_pixel/immerse.cc: New.
+ * tests/world/inter_pixel/Makefile.am: Update.
+
+ Fix missing code for operator less with builtins.
+
+ * mln/value/builtin/ops.hh:
+ (mln_internal_decl_op_less_): New.
+ (mln_internal_def_op_less_): New.
+ (mln_internal_builtins_op_less_): New.
+
+ Misc.
+
+ * mln/accu/stat/all.hh: New.
+ * mln/accu/all.hh: Update.
+ * mln/convert/to_fun.hh: Upgrade doc style.
+ * mln/data/paste_without_localization.hh: New.
+ * mln/data/paste.hh: New static check.
+ * mln/fun/c.hh: Likewise.
+ Fix ending guard.
+
+ Augmenting accumulators.
+
+ * mln/accu/stat/var.hh (mean_t): New typedef.
+ (to_result, mean): Fix null_ construction.
+ * tests/accu/stat: New directory.
+ * tests/accu/stat/Makefile.am: New.
+ * tests/accu/stat/var.cc: New.
+ * tests/accu/Makefile.am: Update.
+
+ Augmenting fun :-)
+
+ * mln/fun/access: New directory.
+ * mln/fun/access/all.hh: New.
+ * mln/fun/access/mean.hh: New.
+ * mln/fun/all.hh: Update.
+ * mln/fun/stat: New.
+ * mln/fun/stat/all.hh: New.
+ * mln/fun/stat/mahalanobis.hh: New.
+ * tests/fun/stat: New.
+ * tests/fun/stat/mahalanobis.cc: New.
+ * tests/fun/stat/Makefile.am: New.
+ * tests/fun/Makefile.am: Update.
+
2009-05-07 Guillaume Sadegh <sadegh(a)lrde.epita.fr>
Add couple to couple conversion.
diff --git a/milena/mln/accu/all.hh b/milena/mln/accu/all.hh
index 5dfe51e..1bf7cf8 100644
--- a/milena/mln/accu/all.hh
+++ b/milena/mln/accu/all.hh
@@ -99,6 +99,7 @@ namespace mln
# include <mln/accu/image/all.hh>
# include <mln/accu/site_set/all.hh>
+# include <mln/accu/stat/all.hh>
#endif // ! MLN_ACCU_ALL_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/accu/stat/all.hh
similarity index 63%
copy from milena/mln/fun/all.hh
copy to milena/mln/accu/stat/all.hh
index 8e9ddad..1c9f8ef 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/accu/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,29 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_ACCU_STAT_ALL_HH
+# define MLN_ACCU_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/accu/stat/all.hh
+///
+/// File that includes all statistical accumulator types.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
- namespace fun
+ namespace accu
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace of statistical accumulators.
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/accu/stat/deviation.hh>
+# include <mln/accu/stat/var.hh>
+# include <mln/accu/stat/variance.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_ACCU_STAT_ALL_HH
diff --git a/milena/mln/accu/stat/var.hh b/milena/mln/accu/stat/var.hh
index c871e7d..3dece0b 100644
--- a/milena/mln/accu/stat/var.hh
+++ b/milena/mln/accu/stat/var.hh
@@ -40,6 +40,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/util/pix.hh>
+
namespace mln
{
@@ -84,8 +85,13 @@ namespace mln
/// Get the number of items.
unsigned n_items() const;
+
+ /// Type equipment.
+ typedef algebra::vec<dim,float> mean_t;
+ // ...
+
/// Get the mean vector.
- algebra::vec<dim,float> mean() const;
+ mean_t mean() const;
/// Check whether this accu returns a valid result.
bool is_valid() const;
@@ -115,7 +121,7 @@ namespace mln
{
n_ = 0;
sum_.set_all(0);
- cov_ .set_all(0);
+ cov_.set_all(0);
}
template <typename T>
@@ -163,7 +169,7 @@ namespace mln
mln_result(var<T>)
var<T>::to_result() const
{
- static result null_(fun::i2v::all_to(0));
+ static result null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
@@ -192,10 +198,10 @@ namespace mln
template <typename T>
inline
- algebra::vec<dim,float>
+ typename var<T>::mean_t
var<T>::mean() const
{
- static algebra::vec<dim,float> null_(fun::i2v::all_to(0));
+ static algebra::vec<dim,float> null_ = literal::zero;
if (n_ == 0u)
return null_; // Safety.
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/convert/to_fun.hh
index 86a1ddc..6484c42 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/convert/to_fun.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,10 +29,9 @@
#ifndef MLN_CONVERT_TO_FUN_HH
# define MLN_CONVERT_TO_FUN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/convert/to_fun.hh
+///
+/// Conversions towards some mln::Function.
# include <mln/pw/value.hh>
# include <mln/fun/c.hh>
diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh
index 9311535..504e2ac 100644
--- a/milena/mln/core/concept/gpoint.hh
+++ b/milena/mln/core/concept/gpoint.hh
@@ -36,7 +36,7 @@
# include <mln/core/concept/site.hh>
# include <mln/core/concept/gdpoint.hh>
-# include <mln/value/concept/scalar.hh>
+# include <mln/value/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
# include <mln/debug/format.hh>
@@ -74,6 +74,14 @@ namespace mln
typedef mln_delta(L) ret;
};
+ template < typename L, typename R >
+ struct set_binary_< op::times,
+ mln::Gpoint, L,
+ mln::Object, mln::value::scalar_<R> >
+ {
+ typedef L ret;
+ };
+
template <typename P>
struct set_unary_< op::ord, mln::Gpoint, P >
@@ -200,7 +208,7 @@ namespace mln
- /// Substract a delta-point \p rhs to a grid point \p lhs.
+ /// Substract a delta-point \p dp to a grid point \p p.
///
/*! \param[in] p A grid point.
* \param[in] dp A delta-point.
@@ -217,6 +225,13 @@ namespace mln
operator-(const Gpoint<P>& p, const Gdpoint<D>& dp);
+ /// Multiply a point \p p by a scalar \p s.
+ //
+ template <typename P, typename S>
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s);
+
+
/// Print a grid point \p p into the output stream \p ostr.
/*! \param[in,out] ostr An output stream.
* \param[in] p A grid point.
@@ -380,6 +395,19 @@ namespace mln
return tmp;
}
+ template <typename P, typename S>
+ inline
+ P
+ operator*(const Gpoint<P>& p, const value::scalar_<S>& s)
+ {
+ int s_ = s.to_equiv();
+ const unsigned n = P::dim;
+ P tmp = exact(p);
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] *= s_;
+ return tmp;
+ }
+
template <typename P>
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>& p)
diff --git a/milena/mln/core/internal/image_morpher.hh b/milena/mln/core/internal/image_morpher.hh
index fd170ea..0969acc 100644
--- a/milena/mln/core/internal/image_morpher.hh
+++ b/milena/mln/core/internal/image_morpher.hh
@@ -64,6 +64,10 @@ namespace mln
I* delegatee_();
+
+ /// Unmorph image associated type.
+ typedef I unmorph;
+
/// Give the morphed image (mutable version).
I& unmorph_();
diff --git a/milena/mln/core/internal/pixel_impl.hh b/milena/mln/core/internal/pixel_impl.hh
index f3162e5..eb956cf 100644
--- a/milena/mln/core/internal/pixel_impl.hh
+++ b/milena/mln/core/internal/pixel_impl.hh
@@ -233,7 +233,7 @@ namespace mln
bool
pixel_impl_<I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -249,7 +249,7 @@ namespace mln
pixel_impl_<I, E>::val()
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -258,7 +258,7 @@ namespace mln
pixel_impl_<I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -267,7 +267,7 @@ namespace mln
pixel_impl_<I, E>::ima() const
{
// a const pixel, yet a mutable image
- return const_cast<I&>(image_);
+ return const_cast<I&>(this->image_);
}
template <typename I, typename E>
@@ -286,7 +286,7 @@ namespace mln
bool
pixel_impl_<const I, E>::is_valid_() const
{
- return value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
+ return this->value_ptr_ != 0 && internal::force_exact<E>(*this).is_valid();
}
template <typename I, typename E>
@@ -302,7 +302,7 @@ namespace mln
pixel_impl_<const I, E>::val() const
{
mln_precondition(is_valid_());
- return *value_ptr_;
+ return *this->value_ptr_;
}
template <typename I, typename E>
@@ -310,7 +310,7 @@ namespace mln
const I&
pixel_impl_<const I, E>::ima() const
{
- return image_;
+ return this->image_;
}
template <typename I, typename E>
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index 8aa59ad..75ab5f0 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -372,6 +372,16 @@
+// u
+
+/// Shortcuts to access the unmorph type associated to T.
+/// \{
+# define mln_unmorph(T) typename T::unmorph
+# define mln_unmorph_(T) T::unmorph
+/// \}
+
+
+
// v
/// Shortcuts to access the value type associated to T.
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index 54289fa..ca15b4c 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 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
@@ -294,16 +294,17 @@ namespace mln
inline
point<G,C>::point(const algebra::vec<dim,C2>& v)
{
+ mlc_converts_to(C2, C)::check();
unsigned j = 0;
- //FIXME: to be improved.
+ //FIXME: to be improved while adding a conversion routine.
if (dim < 3)
coord_ = v;
else
{
for (unsigned i = dim - 2; i < dim; ++i)
- coord_[i] = v[j++];
+ coord_[i] = static_cast<C>(v[j++]);
for (unsigned i = 2; i < dim; ++i, ++j)
- coord_[i-j] = v[j];
+ coord_[i-j] = static_cast<C>(v[j]);
}
}
diff --git a/milena/mln/data/paste.hh b/milena/mln/data/paste.hh
index 6457411..ef3911d 100644
--- a/milena/mln/data/paste.hh
+++ b/milena/mln/data/paste.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 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
@@ -129,6 +129,8 @@ namespace mln
{
trace::entering("data::paste");
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
internal::paste_tests(input, output);
internal::paste_dispatch(input, output);
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/data/paste_without_localization.hh
similarity index 50%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/data/paste_without_localization.hh
index 03102f7..8b10bee 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/data/paste_without_localization.hh
@@ -25,69 +25,69 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
+# define MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/data/paste_without_localization.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Paste the contents of an image into another one without taking
+/// into account the localization of sites.
+
+# include <mln/core/concept/image.hh>
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
namespace mln
{
- namespace world
+ namespace data
{
- namespace inter_pixel
- {
+ /// \brief Paste the contents of image \p input into the image \p
+ /// output without taking into account the localization of sites.
+ ///
+ /// \param[in] input The input image providing pixels values.
+ /// \param[in,out] output The image in which values are
+ /// assigned.
+ //
+ template <typename I, typename J>
+ void paste_without_localization(const Image<I>& input, Image<J>& output);
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
# ifndef MLN_INCLUDE_ONLY
-
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
-
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
-
+ template <typename I, typename J>
+ inline
+ void paste_without_localization(const Image<I>& input_, Image<J>& output_)
+ {
+ trace::entering("data::paste_without_localization");
+
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& input = exact(input_);
+ J& output = exact(output_);
+
+ mln_fwd_piter(I) pi(input.domain());
+ pi.start();
+ mln_fwd_piter(J) po(output.domain());
+ po.start();
+ while (pi.is_valid() && po.is_valid())
+ {
+ output(po) = input(pi);
+ pi.next();
+ po.next();
+ }
+
+ trace::exiting("data::paste_without_localization");
+ }
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::data
- } // end of namespace mln::world::inter_pixel
+} // end of namespace mln
- } // end of namespace mln::world
-} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_DATA_PASTE_WITHOUT_LOCALIZATION_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/access/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/access/all.hh
index 8e9ddad..ecae22d 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/access/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_ACCESS_ALL_HH
+# define MLN_FUN_ACCESS_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/access/all.hh
+///
+/// File that includes all access functions.
namespace mln
{
-
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// Namespace for access functions.
+ namespace access
+ {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/access/mean.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_ACCESS_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/access/mean.hh
similarity index 56%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/access/mean.hh
index 86a1ddc..e287882 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/access/mean.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -7,7 +7,7 @@
//
// 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
+// MERCHANTABILITY or FITNESS FOR F PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
@@ -25,55 +25,67 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+#ifndef MLN_FUN_ACCESS_MEAN_HH
+# define MLN_FUN_ACCESS_MEAN_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
-
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace access
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ struct mean : unary<mean>
+ {
+ };
+ namespace internal
+ {
-# ifndef MLN_INCLUDE_ONLY
+ template <typename T>
+ struct method_mean
+ {
+ typedef method_mean ret;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef typename T::mean_t result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return x.mean();
+ }
+ };
+
+ }
+
+ } // end of namespace mln::access
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
+ } // end of namespace mln
+
+
+ namespace trait
+ {
+
+ namespace next
{
- return pw::value(ima);
- }
-# endif // ! MLN_INCLUDE_ONLY
+ template <typename A>
+ struct set_unary_< fun::access::mean,
+ Accumulator, A > : fun::access::internal::method_mean<A>
+ {
+ };
+
+ } // end of namespace mln::trait::next
- } // end of namespace mln::convert
+ } // end of namespace mln::trait
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_ACCESS_MEAN_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/all.hh
index 8e9ddad..96a347a 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/all.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/all.hh
+///
+/// File that includes all fun-related routines.
namespace mln
@@ -43,25 +43,25 @@ namespace mln
/// Internal namespace of functions.
namespace internal
- {
- }
- }
+ {}
+ }
}
# include <mln/fun/c.hh>
# include <mln/fun/ops.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/fun/meta/all.hh>
# include <mln/fun/p2b/all.hh>
# include <mln/fun/p2v/all.hh>
+# include <mln/fun/stat/all.hh>
# include <mln/fun/v2b/all.hh>
# include <mln/fun/v2v/all.hh>
# include <mln/fun/vv2v/all.hh>
# include <mln/fun/x2p/all.hh>
# include <mln/fun/x2v/all.hh>
# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
#endif // ! MLN_FUN_ALL_HH
diff --git a/milena/mln/fun/c.hh b/milena/mln/fun/c.hh
index 8ee9c24..400c781 100644
--- a/milena/mln/fun/c.hh
+++ b/milena/mln/fun/c.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,11 +29,10 @@
#ifndef MLN_FUN_C_HH
# define MLN_FUN_C_HH
-/*! \file mln/fun/c.hh
- *
- * \brief Encapsulate a plain (C language-like) pointer to function
- * into a functor.
- */
+/// \file mln/fun/c.hh
+///
+/// Encapsulate a plain (C language-like) pointer to function
+/// into a functor.
# include <mln/fun/internal/selector.hh>
# include <mln/metal/unqualif.hh>
@@ -137,4 +137,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_FUN_P2B_C_HH
+#endif // ! MLN_FUN_C_HH
diff --git a/milena/mln/fun/all.hh b/milena/mln/fun/stat/all.hh
similarity index 64%
copy from milena/mln/fun/all.hh
copy to milena/mln/fun/stat/all.hh
index 8e9ddad..8ad5257 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/mln/fun/stat/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,30 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+#ifndef MLN_FUN_STAT_ALL_HH
+# define MLN_FUN_STAT_ALL_HH
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+/// \file mln/fun/stat/all.hh
+///
+/// File that includes all statistical functions.
namespace mln
{
- /// Namespace of image processing routines related to functions.
namespace fun
{
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ /// \brief Namespace of statistical functions.
+ ///
+ /// \ingroup modfun
+ namespace stat {}
+ }
}
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+# include <mln/fun/stat/mahalanobis.hh>
-#endif // ! MLN_FUN_ALL_HH
+#endif // ! MLN_FUN_STAT_ALL_HH
diff --git a/milena/mln/convert/to_fun.hh b/milena/mln/fun/stat/mahalanobis.hh
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/mln/fun/stat/mahalanobis.hh
index 86a1ddc..79eea0e 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/mln/fun/stat/mahalanobis.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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,55 +25,71 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+#ifndef MLN_FUN_STAT_MAHALANOBIS_HH
+# define MLN_FUN_STAT_MAHALANOBIS_HH
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+/// \file mln/fun/stat/mahalanobis.hh
+///
+/// Define the FIXME
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
namespace mln
{
- namespace convert
+ namespace fun
{
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
+ namespace stat
+ {
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+ template <typename V>
+ struct mahalanobis
+ : public Function_v2v< mahalanobis<V> >,
+ private metal::equal< V, algebra::vec<V::dim,float> >::check_t
+ {
+ enum { n = V::dim };
+ typedef float result;
+ mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean);
-# ifndef MLN_INCLUDE_ONLY
+ float operator()(const V& v) const;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ algebra::mat<n,n,float> var_1;
+ algebra::vec<n,float> mean;
+ };
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ mahalanobis<V>::mahalanobis(const algebra::mat<V::dim,V::dim,float>& var,
+ const algebra::vec<V::dim,float>& mean)
+ {
+ var_1 = var._1();
+ mean = mean;
+ }
+
+ template <typename V>
+ inline
+ float
+ mahalanobis<V>::operator()(const V& v) const
+ {
+ return (v - mean).t() * var_1 * (v - mean);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ } // end of namespace mln::fun::stat
+
+ } // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_CONVERT_TO_FUN_HH
+#endif // ! MLN_FUN_X2V_NORM_MAHALANOBIS_HH
diff --git a/milena/mln/value/builtin/ops.hh b/milena/mln/value/builtin/ops.hh
index 24dbfd7..c4bcab6 100644
--- a/milena/mln/value/builtin/ops.hh
+++ b/milena/mln/value/builtin/ops.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -28,11 +29,10 @@
#ifndef MLN_VALUE_BUILTIN_OPS_HH
# define MLN_VALUE_BUILTIN_OPS_HH
-/*! \file mln/value/builtin/ops.hh
- *
- * \brief Definitions of binary operators when lhs is a built-in and
- * rhs is an mln object.
- */
+/// \file mln/value/builtin/ops.hh
+///
+/// Definitions of binary operators when lhs is a built-in and
+/// rhs is an mln object.
# include <mln/value/scalar.hh>
# include <mln/trait/op/all.hh>
@@ -149,6 +149,7 @@
+
# define mln_internal_op_obj_builtins_(De, Symb, Name) \
\
mln_internal_##De##_op_obj_bi_(Symb, Name, signed char); \
@@ -317,6 +318,55 @@
+
+// Operator less (<) is a special case.
+
+# define mln_internal_decl_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs); \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_def_op_less_(Symb, Name, Builtin) \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (O, value::scalar_< Builtin >) \
+ operator Symb (const Object<O>& lhs, const Builtin & rhs) \
+ { \
+ return exact(lhs) Symb value::scalar(rhs); \
+ } \
+ \
+ template <typename O> \
+ mln_trait_op_##Name (value::scalar_< Builtin >, O) \
+ operator Symb (const Builtin & lhs, const Object<O>& rhs) \
+ { \
+ return value::scalar(lhs) Symb exact(rhs); \
+ } \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+# define mln_internal_builtins_op_less_(De, Symb, Name) \
+ \
+ mln_internal_##De##_op_less_(Symb, Name, signed char); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned char); \
+ mln_internal_##De##_op_less_(Symb, Name, signed short); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned short); \
+ mln_internal_##De##_op_less_(Symb, Name, signed int); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned int); \
+ mln_internal_##De##_op_less_(Symb, Name, signed long); \
+ mln_internal_##De##_op_less_(Symb, Name, unsigned long); \
+ mln_internal_##De##_op_less_(Symb, Name, float); \
+ mln_internal_##De##_op_less_(Symb, Name, double); \
+ \
+ struct m_a_c_r_o__e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
+
+
// FIXME: What about pointers, arrays, bool, etc.
// FIXME: Mod is not defined for float and double...
@@ -468,6 +518,12 @@ namespace mln
typedef mln_trait_op_less(O, mln::value::scalar_<B>) ret;
};
+ template <typename B, typename O>
+ struct set_binary_< op::less, mln::value::Built_In, B, mln::Object, O >
+ {
+ typedef mln_trait_op_less(mln::value::scalar_<B>, O) ret;
+ };
+
// 'Op+' is commutative so "o + b" => "o + scalar(b)".
@@ -548,6 +604,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(decl, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(decl, <, less);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -583,6 +643,10 @@ namespace mln
mln_internal_builtins_opeq_obj_(def, %);
+ // Ops "bi < obj" and "obj < bi"
+ mln_internal_builtins_op_less_(def, <, less);
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/compute.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/compute.hh
index 03102f7..9cb01fe 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/compute.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_COMPUTE_HH
+# define MLN_WORLD_INTER_PIXEL_COMPUTE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/compute.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: insert comment.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+# include <mln/world/inter_pixel/separator_to_pixels.hh>
namespace mln
@@ -50,44 +47,53 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I, typename F>
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input, const Function_vv2v<F>& f);
-# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ inline
+ image_if<mln_ch_value(mln_unmorph(I), mln_result(F)), is_separator>
+ compute(const Image<I>& input_, const Function_vv2v<F>& f_)
{
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ trace::entering("world::inter_pixel::compute");
+
+ const I& input = exact(input_);
+ const F& f = exact(f_);
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_precondition(input.is_valid());
- trace::exiting("world::inter_pixel::image2full");
+ typedef mln_unmorph(I) I_;
+ typedef mln_ch_value(I_, mln_result(F)) O_;
+ O_ output_;
+ initialize(output_, input.unmorph_());
+
+ typedef image_if<O_, is_separator> O;
+ O output(output_, is_separator());
+
+ mln_piter(O) e(output.domain());
+ for_all(e)
+ {
+ mln_site(I) p1, p2;
+ separator_to_pixels(e, p1, p2);
+ output(e) = f(input(p1), input(p2));
+ }
+
+ trace::exiting("world::inter_pixel::compute");
return output;
}
-
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_COMPUTE_HH
diff --git a/milena/mln/world/inter_pixel/display_edge.hh b/milena/mln/world/inter_pixel/display_edge.hh
index 6eb43c4..9cfa046 100644
--- a/milena/mln/world/inter_pixel/display_edge.hh
+++ b/milena/mln/world/inter_pixel/display_edge.hh
@@ -82,4 +82,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE
+#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/immerse.hh
similarity index 59%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/immerse.hh
index 03102f7..59df2a6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/immerse.hh
@@ -25,20 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IMMERSE_HH
+# define MLN_WORLD_INTER_PIXEL_IMMERSE_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/immerse.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// Convert a classical image to an inter-pixel image.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/paste_without_localization.hh>
+# include <mln/geom/nsites.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
namespace mln
@@ -50,44 +47,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
+ /// Convert an image to an inter-pixel image.
///
+ /// \param[in] input An image.
/// \return An inter-pixel image.
//
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
+ template <typename I>
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
+ template <typename I>
+ inline
+ image_if<mln_concrete(I), is_pixel>
+ immerse(const Image<I>& input_)
{
- trace::entering("world::inter_pixel::image2full");
+ trace::entering("world::inter_pixel::immerse");
+
+ mlc_is_a(mln_domain(I), Box)::check();
+
+ const I& input = exact(input_);
mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ mln_domain(I) b(2 * input.domain().pmin(),
+ 2 * input.domain().pmax());
+ mln_concrete(I) output(b);
+ mln_assertion(geom::nsites(output | is_pixel()) == input.domain().nsites());
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+ data::paste_without_localization(input, (output | is_pixel()).rw());
+ trace::exiting("world::inter_pixel::immerse");
+ return output | is_pixel();
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IMMERSE_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/is_pixel.hh
similarity index 56%
copy from milena/mln/world/inter_pixel/image2full.hh
copy to milena/mln/world/inter_pixel/is_pixel.hh
index 03102f7..a393de6 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_pixel.hh
@@ -25,20 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
+# define MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_pixel.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
-///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// FIXME: doc.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +46,48 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
-
-# ifndef MLN_INCLUDE_ONLY
+ struct is_pixel : public Function_p2b< is_pixel >
+ {
+ typedef bool result;
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ const unsigned n = P::dim;
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] % 2 == 1)
+ return false;
+ return true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_pixel::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_PIXEL_HH
diff --git a/milena/mln/world/inter_pixel/image2full.hh b/milena/mln/world/inter_pixel/is_separator.hh
similarity index 56%
rename from milena/mln/world/inter_pixel/image2full.hh
rename to milena/mln/world/inter_pixel/is_separator.hh
index 03102f7..0c8f281 100644
--- a/milena/mln/world/inter_pixel/image2full.hh
+++ b/milena/mln/world/inter_pixel/is_separator.hh
@@ -25,20 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WORLD_INTER_PIXEL_FULL_HH
-# define MLN_WORLD_INTER_PIXEL_FULL_HH
+#ifndef MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
+# define MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
-/// \file mln/world/inter_pixel/full.hh
+/// \file mln/world/inter_pixel/is_separator.hh
///
-/// Convert a classical 2D image to an inter-pixel image.
+/// FIXME: doc.
///
-/// FIXME: will NOT work if the image has an origin different from (0,0).
+/// \todo Make it work in n-D.
-# include <mln/core/image/image2d.hh>
-# include <mln/geom/max_col.hh>
-# include <mln/geom/max_row.hh>
-# include <mln/geom/min_col.hh>
-# include <mln/geom/min_row.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/point.hh>
namespace mln
@@ -50,44 +48,44 @@ namespace mln
namespace inter_pixel
{
- /// Convert a classical 2D image to an inter-pixel image.
- ///
- /// \param[in] input A 2d image.
- ///
- /// \return An inter-pixel image.
- //
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input);
-
+ struct is_separator : public Function_p2b< is_separator >
+ {
+ typedef bool result;
-# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ bool operator()(const Gpoint<P>& p) const;
+ template <typename P>
+ bool operator()(const Site_Proxy<P>& p) const;
+ };
- template <typename T>
- image2d<T>
- image2full(const image2d<T>& input)
- {
- trace::entering("world::inter_pixel::image2full");
- mln_precondition(input.is_valid());
- image2d<T> output(2 * input.nrows() - 1, 2 * input.ncols() - 1);
- for (int row = geom::min_row(input); row <= geom::max_row(input); ++row)
- for (int col = geom::min_col(input); col <= geom::max_col(input); ++col)
- opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
-
- trace::exiting("world::inter_pixel::image2full");
- return output;
- }
+# ifndef MLN_INCLUDE_ONLY
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Gpoint<P>& p_) const
+ {
+ const P& p = exact(p_);
+ return p.row() % 2 + p.col() % 2 == 1;
+ }
+
+ template <typename P>
+ inline
+ bool
+ is_separator::operator()(const Site_Proxy<P>& p) const
+ {
+ mlc_is_a(mln_site(P), Gpoint)::check();
+ return this->operator()(exact(p).to_site());
+ }
# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_FULL
+#endif // ! MLN_WORLD_INTER_PIXEL_IS_SEPARATOR_HH
diff --git a/milena/mln/world/inter_pixel/neighb2d.hh b/milena/mln/world/inter_pixel/neighb2d.hh
index a61edeb..00e6418 100644
--- a/milena/mln/world/inter_pixel/neighb2d.hh
+++ b/milena/mln/world/inter_pixel/neighb2d.hh
@@ -101,4 +101,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
diff --git a/milena/mln/world/inter_pixel/separator_to_pixels.hh b/milena/mln/world/inter_pixel/separator_to_pixels.hh
new file mode 100644
index 0000000..9e77afc
--- /dev/null
+++ b/milena/mln/world/inter_pixel/separator_to_pixels.hh
@@ -0,0 +1,123 @@
+// 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_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+# define MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
+
+/// \file mln/world/inter_pixel/separator_to_pixels.hh
+///
+/// FIXME: doc.
+///
+/// \todo Generalize to n-D.
+
+# include <mln/core/concept/gpoint.hh>
+# include <mln/core/concept/site_proxy.hh>
+# include <mln/world/inter_pixel/is_pixel.hh>
+# include <mln/world/inter_pixel/is_separator.hh>
+
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+
+ template <typename P>
+ void
+ separator_to_pixels(const Gpoint<P>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+ template <typename Ps, typename P>
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s,
+ Gpoint<P>& p1, Gpoint<P>& p2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ inline
+ void
+ separator_to_pixels(const Gpoint<P>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const P& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ // FIXME: 2D only.
+ if (s.row() % 2)
+ {
+ // Horizontal edge.
+ p1 = point2d(s.row() - 1, s.col());
+ p2 = point2d(s.row() + 1, s.col());
+ }
+ else
+ {
+ // Vertical edge.
+ p1 = point2d(s.row(), s.col() - 1);
+ p2 = point2d(s.row(), s.col() + 1);
+ }
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+ template <typename Ps, typename P>
+ inline
+ void
+ separator_to_pixels(const Site_Proxy<Ps>& s_,
+ Gpoint<P>& p1_, Gpoint<P>& p2_)
+ {
+ const Ps& s = exact(s_);
+ mln_precondition(is_separator()(s));
+
+ P &p1 = exact(p1_),
+ &p2 = exact(p2_);
+
+ separator_to_pixels(s.to_site(), p1, p2);
+
+ mln_postcondition(is_pixel()(p1));
+ mln_postcondition(is_pixel()(p2));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_SEPARATOR_TO_PIXELS_HH
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index 7aca2bd..f7b9927 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -4,7 +4,8 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
image \
- site_set
+ site_set \
+ stat
check_PROGRAMS = \
all_accus \
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/accu/stat/Makefile.am
similarity index 61%
copy from milena/tests/fun/Makefile.am
copy to milena/tests/accu/stat/Makefile.am
index 4ea605e..2e2b71c 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/accu/stat/Makefile.am
@@ -2,4 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+check_PROGRAMS = \
+ var
+
+var_SOURCES = var.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/accu/stat/var.cc
similarity index 57%
copy from milena/mln/fun/all.hh
copy to milena/tests/accu/stat/var.cc
index 8e9ddad..40d2126 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/accu/stat/var.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,49 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/accu/stat/var.cc
+///
+/// Tests on mln::accu::stat::var.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+ mln_assertion(a.n_items() == n);
-#endif // ! MLN_FUN_ALL_HH
+ vec3f m = a.mean();
+ mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+ mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+ mln_assertion(m[2] > 1.4 && m[2] < 1.6);
+
+ algebra::mat<3,3,float> s_1 = a.variance()._1();
+ mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+ mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+ mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/fun/Makefile.am b/milena/tests/fun/Makefile.am
index 4ea605e..7cea3a5 100644
--- a/milena/tests/fun/Makefile.am
+++ b/milena/tests/fun/Makefile.am
@@ -2,4 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = i2v p2b p2p p2v v2v vv2v x2x
+SUBDIRS = \
+ i2v \
+ p2b \
+ p2p \
+ p2v \
+ stat \
+ v2v \
+ vv2v \
+ x2x
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/fun/stat/Makefile.am
similarity index 61%
copy from milena/tests/world/inter_pixel/Makefile.am
copy to milena/tests/fun/stat/Makefile.am
index cffbcdd..c9bc2e6 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/fun/stat/Makefile.am
@@ -2,12 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- dim2
+check_PROGRAMS = \
+ mahalanobis
-check_PROGRAMS = \
- image2full
-
-image2full_SOURCES = image2full.cc
+mahalanobis_SOURCES = mahalanobis.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/fun/all.hh b/milena/tests/fun/stat/mahalanobis.cc
similarity index 55%
copy from milena/mln/fun/all.hh
copy to milena/tests/fun/stat/mahalanobis.cc
index 8e9ddad..7df7af2 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/fun/stat/mahalanobis.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,50 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/fun/stat/mahalanobis.cc
+///
+/// Tests on mln::fun::stat::mahalanobis.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <cstdlib>
+#include <mln/accu/stat/var.hh>
+#include <mln/fun/stat/mahalanobis.hh>
-namespace mln
+float my_rand(int c)
{
+ return (1 + c) * float(std::rand()) / RAND_MAX;
+}
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+int main()
+{
+ using namespace mln;
-}
+ typedef algebra::vec<3,float> vec3f;
+ enum { n = 1000 };
+ vec3f v[n];
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ for (int i = 0; i < n; ++i)
+ {
+ v[i][0] = my_rand(0);
+ v[i][1] = my_rand(1);
+ v[i][2] = my_rand(2);
+ }
+
+ accu::stat::var<vec3f> a;
+ for (int i = 0; i < n; ++i)
+ a.take(v[i]);
+// vec3f m = a.mean();
+// mln_assertion(m[0] > 0.4 && m[0] < 0.6);
+// mln_assertion(m[1] > 0.9 && m[1] < 1.1);
+// mln_assertion(m[2] > 1.4 && m[2] < 1.6);
-#endif // ! MLN_FUN_ALL_HH
+ fun::stat::mahalanobis<vec3f> f(a.variance(), a.mean());
+
+// algebra::mat<3,3,float> s_1 = a.variance()._1();
+// mln_assertion(s_1(0,0) > 11 && s_1(0,0) < 13);
+// mln_assertion(s_1(1,1) > 2 && s_1(1,1) < 4);
+// mln_assertion(s_1(2,2) > 1.1 && s_1(2,2) < 1.5);
+}
diff --git a/milena/tests/world/inter_pixel/Makefile.am b/milena/tests/world/inter_pixel/Makefile.am
index cffbcdd..fdbcea2 100644
--- a/milena/tests/world/inter_pixel/Makefile.am
+++ b/milena/tests/world/inter_pixel/Makefile.am
@@ -5,9 +5,11 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
dim2
-check_PROGRAMS = \
- image2full
+check_PROGRAMS = \
+ image2full \
+ immerse
image2full_SOURCES = image2full.cc
+immerse_SOURCES = immerse.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/convert/to_fun.hh b/milena/tests/world/inter_pixel/compute.cc
similarity index 52%
copy from milena/mln/convert/to_fun.hh
copy to milena/tests/world/inter_pixel/compute.cc
index 86a1ddc..9226a67 100644
--- a/milena/mln/convert/to_fun.hh
+++ b/milena/tests/world/inter_pixel/compute.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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,55 +25,63 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CONVERT_TO_FUN_HH
-# define MLN_CONVERT_TO_FUN_HH
+/// \file tests/world/inter_pixel/compute.cc
+///
+/// Tests on mln::world::inter_pixel::compute.
-/*! \file mln/convert/to_fun.hh
- *
- * \brief Conversions towards some mln::Function.
- */
+#include <cmath>
-# include <mln/pw/value.hh>
-# include <mln/fun/c.hh>
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
+#include <mln/world/inter_pixel/compute.hh>
+#include <mln/world/inter_pixel/neighb2d.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/debug/println.hh>
-namespace mln
+
+
+struct d_t : mln::Function_vv2v<d_t>
{
+ typedef int result;
- namespace convert
+ int operator()(int i1, int i2) const
{
+ return std::abs(i2 - i1);
+ }
+}
+ d;
- /// Convert a C unary function into an mln::fun::C.
- template <typename R, typename A>
- fun::C<R(*)(A)> to_fun(R (*f)(A));
- /// Convert an image into a function.
- template <typename I>
- pw::value_<I> to_fun(const Image<I>& ima);
+int main()
+{
+ using namespace mln;
-# ifndef MLN_INCLUDE_ONLY
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- template <typename R, typename A>
- inline
- fun::C<R(*)(A)> to_fun(R (*f_)(A))
- {
- fun::C<R(*)(A)> f(f_);
- return f;
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
- template <typename I>
- inline
- pw::value_<I> to_fun(const Image<I>& ima)
- {
- return pw::value(ima);
- }
+ using namespace world::inter_pixel;
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::convert
+ int refs[] = { 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1,
+ 0, 2, 0, 3, 0,
+ 7, 0, 4, 0, 3,
+ 0, 1, 0, 4, 0 };
-} // end of namespace mln
+ mln_assertion(compute(imax, d) == (make::image2d(refs) | is_separator()));
+ mln_VAR(g, compute(imax, d));
-#endif // ! MLN_CONVERT_TO_FUN_HH
+ unsigned n_basins;
+ debug::println(morpho::watershed::flooding(g, e2e(), n_basins));
+}
diff --git a/milena/mln/fun/all.hh b/milena/tests/world/inter_pixel/immerse.cc
similarity index 61%
copy from milena/mln/fun/all.hh
copy to milena/tests/world/inter_pixel/immerse.cc
index 8e9ddad..42094b9 100644
--- a/milena/mln/fun/all.hh
+++ b/milena/tests/world/inter_pixel/immerse.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// 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,43 +25,42 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_ALL_HH
-# define MLN_FUN_ALL_HH
+/// \file tests/world/inter_pixel/immerse.cc
+///
+/// Tests on mln::world::inter_pixel::immerse.
-/*! \file mln/fun/all.hh
- *
- * \brief File that includes all fun-related routines.
- */
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/world/inter_pixel/immerse.hh>
-namespace mln
+int main()
{
+ using namespace mln;
- /// Namespace of image processing routines related to functions.
- namespace fun
- {
+ int vals[] = { 3, 4, 5,
+ 1, 3, 6 ,
+ 8, 7, 3 } ;
- /// Internal namespace of functions.
- namespace internal
- {
- }
- }
+ typedef image2d<int> I;
+ I ima = make::image2d(vals);
-}
+ using namespace world::inter_pixel;
+
+ typedef image_if<I, is_pixel> Ix;
+ Ix imax = immerse(ima);
-# include <mln/fun/c.hh>
-# include <mln/fun/ops.hh>
-# include <mln/fun/i2v/all.hh>
-# include <mln/fun/p2b/all.hh>
-# include <mln/fun/p2v/all.hh>
-# include <mln/fun/v2b/all.hh>
-# include <mln/fun/v2v/all.hh>
-# include <mln/fun/vv2v/all.hh>
-# include <mln/fun/x2p/all.hh>
-# include <mln/fun/x2v/all.hh>
-# include <mln/fun/x2x/all.hh>
-# include <mln/fun/meta/all.hh>
+ int refs[] = { 3, 0, 4, 0, 5,
+ 0, 0, 0, 0, 0,
+ 1, 0, 3, 0, 6,
+ 0, 0, 0, 0, 0,
+ 8, 0, 7, 0, 3 };
+ mln_assertion(imax == (make::image2d(refs) | is_pixel()));
-#endif // ! MLN_FUN_ALL_HH
+ mln_piter_(Ix) p(imax.domain());
+ for_all(p)
+ mln_assertion(is_pixel()(p));
+}
--
1.6.1.2
1
0
* mln/fun/i2v/array.hh (from_to_): Remove static check.
* milena/mln/convert/from_to.hxx: New overload for couple->couple.
---
milena/ChangeLog | 56 ++++++++++++++++++++++------------------
milena/mln/convert/from_to.hxx | 10 +++++++
milena/mln/fun/i2v/array.hh | 4 ---
3 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a8a37ed..2583428 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-07 Guillaume Sadegh <sadegh(a)lrde.epita.fr>
+
+ Add couple to couple conversion.
+ * mln/fun/i2v/array.hh (from_to_): Remove static check.
+ * milena/mln/convert/from_to.hxx: New overload for couple->couple.
+
2009-05-06 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add I/O tests.
@@ -66,7 +72,7 @@
* sandbox/fred/tests/thru.cc: Added test for thrubin.
2009-05-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
-
+
Add make_edge_image in world::inter_pixel and few missing tests.
* mln/world/inter_pixel/dim2/make_edge_image.hh: new routine.
@@ -368,7 +374,7 @@
* mln/algebra/vec.hh (trait): Fix missing definitions.
(set_precise_binary_): Duplicate explicitly for op::times
and op::div.
- (operator-): New unary operator.
+ (operator-): New unary operator.
* tests/algebra/mat.cc: Copy to...
* tests/algebra/h_mat.cc: ...this new file.
* tests/algebra/mat.cc: Revamp so that there is no h_mat.
@@ -540,7 +546,7 @@
* mln/algebra/all.hh: fix comments.
* mln/algebra/vec.hh: add operator>>.
-
+
* mln/core/internal/graph_psite_base.hh: convert to the correct id
type.
@@ -701,7 +707,7 @@
Fix ambiguities while loading PGM images into label values.
- * mln/io/pnm/load.hh: Use the value equivalent type to read
+ * mln/io/pnm/load.hh: Use the value equivalent type to read
data correctly.
2009-04-28 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -760,7 +766,7 @@
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Revamp graph images.
-
+
* headers.mk: update distributed file list.
* mln/make/dummy_p_edges.hh,
@@ -799,7 +805,7 @@
* mln/util/internal/id2element.hh: function mapping ids to graph
elements.
-
+
* mln/make/p_edges_with_mass_centers.hh: fix guards.
* tests/make/dummy_p_vertices.cc,
@@ -822,7 +828,7 @@
* doc/outputs/outputs.mk,
* doc/generate_dist_files.sh: do not add distributed files in
EXTRA_DIST.
-
+
* doc/examples/samples.mk: remove since useless now.
2009-04-27 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -847,7 +853,7 @@
* mln/registration/get_rot.hh: Update.
* mln/registration/icp.hh: Update.
* mln/algebra/vec.hh (mat<n, 1, U>): New conversion op, ctor,
- and assignment; declarations only, definitions are...
+ and assignment; declarations only, definitions are...
* mln/algebra/mat.hh (mat<n, 1, U>): ...new.
* tests/algebra/op_times.cc: New.
@@ -905,9 +911,9 @@
* mln/make/influence_zone_adjacency_graph.hh: rename the routine in
order to have the same name as the file name.
-
+
* mln/make/rag_and_labeled_wsl.hh: Add more doc.
-
+
* mln/value/lut_vec.hh: add a constructor overload for util::array
which is now considered as a function.
@@ -1057,7 +1063,7 @@
* mln/labeling/pack.hh: ... in this new routine.
* tests/labeling/Makefile.am,
- * tests/labeling/pack.cc: add a new test.
+ * tests/labeling/pack.cc: add a new test.
2009-04-09 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
@@ -1099,7 +1105,7 @@
* mln/core/site_set/p_graph_piter.hh,
* mln/core/internal/image_base.hh,
* mln/core/image/essential.hh: update doc.
-
+
* mln/core/image/all.hh: include new headers.
* mln/core/image/vertex_image.hh,
@@ -1183,7 +1189,7 @@
fun::l2l::relabel as lut.
2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
-
+
Remove debug in io::tiff::load.
* mln/io/tiff/load.hh: Remove debug.
@@ -1308,7 +1314,7 @@
Add new accumulators related to labels.
* mln/accu/all.hh: include new accumulators.
-
+
* mln/accu/count_labels.hh: count how many different labels are in an
image.
@@ -1382,8 +1388,8 @@
Add some simple triangle meshes.
- * mesh/one-triangle.off:
- * mesh/two-triangles.off:
+ * mesh/one-triangle.off:
+ * mesh/two-triangles.off:
* mesh/three-triangles.off:
New.
@@ -1595,7 +1601,7 @@
Small fixes.
* headers.mk: update distributed header list.
-
+
* doc/Doxyfile.in: Do not use mln:: prefix in class name lists.
* doc/ref_guide/ref_guide.tex: update reference to clone().
@@ -2714,7 +2720,7 @@
* mln/transform/distance_and_closest_point_geodesic.hh: ... this.
Now returns both dmap and closest point images.
Add a version returning a closest point image containing indexes.
-
+
* mln/transform/all.hh: update includes.
* mln/transform/internal/closest_point_functor.hh: add a new functor
@@ -3397,7 +3403,7 @@
* tests/registration/multiscale.cc,
* mln/registration/multiscale.hh: remove.
-
+
* tests/registration/Makefile.am: remove multiscale.cc from test list.
* mln/value/rgb.hh: fix a recursive inclusion.
@@ -3488,7 +3494,7 @@
* mln/fun/x2x/rotation.hh:
(get_rot_h_mat 3d): fix matrix construction.
(rotation(algebra::quat)): update attributes in order to produce a
- valid inverted rotation.
+ valid inverted rotation.
* tests/fun/x2x/rotation.cc: improve test.
@@ -3544,7 +3550,7 @@
Revamp icp2.hh.
- * registration/icp2.hh: move registration*...
+ * registration/icp2.hh: move registration*...
* registration/registration.hh: ... here.
2009-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
@@ -3660,9 +3666,9 @@
Update apps/statues/ to catch up with recent changes of interface.
* apps/statues/mesh-complex-max-curv-segm.cc,
- * apps/statues/mesh-complex-max-curv.cc,
- * apps/statues/mesh-complex-segm.cc,
- * apps/statues/trimesh/misc.hh:
+ * apps/statues/mesh-complex-max-curv.cc,
+ * apps/statues/mesh-complex-segm.cc,
+ * apps/statues/trimesh/misc.hh:
Adjust to the new interface of mln::morpho::closing_area and the
renaming of mln::level as mln::data.
* apps/statues/Makefile.am: Adjust comments.
@@ -3671,7 +3677,7 @@
Add a shortcut for planar 1-complex-based images.
- * mln/core/alias/complex_image.hh (mln::int_u8_1complex_image2d):
+ * mln/core/alias/complex_image.hh (mln::int_u8_1complex_image2d):
New typedef.
2009-02-11 Roland Levillain <roland(a)lrde.epita.fr>
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index ded3998..ca6eb81 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -36,6 +36,7 @@
# include <mln/core/def/all.hh>
# include <mln/core/grids.hh>
+# include <mln/util/couple.hh>
//FIXME: have a forward declaration.
# include <vector>
@@ -409,6 +410,15 @@ namespace mln
void
from_to_(const util::array<V>& from, image1d<T>& to);
+ // util::couple<T, U> -> util::couple<V, W>
+ template <typename T, typename U, typename V, typename W>
+ void
+ from_to_(const util::couple<T, U>& from, util::couple<V, W>& to)
+ {
+ from_to(from.first(), to.first());
+ from_to(from.second(), to.second());
+ }
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index f8030a9..e7fb61a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -211,8 +211,6 @@ namespace mln
void
from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
{
- mlc_converts_to(T,U)::check();
-
to.reserve(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
to.append(convert::to<U>(from[i]));
@@ -231,8 +229,6 @@ namespace mln
void
from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
{
- mlc_converts_to(T,U)::check();
-
to.reserve(from.nelements());
for (unsigned i = 0; i < from.size(); ++i)
to.append(convert::to<U>(from[i]));
--
1.6.1.2
1
0