* mln/fun/meta/blue.hh,
* mln/fun/meta/green.hh: add new meta functions to use with fun_image.
* headers.mk: Add new headers to distribution.
* tests/unit_test/Makefile.am,
* tests/unit_test/mln_fun_meta_blue.cc,
* tests/unit_test/mln_fun_meta_green.cc: Add new unit tests.
---
milena/ChangeLog | 13 +++++
milena/headers.mk | 2 +
milena/mln/fun/meta/blue.hh | 64 ++++++++++++++++++++++++++
milena/mln/fun/meta/green.hh | 64 ++++++++++++++++++++++++++
milena/tests/unit_test/Makefile.am | 4 ++
milena/tests/unit_test/mln_fun_meta_blue.cc | 11 ++++
milena/tests/unit_test/mln_fun_meta_green.cc | 11 ++++
7 files changed, 169 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/fun/meta/blue.hh
create mode 100644 milena/mln/fun/meta/green.hh
create mode 100644 milena/tests/unit_test/mln_fun_meta_blue.cc
create mode 100644 milena/tests/unit_test/mln_fun_meta_green.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b2b7dd9..9472f63 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2009-01-06 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add fun::meta::green and fun::meta::blue.
+
+ * mln/fun/meta/blue.hh,
+ * mln/fun/meta/green.hh: Add new meta functions to use with fun_image.
+
+ * headers.mk: Add new headers to distribution.
+
+ * tests/unit_test/Makefile.am,
+ * tests/unit_test/mln_fun_meta_blue.cc,
+ * tests/unit_test/mln_fun_meta_green.cc: Add new unit tests.
+
+2009-01-06 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Small fixes.
* mln/binarization/binarization.hh: remove a non-valid static test.
diff --git a/milena/headers.mk b/milena/headers.mk
index 3365173..fc78f90 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -239,7 +239,9 @@ mln/fun/x2x/rotation.hh \
mln/fun/x2x/essential.hh \
mln/fun/meta/red.hh \
mln/fun/meta/hue.hh \
+mln/fun/meta/green.hh \
mln/fun/meta/inty.hh \
+mln/fun/meta/blue.hh \
mln/fun/meta/sat.hh \
mln/fun/meta/to_enc.hh \
mln/fun/x2v/linear.hh \
diff --git a/milena/mln/fun/meta/blue.hh b/milena/mln/fun/meta/blue.hh
new file mode 100644
index 0000000..4c5a64d
--- /dev/null
+++ b/milena/mln/fun/meta/blue.hh
@@ -0,0 +1,64 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can blueistribute 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 coveblue by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be coveblue by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_META_BLUE_HH
+# define MLN_FUN_META_BLUE_HH
+
+# include <mln/core/concept/meta_fun.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln {
+
+ namespace meta {
+
+ template <class T>
+ struct blue : impl< blue<T> > { typedef T value; };
+
+ }
+
+ template <unsigned n>
+ struct function< meta::blue< value::rgb<n> > > : public Function_v2w_w2v<function< meta::blue < value::rgb<n> > > >
+ {
+ typedef value::rgb<n> value;
+
+ typedef typename value::blue_t result;
+ result read(const value& c)
+ {
+ return c.blue();
+ }
+
+ typedef result& lresult;
+ lresult write(value& c)
+ {
+ return c.blue();
+ }
+ };
+
+
+}
+
+#endif // MLN_FUN_META_BLUE_HH
diff --git a/milena/mln/fun/meta/green.hh b/milena/mln/fun/meta/green.hh
new file mode 100644
index 0000000..6cce043
--- /dev/null
+++ b/milena/mln/fun/meta/green.hh
@@ -0,0 +1,64 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can greenistribute 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 covegreen by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covegreen by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_META_GREEN_HH
+# define MLN_FUN_META_GREEN_HH
+
+# include <mln/core/concept/meta_fun.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln {
+
+ namespace meta {
+
+ template <class T>
+ struct green : impl< green<T> > { typedef T value; };
+
+ }
+
+ template <unsigned n>
+ struct function< meta::green< value::rgb<n> > > : public Function_v2w_w2v<function< meta::green < value::rgb<n> > > >
+ {
+ typedef value::rgb<n> value;
+
+ typedef typename value::green_t result;
+ result read(const value& c)
+ {
+ return c.green();
+ }
+
+ typedef result& lresult;
+ lresult write(value& c)
+ {
+ return c.green();
+ }
+ };
+
+
+}
+
+#endif // MLN_FUN_META_GREEN_HH
diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am
index 168c709..e055ee3 100644
--- a/milena/tests/unit_test/Makefile.am
+++ b/milena/tests/unit_test/Makefile.am
@@ -236,7 +236,9 @@ mln_fun_x2x_rotation \
mln_fun_x2x_essential \
mln_fun_meta_red \
mln_fun_meta_hue \
+mln_fun_meta_green \
mln_fun_meta_inty \
+mln_fun_meta_blue \
mln_fun_meta_sat \
mln_fun_meta_to_enc \
mln_fun_x2v_linear \
@@ -1244,7 +1246,9 @@ mln_fun_x2x_rotation_SOURCES = mln_fun_x2x_rotation.cc
mln_fun_x2x_essential_SOURCES = mln_fun_x2x_essential.cc
mln_fun_meta_red_SOURCES = mln_fun_meta_red.cc
mln_fun_meta_hue_SOURCES = mln_fun_meta_hue.cc
+mln_fun_meta_green_SOURCES = mln_fun_meta_green.cc
mln_fun_meta_inty_SOURCES = mln_fun_meta_inty.cc
+mln_fun_meta_blue_SOURCES = mln_fun_meta_blue.cc
mln_fun_meta_sat_SOURCES = mln_fun_meta_sat.cc
mln_fun_meta_to_enc_SOURCES = mln_fun_meta_to_enc.cc
mln_fun_x2v_linear_SOURCES = mln_fun_x2v_linear.cc
diff --git a/milena/tests/unit_test/mln_fun_meta_blue.cc b/milena/tests/unit_test/mln_fun_meta_blue.cc
new file mode 100644
index 0000000..790ecc7
--- /dev/null
+++ b/milena/tests/unit_test/mln_fun_meta_blue.cc
@@ -0,0 +1,11 @@
+// Unit test for mln/fun/meta/blue.hh.
+// Generated by ./build_unit_test.sh, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <mln/fun/meta/blue.hh>
+#include <mln/fun/meta/blue.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_fun_meta_green.cc b/milena/tests/unit_test/mln_fun_meta_green.cc
new file mode 100644
index 0000000..b302776
--- /dev/null
+++ b/milena/tests/unit_test/mln_fun_meta_green.cc
@@ -0,0 +1,11 @@
+// Unit test for mln/fun/meta/green.hh.
+// Generated by ./build_unit_test.sh, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <mln/fun/meta/green.hh>
+#include <mln/fun/meta/green.hh>
+
+int main()
+{
+ // Nothing.
+}
--
1.5.6.5
* mln/binarization/binarization.hh: remove a non-valid static test.
* mln/value/rgb16.hh,
* mln/fun/v2b/threshold.hh,
* mln/binarization/threshold.hh: update comments.
* mln/debug/colorize.hh: make it work with rgb16.
* mln/value/rgb8.hh: remove useless include.
* tests/core/image/Makefile.am,
* tests/core/image/tr_image.cc: re-enable tr_image test and make it
work.
---
milena/ChangeLog | 18 +++++++++
milena/mln/binarization/binarization.hh | 32 ++++++++--------
milena/mln/binarization/threshold.hh | 38 +++++++++----------
milena/mln/debug/colorize.hh | 15 ++++---
milena/mln/fun/v2b/threshold.hh | 19 ++++-----
milena/mln/value/rgb16.hh | 18 ++++----
milena/mln/value/rgb8.hh | 19 ++++-----
milena/tests/core/image/Makefile.am | 6 +-
milena/tests/core/image/tr_image.cc | 63 +++++++++++++++++++------------
9 files changed, 128 insertions(+), 100 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6f6463d..b2b7dd9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2009-01-06 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Small fixes.
+
+ * mln/binarization/binarization.hh: remove a non-valid static test.
+
+ * mln/value/rgb16.hh,
+ * mln/fun/v2b/threshold.hh,
+ * mln/binarization/threshold.hh: update comments.
+
+ * mln/debug/colorize.hh: make it work with rgb16.
+
+ * mln/value/rgb8.hh: remove useless include.
+
+ * tests/core/image/Makefile.am,
+ * tests/core/image/tr_image.cc: re-enable tr_image test and make it
+ work.
+
+2009-01-06 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Update tutorial.
* doc/Doxyfile.in: Add a new IMAGE_PATH and a new macro expansion in
diff --git a/milena/mln/binarization/binarization.hh b/milena/mln/binarization/binarization.hh
index a333ef2..1a6f2d7 100644
--- a/milena/mln/binarization/binarization.hh
+++ b/milena/mln/binarization/binarization.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +29,9 @@
#ifndef MLN_BINARIZATION_BINARIZATION_HH
# define MLN_BINARIZATION_BINARIZATION_HH
-/*! \file mln/binarization/threshold.hh
- *
- * \brief Threshold the contents of an image into another binary one.
- */
+/// \file mln/binarization/threshold.hh
+///
+/// Threshold the contents of an image into another binary one.
# include <mln/core/concept/function.hh>
# include <mln/level/transform.hh>
@@ -43,20 +43,19 @@ namespace mln
namespace binarization
{
- /*! Thresholds the values of \p input so that they can be stored in
- * the \p output binary image.
- *
- * \param[in] input The input image.
- * \param[in] fun The thresholding function, from value(I) to bool.
- *
- * for_all(p), output(p) = fun(p)
- *
- */
+ /// Thresholds the values of \p input so that they can be stored in
+ /// the \p output binary image.
+ ///
+ /// \param[in] input The input image.
+ /// \param[in] fun The thresholding function, from value(I) to bool.
+ ///
+ /// for_all(p), output(p) = fun(p)
template <typename I, typename F>
inline
mln_concrete_ch_value(I, bool)
binarization(const Image<I>& input, const Function_v2b<F>& fun);
+
# ifndef MLN_INCLUDE_ONLY
namespace impl
@@ -79,6 +78,9 @@ namespace mln
} // end of namespace mln::binarization::impl
+
+ // Facade
+
template <typename I, typename F>
inline
mln_concrete_ch_value(I, bool)
@@ -86,8 +88,6 @@ namespace mln
{
trace::entering("binarization::binarization");
mln_precondition(exact(input).is_valid());
- mlc_is(mln_trait_value_nature(mln_value(I)),
- trait::value::nature::scalar)::check();
mln_concrete_ch_value(I, bool) output(exact(input).domain());
output = impl::binarization_(exact(input), fun);
diff --git a/milena/mln/binarization/threshold.hh b/milena/mln/binarization/threshold.hh
index 104d40e..f76cd8a 100644
--- a/milena/mln/binarization/threshold.hh
+++ b/milena/mln/binarization/threshold.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +29,9 @@
#ifndef MLN_BINARIZATION_THRESHOLD_HH
# define MLN_BINARIZATION_THRESHOLD_HH
-/*! \file mln/binarization/threshold.hh
- *
- * \brief Threshold the contents of an image into another binary one.
- */
+/// \file mln/binarization/threshold.hh
+///
+/// Threshold the contents of an image into another binary one.
# include <mln/binarization/binarization.hh>
# include <mln/fun/v2b/threshold.hh>
@@ -43,21 +43,19 @@ namespace mln
namespace binarization
{
- /*! Thresholds the values of \p input so that they can be stored in
- * the \p output binary image.
- *
- * \param[in] input The input image.
- * \param[in] threshold The threshold.
- *
- * If input(p) is greater or equal than the threshold, the
- * value in the output image in the same point will be TRUE, else FALSE.
- *
- */
+ /// Thresholds the values of \p input so that they can be stored in
+ /// the \p output binary image.
+ ///
+ /// \param[in] input The input image.
+ /// \param[in] threshold The threshold.
+ ///
+ /// If input(p) is greater or equal than the threshold, the
+ /// value in the output image in the same point will be TRUE, else FALSE.
template <typename I>
mln_concrete_ch_value(I, bool)
threshold(const Image<I>& input, const mln_value(I) threshold);
-
+
# ifndef MLN_INCLUDE_ONLY
template <typename I>
@@ -66,18 +64,18 @@ namespace mln
threshold(const Image<I>& input, const mln_value(I) threshold_value)
{
trace::entering("binarization::threshold");
-
+
mln_precondition(exact(input).is_valid());
mlc_is(mln_trait_value_nature(mln_value(I)),
trait::value::nature::scalar)::check();
mln_concrete_ch_value(I, bool) output(exact(input).domain());
-
+
// FIXME : threshold value should be a percentage.
fun::v2b::threshold< mln_value(I) > f(threshold_value);
-
+
output = binarization::binarization(exact(input), f);
-
+
trace::exiting("binarization::threshold");
return output;
}
diff --git a/milena/mln/debug/colorize.hh b/milena/mln/debug/colorize.hh
index 544a755..44021ec 100644
--- a/milena/mln/debug/colorize.hh
+++ b/milena/mln/debug/colorize.hh
@@ -85,14 +85,15 @@ namespace mln
{
template <typename V>
- V random_color();
+ V random_color(const V&);
- mln::value::rgb8
- random_color()
+ template <unsigned n>
+ mln::value::rgb<n>
+ random_color(const mln::value::rgb<n>&)
{
- return mln::value::rgb8(colorize_::min_value + (rand() % colorize_::max_value),
- colorize_::min_value + (rand() % colorize_::max_value),
- colorize_::min_value + (rand() % colorize_::max_value));
+ return mln::value::rgb<n>(colorize_::min_value + (rand() % colorize_::max_value),
+ colorize_::min_value + (rand() % colorize_::max_value),
+ colorize_::min_value + (rand() % colorize_::max_value));
}
}
@@ -125,7 +126,7 @@ namespace mln
f(0) = literal::black;
}
for (; i < f.size(); ++i)
- f(i) = internal::random_color();
+ f(i) = internal::random_color(value);
}
mln_assertion(f.size() >= (label_count));
mln_ch_value(L, V) output = level::transform(input, f);
diff --git a/milena/mln/fun/v2b/threshold.hh b/milena/mln/fun/v2b/threshold.hh
index c8ea02c..85b7831 100644
--- a/milena/mln/fun/v2b/threshold.hh
+++ b/milena/mln/fun/v2b/threshold.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// 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
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_V2B_THRESHOLD_HH
# define MLN_FUN_V2B_THRESHOLD_HH
-/*! \file mln/fun/v2b/threshold.hh
- *
- * \brief FIXME.
- */
+/// \file mln/fun/v2b/threshold.hh
+///
+/// FIXME.
# include <mln/core/concept/function.hh>
@@ -45,11 +45,8 @@ namespace mln
namespace v2b
{
- /*!
- *\brief Threshold function.
- * f(v) = (v >= threshold).
- *
- */
+ /// Threshold function.
+ /// f(v) = (v >= threshold).
template <typename V>
struct threshold : public Function_v2b< threshold<V> >
{
@@ -75,7 +72,7 @@ namespace mln
bool
threshold<V>::operator()(const V& v) const
{
- return (v >= a);
+ return v >= a;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/value/rgb16.hh b/milena/mln/value/rgb16.hh
index 1a22013..a012aa0 100644
--- a/milena/mln/value/rgb16.hh
+++ b/milena/mln/value/rgb16.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_RGB16_HH
# define MLN_VALUE_RGB16_HH
-/*! \file mln/value/rgb16.hh
- *
- * \brief Color class for red-green-blue where every component is
- * 16-bit encoded.
- */
+/// \file mln/value/rgb16.hh
+///
+/// Color class for red-green-blue where every component is
+/// 16-bit encoded.
# include <mln/value/rgb.hh>
@@ -43,10 +43,10 @@ namespace mln
namespace value
{
- /*! \brief Color class for red-green-blue where every component is
- * 16-bit encoded.
- */
+ /// Color class for red-green-blue where every component is
+ /// 16-bit encoded.
typedef rgb<16> rgb16;
+
} // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/mln/value/rgb8.hh b/milena/mln/value/rgb8.hh
index e31df55..25a2c9a 100644
--- a/milena/mln/value/rgb8.hh
+++ b/milena/mln/value/rgb8.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,14 +29,12 @@
#ifndef MLN_VALUE_RGB8_HH
# define MLN_VALUE_RGB8_HH
-/*! \file mln/value/rgb8.hh
- *
- * \brief Color class for red-green-blue where every component is
- * 8-bit encoded.
- */
+/// \file mln/value/rgb8.hh
+///
+/// Color class for red-green-blue where every component is
+/// 8-bit encoded.
# include <mln/value/rgb.hh>
-# include <mln/value/int_u8.hh>
namespace mln
@@ -44,10 +43,10 @@ namespace mln
namespace value
{
- /*! \brief Color class for red-green-blue where every component is
- * 8-bit encoded.
- */
+ /// Color class for red-green-blue where every component is
+ /// 8-bit encoded.
typedef rgb<8> rgb8;
+
} // end of namespace mln::value
} // end of namespace mln
diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am
index 72f0c93..1faaaf5 100644
--- a/milena/tests/core/image/Makefile.am
+++ b/milena/tests/core/image/Makefile.am
@@ -26,8 +26,8 @@ check_PROGRAMS = \
safe_image \
## sparse_image \
sub_image \
- t_image
-## tr_image
+ t_image \
+ tr_image
## value_enc_image
noinst_HEADERS = complex_image.hh
@@ -55,7 +55,7 @@ safe_image_SOURCES = safe_image.cc
##sparse_image_SOURCES = sparse_image.cc
sub_image_SOURCES = sub_image.cc
t_image_SOURCES = t_image.cc
-##tr_image_SOURCES = tr_image.cc
+tr_image_SOURCES = tr_image.cc
##value_enc_image_SOURCES = value_enc_image.cc
# Tests depending on the FreeImagePlus library.
diff --git a/milena/tests/core/image/tr_image.cc b/milena/tests/core/image/tr_image.cc
index 90b2b9f..804a6a3 100644
--- a/milena/tests/core/image/tr_image.cc
+++ b/milena/tests/core/image/tr_image.cc
@@ -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
@@ -25,10 +26,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/image/tr_image.cc
- *
- * \brief Tests on mln::tr_image.
- */
+/// \file tests/core/image/tr_image.cc
+///
+/// Tests on mln::tr_image.
+/// FIXME: write a real test!
#include <iostream>
@@ -44,28 +45,42 @@ int main()
using namespace mln;
using value::int_u8;
- image3d<int_u8> in(3, 3, 3);
- image3d<int_u8> out(in.domain());
+ {
+ image2d<int_u8> in(3, 3);
- debug::iota(in);
- debug::println(in);
+ debug::iota(in);
+ debug::println(in);
- fun::x2x::rotation<3, float> rot1(1.67, literal::zero);
+ algebra::vec<2, float> v;
+ v[0] = 0;
+ v[1] = 1;
+ fun::x2x::rotation<2, float> rot1(1.67, v);
- tr_image<mln_pset_(image3d<int_u8>),
- image3d<int_u8>,
- fun::x2x::rotation<3, float> >
- inter(out.domain(), in, rot1);
+ tr_image<mln_pset_(image2d<int_u8>),
+ image2d<int_u8>,
+ fun::x2x::rotation<2, float> >
+ inter(in.domain(), in, rot1);
- image3d<int_u8>::fwd_piter p(out.domain());
+ debug::println(inter);
+ }
- for_all(p)
- {
- algebra::vec<3, int> vec = p.to_site().to_vec();
- if (inter.has(p))
- out(p) = inter(vec);
- else
- out(p) = 255;
- }
- debug::println(out);
+ {
+ image3d<int_u8> in(3, 3, 3);
+
+ debug::iota(in);
+ debug::println(in);
+
+ algebra::vec<3, float> v;
+ v[0] = 0;
+ v[1] = 0;
+ v[2] = 1;
+ fun::x2x::rotation<3, float> rot1(1.67, v);
+
+ tr_image<mln_pset_(image3d<int_u8>),
+ image3d<int_u8>,
+ fun::x2x::rotation<3, float> >
+ inter(in.domain(), in, rot1);
+
+ debug::println(inter);
+ }
}
--
1.5.6.5
* milena/headers.mk: add new headers to distribution.
* milena/mln/core/image/graph_elt_neighborhood.hh,
* milena/mln/core/image/line_graph_elt_neighborhood.hh: new files. Add
new aliases for graph based neighborhoods.
* milena/mln/core/image/graph_elt_window.hh,
* milena/mln/core/image/line_graph_elt_window.hh,
* milena/mln/core/internal/neighborhood_base.hh,
* milena/tests/core/image/graph_image.cc,
* milena/tests/core/image/line_graph_image.cc,
* milena/tests/core/other/graph_elt_neighborhood.cc,
* milena/tests/core/other/line_graph_elt_neighborhood.cc,
* milena/tools/area_flooding.cc: make use of these new aliases.
* milena/tests/unit_test/Makefile.am,
* milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc,
* milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc:
Add new unit tests.
---
milena/ChangeLog | 24 ++++++
milena/headers.mk | 2 +
milena/mln/core/image/graph_elt_neighborhood.hh | 79 ++++++++++++++++++++
milena/mln/core/image/graph_elt_window.hh | 14 +---
.../mln/core/image/line_graph_elt_neighborhood.hh | 79 ++++++++++++++++++++
milena/mln/core/image/line_graph_elt_window.hh | 15 +---
milena/mln/core/internal/neighborhood_base.hh | 5 +-
milena/tests/core/image/graph_image.cc | 5 +-
milena/tests/core/image/line_graph_image.cc | 5 +-
milena/tests/core/other/graph_elt_neighborhood.cc | 6 +-
.../core/other/line_graph_elt_neighborhood.cc | 6 +-
milena/tests/unit_test/Makefile.am | 4 +
.../mln_core_image_graph_elt_neighborhood.cc | 11 +++
.../mln_core_image_line_graph_elt_neighborhood.cc | 11 +++
milena/tools/area_flooding.cc | 5 +-
15 files changed, 230 insertions(+), 41 deletions(-)
create mode 100644 milena/mln/core/image/graph_elt_neighborhood.hh
create mode 100644 milena/mln/core/image/line_graph_elt_neighborhood.hh
create mode 100644 milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc
create mode 100644 milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7b4a1f2..f0f8199 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,27 @@
+2009-01-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add graph_elt_neighborhood and line_graph_elt_neighborhood aliases.
+
+ * milena/headers.mk: add new headers to distribution.
+
+ * milena/mln/core/image/graph_elt_neighborhood.hh,
+ * milena/mln/core/image/line_graph_elt_neighborhood.hh: new files. Add
+ new aliases for graph based neighborhoods.
+
+ * milena/mln/core/image/graph_elt_window.hh,
+ * milena/mln/core/image/line_graph_elt_window.hh,
+ * milena/mln/core/internal/neighborhood_base.hh,
+ * milena/tests/core/image/graph_image.cc,
+ * milena/tests/core/image/line_graph_image.cc,
+ * milena/tests/core/other/graph_elt_neighborhood.cc,
+ * milena/tests/core/other/line_graph_elt_neighborhood.cc,
+ * milena/tools/area_flooding.cc: make use of these new aliases.
+
+ * milena/tests/unit_test/Makefile.am,
+ * milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc,
+ * milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc:
+ Add new unit tests.
+
2009-01-05 Nicolas Ballas <ballas(a)lrde.epita.fr>
Update documentation on properties.
diff --git a/milena/headers.mk b/milena/headers.mk
index b348a9e..3365173 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -885,6 +885,7 @@ mln/core/image/t_image.hh \
mln/core/image/hexa_piter.hh \
mln/core/image/value_enc_image.hh \
mln/core/image/fun_image.hh \
+mln/core/image/graph_elt_neighborhood.hh \
mln/core/image/sub_image_if.hh \
mln/core/image/all.hh \
mln/core/image/mono_rle_image.hh \
@@ -909,6 +910,7 @@ mln/core/image/image1d.hh \
mln/core/image/extension_val.hh \
mln/core/image/image_if.hh \
mln/core/image/hexa.hh \
+mln/core/image/line_graph_elt_neighborhood.hh \
mln/core/image/extended.hh \
mln/core/image/image2d_h.hh \
mln/core/image/image2d.hh \
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh b/milena/mln/core/image/graph_elt_neighborhood.hh
new file mode 100644
index 0000000..dc08ad9
--- /dev/null
+++ b/milena/mln/core/image/graph_elt_neighborhood.hh
@@ -0,0 +1,79 @@
+// 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_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+
+/// \file mln/core/image/graph_elt_neighborhood.hh
+///
+/// Definition of the elementary ``neighborhood'' on a graph.
+
+# include <mln/core/neighb.hh>
+# include <mln/core/image/graph_elt_window.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename G, typename F, typename E>
+ struct neighborhood_impl<graph_elt_window<G,F>,E>
+ : public neighborhood_extra_impl<graph_elt_window<G,F>,E>
+ {
+ };
+
+ } // end of namespace mln::internal
+
+
+ /// Elementary neighborhood on graph class.
+ template <typename G, typename F>
+ struct graph_elt_neighborhood
+ : public neighb< graph_elt_window<G,F> >
+ {
+ typedef neighb< graph_elt_window<G,F> > super_;
+
+ graph_elt_neighborhood();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+template <typename G, typename F>
+inline
+graph_elt_neighborhood<G,F>::graph_elt_neighborhood()
+{
+}
+
+# endif // ! MLN_INCLUDE_ONLY
+
+}
+
+#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+
diff --git a/milena/mln/core/image/graph_elt_window.hh b/milena/mln/core/image/graph_elt_window.hh
index 2e47cb2..e1929df 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_window.hh
@@ -46,18 +46,6 @@ namespace mln
/// Forward declaration
template <typename G, typename F> class graph_elt_window;
- namespace internal
- {
-
- template <typename G, typename F, typename E>
- struct neighborhood_impl<graph_elt_window<G,F>,E>
- : public neighborhood_extra_impl<graph_elt_window<G,F>,E>
- {
- };
-
- } // end of namespace mln::internal
-
-
namespace trait
{
@@ -72,7 +60,7 @@ namespace mln
} // end of namespace mln::trait
- /// \brief Elementary window on graph class.
+ /// Elementary window on graph class.
template <typename G, typename F>
class graph_elt_window : public graph_window_base<mln_result(F),
graph_elt_window<G,F> >
diff --git a/milena/mln/core/image/line_graph_elt_neighborhood.hh b/milena/mln/core/image/line_graph_elt_neighborhood.hh
new file mode 100644
index 0000000..92c7611
--- /dev/null
+++ b/milena/mln/core/image/line_graph_elt_neighborhood.hh
@@ -0,0 +1,79 @@
+// 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_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+
+/// \file mln/core/image/line_graph_elt_neighborhood.hh
+///
+/// Definition of the elementary ``neighborhood'' on a line graph.
+
+# include <mln/core/neighb.hh>
+# include <mln/core/image/line_graph_elt_window.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename G, typename F, typename E>
+ struct neighborhood_impl<line_graph_elt_window<G,F>,E>
+ : public neighborhood_extra_impl<line_graph_elt_window<G,F>,E>
+ {
+ };
+
+ } // end of namespace mln::internal
+
+
+ /// Elementary neighborhood on line graph class.
+ template <typename G, typename F>
+ struct line_graph_elt_neighborhood
+ : public neighb< line_graph_elt_window<G,F> >
+ {
+ typedef neighb< line_graph_elt_window<G,F> > super_;
+
+ line_graph_elt_neighborhood();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+template <typename G, typename F>
+inline
+line_graph_elt_neighborhood<G,F>::line_graph_elt_neighborhood()
+{
+}
+
+# endif // ! MLN_INCLUDE_ONLY
+
+}
+
+#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+
diff --git a/milena/mln/core/image/line_graph_elt_window.hh b/milena/mln/core/image/line_graph_elt_window.hh
index 9717f48..d9f7138 100644
--- a/milena/mln/core/image/line_graph_elt_window.hh
+++ b/milena/mln/core/image/line_graph_elt_window.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
@@ -46,17 +46,6 @@ namespace mln
/// Forward declaration
template <typename G, typename F> class line_graph_elt_window;
- namespace internal
- {
-
- template <typename G, typename F, typename E>
- struct neighborhood_impl<line_graph_elt_window<G,F>,E>
- : public neighborhood_extra_impl<line_graph_elt_window<G,F>,E>
- {
- };
-
- } // end of namespace mln::internal
-
namespace trait
{
diff --git a/milena/mln/core/internal/neighborhood_base.hh b/milena/mln/core/internal/neighborhood_base.hh
index 4879fc1..35349fc 100644
--- a/milena/mln/core/internal/neighborhood_base.hh
+++ b/milena/mln/core/internal/neighborhood_base.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
@@ -143,7 +144,7 @@ namespace mln
// neighborhood_base
-
+
template <typename W, typename E>
inline
neighborhood_base<W,E>::neighborhood_base()
diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/graph_image.cc
index f12d8f9..e8a71f2 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/graph_image.cc
@@ -33,6 +33,7 @@
#include <mln/core/site_set/p_vertices.hh>
#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
#include <mln/core/concept/function.hh>
#include <mln/core/neighb.hh>
#include <mln/core/var.hh>
@@ -204,8 +205,8 @@ int main()
}
}
- typedef neighb<win_t> neighb_t;
- neighb_t neigh(win);
+ typedef graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
+ neighb_t neigh;
{
// Neighborhood - Forward iteration
mln_niter_(neighb_t) n(neigh, p);
diff --git a/milena/tests/core/image/line_graph_image.cc b/milena/tests/core/image/line_graph_image.cc
index d565a9f..fe660f5 100644
--- a/milena/tests/core/image/line_graph_image.cc
+++ b/milena/tests/core/image/line_graph_image.cc
@@ -34,6 +34,7 @@
/// Required for line graph images.
#include <mln/core/site_set/p_edges.hh>
#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/core/neighb.hh>
#include <mln/core/var.hh>
#include <mln/pw/all.hh>
@@ -163,8 +164,8 @@ int main()
}
- typedef neighb<win_t> neighb_t;
- neighb_t neigh(win);
+ typedef line_graph_elt_neighborhood<util::graph, fsite_t> neighb_t;
+ neighb_t neigh;
{
// Neighborhood - Forward iteration
diff --git a/milena/tests/core/other/graph_elt_neighborhood.cc b/milena/tests/core/other/graph_elt_neighborhood.cc
index 797b826..aafe485 100644
--- a/milena/tests/core/other/graph_elt_neighborhood.cc
+++ b/milena/tests/core/other/graph_elt_neighborhood.cc
@@ -33,12 +33,12 @@
#include <vector>
-#include <mln/core/neighb.hh>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/graph_elt_window.hh>
#include <mln/core/site_set/p_vertices.hh>
#include <mln/util/graph.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+
unsigned fwd_neighb[] = { 0, 2, 3 };
unsigned bkd_neighb[] = { 3, 2, 0 };
@@ -101,7 +101,7 @@ int main()
mln_psite_(pv_t) p(pg, 1);
// ``Sliding'' neighborhood of a psite of PG.
- typedef neighb< graph_elt_window<G, F> > nbh_t;
+ typedef graph_elt_neighborhood<G, F> nbh_t;
nbh_t nbh;
unsigned i = 0;
diff --git a/milena/tests/core/other/line_graph_elt_neighborhood.cc b/milena/tests/core/other/line_graph_elt_neighborhood.cc
index 197091e..cbc7d75 100644
--- a/milena/tests/core/other/line_graph_elt_neighborhood.cc
+++ b/milena/tests/core/other/line_graph_elt_neighborhood.cc
@@ -32,11 +32,11 @@
#include <vector>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/neighb.hh>
#include <mln/core/site_set/p_edges.hh>
-#include <mln/core/image/line_graph_elt_window.hh>
#include <mln/util/graph.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+
unsigned fwd_neighb[] = { 0, 2, 4 };
unsigned bkd_neighb[] = { 4, 2, 0 };
@@ -100,7 +100,7 @@ int main()
mln_psite_(pe_t) p(pe, 1);
// ``Sliding'' neighborhood of a psite of PLG.
- typedef neighb< line_graph_elt_window<G, F> > nbh_t;
+ typedef line_graph_elt_neighborhood<G, F> nbh_t;
nbh_t nbh;
unsigned i = 0;
diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am
index 91e56f5..168c709 100644
--- a/milena/tests/unit_test/Makefile.am
+++ b/milena/tests/unit_test/Makefile.am
@@ -856,6 +856,7 @@ mln_core_image_t_image \
mln_core_image_hexa_piter \
mln_core_image_value_enc_image \
mln_core_image_fun_image \
+mln_core_image_graph_elt_neighborhood \
mln_core_image_sub_image_if \
mln_core_image_all \
mln_core_image_mono_rle_image \
@@ -880,6 +881,7 @@ mln_core_image_image1d \
mln_core_image_extension_val \
mln_core_image_image_if \
mln_core_image_hexa \
+mln_core_image_line_graph_elt_neighborhood \
mln_core_image_extended \
mln_core_image_image2d_h \
mln_core_image_image2d \
@@ -1862,6 +1864,7 @@ mln_core_image_t_image_SOURCES = mln_core_image_t_image.cc
mln_core_image_hexa_piter_SOURCES = mln_core_image_hexa_piter.cc
mln_core_image_value_enc_image_SOURCES = mln_core_image_value_enc_image.cc
mln_core_image_fun_image_SOURCES = mln_core_image_fun_image.cc
+mln_core_image_graph_elt_neighborhood_SOURCES = mln_core_image_graph_elt_neighborhood.cc
mln_core_image_sub_image_if_SOURCES = mln_core_image_sub_image_if.cc
mln_core_image_all_SOURCES = mln_core_image_all.cc
mln_core_image_mono_rle_image_SOURCES = mln_core_image_mono_rle_image.cc
@@ -1886,6 +1889,7 @@ mln_core_image_image1d_SOURCES = mln_core_image_image1d.cc
mln_core_image_extension_val_SOURCES = mln_core_image_extension_val.cc
mln_core_image_image_if_SOURCES = mln_core_image_image_if.cc
mln_core_image_hexa_SOURCES = mln_core_image_hexa.cc
+mln_core_image_line_graph_elt_neighborhood_SOURCES = mln_core_image_line_graph_elt_neighborhood.cc
mln_core_image_extended_SOURCES = mln_core_image_extended.cc
mln_core_image_image2d_h_SOURCES = mln_core_image_image2d_h.cc
mln_core_image_image2d_SOURCES = mln_core_image_image2d.cc
diff --git a/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc b/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc
new file mode 100644
index 0000000..b5c220b
--- /dev/null
+++ b/milena/tests/unit_test/mln_core_image_graph_elt_neighborhood.cc
@@ -0,0 +1,11 @@
+// Unit test for mln/core/image/graph_elt_neighborhood.hh.
+// Generated by ./build_unit_test.sh, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <mln/core/image/graph_elt_neighborhood.hh>
+#include <mln/core/image/graph_elt_neighborhood.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc b/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc
new file mode 100644
index 0000000..9e4a7de
--- /dev/null
+++ b/milena/tests/unit_test/mln_core_image_line_graph_elt_neighborhood.cc
@@ -0,0 +1,11 @@
+// Unit test for mln/core/image/line_graph_elt_neighborhood.hh.
+// Generated by ./build_unit_test.sh, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc
index da7c378..fc5c444 100644
--- a/milena/tools/area_flooding.cc
+++ b/milena/tools/area_flooding.cc
@@ -57,8 +57,7 @@
#include <mln/core/routine/duplicate.hh>
#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/image/line_graph_elt_neighborhood.hh>
#include <mln/core/var.hh>
#include <mln/morpho/line_gradient.hh>
@@ -114,7 +113,7 @@ int main(int argc, char* argv[])
/* FIXME: I'm not sure this is the way it should be done. Anyway,
we should implement this as a canvas. */
- typedef neighb< line_graph_elt_window<util::graph, lg_ima_t::pset::fun_t> > nbh_t;
+ typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t;
nbh_t nbh;
unsigned area = 0;
--
1.5.6.5