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
* headers.mk,
* tests/unit_test/unit-tests.mk: update.
* mln/morpho/watershed/all.hh: add new include.
* mln/morpho/watershed/superpose.hh: new routine.
* tests/morpho/watershed/Makefile.am,
* tests/morpho/watershed/superpose.cc: add associated test.
---
milena/ChangeLog | 16 +++-
milena/headers.mk | 12 ++
milena/mln/morpho/watershed/all.hh | 1 +
milena/mln/morpho/watershed/superpose.hh | 127 ++++++++++++++++++++
milena/tests/morpho/watershed/Makefile.am | 4 +-
.../all.hh => tests/morpho/watershed/superpose.cc} | 65 +++++++----
milena/tests/unit_test/unit-tests.mk | 22 ++++
7 files changed, 222 insertions(+), 25 deletions(-)
create mode 100644 milena/mln/morpho/watershed/superpose.hh
copy milena/{mln/morpho/watershed/all.hh => tests/morpho/watershed/superpose.cc} (53%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index cda14ac..46e8b76 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,18 @@
-2009-03-16 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+2009-03-18 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add morpho::watershed::superpose.
+
+ * headers.mk,
+ * tests/unit_test/unit-tests.mk: update.
+
+ * mln/morpho/watershed/all.hh: add new include.
+
+ * mln/morpho/watershed/superpose.hh: new routine.
+
+ * tests/morpho/watershed/Makefile.am,
+ * tests/morpho/watershed/superpose.cc: add associated test.
+
+2009-03-18 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes.
diff --git a/milena/headers.mk b/milena/headers.mk
index dfab609..a74f35f 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -234,6 +234,7 @@ mln/fun/v2v/cast.hh \
mln/fun/v2v/ch_function_value.hh \
mln/fun/v2v/rgb_to_hsi.hh \
mln/fun/v2v/enc.hh \
+mln/fun/v2v/projection.hh \
mln/fun/v2v/convert.hh \
mln/fun/v2v/essential.hh \
mln/fun/v2w2v/cos.hh \
@@ -410,6 +411,12 @@ mln/accu/lor_basic.hh \
mln/accu/transform_diagonal.hh \
mln/accu/nil.hh \
mln/accu/bbox.hh \
+mln/accu/image/init.hh \
+mln/accu/image/to_result.hh \
+mln/accu/image/all.hh \
+mln/accu/image/set_value.hh \
+mln/accu/image/take.hh \
+mln/accu/image/take_as_init.hh \
mln/accu/center.hh \
mln/accu/line.hh \
mln/accu/essential.hh \
@@ -652,6 +659,7 @@ mln/morpho/laplacian.hh \
mln/morpho/all.hh \
mln/morpho/watershed/flooding.hh \
mln/morpho/watershed/all.hh \
+mln/morpho/watershed/superpose.hh \
mln/morpho/opening/approx/all.hh \
mln/morpho/opening/approx/structural.hh \
mln/morpho/opening/all.hh \
@@ -812,6 +820,7 @@ mln/core/internal/image_domain_morpher.hh \
mln/core/internal/image_primary.hh \
mln/core/internal/set_of.hh \
mln/core/internal/complex_window_p_base.hh \
+mln/core/internal/piter_identity.hh \
mln/core/internal/graph_window_base.hh \
mln/core/internal/piter_adaptor.hh \
mln/core/internal/weighted_window_base.hh \
@@ -936,6 +945,7 @@ mln/core/clock_neighb2d.hh \
mln/core/pixter3d.hh \
mln/core/image/obased_rle_encode.hh \
mln/core/image/plain.hh \
+mln/core/image/unproject_image.hh \
mln/core/image/image3d.hh \
mln/core/image/decorated_image.hh \
mln/core/image/extension_ima.hh \
@@ -1047,6 +1057,8 @@ mln/io/cloud/load.hh \
mln/io/cloud/all.hh \
mln/io/cloud/save.hh \
mln/io/all.hh \
+mln/io/magick/load.hh \
+mln/io/magick/all.hh \
mln/io/dump/load.hh \
mln/io/dump/all.hh \
mln/io/dump/save.hh \
diff --git a/milena/mln/morpho/watershed/all.hh b/milena/mln/morpho/watershed/all.hh
index 472ff20..cb2238e 100644
--- a/milena/mln/morpho/watershed/all.hh
+++ b/milena/mln/morpho/watershed/all.hh
@@ -60,6 +60,7 @@ namespace mln
# include <mln/morpho/watershed/flooding.hh>
+# include <mln/morpho/watershed/superpose.hh>
#endif // ! MLN_MORPHO_WATERSHED_ALL_HH
diff --git a/milena/mln/morpho/watershed/superpose.hh b/milena/mln/morpho/watershed/superpose.hh
new file mode 100644
index 0000000..bad2a71
--- /dev/null
+++ b/milena/mln/morpho/watershed/superpose.hh
@@ -0,0 +1,127 @@
+// 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_MORPHO_WATERSHED_SUPERPOSE_HH
+# define MLN_MORPHO_WATERSHED_SUPERPOSE_HH
+
+/// \file mln/morpho/watershed/superpose.hh
+///
+/// Convert an image to a rgb8 image and draw the watershed lines.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/level/convert.hh>
+# include <mln/data/fill.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/literal/colors.hh>
+# include <mln/pw/all.hh>
+
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace watershed
+ {
+
+ /// Convert an image to a rgb8 image and draw the watershed lines.
+ /*
+ ** \param[in] input_ An image.
+ ** \param[in] ws_ima_ The watershed transform of \p input_.
+ ** \param[in] wsl_color The color used for the watershed line.
+ */
+ template <typename I, typename J>
+ inline
+ mln_ch_value(I,value::rgb8)
+ superpose(const Image<I>& input_,
+ const Image<J>& ws_ima_,
+ const value::rgb8& wsl_color);
+
+
+ /// Convert an image to a rgb8 image and draw the watershed lines.
+ /*
+ ** \param[in] input_ An image.
+ ** \param[in] ws_ima_ The watershed transform of \p input_.
+ **
+ ** The watershed line is drawn in red.
+ */
+ template <typename I, typename J>
+ inline
+ mln_ch_value(I,value::rgb8)
+ superpose(const Image<I>& input,
+ const Image<J>& ws_ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename J>
+ inline
+ mln_ch_value(I,value::rgb8)
+ superpose(const Image<I>& input_,
+ const Image<J>& ws_ima_,
+ const value::rgb8& wsl_color)
+ {
+ trace::entering("morpho::watershed::superpose");
+
+ const I& input = exact(input_);
+ const J& ws_ima = exact(ws_ima_);
+ mln_precondition(input.is_valid());
+ mln_precondition(ws_ima.is_valid());
+
+ mln_ch_value(I,value::rgb8) output = level::convert(value::rgb8(), input);
+
+ data::fill((output | (pw::value(ws_ima) == pw::cst(literal::zero))).rw(),
+ wsl_color);
+
+ trace::exiting("morpho::watershed::superpose");
+ return output;
+ }
+
+
+ template <typename I, typename J>
+ inline
+ mln_ch_value(I,value::rgb8)
+ superpose(const Image<I>& input,
+ const Image<J>& ws_ima)
+ {
+ return superpose(input, ws_ima, literal::red);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::morpho::watershed
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+#endif // ! MLN_MORPHO_WATERSHED_SUPERPOSE_HH
diff --git a/milena/tests/morpho/watershed/Makefile.am b/milena/tests/morpho/watershed/Makefile.am
index 2b022e8..63dc2a7 100644
--- a/milena/tests/morpho/watershed/Makefile.am
+++ b/milena/tests/morpho/watershed/Makefile.am
@@ -3,8 +3,10 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- flooding
+ flooding \
+ superpose
flooding_SOURCES = flooding.cc
+superpose_SOURCES = superpose.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/mln/morpho/watershed/all.hh b/milena/tests/morpho/watershed/superpose.cc
similarity index 53%
copy from milena/mln/morpho/watershed/all.hh
copy to milena/tests/morpho/watershed/superpose.cc
index 472ff20..edace77 100644
--- a/milena/mln/morpho/watershed/all.hh
+++ b/milena/tests/morpho/watershed/superpose.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,41 +25,60 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_WATERSHED_ALL_HH
-# define MLN_MORPHO_WATERSHED_ALL_HH
-
-/// \file mln/morpho/watershed/all.hh
+/// \file tests/morpho/watershed/superpose.cc
///
-/// File that includes all morphological watershed routines.
+/// Test on mln::morpho::watershed::superpose.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/make/image2d.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/watershed/superpose.hh>
+#include <mln/level/compare.hh>
+#include "tests/data.hh"
+
+#include <mln/debug/println.hh>
+#include <mln/debug/iota.hh>
namespace mln
{
- namespace morpho
+ struct ref_data : Function_p2v<ref_data>
{
+ typedef value::rgb8 result;
- /// Namespace of morphological watershed routines.
- namespace watershed
+ value::rgb8 operator()(const point2d& p) const
{
+ if (p.row() == 2 || p.col() == 2)
+ return literal::red;
+ unsigned val = p.col() + 1 + p.row() * 4;
+ return value::rgb8(val, val, val);
+ }
- /// Namespace of morphological watershed routines
- /// implementations.
- namespace watershed
- {
+ };
- /// Namespace of morphological watershed routines generic
- /// implementations.
- namespace generic
- {}
+} // end of namespace mln
- }
- }
- }
-}
+int main()
+{
+ using namespace mln;
+ image2d<value::int_u8> ima(4,4);
+ debug::iota(ima);
-# include <mln/morpho/watershed/flooding.hh>
+ value::label_8 data_ws[16] = { 1, 1, 0, 2,
+ 1, 1, 0, 2,
+ 0, 0, 0, 0,
+ 5, 5, 0, 4 };
+ image2d<value::label_8> ima_ws = make::image2d(data_ws);
-#endif // ! MLN_MORPHO_WATERSHED_ALL_HH
+ image2d<value::rgb8> sup = morpho::watershed::superpose(ima, ima_ws);
+ mln_assertion(sup == (ref_data() | sup.domain()));
+}
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index f288f80..1449e41 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -229,6 +229,7 @@ mln_fun_v2v_cast \
mln_fun_v2v_ch_function_value \
mln_fun_v2v_rgb_to_hsi \
mln_fun_v2v_enc \
+mln_fun_v2v_projection \
mln_fun_v2v_convert \
mln_fun_v2v_essential \
mln_fun_v2w2v_cos \
@@ -405,6 +406,12 @@ mln_accu_lor_basic \
mln_accu_transform_diagonal \
mln_accu_nil \
mln_accu_bbox \
+mln_accu_image_init \
+mln_accu_image_to_result \
+mln_accu_image_all \
+mln_accu_image_set_value \
+mln_accu_image_take \
+mln_accu_image_take_as_init \
mln_accu_center \
mln_accu_line \
mln_accu_essential \
@@ -645,6 +652,7 @@ mln_morpho_laplacian \
mln_morpho_all \
mln_morpho_watershed_flooding \
mln_morpho_watershed_all \
+mln_morpho_watershed_superpose \
mln_morpho_opening_approx_all \
mln_morpho_opening_approx_structural \
mln_morpho_opening_all \
@@ -804,6 +812,7 @@ mln_core_internal_image_domain_morpher \
mln_core_internal_image_primary \
mln_core_internal_set_of \
mln_core_internal_complex_window_p_base \
+mln_core_internal_piter_identity \
mln_core_internal_graph_window_base \
mln_core_internal_piter_adaptor \
mln_core_internal_weighted_window_base \
@@ -911,6 +920,7 @@ mln_core_clock_neighb2d \
mln_core_pixter3d \
mln_core_image_obased_rle_encode \
mln_core_image_plain \
+mln_core_image_unproject_image \
mln_core_image_image3d \
mln_core_image_decorated_image \
mln_core_image_extension_ima \
@@ -1018,6 +1028,8 @@ mln_io_cloud_load \
mln_io_cloud_all \
mln_io_cloud_save \
mln_io_all \
+mln_io_magick_load \
+mln_io_magick_all \
mln_io_dump_load \
mln_io_dump_all \
mln_io_dump_save \
@@ -1326,6 +1338,7 @@ mln_fun_v2v_cast_SOURCES = mln_fun_v2v_cast.cc
mln_fun_v2v_ch_function_value_SOURCES = mln_fun_v2v_ch_function_value.cc
mln_fun_v2v_rgb_to_hsi_SOURCES = mln_fun_v2v_rgb_to_hsi.cc
mln_fun_v2v_enc_SOURCES = mln_fun_v2v_enc.cc
+mln_fun_v2v_projection_SOURCES = mln_fun_v2v_projection.cc
mln_fun_v2v_convert_SOURCES = mln_fun_v2v_convert.cc
mln_fun_v2v_essential_SOURCES = mln_fun_v2v_essential.cc
mln_fun_v2w2v_cos_SOURCES = mln_fun_v2w2v_cos.cc
@@ -1502,6 +1515,12 @@ mln_accu_lor_basic_SOURCES = mln_accu_lor_basic.cc
mln_accu_transform_diagonal_SOURCES = mln_accu_transform_diagonal.cc
mln_accu_nil_SOURCES = mln_accu_nil.cc
mln_accu_bbox_SOURCES = mln_accu_bbox.cc
+mln_accu_image_init_SOURCES = mln_accu_image_init.cc
+mln_accu_image_to_result_SOURCES = mln_accu_image_to_result.cc
+mln_accu_image_all_SOURCES = mln_accu_image_all.cc
+mln_accu_image_set_value_SOURCES = mln_accu_image_set_value.cc
+mln_accu_image_take_SOURCES = mln_accu_image_take.cc
+mln_accu_image_take_as_init_SOURCES = mln_accu_image_take_as_init.cc
mln_accu_center_SOURCES = mln_accu_center.cc
mln_accu_line_SOURCES = mln_accu_line.cc
mln_accu_essential_SOURCES = mln_accu_essential.cc
@@ -1742,6 +1761,7 @@ mln_morpho_laplacian_SOURCES = mln_morpho_laplacian.cc
mln_morpho_all_SOURCES = mln_morpho_all.cc
mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc
mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc
+mln_morpho_watershed_superpose_SOURCES = mln_morpho_watershed_superpose.cc
mln_morpho_opening_approx_all_SOURCES = mln_morpho_opening_approx_all.cc
mln_morpho_opening_approx_structural_SOURCES = mln_morpho_opening_approx_structural.cc
mln_morpho_opening_all_SOURCES = mln_morpho_opening_all.cc
@@ -1901,6 +1921,7 @@ mln_core_internal_image_domain_morpher_SOURCES = mln_core_internal_image_domain_
mln_core_internal_image_primary_SOURCES = mln_core_internal_image_primary.cc
mln_core_internal_set_of_SOURCES = mln_core_internal_set_of.cc
mln_core_internal_complex_window_p_base_SOURCES = mln_core_internal_complex_window_p_base.cc
+mln_core_internal_piter_identity_SOURCES = mln_core_internal_piter_identity.cc
mln_core_internal_graph_window_base_SOURCES = mln_core_internal_graph_window_base.cc
mln_core_internal_piter_adaptor_SOURCES = mln_core_internal_piter_adaptor.cc
mln_core_internal_weighted_window_base_SOURCES = mln_core_internal_weighted_window_base.cc
@@ -2008,6 +2029,7 @@ mln_core_clock_neighb2d_SOURCES = mln_core_clock_neighb2d.cc
mln_core_pixter3d_SOURCES = mln_core_pixter3d.cc
mln_core_image_obased_rle_encode_SOURCES = mln_core_image_obased_rle_encode.cc
mln_core_image_plain_SOURCES = mln_core_image_plain.cc
+mln_core_image_unproject_image_SOURCES = mln_core_image_unproject_image.cc
mln_core_image_image3d_SOURCES = mln_core_image_image3d.cc
mln_core_image_decorated_image_SOURCES = mln_core_image_decorated_image.cc
mln_core_image_extension_ima_SOURCES = mln_core_image_extension_ima.cc
--
1.5.6.5
1
0
* Makefile.am,
* headers.mk,
* tests/accu/Makefile.am,
* tests/make/Makefile.am,
* tests/unit_test/unit-tests.mk: fix build system. 'make dist' now
works.
* mln/convert/impl/from_unsigned_to_value.hh: add missing include.
* mln/core/image/complex_neighborhood_piter.hh,
* mln/io/magick/load.hh: avoid warnings.
* mln/core/routine/all.hh
* mln/labeling/blobs.hh: update doc
* mln/labeling/compute.hh: add a new postcondition.
* mln/labeling/relabel.hh: use v2v and v2b functions instead of l2l
and l2b.
* mln/make/relabelfun.hh: use v2v and v2b functions instead of l2l
and l2b and add a new overload.
* tools/area_flooding.cc: update use of
morpho::closing::area_on_vertices.
---
milena/ChangeLog | 30 +++++++++
milena/Makefile.am | 2 -
milena/headers.mk | 11 +++
milena/mln/convert/impl/from_unsigned_to_value.hh | 1 +
.../mln/core/image/complex_neighborhood_piter.hh | 2 +-
milena/mln/core/routine/all.hh | 14 ++--
milena/mln/io/magick/load.hh | 13 ++--
milena/mln/labeling/blobs.hh | 3 +-
milena/mln/labeling/compute.hh | 2 +
milena/mln/labeling/relabel.hh | 59 ++++++++++-------
milena/mln/make/relabelfun.hh | 69 ++++++++++++++++----
milena/tests/accu/Makefile.am | 3 -
milena/tests/make/Makefile.am | 2 +-
milena/tests/unit_test/unit-tests.mk | 46 ++++++++++---
milena/tools/area_flooding.cc | 19 ++++--
15 files changed, 200 insertions(+), 76 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f0c8e0f..cda14ac 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,33 @@
+2009-03-16 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes.
+
+ * Makefile.am,
+ * headers.mk,
+ * tests/accu/Makefile.am,
+ * tests/make/Makefile.am,
+ * tests/unit_test/unit-tests.mk: fix build system. 'make dist' now
+ works.
+
+ * mln/convert/impl/from_unsigned_to_value.hh: add missing include.
+
+ * mln/core/image/complex_neighborhood_piter.hh,
+ * mln/io/magick/load.hh: avoid warnings.
+
+ * mln/core/routine/all.hh
+ * mln/labeling/blobs.hh: update doc
+
+ * mln/labeling/compute.hh: add a new postcondition.
+
+ * mln/labeling/relabel.hh: use v2v and v2b functions instead of l2l
+ and l2b.
+
+ * mln/make/relabelfun.hh: use v2v and v2b functions instead of l2l
+ and l2b and add a new overload.
+
+ * tools/area_flooding.cc: update use of
+ morpho::closing::area_on_vertices.
+
2009-03-17 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Integrate ImageMagick support in Milena.
diff --git a/milena/Makefile.am b/milena/Makefile.am
index b394cf2..a2b83c6 100644
--- a/milena/Makefile.am
+++ b/milena/Makefile.am
@@ -43,10 +43,8 @@ img/medium.ppm \
img/picasso.pbm \
img/picasso.pgm \
img/quite-small.pgm \
-img/small-enlarged.png \
img/small.pbm \
img/small.pgm \
-img/small.png \
img/small.ppm \
img/squares-lc.pgm \
img/squares.pgm \
diff --git a/milena/headers.mk b/milena/headers.mk
index 9513a84..dfab609 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -262,10 +262,13 @@ mln/fun/meta/hue.hh \
mln/fun/meta/lum.hh \
mln/fun/meta/all.hh \
mln/fun/meta/green.hh \
+mln/fun/meta/second.hh \
mln/fun/meta/inty.hh \
mln/fun/meta/blue.hh \
mln/fun/meta/sat.hh \
+mln/fun/meta/first.hh \
mln/fun/meta/to_enc.hh \
+mln/fun/meta/essential.hh \
mln/fun/x2v/trilinear.hh \
mln/fun/x2v/linear.hh \
mln/fun/x2v/bilinear.hh \
@@ -285,6 +288,7 @@ mln/convert/to_window.hh \
mln/convert/from_to.hh \
mln/convert/impl/from_value_to_value.hh \
mln/convert/impl/all.hh \
+mln/convert/impl/from_unsigned_to_value.hh \
mln/convert/impl/from_double_to_value.hh \
mln/convert/impl/from_site_set_to_image.hh \
mln/convert/impl/from_image_to_site_set.hh \
@@ -629,6 +633,11 @@ mln/morpho/internal/elementary.hh \
mln/morpho/contrast.hh \
mln/morpho/thickening.hh \
mln/morpho/dilation.hh \
+mln/morpho/approx/dilation.hh \
+mln/morpho/approx/all.hh \
+mln/morpho/approx/erosion.hh \
+mln/morpho/closing/approx/all.hh \
+mln/morpho/closing/approx/structural.hh \
mln/morpho/closing/all.hh \
mln/morpho/closing/algebraic.hh \
mln/morpho/closing/leveling.hh \
@@ -643,6 +652,8 @@ mln/morpho/laplacian.hh \
mln/morpho/all.hh \
mln/morpho/watershed/flooding.hh \
mln/morpho/watershed/all.hh \
+mln/morpho/opening/approx/all.hh \
+mln/morpho/opening/approx/structural.hh \
mln/morpho/opening/all.hh \
mln/morpho/opening/algebraic.hh \
mln/morpho/opening/leveling.hh \
diff --git a/milena/mln/convert/impl/from_unsigned_to_value.hh b/milena/mln/convert/impl/from_unsigned_to_value.hh
index 4c6bac7..f5b08ac 100644
--- a/milena/mln/convert/impl/from_unsigned_to_value.hh
+++ b/milena/mln/convert/impl/from_unsigned_to_value.hh
@@ -37,6 +37,7 @@
# include <utility>
# include <mln/value/concept/integer.hh>
# include <mln/core/concept/value.hh>
+# include <mln/value/label.hh>
# include <mln/math/round.hh>
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index 32beda6..3eb7b8e 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -339,7 +339,7 @@ namespace mln
template <typename Pref>
inline
void
- complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref& c)
+ complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref&)
{
iter_.center_at(this->center().face());
}
diff --git a/milena/mln/core/routine/all.hh b/milena/mln/core/routine/all.hh
index 503919b..1c0d3f0 100644
--- a/milena/mln/core/routine/all.hh
+++ b/milena/mln/core/routine/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,11 @@
#ifndef MLN_CORE_ROUTINE_ALL_HH
# define MLN_CORE_ROUTINE_ALL_HH
-/*! \file mln/core/routine/all.hh
- *
- * \brief File that includes all core routines.
- *
- * \todo Move files, update, and activate.
- */
+/// \file mln/core/routine/all.hh
+///
+/// File that includes all core routines.
+///
+/// \todo Move files, update, and activate.
# include <mln/core/routine/duplicate.hh>
@@ -42,5 +41,4 @@
# include <mln/core/routine/initialize.hh>
# include <mln/core/routine/primary.hh>
-
#endif // ! MLN_CORE_ROUTINE_ALL_HH
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index 8636b77..4067395 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -28,13 +28,11 @@
#ifndef MLN_IO_MAGICK_LOAD_HH
# define MLN_IO_MAGICK_LOAD_HH
-/*!
- * \file mln/io/magick/load.hh
- *
- * \brief Define a function which loads an image of kind magick with
- * given path.
- *
- */
+///
+/// \file mln/io/magick/load.hh
+///
+/// Define a function which loads an image of kind magick with
+/// given path.
# include <mln/core/image/image2d.hh>
# include <mln/value/int_u8.hh>
@@ -99,6 +97,7 @@ namespace mln
inline
bool do_it(const value::rgb8& in, value::rgb8& out, const std::string& filename)
{
+ (void) filename;
out = in;
return true;
}
diff --git a/milena/mln/labeling/blobs.hh b/milena/mln/labeling/blobs.hh
index 566d2ba..60040db 100644
--- a/milena/mln/labeling/blobs.hh
+++ b/milena/mln/labeling/blobs.hh
@@ -54,7 +54,8 @@ namespace mln
///
/// \param[in] input The input image.
/// \param[in] nbh The connexity of the objects.
- /// \param[out] nlabels The number of labels.
+ /// \param[out] nlabels The Number of labels. Its value is set in the
+ /// algorithms.
/// \return The label image.
///
/// \pre The input image has to be binary (checked at compile-time).
diff --git a/milena/mln/labeling/compute.hh b/milena/mln/labeling/compute.hh
index f6e45f0..e0ad32a 100644
--- a/milena/mln/labeling/compute.hh
+++ b/milena/mln/labeling/compute.hh
@@ -295,6 +295,8 @@ namespace mln
typedef util::array<mln_result(A)> R;
R res = internal::compute_dispatch(a, label, nlabels);
+ mln_postcondition(res.nelements() == nlabels.next());
+
trace::exiting("labeling::compute");
return res;
}
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index 71e4d05..867a0fb 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -1,4 +1,4 @@
-// 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
@@ -58,12 +58,11 @@ namespace mln
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
mln_value(I)& new_nlabels,
- const Function_l2b<F>& fl2b);
+ const Function_v2b<F>& fv2b);
/// Remove components and relabel a labeled image.
/// \input[in] label the labeled image.
/// \input[in] nlabels the number of labels in \p label.
- /// \input[out] new_nlabels the number of labels after relabeling.
/// \input[in] f function returning the new component id for each pixel
/// value.
///
@@ -72,8 +71,7 @@ namespace mln
mln_concrete(I)
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
- mln_value(I)& new_nlabels,
- const Function_l2l<F>& fl2l);
+ const Function_v2v<F>& fv2v);
/// Remove components and relabel a labeled image inplace.
/// \input[in, out] label the labeled image.
@@ -85,7 +83,7 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2b<F>& fl2b);
+ const Function_v2b<F>& fv2b);
/// Remove components and relabel a labeled image inplace.
/// \input[in, out] label the labeled image.
@@ -97,7 +95,7 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2l<F>& fl2l);
+ const Function_v2v<F>& fv2v);
# ifndef MLN_INCLUDE_ONLY
@@ -124,6 +122,20 @@ namespace mln
}
template <typename I, typename F>
+ void
+ relabel_tests(const Image<I>& label,
+ const mln_value(I)& nlabels,
+ const Function<F>& f)
+ {
+ // FIXME: we may want to check that it is exactly a label.
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_precondition(exact(label).is_valid());
+ (void) label;
+ (void) nlabels;
+ (void) f;
+ }
+
+ template <typename I, typename F>
inline
void
relabel_inplace_tests(Image<I>& label,
@@ -147,14 +159,13 @@ namespace mln
mln_concrete(I)
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
- mln_value(I)& new_nlabels,
- const Function_l2l<F>& fl2l)
+ const Function_v2v<F>& fv2v)
{
trace::entering("labeling::relabel");
- internal::relabel_tests(label, nlabels, new_nlabels, fl2l);
+ internal::relabel_tests(label, nlabels, fv2v);
- mln_concrete(I) output = level::transform(label, fl2l);
+ mln_concrete(I) output = level::transform(label, fv2v);
trace::exiting("labeling::relabel");
return output;
@@ -168,15 +179,15 @@ namespace mln
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
mln_value(I)& new_nlabels,
- const Function_l2b<F>& fl2b)
+ const Function_v2b<F>& fv2b)
{
trace::entering("labeling::relabel");
- internal::relabel_tests(label, nlabels, new_nlabels, fl2b);
+ internal::relabel_tests(label, nlabels, new_nlabels, fv2b);
- typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
- fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
- mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l);
+ typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+ fv2v_t fv2v = make::relabelfun(fv2b, nlabels, new_nlabels);
+ mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fv2v);
trace::exiting("labeling::relabel");
return output;
@@ -189,13 +200,13 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2l<F>& fl2l)
+ const Function_v2v<F>& fv2v)
{
trace::entering("labeling::relabel_inplace");
- internal::relabel_inplace_tests(label, nlabels, fl2l);
+ internal::relabel_inplace_tests(label, nlabels, fv2v);
- level::transform_inplace(label, fl2l);
+ level::transform_inplace(label, fv2v);
trace::exiting("labeling::relabel_inplace");
}
@@ -207,15 +218,15 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2b<F>& fl2b)
+ const Function_v2b<F>& fv2b)
{
trace::entering("labeling::relabel_inplace");
- internal::relabel_inplace_tests(label, nlabels, fl2b);
+ internal::relabel_inplace_tests(label, nlabels, fv2b);
- typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
- fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels);
- labeling::relabel_inplace(label, nlabels, fl2l);
+ typedef fun::l2l::relabel<mln_value(I)> fv2v_t;
+ fv2v_t fv2v = make::relabelfun(fv2b, nlabels, nlabels);
+ labeling::relabel_inplace(label, nlabels, fv2v);
trace::exiting("labeling::relabel_inplace");
}
diff --git a/milena/mln/make/relabelfun.hh b/milena/mln/make/relabelfun.hh
index abbba80..612e3a6 100644
--- a/milena/mln/make/relabelfun.hh
+++ b/milena/mln/make/relabelfun.hh
@@ -42,43 +42,86 @@ namespace mln
namespace make
{
- /// Create a l2l function from a l2b function.
+ /// Create a l2l function from a v2b function.
/// This function can be used to relabel a labeled image.
///
- /// \param[in] f a l2b function.
+ /// \param[in] f a v2b function.
///
/// \return a l2l function.
///
/// \sa mln::labeling::relabel
template <unsigned n, typename F>
- mln::fun::l2l::relabel< value::label<n> >
- relabelfun(const mln::Function_l2b<F>& fl2b,
- const value::label<n>& nlabels);
+ fun::l2l::relabel< value::label<n> >
+ relabelfun(const Function_v2b<F>& fv2b,
+ const value::label<n>& nlabels,
+ value::label<n>& new_nlabels);
+
+ /// Create a l2l function from a v2v function.
+ /// This function can be used to relabel a labeled image.
+ ///
+ /// \param[in] f a v2v function.
+ ///
+ /// \return a l2l function.
+ ///
+ /// \sa mln::labeling::relabel
+ template <unsigned n, typename F>
+ fun::l2l::relabel< value::label<n> >
+ relabelfun(const Function_v2v<F>& fv2v,
+ const value::label<n>& nlabels,
+ value::label<n>& new_nlabels);
# ifndef MLN_INCLUDE_ONLY
template <unsigned n, typename F>
inline
- mln::fun::l2l::relabel< value::label<n> >
- relabelfun(const mln::Function_l2b<F>& fl2b_,
- const value::label<n>& nlabels,
- value::label<n>& new_nlabels)
+ fun::l2l::relabel< value::label<n> >
+ relabelfun(const Function_v2b<F>& fv2b_,
+ const value::label<n>& nlabels,
+ value::label<n>& new_nlabels)
{
- trace::entering("mln::make::relabelfun");
+ trace::entering("make::relabelfun");
- const F& fl2b = exact(fl2b_);
+ const F& fv2b = exact(fv2b_);
value::label<n> tmp_nlabels = literal::zero;
typedef value::label<n> label_t;
fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
for (label_t i = 1; i <= nlabels; ++i)
- if (fl2b(i))
+ if (fv2b(i))
{
fl2l(i) = ++tmp_nlabels;
}
new_nlabels = tmp_nlabels;
- trace::exiting("mln::make::relabelfun");
+ trace::exiting("make::relabelfun");
+ return fl2l;
+ }
+
+
+ template <unsigned n, typename F>
+ inline
+ fun::l2l::relabel< value::label<n> >
+ relabelfun(const Function_v2v<F>& fv2v_,
+ const value::label<n>& nlabels,
+ value::label<n>& new_nlabels)
+ {
+ trace::entering("make::relabelfun");
+
+ const F& fv2v = exact(fv2v_);
+
+ value::label<n> tmp_nlabels = literal::zero;
+ typedef value::label<n> label_t;
+ fun::l2l::relabel<label_t> fl2l(nlabels.next(), literal::zero);
+ for (label_t i = 1; i < nlabels.next(); ++i)
+ if (fl2l(fv2v(i)) == literal::zero)
+ {
+ fl2l(fv2v(i)) = ++tmp_nlabels;
+ fl2l(i) = tmp_nlabels;
+ }
+ else
+ fl2l(i) = fl2l(fv2v(i));
+ new_nlabels = tmp_nlabels;
+ trace::exiting("make::relabelfun");
return fl2l;
}
diff --git a/milena/tests/accu/Makefile.am b/milena/tests/accu/Makefile.am
index 3f78d07..fafbec1 100644
--- a/milena/tests/accu/Makefile.am
+++ b/milena/tests/accu/Makefile.am
@@ -2,9 +2,6 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- image
-
check_PROGRAMS = \
all_accus \
bbox \
diff --git a/milena/tests/make/Makefile.am b/milena/tests/make/Makefile.am
index 95eb5ea..bf96093 100644
--- a/milena/tests/make/Makefile.am
+++ b/milena/tests/make/Makefile.am
@@ -13,7 +13,7 @@ check_PROGRAMS = \
w_window \
w_window_directional
-dual_neighb_SOURCES = dual_neighb.c
+dual_neighb_SOURCES = dual_neighb.cc
graph_SOURCES = graph.cc
h_mat_SOURCES = h_mat.cc
image2d_SOURCES = image2d.cc
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index 53cd03f..f288f80 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -93,6 +93,7 @@ mln_util_line_graph \
mln_util_ord \
mln_util_tree_fast_to_image \
mln_util_tree \
+mln_util_couple \
mln_util_index \
mln_util_multi_site \
mln_util_branch_iter \
@@ -256,10 +257,13 @@ mln_fun_meta_hue \
mln_fun_meta_lum \
mln_fun_meta_all \
mln_fun_meta_green \
+mln_fun_meta_second \
mln_fun_meta_inty \
mln_fun_meta_blue \
mln_fun_meta_sat \
+mln_fun_meta_first \
mln_fun_meta_to_enc \
+mln_fun_meta_essential \
mln_fun_x2v_trilinear \
mln_fun_x2v_linear \
mln_fun_x2v_bilinear \
@@ -279,6 +283,7 @@ mln_convert_to_window \
mln_convert_from_to \
mln_convert_impl_from_value_to_value \
mln_convert_impl_all \
+mln_convert_impl_from_unsigned_to_value \
mln_convert_impl_from_double_to_value \
mln_convert_impl_from_site_set_to_image \
mln_convert_impl_from_image_to_site_set \
@@ -362,6 +367,7 @@ mln_value_label_8 \
mln_value_essential \
mln_accu_tuple \
mln_accu_min_h \
+mln_accu_stat_deviation \
mln_accu_max \
mln_accu_lor \
mln_accu_rank \
@@ -595,7 +601,6 @@ mln_linear_log \
mln_linear_essential \
mln_morpho_thinning \
mln_morpho_meyer_wst \
-mln_morpho_opening \
mln_morpho_includes \
mln_morpho_elementary_opening \
mln_morpho_elementary_gradient_internal \
@@ -621,18 +626,27 @@ mln_morpho_internal_elementary \
mln_morpho_contrast \
mln_morpho_thickening \
mln_morpho_dilation \
+mln_morpho_approx_dilation \
+mln_morpho_approx_all \
+mln_morpho_approx_erosion \
+mln_morpho_closing_approx_all \
+mln_morpho_closing_approx_structural \
mln_morpho_closing_all \
mln_morpho_closing_algebraic \
mln_morpho_closing_leveling \
mln_morpho_closing_area_on_vertices \
mln_morpho_closing_area \
mln_morpho_closing_volume \
+mln_morpho_closing_sum \
mln_morpho_closing_height \
+mln_morpho_closing_structural \
mln_morpho_closing_essential \
mln_morpho_laplacian \
mln_morpho_all \
mln_morpho_watershed_flooding \
mln_morpho_watershed_all \
+mln_morpho_opening_approx_all \
+mln_morpho_opening_approx_structural \
mln_morpho_opening_all \
mln_morpho_opening_algebraic \
mln_morpho_opening_leveling \
@@ -640,6 +654,7 @@ mln_morpho_opening_area_on_vertices \
mln_morpho_opening_area \
mln_morpho_opening_volume \
mln_morpho_opening_height \
+mln_morpho_opening_structural \
mln_morpho_opening_essential \
mln_morpho_attribute_all \
mln_morpho_attribute_volume \
@@ -657,15 +672,12 @@ mln_morpho_tree_utils \
mln_morpho_tree_data \
mln_morpho_tree_compute_attribute_image \
mln_morpho_min \
-mln_morpho_closing \
mln_morpho_top_hat \
mln_morpho_erosion \
mln_morpho_leveling_filter \
-mln_morpho_closing_sum \
mln_morpho_Rd \
mln_morpho_thick_miss \
mln_morpho_algebraic_filter \
-mln_morpho_closing_attribute \
mln_morpho_rank_filter \
mln_morpho_essential \
mln_topo_n_face_iter \
@@ -700,6 +712,7 @@ mln_essential_routine \
mln_essential_3d \
mln_essential_2d \
mln_win_inter \
+mln_win_sphere3d \
mln_win_backdiag2d \
mln_win_segment1d \
mln_win_cuboid3d \
@@ -710,10 +723,10 @@ mln_win_multiple_size \
mln_win_cube3d \
mln_win_shift \
mln_win_sym \
+mln_win_ball \
mln_win_diff \
mln_win_multiple \
mln_win_diag2d \
-mln_win_ball3d \
mln_win_disk2d \
mln_win_rectangle2d \
mln_win_hline2d \
@@ -1177,6 +1190,7 @@ mln_util_line_graph_SOURCES = mln_util_line_graph.cc
mln_util_ord_SOURCES = mln_util_ord.cc
mln_util_tree_fast_to_image_SOURCES = mln_util_tree_fast_to_image.cc
mln_util_tree_SOURCES = mln_util_tree.cc
+mln_util_couple_SOURCES = mln_util_couple.cc
mln_util_index_SOURCES = mln_util_index.cc
mln_util_multi_site_SOURCES = mln_util_multi_site.cc
mln_util_branch_iter_SOURCES = mln_util_branch_iter.cc
@@ -1340,10 +1354,13 @@ mln_fun_meta_hue_SOURCES = mln_fun_meta_hue.cc
mln_fun_meta_lum_SOURCES = mln_fun_meta_lum.cc
mln_fun_meta_all_SOURCES = mln_fun_meta_all.cc
mln_fun_meta_green_SOURCES = mln_fun_meta_green.cc
+mln_fun_meta_second_SOURCES = mln_fun_meta_second.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_first_SOURCES = mln_fun_meta_first.cc
mln_fun_meta_to_enc_SOURCES = mln_fun_meta_to_enc.cc
+mln_fun_meta_essential_SOURCES = mln_fun_meta_essential.cc
mln_fun_x2v_trilinear_SOURCES = mln_fun_x2v_trilinear.cc
mln_fun_x2v_linear_SOURCES = mln_fun_x2v_linear.cc
mln_fun_x2v_bilinear_SOURCES = mln_fun_x2v_bilinear.cc
@@ -1363,6 +1380,7 @@ mln_convert_to_window_SOURCES = mln_convert_to_window.cc
mln_convert_from_to_SOURCES = mln_convert_from_to.cc
mln_convert_impl_from_value_to_value_SOURCES = mln_convert_impl_from_value_to_value.cc
mln_convert_impl_all_SOURCES = mln_convert_impl_all.cc
+mln_convert_impl_from_unsigned_to_value_SOURCES = mln_convert_impl_from_unsigned_to_value.cc
mln_convert_impl_from_double_to_value_SOURCES = mln_convert_impl_from_double_to_value.cc
mln_convert_impl_from_site_set_to_image_SOURCES = mln_convert_impl_from_site_set_to_image.cc
mln_convert_impl_from_image_to_site_set_SOURCES = mln_convert_impl_from_image_to_site_set.cc
@@ -1446,6 +1464,7 @@ mln_value_label_8_SOURCES = mln_value_label_8.cc
mln_value_essential_SOURCES = mln_value_essential.cc
mln_accu_tuple_SOURCES = mln_accu_tuple.cc
mln_accu_min_h_SOURCES = mln_accu_min_h.cc
+mln_accu_stat_deviation_SOURCES = mln_accu_stat_deviation.cc
mln_accu_max_SOURCES = mln_accu_max.cc
mln_accu_lor_SOURCES = mln_accu_lor.cc
mln_accu_rank_SOURCES = mln_accu_rank.cc
@@ -1679,7 +1698,6 @@ mln_linear_log_SOURCES = mln_linear_log.cc
mln_linear_essential_SOURCES = mln_linear_essential.cc
mln_morpho_thinning_SOURCES = mln_morpho_thinning.cc
mln_morpho_meyer_wst_SOURCES = mln_morpho_meyer_wst.cc
-mln_morpho_opening_SOURCES = mln_morpho_opening.cc
mln_morpho_includes_SOURCES = mln_morpho_includes.cc
mln_morpho_elementary_opening_SOURCES = mln_morpho_elementary_opening.cc
mln_morpho_elementary_gradient_internal_SOURCES = mln_morpho_elementary_gradient_internal.cc
@@ -1705,18 +1723,27 @@ mln_morpho_internal_elementary_SOURCES = mln_morpho_internal_elementary.cc
mln_morpho_contrast_SOURCES = mln_morpho_contrast.cc
mln_morpho_thickening_SOURCES = mln_morpho_thickening.cc
mln_morpho_dilation_SOURCES = mln_morpho_dilation.cc
+mln_morpho_approx_dilation_SOURCES = mln_morpho_approx_dilation.cc
+mln_morpho_approx_all_SOURCES = mln_morpho_approx_all.cc
+mln_morpho_approx_erosion_SOURCES = mln_morpho_approx_erosion.cc
+mln_morpho_closing_approx_all_SOURCES = mln_morpho_closing_approx_all.cc
+mln_morpho_closing_approx_structural_SOURCES = mln_morpho_closing_approx_structural.cc
mln_morpho_closing_all_SOURCES = mln_morpho_closing_all.cc
mln_morpho_closing_algebraic_SOURCES = mln_morpho_closing_algebraic.cc
mln_morpho_closing_leveling_SOURCES = mln_morpho_closing_leveling.cc
mln_morpho_closing_area_on_vertices_SOURCES = mln_morpho_closing_area_on_vertices.cc
mln_morpho_closing_area_SOURCES = mln_morpho_closing_area.cc
mln_morpho_closing_volume_SOURCES = mln_morpho_closing_volume.cc
+mln_morpho_closing_sum_SOURCES = mln_morpho_closing_sum.cc
mln_morpho_closing_height_SOURCES = mln_morpho_closing_height.cc
+mln_morpho_closing_structural_SOURCES = mln_morpho_closing_structural.cc
mln_morpho_closing_essential_SOURCES = mln_morpho_closing_essential.cc
mln_morpho_laplacian_SOURCES = mln_morpho_laplacian.cc
mln_morpho_all_SOURCES = mln_morpho_all.cc
mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc
mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc
+mln_morpho_opening_approx_all_SOURCES = mln_morpho_opening_approx_all.cc
+mln_morpho_opening_approx_structural_SOURCES = mln_morpho_opening_approx_structural.cc
mln_morpho_opening_all_SOURCES = mln_morpho_opening_all.cc
mln_morpho_opening_algebraic_SOURCES = mln_morpho_opening_algebraic.cc
mln_morpho_opening_leveling_SOURCES = mln_morpho_opening_leveling.cc
@@ -1724,6 +1751,7 @@ mln_morpho_opening_area_on_vertices_SOURCES = mln_morpho_opening_area_on_vertice
mln_morpho_opening_area_SOURCES = mln_morpho_opening_area.cc
mln_morpho_opening_volume_SOURCES = mln_morpho_opening_volume.cc
mln_morpho_opening_height_SOURCES = mln_morpho_opening_height.cc
+mln_morpho_opening_structural_SOURCES = mln_morpho_opening_structural.cc
mln_morpho_opening_essential_SOURCES = mln_morpho_opening_essential.cc
mln_morpho_attribute_all_SOURCES = mln_morpho_attribute_all.cc
mln_morpho_attribute_volume_SOURCES = mln_morpho_attribute_volume.cc
@@ -1741,15 +1769,12 @@ mln_morpho_tree_utils_SOURCES = mln_morpho_tree_utils.cc
mln_morpho_tree_data_SOURCES = mln_morpho_tree_data.cc
mln_morpho_tree_compute_attribute_image_SOURCES = mln_morpho_tree_compute_attribute_image.cc
mln_morpho_min_SOURCES = mln_morpho_min.cc
-mln_morpho_closing_SOURCES = mln_morpho_closing.cc
mln_morpho_top_hat_SOURCES = mln_morpho_top_hat.cc
mln_morpho_erosion_SOURCES = mln_morpho_erosion.cc
mln_morpho_leveling_filter_SOURCES = mln_morpho_leveling_filter.cc
-mln_morpho_closing_sum_SOURCES = mln_morpho_closing_sum.cc
mln_morpho_Rd_SOURCES = mln_morpho_Rd.cc
mln_morpho_thick_miss_SOURCES = mln_morpho_thick_miss.cc
mln_morpho_algebraic_filter_SOURCES = mln_morpho_algebraic_filter.cc
-mln_morpho_closing_attribute_SOURCES = mln_morpho_closing_attribute.cc
mln_morpho_rank_filter_SOURCES = mln_morpho_rank_filter.cc
mln_morpho_essential_SOURCES = mln_morpho_essential.cc
mln_topo_n_face_iter_SOURCES = mln_topo_n_face_iter.cc
@@ -1784,6 +1809,7 @@ mln_essential_routine_SOURCES = mln_essential_routine.cc
mln_essential_3d_SOURCES = mln_essential_3d.cc
mln_essential_2d_SOURCES = mln_essential_2d.cc
mln_win_inter_SOURCES = mln_win_inter.cc
+mln_win_sphere3d_SOURCES = mln_win_sphere3d.cc
mln_win_backdiag2d_SOURCES = mln_win_backdiag2d.cc
mln_win_segment1d_SOURCES = mln_win_segment1d.cc
mln_win_cuboid3d_SOURCES = mln_win_cuboid3d.cc
@@ -1794,10 +1820,10 @@ mln_win_multiple_size_SOURCES = mln_win_multiple_size.cc
mln_win_cube3d_SOURCES = mln_win_cube3d.cc
mln_win_shift_SOURCES = mln_win_shift.cc
mln_win_sym_SOURCES = mln_win_sym.cc
+mln_win_ball_SOURCES = mln_win_ball.cc
mln_win_diff_SOURCES = mln_win_diff.cc
mln_win_multiple_SOURCES = mln_win_multiple.cc
mln_win_diag2d_SOURCES = mln_win_diag2d.cc
-mln_win_ball3d_SOURCES = mln_win_ball3d.cc
mln_win_disk2d_SOURCES = mln_win_disk2d.cc
mln_win_rectangle2d_SOURCES = mln_win_rectangle2d.cc
mln_win_hline2d_SOURCES = mln_win_hline2d.cc
diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc
index fc5c444..742ec94 100644
--- a/milena/tools/area_flooding.cc
+++ b/milena/tools/area_flooding.cc
@@ -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
@@ -44,7 +45,6 @@
an average grey level of the corresponding region in the input
image.
- FIXME: do not use mln_VAR.
*/
#include <cstdlib>
@@ -61,7 +61,7 @@
#include <mln/core/var.hh>
#include <mln/morpho/line_gradient.hh>
-#include <mln/morpho/closing_area_on_vertices.hh>
+#include <mln/morpho/closing/area_on_vertices.hh>
#include <mln/labeling/regional_minima.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -101,10 +101,14 @@ int main(int argc, char* argv[])
| Line gradient. |
`----------------*/
+ // Type of the function mapping graph edges and image sites.
+ typedef fun::i2v::array<util::site_pair<point2d> > fedge_site_t;
+
// Line graph image.
typedef fun::i2v::array<val_t> fval_t;
fval_t values;
- mln_VAR(lg_ima, morpho::line_gradient(input));
+ typedef pw::image<fval_t, p_edges<util::graph,fedge_site_t> > lg_ima_t;
+ lg_ima_t lg_ima = morpho::line_gradient(input);
/*-----------.
| Flooding. |
@@ -129,7 +133,7 @@ int main(int argc, char* argv[])
<< "nregions = " << nregions << std::endl;
lg_ima_t work = duplicate(result);
// Compute the closing.
- result = morpho::closing_area_on_vertices(work, nbh, area);
+ result = morpho::closing::area_on_vertices(work, nbh, area);
// Compute the number of local minima (but get rid of the image,
// as we don't need it).
labeling::regional_minima(result, nbh, nregions);
@@ -142,7 +146,10 @@ int main(int argc, char* argv[])
// Perform a Watershed Transform.
typedef int_u16 wst_val_t;
wst_val_t nbasins;
- mln_VAR(wshed, morpho::meyer_wst(result, nbh, nbasins));
+ typedef pw::image<fun::i2v::array<wst_val_t>,
+ p_edges<util::graph,fedge_site_t> > wshed_t;
+
+ wshed_t wshed = morpho::meyer_wst(result, nbh, nbasins);
std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
--
1.5.6.5
1
0
18 Mar '09
---
ChangeLog | 4 ++++
configure.ac | 4 +---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 46326b6..35f0ba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-03-18 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * configure.ac: Always configure directory external/trimesh/.
+
2009-03-13 Frederic Bour <bour(a)lrde.epita.fr>
fun update: add unary & binary composition.
diff --git a/configure.ac b/configure.ac
index 52b5b19..0b05502 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,9 +113,7 @@ AM_CONDITIONAL([DARWIN], [echo "$host_os" | grep '^darwin'])
# (Bundled) trimesh2 library.
OLN_WITH_TRIMESH
-if test x$with_trimesh = xyes; then
- AC_CONFIG_SUBDIRS([external/trimesh])
-fi
+AC_CONFIG_SUBDIRS([external/trimesh])
AM_CONDITIONAL([WITH_TRIMESH], [test x$with_trimesh = xyes])
# FreeImage library.
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-17 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Integrate ImageMagick support in Milena.
* mln/io/all.hh: Update.
* mln/io/magick/all.hh: New file, including load.hh
* mln/io/magick/load.hh: Implement ImageMagick load support.
---
all.hh | 1
magick/all.hh | 50 ++++++++++++++++
magick/load.hh | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 222 insertions(+)
Index: trunk/milena/mln/io/magick/all.hh
===================================================================
--- trunk/milena/mln/io/magick/all.hh (revision 0)
+++ trunk/milena/mln/io/magick/all.hh (revision 3539)
@@ -0,0 +1,50 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_IO_MAGICK_ALL_HH
+# define MLN_IO_MAGICK_ALL_HH
+
+/*! \file mln/io/magick/all.hh
+ *
+ * \brief File that includes all magick io materials.
+ */
+
+
+namespace mln
+{
+
+ namespace io
+ {
+ /// Namespace of magick input/output handling.
+ namespace magick {}
+ }
+
+}
+
+# include <mln/io/magick/load.hh>
+
+#endif // ! MLN_IO_MAGICK_ALL_HH
Index: trunk/milena/mln/io/magick/load.hh
===================================================================
--- trunk/milena/mln/io/magick/load.hh (revision 0)
+++ trunk/milena/mln/io/magick/load.hh (revision 3539)
@@ -0,0 +1,171 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_IO_MAGICK_LOAD_HH
+# define MLN_IO_MAGICK_LOAD_HH
+
+/*!
+ * \file mln/io/magick/load.hh
+ *
+ * \brief Define a function which loads an image of kind magick with
+ * given path.
+ *
+ */
+
+# include <mln/core/image/image2d.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <Magick++.h>
+
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace magick
+ {
+
+ /*! Load a magick image in a Milena image.
+ *
+ * \param[out] ima A reference to the image which will receive
+ * data.
+ * \param[in] filename The source.
+ */
+ template <typename I>
+ void load(Image<I>& ima,
+ const std::string& filename);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ bool do_it(const value::rgb8& in, bool& out, const std::string& filename)
+ {
+ if (in.red() == 255u && in.green() == 255u && in.blue() == 255u)
+ {
+ out = true;
+ return true;
+ }
+ if (in.red() == 0u && in.green() == 0u && in.blue() == 0u)
+ {
+ out = false;
+ return true;
+ }
+ if (in.red() == in.green() && in.green() == in.blue())
+ std::cerr << "error: trying to load '" << filename << "' which is a grayscale image into a bool image" << std::endl;
+ else
+ std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a bool image" << std::endl;
+ return false;
+ }
+
+ inline
+ bool do_it(const value::rgb8& in, value::int_u8& out, const std::string& filename)
+ {
+ if (in.red() == in.green() && in.green() == in.blue())
+ {
+ out = in.red();
+ return true;
+ }
+ std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a grayscale image" << std::endl;
+ return false;
+ }
+
+ inline
+ bool do_it(const value::rgb8& in, value::rgb8& out, const std::string& filename)
+ {
+ out = in;
+ return true;
+ }
+
+
+ template <typename I>
+ inline
+ void load(Image<I>& ima_,
+ const std::string& filename)
+ {
+ trace::entering("mln::io::magick::load");
+
+ I& ima = exact(ima_);
+
+ //std::ifstream file(filename.c_str());
+ //if (! file)
+ //{
+ // std::cerr << "error: cannot open file '" << filename << "'!";
+ // abort();
+ //}
+
+ Magick::Image im_file(filename);
+ im_file.modifyImage();
+ im_file.type(Magick::TrueColorType);
+ int columns = im_file.columns();
+ int rows = im_file.rows();
+ /*std::cout << "width: " <<columns << std::endl;
+ std::cout << "height: " <<rows << std::endl;
+ std::cout << "depth: " <<im_file.depth() << std::endl;
+ std::cout << "format: " <<im_file.format() << std::endl;
+ std::cout << "magick: " <<im_file.magick() << std::endl;*/
+
+ const Magick::PixelPacket *pixel_cache = im_file.getConstPixels(0, 0, columns, rows);
+
+ algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
+ algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
+ vmin[0] = 0;
+ vmin[1] = 0;
+ vmax[0] = rows - 1;
+ vmax[1] = columns - 1;
+ mln_site(I) pmin(vmin);
+ mln_site(I) pmax(vmax);
+ mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
+ initialize(ima, result);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+ + (int) p.to_site().to_vec()[1];
+ value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // WARNING: Quantum = 16bits but rgb is 8bits
+ mln_value(I) res;
+ if (!do_it(pix, res, filename))
+ abort();
+ ima(p) = res;
+ }
+
+ trace::exiting("mln::io::magick::load");
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::magick
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_MAGICK_LOAD_HH
Index: trunk/milena/mln/io/all.hh
===================================================================
--- trunk/milena/mln/io/all.hh (revision 3538)
+++ trunk/milena/mln/io/all.hh (revision 3539)
@@ -49,6 +49,7 @@
# include <mln/io/cloud/all.hh>
# include <mln/io/dump/all.hh>
# include <mln/io/dicom/load.hh>
+# include <mln/io/magick/all.hh>
# include <mln/io/pbm/all.hh>
# include <mln/io/pfm/all.hh>
# include <mln/io/pgm/all.hh>
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-16 Frederic Bour <bour(a)lrde.epita.fr>
Clean of new function implementation.
* sandbox/fred/mln/core/concept/meta_function.hh,
* sandbox/fred/mln/core/concept,
* sandbox/fred/mln/core/image/thru_morpher.hh,
* sandbox/fred/mln/core/image,
* sandbox/fred/mln/core,
* sandbox/fred/mln/fun/binary.hh,
* sandbox/fred/mln/fun/compose.hh,
* sandbox/fred/mln/fun/composition.hh,
* sandbox/fred/mln/fun/math/abs.hh,
* sandbox/fred/mln/fun/math/cos.hh,
* sandbox/fred/mln/fun/math/inf.hh,
* sandbox/fred/mln/fun/math/norm.hh,
* sandbox/fred/mln/fun/math/sup.hh,
* sandbox/fred/mln/fun/math,
* sandbox/fred/mln/fun/spe/binary.hh,
* sandbox/fred/mln/fun/spe/unary.hh,
* sandbox/fred/mln/fun/spe,
* sandbox/fred/mln/fun/unary.hh,
* sandbox/fred/mln/fun,
* sandbox/fred/mln/trait/fun.hh,
* sandbox/fred/mln/trait/next/solve.hh,
* sandbox/fred/mln/trait/next/solve_binary.hh,
* sandbox/fred/mln/trait/next/solve_unary.hh,
* sandbox/fred/mln/trait/next,
* sandbox/fred/mln/trait,
* sandbox/fred/mln: New. Clean files,
respecting milena file hierarchy.
* sandbox/fred/Makefile,
* sandbox/fred/overload.cc,
* sandbox/fred/old/site_wrapper.hh,
* sandbox/fred/old/value.cc,
* sandbox/fred/old/overload.cc: Old files management.
* sandbox/fred/tests/Makefile,
* sandbox/fred/tests/cos.cc,
* sandbox/fred/tests/fun.cc,
* sandbox/fred/tests/thru.cc,
* sandbox/fred/tests: New. Small test for functions.
---
mln/core/concept/meta_function.hh | 203 +++++++++++++++++++++++++
mln/core/image/thru_morpher.hh | 307 ++++++++++++++++++++++++++++++++++++++
mln/fun/binary.hh | 103 ++++++++++++
mln/fun/compose.hh | 100 ++++++++++++
mln/fun/composition.hh | 237 +++++++++++++++++++++++++++++
mln/fun/math/abs.hh | 69 ++++++++
mln/fun/math/cos.hh | 76 +++++++++
mln/fun/math/inf.hh | 69 ++++++++
mln/fun/math/norm.hh | 119 ++++++++++++++
mln/fun/math/sup.hh | 69 ++++++++
mln/fun/spe/binary.hh | 108 +++++++++++++
mln/fun/spe/unary.hh | 201 ++++++++++++++++++++++++
mln/fun/unary.hh | 247 ++++++++++++++++++++++++++++++
mln/trait/fun.hh | 131 ++++++++++++++++
mln/trait/next/solve.hh | 152 ++++++++++++++++++
mln/trait/next/solve_binary.hh | 302 +++++++++++++++++++++++++++++++++++++
mln/trait/next/solve_unary.hh | 171 +++++++++++++++++++++
old/overload.cc | 296 ++++++++++++++++++++++++++++++++++++
old/site_wrapper.hh | 188 +++++++++++++++++++++++
old/value.cc | 24 ++
tests/Makefile | 25 +++
tests/cos.cc | 34 ++++
tests/fun.cc | 108 +++++++++++++
tests/thru.cc | 37 ++++
24 files changed, 3376 insertions(+)
Index: trunk/milena/sandbox/fred/overload.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/tests/thru.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/thru.cc (revision 0)
+++ trunk/milena/sandbox/fred/tests/thru.cc (revision 3538)
@@ -0,0 +1,37 @@
+// Meta functions test
+#include <mln/fun/essential.hh>
+#include <mln/fun/math/cos.hh>
+#include <mln/core/image/thru_morpher.hh>
+#include <mln/fun/compose.hh>
+
+#include <mln/core/var.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/debug/all.hh>
+#include <iostream>
+#include <typeinfo>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+
+int main()
+{
+ using namespace mln;
+
+ fun::cos cos;
+ typedef image2d<float> I;
+ I ima(5, 5);
+
+ image2d<value::int_u8> tmp(5, 5);
+ debug::iota(tmp);
+ data::fill_with_image(ima, tmp);
+
+ debug::println(ima);
+ debug::println(thru(cos, ima));
+
+ thru_image<I, fun::cos::with<fun::cos>::ret::result::with<float>::ret > ima2;
+ ima2 = thru(cos(cos), ima);
+
+ data::fill_with_image(ima2, (pw::value(tmp) - pw::cst(13.0f)) / pw::cst(12.0f) | tmp.domain());
+
+ debug::println(ima);
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/cos.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/cos.cc (revision 0)
+++ trunk/milena/sandbox/fred/tests/cos.cc (revision 3538)
@@ -0,0 +1,34 @@
+// Meta functions test
+#include <mln/fun/math/cos.hh>
+#include <mln/fun/compose.hh>
+
+#include <iostream>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+int main()
+{
+ mln::fun::cos cos;
+ mln::fun::compose compose;
+
+ double x;
+ dbg_print(cos(compose)(cos,cos)(x) = 0.857553);
+ dbg_print(x);
+ dbg_print(cos(compose)(cos,cos)(0.));
+
+ // COS
+ {
+ mln_invariant(cos(0.) == 1.);
+ dbg_print(cos(0.));
+ dbg_print(cos(mln::math::acos(0.5)));
+ }
+
+ // COS
+ {
+ double x;
+ dbg_print(cos(x) = 1.);
+ mln_invariant(cos(x) == 1.);
+ dbg_print(x);
+ }
+
+ std::cout << "Ok." << std::endl;
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 0)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3538)
@@ -0,0 +1,108 @@
+// Meta functions test
+#include <mln/fun/math/abs.hh>
+#include <mln/fun/math/cos.hh>
+#include <mln/fun/math/norm.hh>
+// #include <mln/fun/math/inc.hh>
+// #include <mln/fun/math/red.hh>
+
+#include <iostream>
+
+#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+int main()
+{
+ mln::fun::abs abs;
+ mln::fun::cos cos;
+// mln::fun::inc inc;
+// mln::fun::red red;
+
+ mln::fun::norm::l1 l1;
+ mln::fun::norm::l2 l2;
+ mln::fun::norm::linfty linfty;
+
+ std::cout << "Read only tests." << std::endl;
+ std::cout << "----------------" << std::endl;
+
+ // ABS
+ mln_invariant(abs(-1) == 1);
+ dbg_print(abs(-1));
+ dbg_print(abs(-3.1415926535));
+
+ int x = 1;
+// abs(x) = 2;
+// abs.set(x, 2);
+
+// // INC
+// mln_invariant(inc(-1) == 0);
+// dbg_print(inc(-1));
+// dbg_print(inc(-3.1415926535));
+
+ // COS
+ mln_invariant(cos(0.) == 1.);
+ dbg_print(cos(0.));
+ dbg_print(cos(mln::math::acos(0.5)));
+
+// // RED
+// mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
+// dbg_print(red(mln::value::rgb8(8,13,21)));
+
+ // NORM
+ mln::algebra::vec<3, double> v;
+ v[0] = 1;
+ v[1] = -1;
+ v[2] = 0;
+ dbg_print(v);
+ dbg_print(l1(v));
+// dbg_print(cos(l1)(v));
+ dbg_print(l2(v));
+ dbg_print(linfty(v));
+
+ std::cout << "Read/Write tests." << std::endl;
+ std::cout << "-----------------" << std::endl;
+
+ // INC
+// {
+// int x;
+// dbg_print(inc(x) = 1);
+// mln_invariant(inc(x) == 1);
+// dbg_print(inc(x));
+// dbg_print(x);
+// }
+
+ // COS
+ {
+ double x;
+ dbg_print(cos(x) = 1.);
+ mln_invariant(cos(x) == 1.);
+ dbg_print(x);
+ }
+
+ // RED
+// {
+// mln::value::rgb8 rgb(8,13,21);
+// dbg_print(rgb);
+// dbg_print(red(rgb) = 0);
+// // FIXME: Doesn't compile! mln_invariant(red(rgb) == 0);
+// dbg_print(rgb);
+// }
+
+ // NORM
+ {
+ dbg_print(v);
+ dbg_print(l1(v) = 1.0);
+ dbg_print(l1(v));
+ dbg_print(v);
+// mln_invariant(l1(v) == 1.0); FIXME: check with epsilon
+
+ dbg_print(l2(v) = 1.0);
+ dbg_print(l2(v));
+ dbg_print(v);
+// mln_invariant(l2(v) == 1.0);
+
+ dbg_print(linfty(v) = 1.0);
+ dbg_print(linfty(v));
+ dbg_print(v);
+// mln_invariant(linfty(v) == 1.0);
+ }
+
+ std::cout << "All invariants passed." << std::endl;
+}
Index: trunk/milena/sandbox/fred/tests/Makefile
===================================================================
--- trunk/milena/sandbox/fred/tests/Makefile (revision 0)
+++ trunk/milena/sandbox/fred/tests/Makefile (revision 3538)
@@ -0,0 +1,25 @@
+TARGET=fun
+OBJS=$(TARGET).o
+
+OLENADIR=../../../..
+MILENADIR=$(OLENADIR)/milena
+
+CXXFLAGS=-I$(MILENADIR) -I../ -DNDEBUG -O1 -ffast-math
+CXX=g++
+LD=g++
+LDFLAGS=
+RM=rm
+
+$(TARGET): $(OBJS)
+ $(LD) $(LDFLAGS) -o $@ $(OBJS)
+
+%.o: %.cc
+ $(CXX) $(CXXFLAGS) -c $<
+
+%.o: %.hh
+ $(CXX) $(CXXFLAGS) -c $<
+
+all: $(TARGET)
+
+clean:
+ $(RM) -f $(TARGET) *.o *~
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 3538)
@@ -0,0 +1,131 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_TRAIT_FUN_HH
+# define MLN_TRAIT_FUN_HH
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/if.hh>
+
+#define mln_trait_fun_is_assignable(Fun) typename mln::trait::fun::is_assignable< Fun >::ret
+#define mln_trait_fun_is_assignable_(Fun) mln::trait::fun::is_assignable< Fun >::ret
+#define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::fun::is_assignable< A, B >::ret
+#define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::fun::is_assignable< A, B >::ret
+
+#define mln_trait_fun_is_parametrable(Fun) typename mln::trait::fun::is_parametrable< Fun >::ret
+#define mln_trait_fun_is_parametrable_(Fun) mln::trait::fun::is_parametrable< Fun >::ret
+
+#define mln_trait_fun_lvalue(Fun) typename mln::trait::fun::get_lvalue< Fun >::ret
+#define mln_trait_fun_param(Fun) typename mln::trait::fun::get_param< Fun >::ret
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ namespace introspect
+ {
+
+ template <typename T>
+ struct except_void_t
+ {
+ typedef void ret;
+ };
+
+ template <>
+ struct except_void_t<void>;
+
+ template <typename T, typename V>
+ struct has_lvalue_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename T::lvalue type;
+ };
+
+ template <typename T, typename V>
+ struct has_param_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_param_t<T, typename except_void_t<typename T::param>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename T::param type;
+ };
+
+ } // end of namespace mln::trait::fun::internal::introspect
+
+ } // end of namespace mln::trait::fun::internal
+
+ template <typename F>
+ struct is_assignable
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct is_parametrable
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct get_lvalue
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_param
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::type ret;
+ };
+
+ } // end of namespace mln::trait::fun
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_FUN_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh (revision 3538)
@@ -0,0 +1,171 @@
+// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_TRAIT_NEXT_SOLVE_UNARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+
+/*!
+ * \file mln/trait/next/solve_unary.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category,
+ typename T >
+ struct trait_set_unary_;
+
+ template < typename Name,
+ template <class> class Category, typename _,
+ typename T >
+ struct trait_set_unary_< Name, Category<_>, T >
+ {
+ typedef typename mln::trait::next::set_unary_<Name, Category, T>::ret ret;
+ };
+
+
+ // Fwd decls.
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_
+ {
+ typedef user_ret ret; // The user has defined 'ret' so we return it.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ not_found,
+ Name, Category, T >
+ {
+ typedef not_found ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename mln::internal::super_category_< Category, T >::ret Super_Category;
+ typedef typename get_unary_<Name, Super_Category, T>::ret ret; // No user ret definition => Recursion.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_
+ {
+ typedef typename trait_set_unary_<Name, Category, T>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_unary_<user_ret, Name, Category, T> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_< /* precise_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename get_unary_<Name, Category, T>::ret ret; // -> Go up into the category inheritance
+ // to fetch a ret from 'set_unary_'s.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_solve_unary_
+ {
+ typedef typename set_precise_unary_<Name, T>::ret precise_ret;
+ typedef helper_choose_unary_wrt_< precise_ret, /* undefined or not (?) */
+ Name, Category, T> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::next::internal
+
+
+ template < typename Name,
+ typename T_ >
+ struct solve_unary
+ {
+ typedef mln_exact(T_) T;
+ typedef typename mln::category<T>::ret Category;
+ typedef internal::helper_solve_unary_< Name, Category, T > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_UNARY_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 3538)
@@ -0,0 +1,152 @@
+// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_TRAIT_NEXT_SOLVE_HH
+# define MLN_TRAIT_NEXT_SOLVE_HH
+
+/*!
+ * \file mln/trait/next/solve.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+# define mln_trait_nunary(Name, T) typename mln::trait::next::solve_unary< Name, T >::ret
+# define mln_trait_nunary_(Name, T) mln::trait::next::solve_unary< Name, T >::ret
+
+# define mln_trait_nbinary(Name, T1, T2) typename mln::trait::next::solve_binary< Name, T1, T2 >::ret
+# define mln_trait_nbinary_(Name, T1, T2) mln::trait::next::solve_binary< Name, T1, T2 >::ret
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary case.
+
+
+ template < typename Name,
+ typename T >
+ struct set_precise_unary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_T, typename T >
+ struct set_unary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename T >
+ struct set_unary_< Name, Unknown, T > // Blocker; top of inheritance.
+ {
+ typedef not_found ret;
+ };
+
+
+
+
+ // Binary case.
+
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_precise_binary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_< Name, Unknown, L, Category_R, R > // Left blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ typename R >
+ struct set_binary_< Name, Category_L, L, Unknown, R > // Right blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_binary_< Name, Unknown, L, Unknown, R > // Blocker.
+ {
+ typedef not_found ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+# include <mln/trait/next/solve_unary.hh>
+# include <mln/trait/next/solve_binary.hh>
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh (revision 3538)
@@ -0,0 +1,302 @@
+// Copyright (C) 2006, 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
+// 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_TRAIT_NEXT_SOLVE_BINARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+
+/// \file mln/trait/next/solve_binary.hh
+///
+/// FIXME
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct trait_set_binary_;
+
+ template < typename Name,
+ template <class> class Category_L, typename _l, typename L,
+ template <class> class Category_R, typename _r, typename R >
+ struct trait_set_binary_< Name,
+ Category_L<_l>, L,
+ Category_R<_r>, R >
+ {
+ typedef typename mln::trait::next::set_binary_<Name,
+ Category_L, L,
+ Category_R, R>::ret ret;
+ };
+
+
+ // triplet_ret_
+
+ template < unsigned i_L_, unsigned i_R_, typename ret_ >
+ struct triplet_
+ {
+ typedef ret_ ret;
+ };
+
+
+ // merge_triplets_
+
+ template < typename L_trp, typename R_trp >
+ struct merge_triplets_;
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret,
+ unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef metal::bool_<(L_i_L <= R_i_L && L_i_R <= R_i_R)> take_L;
+ typedef metal::bool_<(R_i_L <= L_i_L && R_i_R <= L_i_R)> take_R;
+ typedef metal::or_<take_L, take_R> ok;
+ typedef typename metal::if_< metal::and_<ok, take_L>,
+ triplet_<L_i_L, L_i_R, L_ret>,
+ typename metal::if_< metal::and_<ok, take_R>,
+ triplet_<R_i_L, R_i_R, R_ret>,
+ triplet_<0,0, not_found> >::ret >::ret ret;
+ };
+
+ template < unsigned i_L, unsigned i_R, typename LR_ret >
+ struct merge_triplets_< triplet_<i_L, i_R, LR_ret>,
+ triplet_<i_L, i_R, LR_ret> >
+ {
+ typedef triplet_<i_L, i_R, LR_ret> ret;
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned L_i_max,
+ unsigned R_i_L, unsigned R_i_R, unsigned R_i_max >
+ // L_i_max and R_i_max differ
+ struct helper_merge_triplets_same_ret_
+ {
+ // The winning couple between L_* and R_* is the one which
+ // maximum index is the smallest; for instance, with:
+ // left branch giving L_i_L = 5 and L_i_R = 1 so L_i_max = 5
+ // right branch giving L_i_L = 3 and L_i_R = 4 so R_i_max = 4
+ // the right branch wins.
+ enum { i_L = (L_i_max < R_i_max ? L_i_L : R_i_L),
+ i_R = (L_i_max < R_i_max ? L_i_R : R_i_R) };
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned i_max,
+ unsigned R_i_L, unsigned R_i_R >
+ // L_i_max is equal to R_i_max
+ struct helper_merge_triplets_same_ret_< L_i_L, L_i_R, i_max,
+ R_i_L, R_i_R, i_max >
+ {
+ // The winning couple is the one with the minimum index.
+ enum { L_i_min = (L_i_L < L_i_R ? L_i_L : L_i_R),
+ R_i_min = (R_i_L < R_i_R ? R_i_L : R_i_R),
+ i_L = (L_i_min < R_i_min ? L_i_L : R_i_L),
+ i_R = (L_i_min < R_i_min ? L_i_R : R_i_R) };
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, typename LR_ret,
+ unsigned R_i_L, unsigned R_i_R >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, LR_ret>,
+ triplet_<R_i_L, R_i_R, LR_ret> >
+ {
+ typedef helper_merge_triplets_same_ret_< L_i_L, L_i_R, (L_i_L > L_i_R ? L_i_L : L_i_R),
+ R_i_L, R_i_R, (R_i_L > R_i_R ? R_i_L : R_i_R) > helper;
+ typedef triplet_<helper::i_L, helper::i_R, LR_ret> ret;
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_< 0, 0, not_found> >
+ {
+ typedef triplet_<L_i_L, L_i_R, L_ret> ret;
+ };
+
+ template < unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_< 0, 0, not_found>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef triplet_<R_i_L, R_i_R, R_ret> ret;
+ };
+
+ template <> // To disambiguate.
+ struct merge_triplets_< triplet_<0, 0, not_found>,
+ triplet_<0, 0, not_found> >
+ {
+ typedef triplet_<0u,0u, not_found> ret;
+ };
+
+
+
+ // Fwd decl.
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_
+ {
+ typedef triplet_< i_L, i_R, user_ret > ret; // The user has defined 'ret' so we return it.
+ };
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ not_found,
+ Name, i_L, Category_L, L, i_R, Category_R, R >
+ {
+ typedef triplet_< 0, 0, not_found > ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ undefined,
+ Name, i_L,Category_L, L, i_R,Category_R, R >
+ {
+ // No user definition for 'ret' so treillis construction in a static recursive way.
+
+ // FIXME: We *do* need to handle this search with a priority!
+ // FIXME: for a result can be found in both branches...
+
+ typedef typename mln::internal::super_category_< Category_L, L >::ret Super_Category_L;
+ typedef typename mln::internal::super_category_< Category_R, R >::ret Super_Category_R;
+
+ typedef get_binary_< Name,
+ i_L + 1, Super_Category_L, L,
+ i_R, Category_R, R > L_branch;
+ typedef mlc_ret(L_branch) L_trp;
+
+ typedef get_binary_< Name,
+ i_L, Category_L, L,
+ i_R + 1, Super_Category_R, R > R_branch;
+ typedef mlc_ret(R_branch) R_trp;
+
+ typedef typename merge_triplets_< L_trp, R_trp >::ret ret;
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_
+ {
+ typedef typename trait_set_binary_<Name, Category_L,L,
+ Category_R,R>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_binary_<user_ret, Name, i_L,Category_L,L,
+ i_R,Category_R,R> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return a triplet.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_< /* precise_ret == */ undefined,
+ Name, Category_L, L, Category_R, R >
+ {
+ typedef typename get_binary_< Name,
+ 0, Category_L, L,
+ 0, Category_R, R >::ret triplet; // Browse upwards the category inheritance
+ typedef mlc_ret(triplet) ret; // to fetch ret from 'get_binary_'s.
+ };
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_solve_binary_
+ {
+ typedef typename set_precise_binary_<Name, L, R>::ret precise_ret; /* undefined or not (?) */
+ typedef helper_choose_binary_wrt_<precise_ret, Name, Category_L,L, Category_R,R> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::internal
+
+
+ // FIXME: Postfix solve_binary with a '-'(?)
+ template < typename Name,
+ typename L_,
+ typename R_ >
+ struct solve_binary
+ {
+ typedef mln_exact(L_) L;
+ typedef mln_exact(R_) R;
+ typedef typename mln::category<L>::ret Category_L;
+ typedef typename mln::category<R>::ret Category_R;
+ typedef internal::helper_solve_binary_< Name, Category_L, L, Category_R, R > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_BINARY_HH
Index: trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh (revision 3538)
@@ -0,0 +1,307 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_IMAGE_THRU_MORPHER_HH
+# define MLN_CORE_IMAGE_THRU_MORPHER_HH
+
+# include <mln/core/internal/image_value_morpher.hh>
+# include <mln/core/concept/meta_function.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/trait/fun.hh>
+
+///
+/// \file mln/core/image/thru_morpher.hh
+///
+/// \brief Definition of a morpher that morph image values through a function.
+///
+/// \todo Debug constness of thru_image
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thru_image;
+
+ namespace internal
+ {
+ template <typename I, typename F> struct thru_image_write;
+ template <typename I, typename F> struct thru_image_read;
+
+ /// Find correct implementation
+ template <typename I, typename F>
+ struct thru_find_impl
+ {
+ typedef thru_image_write<I, F> write;
+ typedef thru_image_read<I, F> read;
+ typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret,
+ mlc_and(mlc_not(mlc_is_const(I)),
+ mlc_equal(mln_trait_image_pw_io(I),
+ trait::image::pw_io::read_write))),
+ write, read) ret;
+ };
+
+ /// Data structure for \c mln::thru_image<I>.
+ template <typename I, typename F>
+ struct data< thru_image<I, F> >
+ {
+ data(I& ima, const F& f);
+
+ I ima_;
+ // FIXME: value or pointer or whatever ?
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename F>
+ struct image_< thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_write<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read_write vw_io;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_read<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thru_image_read : public internal::image_value_morpher< I, typename F::result, thru_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thru_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thru_image_write : public thru_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thru_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thru_image : public internal::thru_find_impl<I, F>::ret
+ {
+ public:
+
+ thru_image();
+ thru_image(I& ima);
+ thru_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thru_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thru_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thru_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thru_image<I>
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thru_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thru_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::operator thru_image<const I, F>() const
+ {
+ thru_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_read<I, F>::rvalue
+ thru_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_write<I, F>::lvalue
+ thru_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thru
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thru_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thru_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRU_MORPHER_HH
Index: trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh (revision 3538)
@@ -0,0 +1,203 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_CORE_CONCEPT_META_FUNCTION_HH
+# define MLN_CORE_CONCEPT_META_FUNCTION_HH
+
+/// \file mln/core/concept/meta_function.hh
+///
+/// Definition of the concept of mln::Meta_Function.
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
+
+
+# define mln_fun_with(F, T) \
+typename F::template with< T >::ret
+
+# define mln_fun_with_(F, T) \
+F::with< T >::ret
+
+
+# define mln_fun_result(F, T) \
+typename F::template with< T >::ret::result
+
+
+# define mln_fun_result_(F, T) \
+F::with< T >::ret::result
+
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Meta_Function;
+ template <typename E> struct Meta_Function_v2v;
+ template <typename E> struct Meta_Function_vv2v;
+
+ // Meta_Function category flag type.
+ template <>
+ struct Meta_Function<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation of meta functions.
+ *
+ * The parameter \a E is the exact type.
+ *
+ * \see mln::doc::Meta_Function for a complete documentation of
+ * this class contents.
+ */
+ template <typename E>
+ struct Meta_Function : public Object<E>
+ {
+ typedef Meta_Function<void> category;
+ protected:
+ Meta_Function();
+ };
+
+ /*----------------------.
+ | Unary meta function. |
+ `----------------------*/
+
+ template <>
+ struct Meta_Function_v2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_v2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_v2v<void> category;
+
+ protected:
+ Meta_Function_v2v();
+ Meta_Function_v2v(const Meta_Function_v2v&);
+ };
+
+ /*-----------------------.
+ | Binary meta function. |
+ `-----------------------*/
+
+ template <>
+ struct Meta_Function_vv2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_vv2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_vv2v<void> category;
+
+ protected:
+ Meta_Function_vv2v();
+ Meta_Function_vv2v(const Meta_Function_vv2v&);
+ };
+
+ namespace fun
+ {
+
+ // To be specialized when some state (attributes) have to be transfered
+ // from the meta-function to the function.
+ // Warning: the first argument has to be an object with the exact type.
+ template <typename M, typename T>
+ mln_fun_with(M, T)
+ unmeta(const M&, T);
+
+ template <typename M, typename T>
+ void
+ unmeta(const Meta_Function<M>&, T); // Safety.
+
+ } // end of namespace mln::fun
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ Meta_Function<E>::Meta_Function()
+ {
+ // FIXME: Check "with" on E.
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v(const Meta_Function_v2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v(const Meta_Function_vv2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ namespace fun
+ {
+
+ template <typename M, typename T>
+ inline
+ mln_fun_with(M, T)
+ unmeta(const M&, T)
+ {
+ mlc_is_a(M, Meta_Function)::check();
+ mln_fun_with(M, T) a;
+ return a;
+ }
+
+ } // end of namespace mln::fun
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_META_FUNCTION_HH
Index: trunk/milena/sandbox/fred/mln/fun/composition.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/composition.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/composition.hh (revision 3538)
@@ -0,0 +1,237 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_COMPOSITION_HH
+# define MLN_FUN_COMPOSITION_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Compositions may take this has initialization parameter
+ template <typename F, typename G>
+ struct composition_param
+ {
+ composition_param(const F& f, const G& g) : f_(f), g_(g) {}
+ composition_param() {}
+
+ F f_;
+ G g_;
+ };
+
+ // Composition types...
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct composition;
+
+ // Meta
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ : mln::fun::unary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, composition_param<F, G> >
+ {
+ typedef mln::fun::unary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, composition_param<F, G> > super;
+
+ composition() {};
+ composition(const typename super::param& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ : mln::fun::binary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, composition_param<F, G> >
+ {
+ typedef mln::fun::binary_param< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, composition_param<F, G> > super;
+
+ composition() {};
+ composition(const typename super::param& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ // Concrete
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::spe::unary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>, typename G::argument> exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::spe::binary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>,
+ typename G::argument1, typename G::argument2> exact_type;
+ };
+
+ // Unary compositions implementation inherit from composition_unary_impl...
+ template <bool has_lvalue, typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper;
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef typename G_spe::argument argument;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ composition_unary_impl_helper() {}
+ composition_unary_impl_helper(const param& p) : f_(p.f_), g_(p.g_) {}
+
+ void init(const param& p)
+ {
+ f_ = p.f_;
+ g_ = p.g_;
+ }
+
+ result read(const argument& x) const
+ {
+ return this->f_(this->g_(x));
+ }
+
+ protected:
+ F f_;
+ G g_;
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<true, F, F_spe, G, G_spe>
+ : composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<false, F, F_spe, G, G_spe> super;
+ typedef typename G_spe::lvalue lvalue;
+
+ composition_unary_impl_helper() {}
+ composition_unary_impl_helper(const typename super::param& p) : super(p) {}
+
+ void write(lvalue l, const typename super::result& x) const
+ {
+ typename G_spe::result r(this->g_(l));
+
+ this->f_.set(r, x);
+ this->g_.set(l, r);
+ }
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl
+ : composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe> super;
+
+ composition_unary_impl() {}
+ composition_unary_impl(const typename super::param& p) : super(p) {}
+ };
+
+ // Binary compositions implementation inherit from composition_binary_inherit...
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_binary_impl
+ {
+ typedef typename G_spe::argument1 argument1;
+ typedef typename G_spe::argument2 argument2;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ composition_binary_impl() {}
+ composition_binary_impl(const param& p) : f_(p.f_), g_(p.g_) {}
+
+ void init(const param& p)
+ {
+ f_ = p.f_;
+ g_ = p.g_;
+ }
+
+ result read(const argument1& a, const argument2& b) const
+ {
+ return this->f_(this->g_(a, b));
+ }
+
+ protected:
+ F f_;
+ G g_;
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename F, typename G, typename T>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, T>
+ {
+ typedef typename G::template with<T>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G, typename T1, typename T2>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, T1, T2>
+ {
+ typedef typename G::template with<T1, T2>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>,
+ typename G::argument>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>,
+ typename G::argument1, typename G::argument2>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSITION_HH */
Index: trunk/milena/sandbox/fred/mln/fun/binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/binary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/binary.hh (revision 3538)
@@ -0,0 +1,103 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_BINARY_HH
+# define MLN_FUN_BINARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/binary.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename F>
+ struct binary : mln::Meta_Function_vv2v< binary<F> >
+ {
+
+ template <typename T1, typename T2>
+ struct with
+ {
+ typedef spe::binary<F, T1, T2> ret;
+ };
+
+ template <typename T1, typename T2>
+ typename with<T1, T2>::ret::result operator()(const T1& a, const T2& b) const
+ {
+ typename with<T1, T2>::ret tmp;
+ return tmp(a, b);
+ }
+
+ };
+
+ template <typename F, typename P>
+ struct binary_param: binary<F>
+ {
+ typedef P param;
+
+ binary_param() {};
+ binary_param(const param& p) : p_(p) {};
+
+ void init(const param& p)
+ {
+ p_ = p;
+ }
+
+ param& parameter()
+ {
+ return p_;
+ }
+
+ protected:
+ param p_;
+ };
+
+ template <typename F>
+ struct binary_param<F, F>: binary<F>
+ {
+ typedef F param;
+
+ void init(const param& p)
+ {
+ exact(*this) = p;
+ }
+
+ param& parameter()
+ {
+ return exact(*this);
+ }
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_BINARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/compose.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/compose.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/compose.hh (revision 3538)
@@ -0,0 +1,100 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_COMPOSE_HH
+# define MLN_FUN_COMPOSE_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/composition.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+ struct compose : binary<compose> {};
+
+ namespace internal
+ {
+
+ template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+ struct compose_helper
+ {
+ typedef F argument1;
+ typedef G argument2;
+
+ typedef typename composition<CatF, F, CatG, G>::exact_type result;
+ typedef typename result::param param;
+
+ static result read(const F& f, const G& g)
+ {
+ return result(param(f, g));
+ }
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // All kinds of supported compositions (meta : unary) with (meta or not : unary or binary)
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_vv2v, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSE_HH */
Index: trunk/milena/sandbox/fred/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/binary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/spe/binary.hh (revision 3538)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_SPE_BINARY_HH
+# define MLN_FUN_SPE_BINARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+/// \todo Implements parameter support
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ // Forward declaration
+ template <typename Fun, typename T1, typename T2>
+ struct binary;
+
+ namespace impl
+ {
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary_impl : mln::Function_v2v< binary<Fun, T1, T2> >
+ {
+ typedef mln_trait_nbinary(Fun, T1, T2) impl;
+
+ typedef typename impl::argument1 argument1;
+ typedef typename impl::argument2 argument2;
+ typedef typename impl::result result;
+
+ binary_impl()
+ : impl_()
+ {
+ }
+
+ binary_impl(const impl& f)
+ : impl_(f)
+ {
+ }
+
+ result operator () (const argument1& a, const argument2& b) const
+ {
+ return this->impl_.read(a, b);
+ }
+
+ protected:
+ impl impl_;
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary
+ : impl::binary_impl<Fun, T1, T2>
+ {
+ typedef impl::binary_impl<Fun, T1, T2> super;
+
+ binary()
+ : super()
+ {
+ }
+
+ binary(const typename super::impl& f)
+ : super(f)
+ {
+ }
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_SPE_BINARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 3538)
@@ -0,0 +1,201 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_SPE_UNARY_HH
+# define MLN_FUN_SPE_UNARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ namespace internal
+ {
+
+ template <typename Impl>
+ struct unary_modifier
+ {
+ typedef typename Impl::result result;
+ typedef typename Impl::argument argument;
+ typedef typename Impl::lvalue lvalue;
+ typedef unary_modifier lresult;
+
+ // FIXME: "argument& x" or "lvalue x" directly? ~~~
+ unary_modifier(const Impl& impl, argument& x)
+ : x_(&x), impl_(&impl)
+ {
+ }
+
+ result to_result() const
+ {
+ return impl_->read(*x_);
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ impl_->write(*x_, r);
+ return r;
+ }
+
+ private:
+ argument *x_;
+ const Impl *impl_;
+ };
+
+ } // end of namespace mln::fun::internal
+
+ // Forward declaration (defined in mln/fun/unary.hh)
+ template <typename Fun, typename T>
+ struct unary;
+
+ namespace impl
+ {
+
+ template <bool set, typename Fun, typename T>
+ struct unary_impl_set;
+
+ template <typename Fun, typename T>
+ struct unary_impl_set<false, Fun, T> : mln::Function_v2v< unary<Fun, T> >
+ {
+ typedef mln_trait_nunary(Fun, T) impl;
+
+ typedef typename impl::argument argument;
+ typedef typename impl::result result;
+ typedef mln_trait_fun_param(impl) param_;
+ typedef mlc_if(mlc_equal(param_, void), impl, param_) init_param;
+
+ unary_impl_set() {}
+
+ unary_impl_set(const init_param& p) : impl_(p) {}
+
+ result operator () (const argument& value) const
+ {
+ return this->impl_.read(value);
+ }
+
+ protected:
+ impl impl_;
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl_set<true, Fun, T> : unary_impl_set<false, Fun, T>
+ {
+ typedef unary_impl_set<false, Fun, T> super;
+ typedef typename super::impl impl;
+
+ typedef typename impl::argument argument;
+ typedef typename impl::result result;
+ typedef typename impl::lvalue lvalue;
+ typedef mln::fun::spe::internal::unary_modifier<impl> lresult;
+
+ unary_impl_set() {}
+ unary_impl_set(const typename super::init_param& p) : super(p) {}
+
+ void set(lvalue l, const result& r) const
+ {
+ this->impl_.write(l, r);
+ }
+
+ lresult operator () (argument& value) const
+ {
+ return lresult(this->impl_, value);
+ }
+
+ using super::operator();
+ };
+
+ template <bool set, typename Fun, typename T>
+ struct unary_impl_param;
+
+ template <typename Fun, typename T>
+ struct unary_impl_param<false, Fun, T>
+ : impl::unary_impl_set<mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+ {
+ typedef impl::unary_impl_set<mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T> super;
+
+ unary_impl_param() {}
+ unary_impl_param(const typename super::init_param& p) : super(p) {}
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl_param<true, Fun, T>
+ : unary_impl_param<false, Fun, T>
+ {
+ typedef unary_impl_param<false, Fun, T> super;
+
+ unary_impl_param() {}
+ unary_impl_param(const typename super::init_param& p) : super(p) {}
+
+ typedef typename super::param_ param;
+
+ void init(const param& p)
+ {
+ this->impl_.init(p);
+ }
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T>
+ struct unary
+ : impl::unary_impl_param<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+ {
+ typedef impl::unary_impl_param<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+ super;
+
+ unary() {}
+ unary(const typename super::init_param& p) : super(p) {}
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+ template <typename Impl>
+ std::ostream& operator << (std::ostream& o, const mln::fun::spe::internal::unary_modifier<Impl>& m)
+ {
+ return o << m.to_result();
+ }
+
+} // end of namespace mln
+
+#endif /* ! UNARY_HH */
Index: trunk/milena/sandbox/fred/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/cos.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/cos.hh (revision 3538)
@@ -0,0 +1,76 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_MATH_COS_HH
+# define MLN_FUN_MATH_COS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct cos : unary<cos> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Floating, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+ typedef T& lvalue;
+
+ static result read(const argument& x)
+ {
+ return math::cos(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = math::acos(x);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/abs.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/abs.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/abs.hh (revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_MATH_ABS_HH
+# define MLN_FUN_MATH_ABS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/concept/scalar.hh>
+# include <mln/math/abs.hh>
+
+namespace mln
+{
+
+ // Absolute value, pure
+ namespace fun
+ {
+ struct abs : unary<abs> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::abs, mln::value::Scalar, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::abs(x);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_MATH_ABS_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/sup.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/sup.hh (revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_MATH_SUP_HH
+# define MLN_FUN_MATH_SUP_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/max.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct sup : binary<sup> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T, typename T>
+ struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::max(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_SUP_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/norm.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/norm.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/norm.hh (revision 3538)
@@ -0,0 +1,119 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_MATH_NORM_HH
+# define MLN_FUN_MATH_NORM_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/norm/all.hh>
+
+namespace mln
+{
+
+ // Common norm functions, reversible
+ namespace fun
+ {
+ namespace norm
+ {
+ struct l1 : unary<l1> {};
+
+ struct l2 : unary<l2> {};
+
+ struct linfty : unary<linfty> {};
+ }
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l1, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l1(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l2, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l2(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::linfty, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::linfty(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! NORM_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/math/inf.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/math/inf.hh (revision 3538)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_MATH_INF_HH
+# define MLN_FUN_MATH_INF_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/min.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct inf : binary<inf> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T, typename T>
+ struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::min(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_INF_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/fun/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/unary.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/unary.hh (revision 3538)
@@ -0,0 +1,247 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR 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_UNARY_HH
+# define MLN_FUN_UNARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/unary.hh>
+# include <mln/trait/next/solve.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ // Forward declarations, for composition with unary::operator()(Fun)
+ struct compose;
+
+ template <typename F>
+ struct unary;
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct unary_with {};
+
+ template <bool has_param, typename M, typename T>
+ struct unary_with_param_helper;
+
+ template <typename M, typename T>
+ struct unary_with_param_helper<false, M, T>
+ {
+ typedef mln::fun::spe::unary<M, T> function;
+
+ static function inst(const M&)
+ {
+ return function();
+ };
+
+ };
+
+ template <typename M, typename T>
+ struct unary_with_param_helper<true, M, T>
+ {
+ typedef mln::fun::spe::unary<M, T> function;
+
+ static function inst(const M& m)
+ {
+ return function(m.parameter());
+ };
+
+ };
+
+ template <bool has_lvalue, typename M, typename T>
+ struct unary_with_lvalue_helper;
+
+ template <typename M, typename T>
+ struct unary_with_lvalue_helper<false, M, T>
+ : unary_with_param_helper<mln_trait_fun_is_parametrable_(M)::value, M, T>
+ {
+ typedef unary_with_param_helper<mln_trait_fun_is_parametrable_(M)::value, M, T> super;
+ typedef typename super::function function;
+
+ static typename function::result call(const M& m, const T& x)
+ {
+ function f(super::inst(m));
+ return f(x);
+ }
+ };
+
+ template <typename M, typename T>
+ struct unary_with_lvalue_helper<true, M, T>
+ : unary_with_lvalue_helper<false, M, T>
+ {
+ typedef unary_with_lvalue_helper<false, M, T> super;
+ typedef typename super::function function;
+
+ static typename function::lresult lcall(const M& m, T& x)
+ {
+ function f(super::inst(m));
+ return f(x);
+ }
+
+ static void set(const M& m, typename function::lvalue v, const T& x)
+ {
+ function f(super::inst(m));
+ f.set(v, x);
+ }
+ };
+
+ template <typename M, typename T>
+ struct unary_with_helper
+ : unary_with_lvalue_helper<mln_trait_fun_is_assignable__1comma_(mln::fun::spe::unary<M, T>)::value, M, T>
+ {
+ };
+
+ } // end of namespace mln::fun::internal
+
+ template <typename F>
+ struct unary: mln::Meta_Function_v2v< F >
+ {
+
+ template <typename T>
+ struct with {
+ typedef mln_trait_nunary(internal::unary_with<F>, T) impl;
+ typedef typename impl::function ret;
+ };
+
+ template <typename T>
+ typename with<T>::ret::result operator()(const T& v) const
+ {
+ return with<T>::impl::call(exact(*this), v);
+ }
+
+ template <typename T>
+ typename with<T>::ret::lresult operator()(T& v) const
+ {
+ return with<T>::impl::lcall(exact(*this), v);
+ }
+
+ template <typename T, typename R>
+ void set(T& v, const R& r) const
+ {
+ with<T>::impl::set(exact(*this), v, r);
+ }
+
+ };
+
+ template <typename F, typename P>
+ struct unary_param: unary<F>
+ {
+ typedef P param;
+
+ unary_param() {};
+ unary_param(const param& p) : p_(p) {};
+
+ void init(const param& p)
+ {
+ p_ = p;
+ }
+
+ param& parameter()
+ {
+ return p_;
+ }
+
+ const param& parameter() const
+ {
+ return p_;
+ }
+
+ protected:
+ param p_;
+
+ };
+
+ template <typename F>
+ struct unary_param<F, F>: unary<F>
+ {
+ typedef F param;
+
+ void init(const param& p)
+ {
+ exact(*this) = p;
+ }
+
+ param& parameter()
+ {
+ return exact(*this);
+ }
+
+ const param& parameter() const
+ {
+ return exact(*this);
+ }
+
+ };
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Any type
+ template <typename F, typename T>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Object, T>
+ {
+ typedef mln::fun::internal::unary_with_helper<F, T> ret;
+ };
+
+ // Meta Function
+ template <typename F, typename G>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Meta_Function, G>
+ {
+ // FIXME: Workaround for cyclic references (unary -> unary_with -> compose -> unary)
+ template <typename T>
+ struct identity
+ {
+ typedef T ret;
+ };
+
+ typedef set_unary_ ret;
+ typedef typename identity<mln::fun::compose>::ret::template with<F, G>::ret function;
+
+ static typename function::result call(const F& f, const G& g)
+ {
+ function tmp;
+ return tmp(f, g);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_UNARY_HH */
Index: trunk/milena/sandbox/fred/old/overload.cc
===================================================================
--- trunk/milena/sandbox/fred/old/overload.cc (revision 0)
+++ trunk/milena/sandbox/fred/old/overload.cc (revision 3538)
@@ -0,0 +1,296 @@
+#include <mln/core/concept/function.hh>
+#include <mln/core/concept/value.hh>
+#include <mln/fun/internal/resolve.hh>
+#include <mln/trait/op/plus.hh>
+
+
+#define mln_result__1comma(Tleft, Tright) \
+ typename Tleft, Tright ::result
+
+
+// Avantage de cette methode:
+// - la surcharge est rendue effectivement possible pour des familles de types
+// et permet de passer en argument une fonction meme s'il existe de multiple definitions
+// (^^ sic pour la qualite de l'explication ^^)
+// - de maniere souple (set_previse_binary & set_binary).
+//
+// Inconvenients:
+// - beaucoup de code/verbeux
+// - necessite de reecrire la resolution a la main
+// - l'implementation des differentes surcharge n'est pas aussi intuitive qu'en C++
+// naturel
+// - passage par les categories. Impossible de tirer parti de la hierarchie
+// "naturelle" des types en C++.
+//
+
+// INF
+namespace mln
+{
+
+ // Forward declaration.
+ namespace fun {
+ namespace vv2v {
+ template <typename T> struct inf;
+ }
+ }
+
+
+ namespace trait
+ {
+
+ // Default (whatever the category):
+ // "inf" performs a "min"!
+ template <template <class> class Category, typename T>
+ struct set_unary_< fun::vv2v::inf, Category, T >
+ {
+ typedef set_unary_< fun::vv2v::inf, Category, T > ret;
+
+ static T exec(const T& t1, const T& t2)
+ {
+ return t1 < t2 ? t1 : t2;
+ }
+
+ // In the case of a binary function with two different argument
+ // types, we shall instrument this definition with the result
+ // type...
+ };
+
+ } // mln::trait
+
+
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // fun::vv2v::inf<T>
+
+ template <typename T>
+ struct inf : Function_vv2v< inf<T> >
+ {
+ typedef T result;
+
+ typedef mln_fun_internal_resolve(inf) impl;
+
+ T operator()(const T& t1, const T& t2) const
+ {
+ return impl::exec(t1, t2);
+ }
+ };
+
+
+ // fun::vv2v::meta::inf
+
+ namespace meta
+ {
+
+ struct inf
+ {
+
+ // A meta-fun can act as a function :-)
+
+ template <typename T>
+ T operator()(const T& t1, const T& t2) const
+ // Here, we know the result type of vv2v::inf<T> so
+ // we explictly write it.
+ {
+ fun::vv2v::inf<T> f;
+ return f(t1, t2);
+ }
+
+ // The "meta-fun -> fun" code is similar to the one in
+ // mln/accu/min.hh
+ template <typename T>
+ struct with
+ {
+ typedef fun::vv2v::inf<T> ret;
+ };
+ };
+
+ } // mln::fun::vv2v::meta
+
+ } // mln::fun::vv2v
+
+ } // mln::fun
+
+ // Yay! A special type equipped with a particular 'inf'.
+
+ struct rgb : Value<rgb>
+ {
+ typedef rgb enc;
+ typedef rgb equiv; // Those couple of typedefs are required by the concept.
+ rgb() {}
+ rgb(int r, int g, int b) : r(r), g(g), b(b) {}
+ int r, g, b;
+ };
+
+ std::ostream& operator<<(std::ostream& ostr, const rgb& c)
+ {
+ ostr << c.r << ' ' << c.g << ' ' << c.b;
+ }
+
+ namespace trait
+ {
+
+ template <>
+ struct set_precise_unary_< fun::vv2v::inf, rgb >
+ {
+ typedef set_precise_unary_< fun::vv2v::inf, rgb > ret;
+
+ static rgb exec(const rgb& c1, const rgb& c2)
+ {
+ // "Inf" is component-wise "min".
+ return rgb(c1.r < c2.r ? c1.r : c2.r,
+ c1.g < c2.g ? c1.g : c2.g,
+ c1.b < c2.b ? c1.b : c2.b);
+ }
+ };
+
+ } // mln::trait
+
+} // mln
+
+// PLUS
+namespace mln
+{
+
+ // Forward declaration.
+ namespace fun {
+ namespace vv2v {
+ template <typename L, typename R> struct plus;
+ }
+ }
+
+
+ namespace trait
+ {
+
+ // Default (whatever the category):
+ // "plus(l, r)" performs "l + r"!
+ template <template <class> class Category_L, typename L,
+ template <class> class Category_R, typename R>
+ struct set_binary_< fun::vv2v::plus,
+ Category_L, L,
+ Category_R, R>
+ {
+ typedef set_binary_< fun::vv2v::plus, Category_L, L, Category_R, R> ret;
+
+ typedef mln_trait_op_plus(L,R) result;
+
+ static result exec(const L& t1, const R& t2)
+ {
+ return t1 + t2;
+ }
+
+ // In the case of a binary function with two different argument
+ // types, we shall instrument this definition with the result
+ // type...
+ };
+
+ } // mln::trait
+
+
+
+ namespace fun
+ {
+
+ namespace vv2v
+ {
+
+ // fun::vv2v::plus<L,R>
+
+ template <typename L, typename R>
+ struct plus : Function_vv2v< plus<L,R> >
+ {
+ typedef mln_fun_internal_resolve(plus) impl;
+ typedef mln_result(impl) result;
+
+ result operator()(const L& t1, const R& t2) const
+ {
+ return impl::exec(t1, t2);
+ }
+ };
+
+
+ // fun::vv2v::meta::plus
+
+ namespace meta
+ {
+
+ struct plus
+ {
+
+ // A meta-fun can act as a function :-)
+
+ template <typename L, typename R>
+ mln_result__1comma(fun::vv2v::plus<L,R>)
+ operator()(const L& t1, const R& t2) const
+ // Here, we do NOT know the result type of vv2v::plus<L,R> so
+ // we cannot explictly write it.
+ {
+ fun::vv2v::plus<L,R> f;
+ return f(t1, t2);
+ }
+
+ // The "meta-fun -> fun" code is similar to the one in
+ // mln/accu/min.hh
+ template <typename L, typename R>
+ struct with
+ {
+ typedef fun::vv2v::plus<L,R> ret;
+ };
+ };
+
+ } // mln::fun::vv2v::meta
+
+ } // mln::fun::vv2v
+
+ } // mln::fun
+
+
+ namespace trait
+ {
+
+ template <>
+ struct set_precise_binary_< fun::vv2v::plus, rgb, rgb >
+ {
+ typedef set_precise_binary_< fun::vv2v::plus, rgb, rgb > ret;
+ typedef rgb result;
+
+ static rgb exec(const rgb& c1, const rgb& c2)
+ {
+ // "plus" is component-wise "plus".
+ return rgb(c1.r + c2.r,
+ c1.g + c2.g,
+ c1.b + c2.b);
+ }
+ };
+
+ template <>
+ struct set_precise_binary_< mln::trait::op::plus, rgb, rgb >
+ {
+ typedef rgb ret;
+ };
+
+ } // mln::trait
+
+} // mln
+
+
+using namespace mln;
+
+int main()
+{
+ fun::vv2v::meta::inf inf;
+ std::cout << inf(3, 5) << std::endl;
+
+ rgb c1(1, 2, 3), c2(2, 1, 2);
+ std::cout << inf(c1, c2) << std::endl;
+
+ fun::vv2v::meta::plus plus;
+ std::cout << plus(plus(3.1f, 5), 3.1415926535) << std::endl;
+
+ std::cout << plus(c1, c2) << std::endl;
+}
Index: trunk/milena/sandbox/fred/old/value.cc
===================================================================
--- trunk/milena/sandbox/fred/old/value.cc (revision 0)
+++ trunk/milena/sandbox/fred/old/value.cc (revision 3538)
@@ -0,0 +1,24 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/opt/at.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/accu/bbox.hh>
+#include <mln/canvas/morpho/connected_filter.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include "value_wrapper.hh"
+#include "site_wrapper.hh"
+
+using namespace mln;
+
+int main()
+{
+ typedef mln::image2d<mln::point2d> I;
+
+ I a(8, 8);
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ for (int k = 0; k < 2; k++)
+ opt::at(a, i, j)[k] = 20 + (k ? i : j);
+
+ debug::println(canvas::morpho::connected_filter(a, c4(), morpho::attribute::site_wrapper< accu::bbox<mln::point2d> >(), make::box2d(8, 8), true));
+}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/old/site_wrapper.hh
===================================================================
--- trunk/milena/sandbox/fred/old/site_wrapper.hh (revision 0)
+++ trunk/milena/sandbox/fred/old/site_wrapper.hh (revision 3538)
@@ -0,0 +1,188 @@
+// 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
+// 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_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
+# define MLN_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
+
+/// \file mln/morpho/attribute/volume.hh
+///
+/// Transform an accumulator to a site (when_pix::use_p) accumulator.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/util/pix.hh>
+
+# define mln_morpho_attribute_use_p_(T) mln::morpho::attribute::site_wrapper< T >
+# define mln_morpho_attribute_use_p(T) mln::morpho::attribute::site_wrapper< T >
+
+namespace mln
+{
+
+ // Forward declaration.
+ namespace morpho {
+ namespace attribute {
+ template <typename T> class site_wrapper;
+ }
+ }
+
+
+ // Traits.
+
+ namespace trait
+ {
+
+ template <typename A>
+ struct accumulator_< morpho::attribute::site_wrapper<A> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_site;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_p when_pix;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace morpho
+ {
+
+ namespace attribute
+ {
+
+ /// Value wrapper accumulator meta-class.
+ ///
+ /// The parameter \p A is the base accumulator to wrap.
+ template <typename A>
+ struct site_wrapper
+ : public mln::accu::internal::base< typename A::result , site_wrapper<A> >
+ {
+ typedef typename A::argument argument;
+ typedef typename A::result result;
+
+ site_wrapper();
+
+ /// Manipulators.
+ /// \{
+ void init();
+
+ void take(const argument& v);
+ template <typename I>
+ void take(const util::pix<I>& px);
+ void take(const site_wrapper<A>& other);
+
+ void take_as_init(const argument& v);
+ template <typename I>
+ void take_as_init(const util::pix<I>& px);
+ /// \}
+
+ /// Get the site of the accumulator.
+ result to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ bool is_valid() const;
+
+ protected:
+ /// Delegatee accumulator.
+ A accu_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename A>
+ site_wrapper<A>::site_wrapper()
+ : accu_()
+ {
+ }
+
+ template <typename A>
+ void
+ site_wrapper<A>::init()
+ {
+ accu_.init();
+ }
+
+ template <typename A>
+ void
+ site_wrapper<A>::take(const argument& v)
+ {
+ accu_.take(v);
+ }
+
+ template <typename A>
+ template <typename I>
+ void
+ site_wrapper<A>::take(const util::pix<I>& px)
+ {
+ take(px.v());
+ }
+
+ template <typename A>
+ void
+ site_wrapper<A>::take(const site_wrapper<A>& other)
+ {
+ accu_.take(other.accu_);
+ }
+
+ template <typename A>
+ void
+ site_wrapper<A>::take_as_init(const argument& v)
+ {
+ accu_.take_as_init(v);
+ }
+
+ template <typename A>
+ template <typename I>
+ void
+ site_wrapper<A>::take_as_init(const util::pix<I>& px)
+ {
+ accu_.take_as_init(px);
+ }
+
+ template <typename A>
+ typename site_wrapper<A>::result
+ site_wrapper<A>::to_result() const
+ {
+ return accu_.to_result();
+ }
+
+ template <typename A>
+ bool
+ site_wrapper<A>::is_valid() const
+ {
+ return accu_.is_valid();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::attribute
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ATTRIBUTE_SITE_WRAPPER_HH
1
0
16 Mar '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-16 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Fix component tree test to work with new iterators.
* mln/morpho/tree/compute_attribute_image.hh: Modify code to
make it work with new tree implementation.
* mln/morpho/tree/data.hh: Fix bug in preorder iterator (last
element was ignored).
* sandbox/edwin/tree/propagate_node.hh,
* sandbox/edwin/tree/propagation.cc: Optimize propagation for
new component tree implementation.
* tests/morpho/tree/data.cc: Add some tests.
---
mln/morpho/tree/compute_attribute_image.hh | 3 -
mln/morpho/tree/data.hh | 61 +++++++++++++++------
sandbox/edwin/tree/propagate_node.hh | 84 +++--------------------------
sandbox/edwin/tree/propagation.cc | 44 +++++++--------
tests/morpho/tree/data.cc | 41 ++++++++++----
5 files changed, 110 insertions(+), 123 deletions(-)
Index: trunk/milena/tests/morpho/tree/data.cc
===================================================================
--- trunk/milena/tests/morpho/tree/data.cc (revision 3536)
+++ trunk/milena/tests/morpho/tree/data.cc (revision 3537)
@@ -62,18 +62,39 @@
debug::println( "on node = ", t.parent_image() | t.nodes() );
{
- std::cout << "nodes = ";
- tree_t::nodes_t::fwd_piter p(t.nodes());
- for_all(p)
- std::cout << p << ' ';
- std::cout << std::endl;
+ /* Check site and node up order */
+ tree_t::up_node_piter n(t);
+ tree_t::up_site_piter s(t);
+ n.start();
+ for_all(s)
+ if (t.is_a_node(s))
+ {
+ mln_assertion(s == n);
+ n.next();
+ }
+ mln_assertion(!n.is_valid());
+ }
+
+ {
+ /* Check site and node up order */
+ tree_t::dn_node_piter n(t);
+ tree_t::dn_site_piter s(t);
+ n.start();
+ for_all(s)
+ if (t.is_a_node(s))
+ {
+ mln_assertion(s == n);
+ n.next();
+ }
+ mln_assertion(!n.is_valid());
}
+
+
{
std::cout << "nodes = ";
- tree_t::fwd_piter p(t.domain());
- for_all(p)
- if (t.is_a_node(p))
- std::cout << p << ' ';
+ tree_t::up_node_piter n(t);
+ for_all(n)
+ std::cout << n << ' ';
std::cout << std::endl
<< std::endl;
}
@@ -82,7 +103,7 @@
{
image2d<unsigned> area(ima.domain());
data::fill(area, 1);
- tree_t::fwd_piter p(t.domain());
+ tree_t::up_site_piter p(t);
for_all(p)
if (! t.is_root(p))
area(t.parent(p)) += area(p);
Index: trunk/milena/mln/morpho/tree/compute_attribute_image.hh
===================================================================
--- trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3536)
+++ trunk/milena/mln/morpho/tree/compute_attribute_image.hh (revision 3537)
@@ -36,6 +36,7 @@
/// \todo Specialize for low quant (and try fastest).
# include <mln/core/concept/image.hh>
+# include <mln/morpho/tree/data.hh>
# include <mln/trait/accumulators.hh>
# include <mln/util/pix.hh>
# include <mln/data/fill.hh>
@@ -143,7 +144,7 @@
take_as_init(acc(p), t.f(), p);
}
{
- mln_fwd_piter(T) p(t.domain());
+ mln_up_site_piter(T) p(t);
// Propagate attribute from a site to its parent.
for_all(p)
if (! t.is_root(p))
Index: trunk/milena/mln/morpho/tree/data.hh
===================================================================
--- trunk/milena/mln/morpho/tree/data.hh (revision 3536)
+++ trunk/milena/mln/morpho/tree/data.hh (revision 3537)
@@ -38,7 +38,6 @@
/// learn why we want the 1st pass to be in forward scan of s).
# include <mln/morpho/tree/compute_parent.hh>
-//# include <mln/core/image/sub_image.hh>
# include <mln/core/site_set/p_array.hh>
# include <mln/core/internal/site_set_iterator_base.hh>
# include <mln/core/internal/piter_identity.hh>
@@ -56,10 +55,6 @@
# define mln_dn_node_piter_(T) T::dn_node_piter
# define mln_preorder_piter_(T) T::preorder_piter
-// FIXME: rename these iterators.
-//# define mln_up_leaf_piter(T) typename T::up_leaf_piter;
-//# define mln_dn_leaf_piter(T) typename T::dn_leaf_piter;
-
namespace mln
{
@@ -139,15 +134,8 @@
/// \}
- const p_array<mln_psite(I)>& children(const mln_psite(I)& p) const
- {
- return children_(p);
- }
-
- const mln_ch_value(I, nodes_t)& children_image() const
- {
- return children_;
- }
+ const p_array<mln_psite(I)>& children(const mln_psite(I)& p) const;
+ const mln_ch_value(I, nodes_t)& children_image() const;
/// \{ Tests.
@@ -290,6 +278,10 @@
/// Constructor.
preorder_piter(const T& t);
+
+ preorder_piter(const T& t,
+ const mln_psite(T::function)& p);
+
/// Test if the iterator is valid.
bool is_valid_() const;
@@ -305,7 +297,8 @@
protected:
using super_::p_;
using super_::s_;
- std::deque<mln_psite(T)> stack_; // FIXME: implement p_stack.
+ std::deque<mln_psite(T::function)> stack_; // FIXME: implement p_stack.
+ const mln_psite(T::function)* root_;
};
@@ -455,6 +448,22 @@
return f_(p);
}
+ template <typename I, typename S>
+ inline
+ const p_array<mln_psite(I)>&
+ data<I,S>::children(const mln_psite(I)& p) const
+ {
+ return children_(p);
+ }
+
+ template <typename I, typename S>
+ inline
+ const mln_ch_value(I, p_array<mln_psite(I)>)&
+ data<I,S>::children_image() const
+ {
+ return children_;
+ }
+
// Iterators.
@@ -463,12 +472,23 @@
template <typename T>
inline
preorder_piter<T>::preorder_piter()
+ : root_ (0)
{
}
template <typename T>
inline
preorder_piter<T>::preorder_piter(const T& t)
+ : root_ (0)
+ {
+ this->change_target(t);
+ }
+
+ template <typename T>
+ inline
+ preorder_piter<T>::preorder_piter(const T& t,
+ const mln_psite(T::function)& p)
+ : root_ (&p)
{
this->change_target(t);
}
@@ -495,7 +515,13 @@
preorder_piter<T>::start_()
{
this->invalidate();
- mln_dn_node_piter(T) n(s_->nodes());
+ stack_.push_back(mln_psite(T::function)()); // needed for last element.
+
+ if (root_)
+ stack_.push_back(*root_);
+ else
+ {
+ mln_dn_node_piter(T) n(*s_);
int roots = 0;
for (n.start(); n.is_valid() && roots < s_->nroots(); n.next())
if (s_->is_root(n))
@@ -503,6 +529,7 @@
stack_.push_back(n);
roots++;
}
+ }
this->next();
}
@@ -514,6 +541,8 @@
{
p_ = stack_.back();
stack_.pop_back();
+ if (!exact(this)->is_valid())
+ return;
mln_fwd_piter(T::nodes_t) child(s_->children(p_));
for_all(child)
stack_.push_back(child);
Index: trunk/milena/sandbox/edwin/tree/propagate_node.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3536)
+++ trunk/milena/sandbox/edwin/tree/propagate_node.hh (revision 3537)
@@ -31,6 +31,7 @@
#include <mln/morpho/tree/data.hh>
#include <mln/core/site_set/p_array.hh>
+#include <stack>
/// \file mln/morpho/tree/propagate_node.hh
///
@@ -44,35 +45,6 @@
/**
** Propagate a value to a node and its descendants.
**
- ** @param n Forward iterator related to the node.
- ** @param t Reference to components tree.
- ** @param a_ Reference to image.
- ** @param v Value to propagate. Default is a_(n).
- */
- template <typename T, typename A>
- void
- propagate_node_to_descendants(mln_dn_node_piter(T)& n,
- const T& t,
- Image<A>& a_,
- mln_value(A) v);
-
- /**
- ** Propagate the value of a node to its descendants.
- **
- ** @param n Forward iterator related to the node.
- ** @param t Reference to components tree.
- ** @param a_ Reference to image.
- */
- template <typename T, typename A>
- void
- propagate_node_to_descendants(mln_dn_node_piter(T)& n,
- const T& t,
- Image<A>& a_);
-
-
- /**
- ** Propagate a value to a node and its descendants.
- **
** @param n The root of subtree which value propagates in.
** @param t The reference to components tree.
** @param a_ The reference to image.
@@ -127,51 +99,10 @@
Image<A>& a_);
-
-
-
+# ifndef MLN_INCLUDE_ONLY
/* Descendants propagation */
- template <typename T, typename A>
- void
- propagate_node_to_descendants(mln_dn_node_piter(T)& n,
- const T& t,
- Image<A>& a_,
- mln_value(A) v)
- {
- A& a = exact(a_);
- mln_precondition(a.is_valid());
- mln_precondition(a.domain() == t.f().domain());
- mln_precondition(n.is_valid());
- mln_precondition(t.is_a_node(n));
-
- mln_ch_value(A, bool) ancestors;
- initialize(ancestors, a);
- data::fill(ancestors, false);
- ancestors(n) = true;
-
- mln_dn_node_piter(T) it(n);
- for (it.next(); it.is_valid(); it.next())
- {
- if (ancestors(t.parent(it)))
- {
- ancestors(it) = true;
- a(it) = v;
- }
- }
- }
-
- template <typename T, typename A>
- inline
- void
- propagate_node_to_descendants(mln_bkd_piter(T::nodes_t)& n,
- const T& t,
- Image<A>& a_)
- {
- A& a = exact(a_);
- propagate_node_to_descendants(n, t, a, a(n));
- }
template <typename T, typename A>
void
@@ -188,9 +119,13 @@
if (!t.is_a_node(n)) // Get the representant.
n = t.parent(n);
+ mln_assertion(t.is_a_node(n));
+
+ typename T::preorder_piter pp(t, n);
- mln_dn_node_piter(T) it(find_bkd(t.nodes(), n));
- propagate_node_to_descendants(it, t, a, v);
+ pp.start(); // We don't set n to v.
+ for (pp.next(); pp.is_valid(); pp.next())
+ a(pp) = v;
}
template <typename T, typename A>
@@ -220,7 +155,7 @@
mln_precondition(a.domain() == t.f().domain());
mln_precondition(a.domain().has(n));
- if (!t.is_a_node(n))
+ if (!t.is_a_node(n)) // Get the representant.
n = t.parent(n);
mln_assertion(t.is_a_node(n));
@@ -245,6 +180,7 @@
propagate_node_to_ancestors(n, t, a, a(n));
}
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho::tree
} // end of namespace mln::morpho
Index: trunk/milena/sandbox/edwin/tree/propagation.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagation.cc (revision 3536)
+++ trunk/milena/sandbox/edwin/tree/propagation.cc (revision 3537)
@@ -90,25 +90,25 @@
dsp("Propagate node to descendants : (point2d(0, 2), tree, dup)");
display_tree_attributes(tree, dup);
- dup = duplicate(input);
- morpho::tree::propagate_value_to_ancestors(117, tree, dup, 0);
- dsp("Propagate value to ancestors : (117, tree, dup, 0)");
- display_tree_attributes(tree, dup);
-
- dup = duplicate(input);
- morpho::tree::propagate_value_to_ancestors(117, tree, dup);
- dsp("Propagate value to ancestors : (117, tree, dup)");
- display_tree_attributes(tree, dup);
-
- dup = duplicate(input);
- morpho::tree::propagate_value_to_descendants(117, tree, dup, 0);
- dsp("Propagate value to descendants : (117, tree, dup, 0)");
- display_tree_attributes(tree, dup);
-
- dup = duplicate(input);
- morpho::tree::propagate_value_to_descendants(117, tree, dup);
- dsp("Propagate value to descendants : (117, tree, dup)");
- display_tree_attributes(tree, dup);
+ // dup = duplicate(input);
+// morpho::tree::propagate_value_to_ancestors(117, tree, dup, 0);
+// dsp("Propagate value to ancestors : (117, tree, dup, 0)");
+// display_tree_attributes(tree, dup);
+
+// dup = duplicate(input);
+// morpho::tree::propagate_value_to_ancestors(117, tree, dup);
+// dsp("Propagate value to ancestors : (117, tree, dup)");
+// display_tree_attributes(tree, dup);
+
+// dup = duplicate(input);
+// morpho::tree::propagate_value_to_descendants(117, tree, dup, 0);
+// dsp("Propagate value to descendants : (117, tree, dup, 0)");
+// display_tree_attributes(tree, dup);
+
+// dup = duplicate(input);
+// morpho::tree::propagate_value_to_descendants(117, tree, dup);
+// dsp("Propagate value to descendants : (117, tree, dup)");
+// display_tree_attributes(tree, dup);
@@ -123,9 +123,9 @@
dsp("Propagate value to descendants : (it_max, tree, dup, 69)");
display_tree_attributes(tree, dup);
- mln_dn_node_piter_(tree_t) n(tree);
- n.start();
- print(tree.children_image(), n);
+// mln_dn_node_piter_(tree_t) n(tree);
+// n.start();
+// print(tree.children_image(), n);
std::cout << "\n";
mln_preorder_piter_(tree_t) pit(tree);
1
0
16 Mar '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-16 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix median threshold and add ImageMagick load support..
* fabien/igr/Makefile: Update.
* fabien/igr/check.sh: Update.
* fabien/igr/med.cc: Fix median value.
* fabien/magick/Makefile: Update.
* fabien/magick/load.hh: Implement Magick support.
* fabien/magick/magick.cc: Test file for Magick support.
---
igr/Makefile | 2 -
igr/check.sh | 7 ++--
igr/med.cc | 26 +++++++++++----
magick/load.hh | 95 ++++++++++++++++++++-----------------------------------
magick/magick.cc | 19 +++++++----
5 files changed, 74 insertions(+), 75 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/check.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/check.sh (revision 3535)
+++ trunk/milena/sandbox/fabien/igr/check.sh (revision 3536)
@@ -12,11 +12,14 @@
echo " for lambda_closing = ${lambda_closing}";
./clo_vol grad.dump $dim ${lambda_closing}
nbasins=`./wst clo_vol.dump $dim`
+ echo " nbasins = $nbasins"
../bin/dumpl32_to_colorize wst.dump $dim $nbasins results/colorize_${3}_${lambda_closing}.ppm
median=`./med wst.dump $dim $input $nbasins`
+ echo " median = $median"
+ threshold=$(($median / 2))
../bin/dumpi12_to_pgm med.dump $dim results/median_${3}_${lambda_closing}.pgm
- ./thres med.dump $dim $median
- mv bin_result.pbm results/result_${3}_${lambda_closing}.pbm
+ ./thres med.dump $dim $threshold
+ mv result.pbm results/result_${3}_${lambda_closing}.pbm
#if [ $2 -eq 2 ]; then
# if [ ${lambda_closing} -eq 100 ]; then
Index: trunk/milena/sandbox/fabien/igr/med.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/med.cc (revision 3535)
+++ trunk/milena/sandbox/fabien/igr/med.cc (revision 3536)
@@ -20,9 +20,12 @@
#include <mln/core/routine/extend.hh>
#include <mln/accu/mean.hh>
#include <mln/accu/median_h.hh>
-#include <mln/morpho/elementary/dilation.hh>
+#include <mln/histo/array.hh>
+#include <mln/histo/compute.hh>
+#include <mln/labeling/compute.hh>
#include <mln/labeling/mean_values.hh>
#include <mln/level/compute.hh>
+#include <mln/morpho/elementary/dilation.hh>
#include <mln/pw/all.hh>
#include <mln/util/array.hh>
@@ -59,6 +62,8 @@
return 1;
}
+ unsigned median = 0;
+
if (dim == 2)
{
image2d<L> labels;
@@ -70,18 +75,27 @@
data::fill((labels | (pw::value(labels) == 0u)).rw(), wst_dilate);
mln_VAR(wst_mean, labeling::mean_values(dcm, labels, nbasins));
- accu::mean<float> accu_mean;
- util::array<float> means = level::compute(accu_mean, wst_mean);
-
- // FIXME: Take median value of means
+ histo::array<int_u12> histogram = histo::compute(wst_mean);
+ int j = 0;
+ int k = 0;
+ for (int i = 0; i < histogram.nvalues(); ++i)
+ {
+ if (histogram[i])
+ histogram[i] = i;
+ }
+ image1d<unsigned> ima_histo;
+ convert::from_to(histogram, ima_histo);
+ accu::median_h<int_u12> accu_med;
+ median = level::compute(accu_med, ima_histo | pw::value(ima_histo) != pw::cst(0));
io::dump::save(wst_mean, "med.dump");
- std::cout << median << std::endl;
}
else
{
// FIXME
}
+ std::cout << median << std::endl;
+
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3535)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3536)
@@ -49,4 +49,4 @@
g++ -I../../../ ${CXXFLAGS} $^ -o thres
clean:
- rm -rf *.dump *.p?m *.plot *.log *.csv
+ rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
Index: trunk/milena/sandbox/fabien/magick/magick.cc
===================================================================
--- trunk/milena/sandbox/fabien/magick/magick.cc (revision 3535)
+++ trunk/milena/sandbox/fabien/magick/magick.cc (revision 3536)
@@ -1,15 +1,22 @@
#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
#include "load.hh"
-int main()
+int main(int argc, char* argv[])
{
using namespace mln;
- using value::int_u8;
+ using value::rgb8;
- image2d<int_u8> lena;
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " filename.ext" << std::endl;
+ return 1;
+ }
+
+ image2d<rgb8> lena;
+
+ io::magick::load(lena, argv[1]);
- //io::magick::load(lena, "/Users/HiSoKa/Work/LRDE/Olena/resources/CardiacCT/178562160.dcm");
- io::magick::load(lena, "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm");
+ return 0;
}
Index: trunk/milena/sandbox/fabien/magick/Makefile
===================================================================
Index: trunk/milena/sandbox/fabien/magick/load.hh
===================================================================
--- trunk/milena/sandbox/fabien/magick/load.hh (revision 3535)
+++ trunk/milena/sandbox/fabien/magick/load.hh (revision 3536)
@@ -37,6 +37,7 @@
*/
# include <mln/core/image/image2d.hh>
+# include <mln/value/rgb8.hh>
# include <Magick++.h>
@@ -59,58 +60,19 @@
void load(Image<I>& ima,
const std::string& filename);
- /*! Load a magick image in a Milena image. To use this routine, you
- * should specialize the template whith the value type of the
- * image loaded. (ex : load<value::int_u8>("...") )
- *
- * \param[in] filename The image source.
- *
- * \return An image2d which contains loaded data.
- */
- template <typename V>
- image2d<V> load(const std::string& filename);
-
- /*! Load a magick image in a Milena image. To use this routine, you
- * should specialize the template whith the value type of the
- * image loaded. (ex : load<value::int_u8>("...") )
- *
- * \param[in] filename The image source.
- *
- * \return An image2d which contains loaded data.
- */
- template <typename V>
- image3d<V> load(const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
- template <typename V>
- inline
- image2d<V> load(const std::string& filename)
- {
- trace::entering("mln::io::magick::load");
- image2d<V> ima;// = io::pnm::load<V>(MAGICK, filename);
- trace::exiting("mln::io::magick::load");
- return ima;
- }
-
- template <typename V>
- inline
- image3d<V> load(const std::string& filename)
- {
- trace::entering("mln::io::magick::load");
- image2d<V> ima;// = io::pnm::load<V>(MAGICK, filename);
- trace::exiting("mln::io::magick::load");
- return ima;
- }
-
template <typename I>
inline
- void load(Image<I>& ima,
+ void load(Image<I>& ima_,
const std::string& filename)
{
trace::entering("mln::io::magick::load");
+ I& ima = exact(ima_);
+
//std::ifstream file(filename.c_str());
//if (! file)
//{
@@ -118,24 +80,37 @@
// abort();
//}
- Magick::Image file(filename);
- //std::cout << "file attribute: " << file.attribute() << std::endl;
- std::cout << "width: " << file.columns() << std::endl;
- std::cout << "height: " << file.rows() << std::endl;
- std::cout << "x resolution: " << file.xResolution() << std::endl;
- std::cout << "y resolution: " << file.yResolution() << std::endl;
- std::cout << "depth: " << file.depth() << std::endl;
- //std::cout << "packets: " << file.packets() << std::endl;
- //std::cout << "packet size: " << file.packetSize() << std::endl;
- std::cout << "comment: " << file.comment() << std::endl;
- std::cout << "format: " << file.format() << std::endl;
- std::cout << "number of scenes: " << file.imageInfo()->number_scenes << std::endl;
- std::cout << "scene: " << file.imageInfo()->scene << std::endl;
- std::cout << "filename: " << file.imageInfo()->filename << std::endl;
-
- //Magick::Pixels::Pixels pixels(file);
- //std::cout << "sizeof PixelPacket: " << sizeof (pixel_cache) << std::endl;
- //std::cout << "sizeof *PixelPacket: " << sizeof (*pixel_cache) << std::endl;
+ Magick::Image im_file(filename);
+ im_file.modifyImage();
+ im_file.type(Magick::TrueColorType);
+ int columns = im_file.columns();
+ int rows = im_file.rows();
+ /*std::cout << "width: " <<columns << std::endl;
+ std::cout << "height: " <<rows << std::endl;
+ std::cout << "depth: " <<im_file.depth() << std::endl;
+ std::cout << "comment: " <<im_file.comment() << std::endl;
+ std::cout << "format: " <<im_file.format() << std::endl;
+ std::cout << "filename: " <<im_file.imageInfo()->filename << std::endl;*/
+
+ const Magick::PixelPacket *pixel_cache = im_file.getConstPixels(0, 0, columns, rows);
+
+ algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
+ algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
+ vmin[0] = 0;
+ vmin[1] = 0;
+ vmax[0] = rows - 1;
+ vmax[1] = columns - 1;
+ mln_site(I) pmin(vmin);
+ mln_site(I) pmax(vmax);
+ mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
+ initialize(ima, result);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
+ + (int) p.to_site().to_vec()[1];
+ ima(p) = value::rgb8(pixel->red % 256, pixel->green % 256, pixel->blue % 256); // WARNING: Quantum = 16bits but rgb is 8bits
+ }
trace::exiting("mln::io::magick::load");
}
1
0
* mln/convert/from_to.hxx: add forward declaration.
* mln/core/alias/point2d.hh: add point2df alias.
* mln/core/alias/point3d.hh: update comments.
* mln/core/point.hh: add a new from_to_ overload.
---
milena/ChangeLog | 12 ++++++++++++
milena/mln/convert/from_to.hxx | 5 +++++
milena/mln/core/alias/point2d.hh | 3 ++-
milena/mln/core/alias/point3d.hh | 19 ++++++++-----------
milena/mln/core/point.hh | 35 +++++++++++++++++++++++++++++++++++
5 files changed, 62 insertions(+), 12 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6199774..acb63ae 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2009-03-16 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add conversion from point<G,C1> to point<G,C2>.
+
+ * mln/convert/from_to.hxx: add forward declaration.
+
+ * mln/core/alias/point2d.hh: add point2df alias.
+
+ * mln/core/alias/point3d.hh: update comments.
+
+ * mln/core/point.hh: add a new from_to_ overload.
+
2009-03-15 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add an ''un-projection'' image morpher.
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index d4ccc22..db38e36 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -145,6 +145,11 @@ namespace mln
void
from_to_(const T& from, T& to);
+ // point -> point.
+ template <typename G, typename C1, typename C2>
+ inline
+ void
+ from_to_(const point<G,C1>& from, point<G,C2>& to);
// algebra::vec -> Gpoint.
template <unsigned n, typename T, typename P>
diff --git a/milena/mln/core/alias/point2d.hh b/milena/mln/core/alias/point2d.hh
index 8c141e1..3059169 100644
--- a/milena/mln/core/alias/point2d.hh
+++ b/milena/mln/core/alias/point2d.hh
@@ -1,4 +1,4 @@
-// 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
@@ -46,6 +46,7 @@ namespace mln
/// integer coordinates.
///
typedef point<grid::square, def::coord> point2d;
+ typedef point<grid::square, def::coordf> point2df;
namespace internal
diff --git a/milena/mln/core/alias/point3d.hh b/milena/mln/core/alias/point3d.hh
index acbf721..ceff9c1 100644
--- a/milena/mln/core/alias/point3d.hh
+++ b/milena/mln/core/alias/point3d.hh
@@ -29,11 +29,10 @@
#ifndef MLN_CORE_ALIAS_POINT3D_HH
# define MLN_CORE_ALIAS_POINT3D_HH
-/*! \file mln/core/alias/point3d.hh
- *
- * \brief Definition of the mln::point3d alias and of its construction
- * routine.
- */
+/// \file mln/core/alias/point3d.hh
+///
+/// Definition of the mln::point3d alias and of its construction
+/// routine.
# include <mln/core/point.hh>
// For site_const_impl and site_mutable_impl:
@@ -43,14 +42,12 @@
namespace mln
{
- /*! \brief Type alias for a point defined on the 3D square grid with
- * integer coordinates.
- */
+ /// Type alias for a point defined on the 3D square grid with
+ /// integer coordinates.
typedef point<grid::cube, def::coord> point3d;
- /*! \brief Type alias for a point defined on the 3D square grid with
- * floating-point coordinates.
- */
+ /// Type alias for a point defined on the 3D square grid with
+ /// floating-point coordinates.
typedef point<grid::cube, def::coordf> point3df;
namespace internal
diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh
index 755f50c..54289fa 100644
--- a/milena/mln/core/point.hh
+++ b/milena/mln/core/point.hh
@@ -61,6 +61,21 @@ namespace mln
/// \}
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ template <typename G, typename C1, typename C2>
+ void from_to_(const point<G,C1>& from, point<G,C2>& to);
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+
+
+
/// Generic point class.
///
/// Parameters are \c n the dimension of the space and \c C the
@@ -213,6 +228,26 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ template <typename G, typename C1, typename C2>
+ inline
+ void
+ from_to_(const point<G,C1>& from, point<G,C2>& to)
+ {
+ mlc_converts_to(C1,C2)::check();
+ to = point<G,C2>(from.to_vec());
+ }
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+
+
template <typename G, typename C>
inline
const C& point<G,C>::operator[](unsigned i) const
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add sample code for Etienne and Fabien.
* theo/experimental: New directory.
* theo/experimental/projected_histo.cc: New.
projected_histo.cc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
Index: theo/experimental/projected_histo.cc
--- theo/experimental/projected_histo.cc (revision 0)
+++ theo/experimental/projected_histo.cc (revision 0)
@@ -0,0 +1,66 @@
+#include <mln/core/var.hh>
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/unproject_image.hh>
+#include <mln/fun/v2v/projection.hh>
+
+#include <mln/core/image/image_if.hh>
+#include <mln/pw/value.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/image/init.hh>
+#include <mln/accu/image/take.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, "../../../img/fly.pgm");
+ debug::println(lena);
+
+ typedef accu::mean<int_u8, unsigned, int_u8> A;
+
+ image1d<A> vmean(lena.ncols());
+ accu::image::init(vmean);
+ {
+ fun::v2v::projection<point2d, 0> vproj;
+ mln_VAR( vmean_, unproject(vmean, lena.domain(), vproj) );
+ accu::image::take(vmean_, lena);
+ }
+ debug::println(vmean);
+ }
+
+ std::cout << std::endl;
+
+ {
+
+ image2d<bool> pic;
+ io::pbm::load(pic, "../../../img/fly.pbm");
+ debug::println(pic);
+
+ typedef accu::count<bool> A;
+
+ image1d<A> h(pic.ncols());
+ accu::image::init(h);
+ {
+ fun::v2v::projection<point2d, 0> vproj;
+ mln_VAR( h_, unproject(h, pic.domain(), vproj) );
+ accu::image::take(h_, (pic | pw::value(pic)));
+ }
+ debug::println(h);
+ }
+
+
+}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add an ''un-projection'' image morpher.
* mln/fun/v2v/projection.hh: New.
* mln/fun/v2v/all.hh: Update.
* tests/fun/v2v/projection.cc: New.
* tests/fun/v2v/Makefile.am: Update.
* mln/core/image/unproject_image.hh: New.
* mln/core/image/all.hh: Update.
* tests/core/image/unproject_image.cc: New.
* tests/core/image/Makefile.am: Update.
mln/core/image/all.hh | 35 ++--
mln/core/image/unproject_image.hh | 272 ++++++++++++++++++++++++++++++++++++
mln/fun/v2v/all.hh | 17 +-
mln/fun/v2v/projection.hh | 91 ++++++++++++
tests/core/image/Makefile.am | 19 +-
tests/core/image/unproject_image.cc | 63 ++++++++
tests/fun/v2v/Makefile.am | 6
tests/fun/v2v/projection.cc | 73 +++++++++
8 files changed, 543 insertions(+), 33 deletions(-)
Index: mln/core/image/all.hh
--- mln/core/image/all.hh (revision 3532)
+++ mln/core/image/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
@@ -33,8 +34,6 @@
/// File that includes all image types.
-//# include <mln/core/image/bgraph_image.hh>
-//# include <mln/core/image/bgraph_psite.hh>
# include <mln/core/image/cast_image.hh>
# include <mln/core/image/ch_piter.hh>
# include <mln/core/image/complex_image.hh>
@@ -46,7 +45,6 @@
# include <mln/core/image/flat_image.hh>
# include <mln/core/image/image_if.hh>
# include <mln/core/image/sub_image.hh>
-//# include <mln/core/image/fi_adaptor.hh>
# include <mln/core/image/image1d.hh>
# include <mln/core/image/decorated_image.hh>
# include <mln/core/image/extended.hh>
@@ -55,28 +53,16 @@
# include <mln/core/image/extension_val.hh>
# include <mln/core/image/flat_image.hh>
# include <mln/core/image/graph_elt_window.hh>
-//# include <mln/core/image/graph_image.hh>
# include <mln/core/image/graph_window_piter.hh>
-//# include <mln/core/image/hexa.hh>
-//# include <mln/core/image/hexa_piter.hh>
# include <mln/core/image/image1d.hh>
# include <mln/core/image/image2d.hh>
-//# include <mln/core/image/image2d_h.hh>
# include <mln/core/image/image3d.hh>
# include <mln/core/image/image_if.hh>
# include <mln/core/image/interpolated.hh>
# include <mln/core/image/lazy_image.hh>
# include <mln/core/image/line_graph_elt_window.hh>
-//# include <mln/core/image/mono_obased_rle_encode.hh>
-//# include <mln/core/image/mono_obased_rle_image.hh>
-//# include <mln/core/image/mono_rle_encode.hh>
-//# include <mln/core/image/mono_rle_image.hh>
-//# include <mln/core/image/obased_rle_encode.hh>
-//# include <mln/core/image/obased_rle_image.hh>
# include <mln/core/image/p2p_image.hh>
# include <mln/core/image/plain.hh>
-//# include <mln/core/image/rle_encode.hh>
-//# include <mln/core/image/rle_image.hh>
# include <mln/core/image/safe.hh>
# include <mln/core/image/slice_image.hh>
# include <mln/core/image/sparse_encode.hh>
@@ -86,6 +72,23 @@
# include <mln/core/image/t_image.hh>
# include <mln/core/image/tr_image.hh>
# include <mln/core/image/tr_mesh.hh>
+# include <mln/core/image/unproject_image.hh>
+
+//# include <mln/core/image/bgraph_image.hh>
+//# include <mln/core/image/bgraph_psite.hh>
+//# include <mln/core/image/fi_adaptor.hh>
+//# include <mln/core/image/graph_image.hh>
+//# include <mln/core/image/hexa.hh>
+//# include <mln/core/image/hexa_piter.hh>
+//# include <mln/core/image/image2d_h.hh>
+//# include <mln/core/image/mono_obased_rle_encode.hh>
+//# include <mln/core/image/mono_obased_rle_image.hh>
+//# include <mln/core/image/mono_rle_encode.hh>
+//# include <mln/core/image/mono_rle_image.hh>
+//# include <mln/core/image/obased_rle_encode.hh>
+//# include <mln/core/image/obased_rle_image.hh>
+//# include <mln/core/image/rle_encode.hh>
+//# include <mln/core/image/rle_image.hh>
//# include <mln/core/image/value_enc_image.hh>
//# include <mln/core/image/value_encode.hh>
Index: mln/core/image/unproject_image.hh
--- mln/core/image/unproject_image.hh (revision 0)
+++ mln/core/image/unproject_image.hh (revision 0)
@@ -0,0 +1,272 @@
+// 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_UNPROJECT_IMAGE_HH
+# define MLN_CORE_IMAGE_UNPROJECT_IMAGE_HH
+
+/// \file mln/core/image/unproject_image.hh
+///
+/// Definition of a morpher that un-projects an image.
+/// FIXME: Doc!
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/grids.hh>
+# include <mln/core/site_set/box.hh>
+
+
+namespace mln
+{
+
+
+ // Forward declaration.
+ template <typename I, typename D, typename F> struct unproject_image;
+
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::unproject_image<I,D,F>.
+ template <typename I, typename D, typename F>
+ struct data< unproject_image<I,D,F> >
+ {
+ data(I& ima, const D& dom, const F& f);
+
+ I ima_;
+ D dom_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename D, typename F>
+ struct image_< unproject_image<I,D,F> > : default_image_morpher< I,
+ mln_value(I),
+ unproject_image<I,D,F> >
+ {
+ typedef trait::image::category::domain_morpher category;
+
+ // FIXME:
+// typedef trait::image::dimension::two_d dimension;
+
+ typedef trait::image::ext_domain::none ext_domain; // No extension of domain.
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::vw_io::none vw_io;
+ typedef trait::image::vw_set::none vw_set;
+ typedef trait::image::value_alignment::not_aligned value_alignment;
+ typedef trait::image::value_storage::disrupted value_storage;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ /// FIXME: Doc!
+ template <typename I, typename D, typename F>
+ struct unproject_image : public internal::image_domain_morpher< I,
+ D,
+ unproject_image<I,D,F> >
+ {
+ // FIXME:
+ typedef void skeleton;
+// /// Skeleton.
+// typedef unproject_image< tag::image_<I> > skeleton;
+
+
+ /// Constructor without argument.
+ unproject_image();
+
+ /// Constructor from an image \p ima, a domain \p dom, and a function \p f.
+ unproject_image(I& ima, const D& dom, const F& f);
+
+ void init_(I& ima, const D& dom, const F& f);
+
+
+ /// Give the definition domain.
+ const D& domain() const;
+
+ /// Read-only access to the image value located at point \p p.
+ mln_rvalue(I) operator()(const mln_psite(D)& p) const;
+
+ /// Read-write access to the image value located at point \p p.
+ mln_morpher_lvalue(I) operator()(const mln_psite(D)& p);
+
+
+// /// Const promotion via conversion.
+// operator unproject_image<const I, D, F>() const;
+ };
+
+
+
+ template <typename I, typename D, typename F>
+ unproject_image<I, D, F>
+ unproject(Image<I>& ima, const Site_Set<D>& dom, const Function_v2v<F>& f);
+
+ template <typename I, typename D, typename F>
+ unproject_image<const I, D, F>
+ unproject(const Image<I>& ima, const Site_Set<D>& dom, const Function_v2v<F>& f);
+
+
+
+
+// namespace trait
+// {
+
+// template <typename I, typename D, typename F,
+// typename V>
+// struct ch_value< unproject_image<I,D,F>, V >
+// {
+// // FIXME: Somthing like:
+// typedef pw::image< pw::cst_<mln_value(I)>, D> I_;
+// typedef mln_ch_value(I_,V) ret;
+// };
+
+// } // end of namespace mln::trait
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // internal::data< unproject_image<I,D,F> >
+
+ namespace internal
+ {
+
+ template <typename I, typename D, typename F>
+ inline
+ data< unproject_image<I,D,F> >::data(I& ima, const D& dom, const F& f)
+ : ima_(ima),
+ dom_(dom),
+ f_(f)
+ {
+ }
+
+ }
+
+
+ // unproject_image<I,D,F>
+
+ template <typename I, typename D, typename F>
+ inline
+ unproject_image<I,D,F>::unproject_image()
+ {
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ unproject_image<I,D,F>::unproject_image(I& ima, const D& dom, const F& f)
+ {
+ init_(ima, dom, f);
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ void
+ unproject_image<I,D,F>::init_(I& ima, const D& dom, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ this->data_ = new internal::data< unproject_image<I,D,F> >(ima, dom, f);
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ const D&
+ unproject_image<I,D,F>::domain() const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->dom_;
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ mln_rvalue(I)
+ unproject_image<I,D,F>::operator()(const mln_psite(D)& p) const
+ {
+ mln_precondition(this->has(p));
+ mln_result(F) p_ = this->data_->f_(p);
+ mln_precondition(this->data_->ima_.has(p_));
+ return this->data_->ima_(p_);
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ mln_morpher_lvalue(I)
+ unproject_image<I,D,F>::operator()(const mln_psite(D)& p)
+ {
+ mln_precondition(this->has(p));
+ mln_result(F) p_ = this->data_->f_(p);
+ mln_precondition(this->data_->ima_.has(p_));
+ return this->data_->ima_(p_);
+ }
+
+
+ // Routines.
+
+ template <typename I, typename D, typename F>
+ inline
+ unproject_image<I, D, F>
+ unproject(Image<I>& ima_, const Site_Set<D>& dom, const Function_v2v<F>& f)
+ {
+ mlc_converts_to(mln_psite(D), mln_argument(F))::check();
+ mlc_converts_to(mln_result(F), mln_psite(I))::check();
+
+ I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+
+ unproject_image<I,D,F> tmp(ima, exact(dom), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename D, typename F>
+ inline
+ unproject_image<const I, D, F>
+ unproject(const Image<I>& ima_, const Site_Set<D>& dom, const Function_v2v<F>& f)
+ {
+ mlc_converts_to(mln_psite(D), mln_argument(F))::check();
+ mlc_converts_to(mln_result(F), mln_psite(I))::check();
+
+ const I& ima = exact(ima_);
+ mln_precondition(ima.is_valid());
+
+ unproject_image<const I,D,F> tmp(ima, exact(dom), exact(f));
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_CORE_IMAGE_UNPROJECT_IMAGE_HH
Index: mln/fun/v2v/all.hh
--- mln/fun/v2v/all.hh (revision 3532)
+++ mln/fun/v2v/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_V2V_ALL_HH
# define MLN_FUN_V2V_ALL_HH
-/*! \file mln/fun/v2v/all.hh
- *
- * \brief File that includes all functions from value to value.
- */
+/// \file mln/fun/v2v/all.hh
+///
+/// File that includes all functions from value to value.
namespace mln
@@ -41,12 +41,10 @@
{
/// Namespace of functions from value to value.
- namespace v2v
- {
- }
- }
+ namespace v2v {}
}
+}
# include <mln/fun/v2v/abs.hh>
@@ -57,6 +55,7 @@
# include <mln/fun/v2v/id.hh>
# include <mln/fun/v2v/linear.hh>
# include <mln/fun/v2v/norm.hh>
+# include <mln/fun/v2v/projection.hh>
# include <mln/fun/v2v/rgb_to_hsi.hh>
# include <mln/fun/v2v/saturate.hh>
Index: mln/fun/v2v/projection.hh
--- mln/fun/v2v/projection.hh (revision 0)
+++ mln/fun/v2v/projection.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_FUN_V2V_PROJECTION_HH
+# define MLN_FUN_V2V_PROJECTION_HH
+
+/// \file mln/fun/v2v/projection.hh
+///
+/// FIXME.
+
+# include <mln/core/concept/function.hh>
+# include <mln/core/point.hh>
+# include <mln/core/grids.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename P, unsigned dir>
+ struct projection : public Function_v2v< projection<P,dir> >
+ {
+ private:
+ typedef mln_grid(P) G_;
+ typedef mln_coord(P) C_;
+ enum { n_ = G_::dim };
+
+ public:
+
+ typedef point<mln_regular_grid_from_dim(n_ - 1), C_> result;
+ typedef P argument;
+
+ result operator()(const P& p) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, unsigned dir>
+ inline
+ typename projection<P, dir>::result
+ projection<P, dir>::operator()(const P& p) const
+ {
+ result tmp;
+ for (unsigned i = 0, j = 0; i < n_; ++i)
+ if (i == dir)
+ continue;
+ else
+ tmp[j++] = p[i];
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_PROJECTION_HH
Index: tests/core/image/unproject_image.cc
--- tests/core/image/unproject_image.cc (revision 0)
+++ tests/core/image/unproject_image.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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/core/image/unproject_image.cc
+///
+/// Tests on mln::unproject_image.
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/unproject_image.hh>
+#include <mln/core/var.hh>
+
+#include <mln/fun/v2v/projection.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ image1d<int> ima(3);
+ debug::iota(ima);
+
+ debug::println(ima);
+ std::cout << std::endl;
+
+ fun::v2v::projection<point2d, 0> f;
+
+ mln_VAR( ima_, unproject(ima, make::box2d(3, 3), f) );
+ debug::println(ima_);
+
+ ima_(point2d(1,1)) = 9;
+ debug::println(ima_);
+
+ debug::println(ima);
+}
Index: tests/core/image/Makefile.am
--- tests/core/image/Makefile.am (revision 3532)
+++ tests/core/image/Makefile.am (working copy)
@@ -4,7 +4,6 @@
##FIXME: re-enable tests
check_PROGRAMS = \
-## bgraph_image \
cast_image \
complex_image \
decorated_image \
@@ -18,20 +17,25 @@
image_if \
interpolated \
line_graph_image \
-## mono_obased_rle_image \
-## mono_rle_image \
-## obased_rle_image \
p2p_image \
plain \
-## rle_image \
safe_image \
slice_image \
-## sparse_image \
sub_image \
t_image \
- tr_image
+ tr_image \
+ unproject_image
+
+## bgraph_image \
+## mono_obased_rle_image \
+## mono_rle_image \
+## obased_rle_image \
+## rle_image \
+## sparse_image \
## value_enc_image
+
+
noinst_HEADERS = complex_image.hh
##bgraph_image_SOURCES = bgraph_image.cc
@@ -60,6 +64,7 @@
sub_image_SOURCES = sub_image.cc
t_image_SOURCES = t_image.cc
tr_image_SOURCES = tr_image.cc
+unproject_image_SOURCES = unproject_image.cc
##value_enc_image_SOURCES = value_enc_image.cc
# Tests depending on the FreeImagePlus library.
Index: tests/fun/v2v/projection.cc
--- tests/fun/v2v/projection.cc (revision 0)
+++ tests/fun/v2v/projection.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/fun/v2v/projection.cc
+///
+/// Test on mln::fun::v2v::projection.
+
+#include <mln/fun/v2v/projection.hh>
+
+#include <mln/core/alias/point3d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/point1d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ typedef point2d P;
+ P p(0,1);
+ {
+ fun::v2v::projection<P,0> f;
+ mln_assertion(f(p) == point1d(1));
+ }
+ {
+ fun::v2v::projection<P,1> f;
+ mln_assertion(f(p) == point1d(0));
+ }
+ }
+
+ {
+ typedef point3d P;
+ P p(0,1,2);
+ {
+ fun::v2v::projection<P,0> f;
+ mln_assertion(f(p) == point2d(1,2));
+ }
+ {
+ fun::v2v::projection<P,1> f;
+ mln_assertion(f(p) == point2d(0,2));
+ }
+ {
+ fun::v2v::projection<P,2> f;
+ mln_assertion(f(p) == point2d(0,1));
+ }
+ }
+
+}
Index: tests/fun/v2v/Makefile.am
--- tests/fun/v2v/Makefile.am (revision 3532)
+++ tests/fun/v2v/Makefile.am (working copy)
@@ -2,9 +2,13 @@
include $(top_srcdir)/milena/tests/tests.mk
-check_PROGRAMS = norm rgb_hsi_conversion
+check_PROGRAMS = \
+ norm \
+ projection \
+ rgb_hsi_conversion
norm_SOURCES = norm.cc
+projection_SOURCES = projection.cc
rgb_hsi_conversion_SOURCES = rgb_hsi_conversion.cc
TESTS = $(check_PROGRAMS)
1
0